Files
xen/automation/scripts/run-tools-tests
T
Anthony PERARD 1cdf180308 CI: Fix status check for tools/tests
Without "pipefail", $? have the exit value of `tee`, which should
always be 0. But instead of using "pipefail", do collect the value of
from the test with $PIPESTATUS.

Signed-off-by: Anthony PERARD <anthony.perard@vates.tech>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
2025-06-06 12:06:34 +02:00

44 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
usage() {
echo "Usage: $0 tests-dir xml-out"
}
xml_out=$2
if [ -z "$xml_out" ]; then
xml_out=/dev/null
fi
printf '<?xml version="1.0" encoding="UTF-8"?>\n' > "$xml_out"
printf '<testsuites name="tools.tests">\n' >> "$xml_out"
printf ' <testsuite name="tools.tests">\n' >> "$xml_out"
failed=
for f in "$1"/*; do
if [ ! -x "$f" ]; then
echo "SKIP: $f not executable"
continue
fi
echo "Running $f"
printf ' <testcase name="%s">\n' "$f" >> "$xml_out"
"$f" 2>&1 | tee /tmp/out
ret=${PIPESTATUS[0]}
if [ "$ret" -ne 0 ]; then
echo "FAILED: $f"
failed+=" $f"
printf ' <failure type="failure" message="binary %s exited with code %d">\n' "$f" "$ret" >> "$xml_out"
printf '<![CDATA[' >> "$xml_out"
# TODO: Escape ']]>' if necessary
cat /tmp/out >> "$xml_out"
printf ']]>\n' >> "$xml_out"
printf ' </failure>\n' >> "$xml_out"
else
echo "PASSED"
fi
printf ' </testcase>\n' >> "$xml_out"
done
printf ' </testsuite>\n' >> "$xml_out"
printf '</testsuites>\n' >> "$xml_out"
if [ -n "$failed" ]; then
exit 1
fi