Skip to content

Commit

Permalink
Fix a race in ktest-all and improve output
Browse files Browse the repository at this point in the history
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".
  • Loading branch information
haesbaert committed Nov 25, 2024
1 parent 1025602 commit ac94ceb
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions ktest-all.sh
Original file line number Diff line number Diff line change
@@ -1,41 +1,46 @@
#!/bin/bash

Script=${0##*/}

set -euo pipefail

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

function maybe_kflag
{
for k in "${kprobe_only[@]}"; do
if [ "$1" = "$k" ]; then
echo "-k"
return 0
fi
done

return 1
}

mkdir -p kernel-images/{amd64,arm64}

while IFS= read -r -d '' k
for k in $all_kernels
do
kname="$(basename "$k")"
echo testing "$kname"
if ./krun.sh initramfs.gz "$k" quark-test "$(maybe_kflag "$kname")"; then
cmdline="./krun.sh initramfs.gz $k quark-test"
if maybe_kflag "$kname"; then
cmdline+=" -k"
fi
if eval "$cmdline"; then
r="$(printf "%s: ok" "$kname")"
else
r="$(printf "%s: fail" "$kname")"
error_run+="${cmdline}"$'\n'
failures=$((failures+1))
fi
result="${result}${r}\n"
done < <(find kernel-images/{amd64,arm64} -type f -print0)
result+="${r}"$'\n'
done

echo -ne "$result"
echo -n "$result"
echo failures $failures
if test -n "$error_run"; then
echo to reproduce failed cases, run:
echo -n "$error_run"
fi

exit $failures

0 comments on commit ac94ceb

Please sign in to comment.