Debian Codegraph @

debian/tests/upstream-binaries

raw
1 #!/usr/bin/env bash
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 TESTSDIR="/usr/libexec/rocm/$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 elif [ ! -d "$TESTSDIR" ]
33 then
34 echo "The directory $TESTSDIR does not exist." >&2
35 echo "Aborting." >&2
36 exit 1
37 fi
38
39 # 16 = testbed failure
40 cd "$AUTOPKGTEST_TMP" || exit 16
41
42 # First, gather system info
43 mount -t debugfs none /sys/kernel/debug || true
44 if [ -d /sys/kernel/debug/dri ]
45 then
46 for index in $(ls /sys/kernel/debug/dri)
47 do
48 info="/sys/kernel/debug/dri/$index/amdgpu_firmware_info"
49 if [ -f "$info" ]
50 then
51 # shellcheck disable=SC2024 # we don't need privileged write
52 cat "$info" > "$AUTOPKGTEST_ARTIFACTS/amdgpu_firmware_info.$index"
53 fi
54 done
55 else
56 echo "Could not read /sys/kernel/debug/dri" >> "$AUTOPKGTEST_ARTIFACTS/firmware.err"
57 fi
58 # shellcheck disable=SC2024 # we don't need privileged write
59 dmesg > "$AUTOPKGTEST_ARTIFACTS/dmesg.before" || true
60
61 EXITCODE=0
62
63 $TESTDIR/amdsmitst || EXITCODE=1
64
65 # Tests might have generated new messages
66 # shellcheck disable=SC2024 # we don't need privileged write
67 dmesg > "$AUTOPKGTEST_ARTIFACTS/dmesg.after" || true
68
69 return $EXITCODE
70