diff --git a/share/vmtest/hw/50-cec-driver-cache.sh b/share/vmtest/hw/50-cec-driver-cache.sh index c9e5332..d25d056 100644 --- a/share/vmtest/hw/50-cec-driver-cache.sh +++ b/share/vmtest/hw/50-cec-driver-cache.sh @@ -6,24 +6,25 @@ real="/var/cache/steamify/cros-ec-cec-${CEC_DRIVER_SHA256:0:12}.c" [[ -f "$real" ]] || { skip "R1.7 cache: no cached CEC driver on the host (~/vms/pkg-cache/steamify)"; exit 0; } dir=$(mktemp -d); sudo chown root: "$dir"; sudo chmod 755 "$dir" # like /var/cache/steamify: the user checks the cache export CEC_DRIVER_URL="file://$real" CEC_DRIVER_CACHE="$dir/cros-ec-cec-${CEC_DRIVER_SHA256:0:12}.c" -run() { cec_driver_enable 2>&1 | sed 's/\x1b\[[0-9;]*m//g'; } +errs="" +run() { out=$(cec_driver_enable 2>&1 | sed 's/\x1b\[[0-9;]*m//g'); errs+=$(grep -B6 '^\[ERROR\]' <<< "$out" | tr '\n' '|'); } # sets out # 1. new pin: an older pin's file is there, this one isn't sudo touch "$dir/cros-ec-cec-000000000000.c" -out=$(run) +run grep -q "Downloading Valve" <<< "$out" && pass "R1.7 cache: a new pin downloads its driver" || fail "R1.7 cache: no download for a new pin" echo "$CEC_DRIVER_SHA256 $CEC_DRIVER_CACHE" | sha256sum -c --quiet - 2>/dev/null && pass "R1.7 cache: the driver is kept, checksum OK" || fail "R1.7 cache: not kept after the download" [[ ! -e "$dir/cros-ec-cec-000000000000.c" ]] && pass "R1.7 cache: the older pin's file is removed" || fail "R1.7 cache: the older pin's file is still there" [[ -d "$CEC_DKMS_SRC" ]] && pass "R1.7 cache: the driver is in DKMS" || fail "R1.7 cache: no DKMS source" # 2. cache hit: no download -out=$(run) +run grep -q "Downloading Valve" <<< "$out" && fail "R1.7 cache: downloaded again although it's cached" || pass "R1.7 cache: the cached driver is used, no download" # 3. a damaged file under the right name: downloaded again and replaced echo broken | sudo tee "$CEC_DRIVER_CACHE" >/dev/null -out=$(run) +run grep -q "Downloading Valve" <<< "$out" && echo "$CEC_DRIVER_SHA256 $CEC_DRIVER_CACHE" | sha256sum -c --quiet - 2>/dev/null && pass "R1.7 cache: a damaged cached driver is replaced" || fail "R1.7 cache: a damaged cached driver stays" -grep -q '^\[ERROR\]' <<< "$out" && fail "R1.7 cache: errors: $(grep -m1 '^\[ERROR\]' <<< "$out")" || pass "R1.7 cache: no errors" +[[ -z "$errs" ]] && pass "R1.7 cache: no errors in the three runs" || fail "R1.7 cache: errors: $(cut -c1-600 <<< "$errs")" sudo rm -rf "$dir" diff --git a/share/vmtest/prelude.sh b/share/vmtest/prelude.sh index bfac52e..8652339 100644 --- a/share/vmtest/prelude.sh +++ b/share/vmtest/prelude.sh @@ -5,6 +5,7 @@ info() { echo "INFO $*"; } pass() { echo "PASS $*"; }; fail() { echo "FAIL $*"; }; skip() { echo "SKIP $*"; } sudo mountpoint -q /mnt || sudo mount -t 9p -o trans=virtio,version=9p2000.L repo /mnt cd /mnt || exit 1 +export SCRIPT_DIR=/mnt # steamify.sh sets it; the libs alone read patches/ and services/ from it for lib in common state packages login-manager single-user steam-desktop steam-machine fremont-poweroff vram-booster hdmi-refresh cec boot-session vapor-theme steamos-extras bios desktop-shortcut wizard-shortcut steam-game update-notifier; do # shellcheck source=/dev/null . "lib/$lib.sh" 2>/dev/null