Skip to content

Commit ac94ceb

Browse files
committed
Fix a race in ktest-all and improve output
Turns out I broke it on last commit when there is more than one kernel to test, both processes were attempting to read from stdin, so revert that and fix it differently. While here, improve some idioms and collect errored out commands to be printed in the end, should make people less angry in the future when stuff just "fails".
1 parent 1025602 commit ac94ceb

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

ktest-all.sh

+16-11
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,46 @@
11
#!/bin/bash
22

3-
Script=${0##*/}
4-
53
set -euo pipefail
64

75
kprobe_only=(linux-3.10.0-123.el7.x86_64)
86
result=""
7+
error_run=""
98
declare -i failures=0
9+
all_kernels="$(find kernel-images/{amd64,arm64} -type f)"
1010

1111
function maybe_kflag
1212
{
1313
for k in "${kprobe_only[@]}"; do
1414
if [ "$1" = "$k" ]; then
15-
echo "-k"
1615
return 0
1716
fi
1817
done
1918

2019
return 1
2120
}
2221

23-
mkdir -p kernel-images/{amd64,arm64}
24-
25-
while IFS= read -r -d '' k
22+
for k in $all_kernels
2623
do
2724
kname="$(basename "$k")"
28-
echo testing "$kname"
29-
if ./krun.sh initramfs.gz "$k" quark-test "$(maybe_kflag "$kname")"; then
25+
cmdline="./krun.sh initramfs.gz $k quark-test"
26+
if maybe_kflag "$kname"; then
27+
cmdline+=" -k"
28+
fi
29+
if eval "$cmdline"; then
3030
r="$(printf "%s: ok" "$kname")"
3131
else
3232
r="$(printf "%s: fail" "$kname")"
33+
error_run+="${cmdline}"$'\n'
3334
failures=$((failures+1))
3435
fi
35-
result="${result}${r}\n"
36-
done < <(find kernel-images/{amd64,arm64} -type f -print0)
36+
result+="${r}"$'\n'
37+
done
3738

38-
echo -ne "$result"
39+
echo -n "$result"
3940
echo failures $failures
41+
if test -n "$error_run"; then
42+
echo to reproduce failed cases, run:
43+
echo -n "$error_run"
44+
fi
4045

4146
exit $failures

0 commit comments

Comments
 (0)