Debian Codegraph @

automation/scripts/run-tools-tests

raw symbols SCIP
1 #!/bin/bash
2
3 usage() {
4 echo "Usage: $0 tests-dir xml-out"
5 }
6
7 xml_out=$2
8 if [ -z "$xml_out" ]; then
9 xml_out=/dev/null
10 fi
11 printf '<?xml version="1.0" encoding="UTF-8"?>\n' > "$xml_out"
12 printf '<testsuites name="tools.tests">\n' >> "$xml_out"
13 printf ' <testsuite name="tools.tests">\n' >> "$xml_out"
14 failed=
15 for dir in "$1"/*; do
16 [ -d "$dir" ] || continue
17 echo "Running test in $dir"
18 printf ' <testcase name="%s">\n' "$dir" >> "$xml_out"
19 ret=
20 for f in "$dir"/*; do
21 [ -f "$f" ] || continue
22 [ -x "$f" ] || continue
23 "$f" 2>&1 | tee /tmp/out
24 ret=$?
25 if [ "$ret" -ne 0 ]; then
26 echo "FAILED: $ret"
27 failed+=" $dir"
28 printf ' <failure type="failure" message="binary %s exited with code %d">\n' "$f" "$ret" >> "$xml_out"
29 # TODO: could use xml escaping... but current tests seems to
30 # produce sane output
31 cat /tmp/out >> "$xml_out"
32 printf ' </failure>\n' >> "$xml_out"
33 else
34 echo "PASSED"
35 fi
36 done
37 if [ -z "$ret" ]; then
38 printf ' <skipped type="skipped" message="no executable test found in %s"/>\n' "$dir" >> "$xml_out"
39 fi
40 printf ' </testcase>\n' >> "$xml_out"
41 done
42 printf ' </testsuite>\n' >> "$xml_out"
43 printf '</testsuites>\n' >> "$xml_out"
44
45 if [ -n "$failed" ]; then
46 exit 1
47 fi