Files
proxy/scripts/test-hermetic.sh
T

54 lines
1.5 KiB
Bash
Executable File

#!/bin/sh
set -eu
repo=$(CDPATH= cd -- "$(dirname "$0")/.." && pwd)
work=$(mktemp -d)
trap 'rm -rf "$work"' EXIT HUP INT TERM
snapshot_path() {
path=$1
if [ ! -e "$path" ] && [ ! -L "$path" ]; then
printf 'absent\t%s\n' "$path"
return
fi
# Keep traversal, metadata collection, hashing, and sorting as separate
# commands so set -e observes every failure without relying on pipefail.
find -H "$path" -xdev \
-exec stat --printf='metadata\t%F\t%a\t%u\t%g\t%N\n' -- {} + \
>"$work/snapshot-metadata"
LC_ALL=C sort "$work/snapshot-metadata"
find -H "$path" -xdev -type f -exec sha256sum -- {} + \
>"$work/snapshot-content"
LC_ALL=C sort "$work/snapshot-content"
}
snapshot() {
for path in \
"$HOME/.bashrc" "$HOME/.zshrc" "$HOME/.docker/config.json" \
/etc/apt/apt.conf.d /etc/docker/daemon.json /var/lib/proxyctl \
/etc/systemd/system/docker.service.d
do
snapshot_path "$path"
done
if command -v gsettings >/dev/null 2>&1; then
gsettings list-recursively org.gnome.system.proxy 2>&1 || true
else
printf 'gsettings absent\n'
fi
if command -v systemctl >/dev/null 2>&1; then
systemctl show docker.service -p ActiveState -p SubState -p NRestarts -p ExecMainStartTimestampMonotonic 2>&1 || true
else
printf 'systemctl absent\n'
fi
}
snapshot >"$work/before"
(
cd "$repo"
go test ./...
)
snapshot >"$work/after"
cmp "$work/before" "$work/after"
printf 'full Go suite passed without changing host Shell, APT, Docker, GNOME, or system-service state\n'