#!/bin/bash usage() { echo "Usage: $0 tests-dir xml-out" } xml_out=$2 if [ -z "$xml_out" ]; then xml_out=/dev/null fi printf '\n' > "$xml_out" printf '\n' >> "$xml_out" printf ' \n' >> "$xml_out" failed= for f in "$1"/*; do if [ ! -x "$f" ]; then echo "SKIP: $f not executable" continue fi echo "Running $f" time_start=$EPOCHREALTIME "$f" 2>&1 | tee /tmp/out ret=${PIPESTATUS[0]} time_end=$EPOCHREALTIME time_delta="$(bc <<<"$time_end - $time_start")" printf ' \n' "$f" "$time_delta" >> "$xml_out" if [ "$ret" -ne 0 ]; then echo "FAILED: $f" failed+=" $f" printf ' \n' "$f" "$ret" >> "$xml_out" printf '> "$xml_out" # TODO: Escape ']]>' if necessary cat /tmp/out >> "$xml_out" printf ']]>\n' >> "$xml_out" printf ' \n' >> "$xml_out" else echo "PASSED" fi printf ' \n' >> "$xml_out" done printf ' \n' >> "$xml_out" printf '\n' >> "$xml_out" if [ -n "$failed" ]; then exit 1 fi