Debian Codegraph @

kernel/tests/runtests

raw symbols SCIP
1 #! /bin/sh
2 set -e
3
4 if [ -z "$1" ]; then
5 echo "Usage: runtests <architecture>" >&2
6 exit 1
7 fi
8
9 ARCH="$1"
10 PASSES=0
11 FAILURES=0
12
13 [ "$TEST_VERBOSE" ] || export TEST_VERBOSE=1
14
15 verbose () {
16 if [ "$TEST_VERBOSE" -ge 2 ]; then
17 echo "$@"
18 fi
19 eval "$@"
20 }
21
22 # Run a test based on a test file.
23 run_test () {
24 TEST="$1"
25
26 unset SUBARCH CPUINFO OFCPUS MACHINE FLAVOUR USABLE UNUSABLE \
27 || true
28 unset $(set | sed -n 's/^\(KERNEL_.*\)=.*/\1/p')
29 NUMCPUS=1
30 MAJORS=2.6
31
32 while read name value; do
33 case $name in
34 subarch)
35 SUBARCH="$value"
36 ;;
37 cpuinfo)
38 CPUINFO="${TEST%/*}/$value"
39 ;;
40 ofcpus)
41 OFCPUS="${TEST%/*}/$value"
42 ;;
43 numcpus)
44 NUMCPUS="$value"
45 ;;
46 machine)
47 MACHINE="$value"
48 ;;
49 majors)
50 MAJORS="$value"
51 ;;
52 flavour)
53 FLAVOUR="$value"
54 ;;
55 kernel-*)
56 KERNEL_LIST_NAME="$(echo "$name" | tr '[a-z].-' '[A-Z]__')"
57 eval $KERNEL_LIST_NAME="\$value"
58 export $KERNEL_LIST_NAME
59 ;;
60 usable)
61 USABLE="$value"
62 ;;
63 unusable)
64 UNUSABLE="$value"
65 ;;
66 env)
67 # TODO: is there any quote-safe way to do
68 # this?
69 eval "export ${value%% *}='${value#* }'"
70 ;;
71 esac
72 done < "$TEST"
73
74 export ARCH SUBARCH CPUINFO OFCPUS NUMCPUS MACHINE
75 export MAJORS FLAVOUR
76 export USABLE UNUSABLE
77
78 TMP="$(mktemp -t base-installer-tests.XXXXXX)"
79 trap 'rm -f "$TMP"' 0 HUP INT QUIT TERM
80
81 # Run the actual testset.
82 verbose ./dotest >"$TMP"
83
84 # Massage testset output into a more useful form.
85 while read state message; do
86 case "$state" in
87 PASS)
88 PASSES="$(($PASSES + 1))"
89 ;;
90 FAIL)
91 FAILURES="$(($FAILURES + 1))"
92 ;;
93 esac
94 if [ "$state" != PASS ] || [ "$TEST_VERBOSE" -ge 2 ]; then
95 echo "$state $TEST $message"
96 fi
97 done <"$TMP"
98 rm -f "$TMP"
99 trap 0 HUP INT QUIT TERM
100 }
101
102 if [ "$2" ]; then
103 ONETEST="$2"
104 run_test "$ONETEST"
105 else
106 for test in "$ARCH"/*.test; do
107 # Sanity check: check test file for incorrect line continuations
108 if ! awk 'BEGIN {lc=0}
109 /\\[[:space:]]*$/ {if (lc==1 && substr($0,1,1)!=" ") {exit 1}; lc=1}
110 /[^\\][[:space:]]*$/ {lc=0}
111 END {if (lc==1) {exit 1}}' $test
112 then
113 echo "Incorrect line continuation in test file '$test'"
114 exit 1
115 fi
116 run_test "$test"
117 done
118 fi
119
120 if [ "$TEST_VERBOSE" -ge 1 ]; then
121 echo "$ARCH: $PASSES passes, $FAILURES failures."
122 fi
123
124 if [ "$FAILURES" -eq 0 ]; then
125 exit 0
126 else
127 exit 1
128 fi