CUDApp
CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit.
Brought by drakestapleton
CUDApp / tests / speculation / run-teardown-host.sh
| 1 | #!/bin/sh |
| 2 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 3 | # Disclosed development orchestration; test behavior is handwritten native Omega. |
| 4 | set -u |
| 5 | if [ "$(uname -s)" != Linux ] || [ "$(uname -m)" != aarch64 ]; then |
| 6 | echo 'NOT_RUN: teardown native-host test needs Linux AArch64 and the pinned native compiler' >&2 |
| 7 | exit 77 |
| 8 | fi |
| 9 | if [ "$#" -ne 1 ]; then |
| 10 | echo 'usage: run-teardown-host.sh /absolute/path/to/pinned-omc' >&2 |
| 11 | exit 64 |
| 12 | fi |
| 13 | omc=$1 |
| 14 | expected=9749f38841a55917d41924a68bce31463ec2339910bddd5e6cbf6ea4420551db |
| 15 | actual=$(sha256sum "$omc") || exit 74 |
| 16 | actual=${actual%% *} |
| 17 | if [ "$actual" != "$expected" ]; then |
| 18 | echo 'REFUSED: compiler digest differs from the d7390d88 native-device receipt' >&2 |
| 19 | exit 69 |
| 20 | fi |
| 21 | root=$(CDPATH= cd -- "$(dirname -- "$0")/../.." && pwd) || exit 74 |
| 22 | out=$(mktemp -d "${TMPDIR:-/tmp}/cudapp-teardown-host.XXXXXX") || exit 74 |
| 23 | echo "Native-host test outputs: $out" |
| 24 | base=f9cd649c1dca92ad81009bcd05a959f34c25c76e |
| 25 | git -C "$root" show "$base:native/nvrm/context.om" > "$out/before.om" || exit 74 |
| 26 | cp "$root/native/nvrm/context.om" "$out/after.om" || exit 74 |
| 27 | for arm in before after; do |
| 28 | # Substitute only OS-effect verbs in a private unit. Preserve the state-machine code. |
| 29 | awk ' |
| 30 | $2 == "=" && ($3 == "devcall" || $3 == "devctl" || $3 == "uvmctl") { print $1 " = tdriver"; next } |
| 31 | $2 == "=" && $3 == "fopen" { print $1 " = tunexpected"; next } |
| 32 | { for (i=1; i<=NF; i++) { if ($i == "mapdrop") $i="tdrop"; if ($i == "fclose") $i="tclose"; if ($i == "mapnew") $i="tmapnew" }; print } |
| 33 | ' "$out/$arm.om" > "$out/$arm-unit.om" || exit 74 |
| 34 | cat "$root/tests/speculation/teardown-host-test.om" >> "$out/$arm-unit.om" || exit 74 |
| 35 | # A new or differently shaped device effect must not silently escape the shim. |
| 36 | awk '$1 != "note" { for (i=1; i<=NF; i++) if ($i == "devcall" || $i == "devctl" || $i == "uvmctl" || $i == "fopen" || $i == "fclose" || $i == "mapdrop" || $i == "mapnew") exit 1 }' "$out/$arm-unit.om" || { |
| 37 | echo 'REFUSED: unbound OS effect in teardown fixture' >&2 |
| 38 | exit 69 |
| 39 | } |
| 40 | timeout 30 "$omc" < "$out/$arm-unit.om" > "$out/$arm.elf" 2> "$out/$arm.compile.log" |
| 41 | rc=$? |
| 42 | if [ "$rc" -ne 0 ] || [ ! -s "$out/$arm.elf" ]; then |
| 43 | echo "FAIL: $arm fixture did not compile successfully (exit $rc)" >&2 |
| 44 | exit 1 |
| 45 | fi |
| 46 | chmod 700 "$out/$arm.elf" || exit 74 |
| 47 | timeout 10 "$out/$arm.elf" > "$out/$arm.stdout" 2> "$out/$arm.stderr" |
| 48 | rc=$? |
| 49 | printf '%s\n' "$rc" > "$out/$arm.exit" || exit 74 |
| 50 | if [ "$arm" = before ]; then |
| 51 | if [ "$rc" -ne 1 ] || ! grep -q '^NATIVE_TEARDOWN_HOST_FAIL$' "$out/$arm.stderr"; then |
| 52 | echo 'FAIL: original source did not fail by the intended test assertion' >&2 |
| 53 | exit 1 |
| 54 | fi |
| 55 | elif [ "$rc" -ne 0 ] || ! grep -q '^NATIVE_TEARDOWN_HOST_PASS$' "$out/$arm.stdout"; then |
| 56 | echo 'FAIL: repaired source did not pass the teardown fixture' >&2 |
| 57 | exit 1 |
| 58 | fi |
| 59 | done |
| 60 | sha256sum "$out"/*.om "$out"/*.elf || exit 74 |
| 61 | echo 'PASS: original cleanup fails its assertion; repaired cleanup passes refusal, retry and close-once controls' |