| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | |
| 3 | usagescip-shell shell xen 4.20.2+37-g61ff35323e-1 usage().() { |
| 4 | echoscip-shell system . . echo. "Usage: $0 tests-dir xml-out" |
| 5 | } |
| 6 | |
| 7 | xml_out=$2 |
| 8 | if [scip-shell system . . `[`. -z "$xml_out" ]; then |
| 9 | xml_out=/dev/nullscip-shell filesystem . . `/dev/null`. |
| 10 | fi |
| 11 | printfscip-shell system . . printf. '<?xml version="1.0" encoding="UTF-8"?>\n' > "$xml_out" |
| 12 | printfscip-shell system . . printf. '<testsuites name="tools.tests">\n' >> "$xml_out" |
| 13 | printfscip-shell system . . printf. ' <testsuite name="tools.tests">\n' >> "$xml_out" |
| 14 | failed= |
| 15 | for dir in "$1"/*; do |
| 16 | [scip-shell system . . `[`. -d "$dir" ] || continue |
| 17 | echoscip-shell system . . echo. "Running test in $dir" |
| 18 | printfscip-shell system . . printf. ' <testcase name="%s">\n' "$dir" >> "$xml_out" |
| 19 | ret= |
| 20 | for f in "$dir"/*; do |
| 21 | [scip-shell system . . `[`. -f "$f" ] || continue |
| 22 | [scip-shell system . . `[`. -x "$f" ] || continue |
| 23 | "$f" 2>&1 | teescip-shell system . . tee. /tmp/outscip-shell filesystem . . `/tmp/out`. |
| 24 | ret=$? |
| 25 | if [scip-shell system . . `[`. "$ret" -ne 0 ]; then |
| 26 | echoscip-shell system . . echo. "FAILED: $ret" |
| 27 | failed+=" $dir" |
| 28 | printfscip-shell system . . 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 | catscip-shell system . . cat. /tmp/outscip-shell filesystem . . `/tmp/out`. >> "$xml_out" |
| 32 | printfscip-shell system . . printf. ' </failure>\n' >> "$xml_out" |
| 33 | else |
| 34 | echoscip-shell system . . echo. "PASSED" |
| 35 | fi |
| 36 | done |
| 37 | if [scip-shell system . . `[`. -z "$ret" ]; then |
| 38 | printfscip-shell system . . printf. ' <skipped type="skipped" message="no executable test found in %s"/>\n' "$dir" >> "$xml_out" |
| 39 | fi |
| 40 | printfscip-shell system . . printf. ' </testcase>\n' >> "$xml_out" |
| 41 | done |
| 42 | printfscip-shell system . . printf. ' </testsuite>\n' >> "$xml_out" |
| 43 | printfscip-shell system . . printf. '</testsuites>\n' >> "$xml_out" |
| 44 | |
| 45 | if [scip-shell system . . `[`. -n "$failed" ]; then |
| 46 | exit 1 |
| 47 | fi |