diff options
author | Klaus Aehlig <klaus.aehlig@huawei.com> | 2022-02-23 15:02:50 +0100 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2022-02-23 15:02:50 +0100 |
commit | 741ef53eab173e10a6e935319ee1af1acdd37273 (patch) | |
tree | 61c5d1d20cac5b52c43dbf858e1c64feff56a814 /shell/test/test_runner.sh | |
parent | 6f1bff70d3757268275fca937ff93d1a6475c3f1 (diff) | |
download | rules-cc-741ef53eab173e10a6e935319ee1af1acdd37273.tar.gz |
Add shell/test rule
... allowing to run simple tests given by a shell script.
Diffstat (limited to 'shell/test/test_runner.sh')
-rwxr-xr-x | shell/test/test_runner.sh | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/shell/test/test_runner.sh b/shell/test/test_runner.sh new file mode 100755 index 0000000..969b80a --- /dev/null +++ b/shell/test/test_runner.sh @@ -0,0 +1,44 @@ +#!/bin/sh + +# ensure all required outputs are present +touch stdout +touch stderr +RESULT=UNKNOWN +echo "${RESULT}" > result +echo UNKNOWN > time-start +echo UNKNOWN > time-stop + +mkdir scratch +export TEST_TMPDIR=$(realpath scratch) +export TMPDIR="${TEST_TMPDIR}" + +# Change to the working directory; note: while unlikely, the test +# might not have test data, so we have to ensure the presence of +# the work directory. +mkdir -p work +cd work + +date +%s > ../time-start +# TODO: +# - proper wrapping with timeout +if sh ../test.sh > ../stdout 2> ../stderr +then + RESULT=PASS +else + RESULT=FAIL +fi +date +%s > ../time-stop + +# Ensure all the promissed output files in the work directory +# are present, even if the test failed to create them. +for f in "$@" +do + touch "./${f}" +done + +echo "${RESULT}" > ../result + +if [ "${RESULT}" '!=' PASS ] +then + exit 1; +fi |