interplane.Get Omega
Read in your language

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

branch main Branches Tags History

CUDApp / tools / c5 / selftest.sh

37 lines · 1778 bytes Raw Blame History
1#!/bin/sh
2# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3# Host check of build/c5_matrix with stand-in processes (no GPU, no CUDA): each case must go green with good stand-ins
4# and red with bad ones. This checks the orchestration (spawn, pipes, markers, group kill, reaping, verdicts) only.
5set -eu
6cd "$(dirname "$0")/../.."
7M=$(pwd)/build/c5_matrix
8T=$(mktemp -d)
9trap 'rm -rf "$T"' EXIT
10cat > "$T/iso" <<'EOF'
11#!/bin/sh
12if [ "$1" = "--values-only" ]; then echo "C5 isolation values: PASS (stand-in)"; /bin/sleep 1; exit 0; fi
13/bin/sh -c 'echo "[$$] ok: hang part: a command list made before the hang"; exec /bin/sleep 30' &
14wait
15EOF
16printf '#!/bin/sh\necho "C5 isolation values: FAIL (stand-in)"; exit 1\n' > "$T/iso_bad"
17printf '#!/bin/sh\n/bin/sleep 1; echo "[cuda] READY"; /bin/sleep 4; exit $5\n' > "$T/py"
18printf '#!/bin/sh\n/bin/sleep 1; echo "[cuda] READY"; exit 0\n' > "$T/py_dies"
19printf '#!/bin/sh\necho "no READY here"; exit 1\n' > "$T/py_noready"
20chmod +x "$T"/*
21fails=0
22expect() { # want_rc case iso py
23 rc=0; out=$(timeout 120 "$M" "$T/$3" "$T/$4" "$2" 2>&1) || rc=$?
24 if [ "$rc" -eq "$1" ]; then echo "ok: case $2 iso=$3 py=$4 exit $rc"; else echo "FAIL: case $2 iso=$3 py=$4 exit $rc, want $1"; echo "$out"; fails=$((fails + 1)); fi
25}
26expect 0 c iso py
27expect 0 p iso py
28expect 0 k iso py
29expect 0 r iso py
30expect 1 c iso_bad py
31expect 1 k iso_bad py
32expect 1 c iso py_dies
33expect 2 c iso py_noready
34expect 2 x iso py
35leftover=$(ps -eo args | grep -c "^/bin/sleep 30$" || true)
36[ "$leftover" -eq 0 ] && echo "ok: no stand-in hang survives the group kill" || { echo "FAIL: $leftover stand-in hang(s) left"; fails=$((fails + 1)); }
37[ "$fails" -eq 0 ] && echo "c5_matrix selftest: PASS" || { echo "c5_matrix selftest: FAIL ($fails)"; exit 1; }