interplane.Get Omega
Read in your language

omega-gpu-driver

aien-dev/omega-gpu-driver

Brought by drakestapleton

branch main Branches Tags History

omega-gpu-driver / tests / mutants-window.sh

53 lines · 2775 bytes Raw Blame History
1#!/bin/sh
2# tests/mutants-window.sh -- each mutant removes one safety step from a copy of window/*.sh; tests/window_sim.sh
3# must then fail. Test-only shell; evidence label EXERCISED (host simulator).
4set -eu
5R=$(CDPATH= cd -- "$(dirname "$0")/.." && pwd)
6W=$(mktemp -d /tmp/owndriver-window-mut.XXXXXX)
7killed=0
8total=0
9# file@sed expression@what the mutant removes
10MUTANTS='common.sh@s/^need_approval() {$/need_approval() { return 0/@approval check
11common.sh@s/^privcheck() {$/privcheck() { return 0/@privilege check
12common.sh@/\[ "$s" = active \] || die/d@runtime PM active check
13d2-pre.sh@s/^flock -n 9 || die/true || die/@W1 chip lock
14d2-pre.sh@s/^trap .abort_w1. EXIT$/:/@W1 abort trap
15d2-pre.sh@s/^\tif cmp -s "$SNAP.now" "$SNAP.want"; then$/\tif true; then/@W0 launch record check
16d2-pre.sh@s/^\[ "$STAGE" = D2 \] || has_mode exec ||/true ||/@D3 needs ogd
17common.sh@s/^\tmodes=$("$BUILD\/ogd" modes 2>\/dev\/null) || return 1$/\tmodes=$("$BUILD\/ogd" modes 2>\/dev\/null) || true/@D3 failed mode query
18d2-pre.sh@s/^\[ "$STAGE" = D2 \] || has_mode exec ||/[ "$STAGE" = D2 ] || [ -x "$BUILD\/ogd" ] ||/@D3 model-only executable
19d2-pre.sh@s/^\t(cd "$BUILD\/fw" .* sha256sum -c --quiet .*) ||$/\ttrue ||/@W0 build\/fw hash check
20d2-run.sh@s/^echo restore > "$STATE"$/:/@W2 state=restore before acting
21d2-run.sh@s/^flock -n 9 || die/true || die/@W2 chip lock
22d2-run.sh@/^\[ "$m" = root:root:600 \] || die/d@W2 /dev/vfio mode check
23d2-run.sh@s/^\tpm_auto$/\t:/@W7 power\/control=auto
24d2-restore.sh@s/^fallback() {$/fallback() { die "$*"/@R1 reboot fallback
25d2-restore.sh@s/^\tif \[ -e "$FALLBACK" \]; then$/\tif false; then/@R1 fallback only once
26d2-restore.sh@s/^\tsudo -n sysctl -q -p "$SAVED" || die/\ttrue || die/@R2 sysctl restore
27d2-restore.sh@s/^sudo -n rm -f "$UNIT"$/:/@R4 unit removal
28d2-restore.sh@s/^rm -f "$LIVE_MARKER" "$APPROVAL"/rm -f "$LIVE_MARKER"/@R4 approval removal
29d2-boot.sh@s/^\tsudo -n rm -f "$UNIT"$/\t:/@stale unit removal'
30printf '%s\n' "$MUTANTS" > "$W/list"
31while IFS='@' read -r f expr what; do
32 total=$((total + 1))
33 M=$W/m$total
34 mkdir -p "$M/build"
35 cp -r "$R/window" "$R/tools" "$R/tests" "$M/"
36 ln -s "$R/build/omc" "$M/build/omc"
37 sed -i "$expr" "$M/window/$f"
38 if cmp -s "$R/window/$f" "$M/window/$f"; then
39 echo "BROKEN mutant $total ($what): sed did not change window/$f"
40 rm -rf "$W"
41 exit 2
42 fi
43 if SIMDIR=$W/sim$total sh "$M/tests/window_sim.sh" > "$W/out$total" 2>&1; then
44 echo "SURVIVED $total: $what ($f)"
45 else
46 killed=$((killed + 1))
47 echo "killed $total: $what ($f): $(tail -1 "$W/out$total" | sed 's/.*in://')"
48 fi
49 for s in "$W"/sim$total/*/st/35b; do [ -s "$s" ] && kill "$(cat "$s")" 2>/dev/null || true; done
50done < "$W/list"
51rm -rf "$W"
52echo "mutants-window: $killed/$total killed"
53[ "$killed" -eq "$total" ]