Debian Codegraph @

debian/tests/upstream-binaries

raw
1 #!/bin/sh
2 # autopkgtest driver for ROCm upstream binaries
3 #
4 # Expects argument "$1" to be the name of a sub-directory, such that the
5 # following following directory exists:
6 #
7 # /usr/libexec/rocm/$1
8 #
9 # Will run all executables in that directory, and exit with status=1 if
10 # any failure occurred, otherwise with status=0. A failure is defined as an
11 # executable exiting with a status != 0.
12
13
14 TESTNAME=$1
15
16 if [ ! -e /dev/kfd ]
17 then
18 echo "/dev/kfd not present, system either lacks AMD GPU or AMDGPU driver is not loaded."
19 echo "Skipping tests."
20 # Magic number to signal 'skipped'
21 exit 77
22 elif [ "$(id -u)" != "0" ] && [ ! -r /dev/kfd ]
23 then
24 echo "/dev/kfd present but no read permission."
25 echo "Skipping tests."
26 exit 77
27 elif [ -z "$1" ]
28 then
29 echo "This script needs to be called with a directory name as an argument." >&2
30 echo "Aborting." >&2
31 exit 1
32 fi
33
34 # 16 = testbed failure
35 cd "$AUTOPKGTEST_TMP" || exit 16
36
37 # First, gather system info
38 sudo -n mount -t debugfs none /sys/kernel/debug || true
39 if sudo -n [ -d /sys/kernel/debug/dri ]
40 then
41 for index in $(sudo -n ls /sys/kernel/debug/dri)
42 do
43 info="/sys/kernel/debug/dri/$index/amdgpu_firmware_info"
44 if sudo -n [ -f "$info" ]
45 then
46 # shellcheck disable=SC2024 # we don't need privileged write
47 sudo -n cat "$info" > "$AUTOPKGTEST_ARTIFACTS/amdgpu_firmware_info.$index"
48 fi
49 done
50 else
51 echo "Could not read /sys/kernel/debug/dri" >> "$AUTOPKGTEST_ARTIFACTS/firmware.err"
52 fi
53 # shellcheck disable=SC2024 # we don't need privileged write
54 sudo -n dmesg > "$AUTOPKGTEST_ARTIFACTS/dmesg.before" || true
55 # shellcheck disable=SC2024 # we don't need privileged write
56 sudo rocminfo > "$AUTOPKGTEST_ARTIFACTS/rocminfo.txt" || true
57
58 # Any individual failure is overall failure
59 EXITCODE=0
60 $TESTNAME || EXITCODE=1
61
62 # Tests might have generated new messages
63 # shellcheck disable=SC2024 # we don't need privileged write
64 sudo -n dmesg > "$AUTOPKGTEST_ARTIFACTS/dmesg.after" || true
65
66 exit $EXITCODE