forked from mtusi2026/mtusi2026lab4
24 lines
888 B
Bash
Executable File
24 lines
888 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
cd "$(dirname "$0")/.."
|
|
game_guard(){
|
|
local code
|
|
if game-running >/dev/null; then code=0; else code=$?; fi
|
|
if [ "$code" -ne 1 ]; then echo 'Game is active or its state is unknown; measurement stopped' >&2;exit 75;fi
|
|
}
|
|
game_guard
|
|
mkdir -p evidence/k3s
|
|
RUN=$(mktemp -d evidence/k3s/image-memory-XXXXXX)
|
|
printf '{"state":"started"}\n' >"$RUN/run.json"
|
|
sha256sum backend/internal/adapter/imagefile/image.go >"$RUN/source.sha256"
|
|
if [ "${VP_RUNTIME:-k3s}" = k3s ]; then
|
|
bun --no-env-file scripts/k3s.ts task image-memory >"$RUN/output.txt" 2>&1
|
|
else
|
|
./scripts/compose.sh run --rm --no-deps image-memory >"$RUN/output.txt" 2>&1
|
|
fi
|
|
game_guard
|
|
grep -F -- '--- PASS: TestWorstCaseImagesWithinBudget' "$RUN/output.txt"
|
|
grep -F 'peak_rss_kib=' "$RUN/output.txt"
|
|
printf '{"state":"complete"}\n' >"$RUN/run.json"
|
|
printf 'PASS image memory: %s\n' "$RUN"
|