-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
7,235 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#!/bin/bash | ||
|
||
case "$0" in | ||
*/*) MYDIR="${0%/*}" ;; | ||
*) MYDIR="`type -path $0`"; MYDIR="${MYDIR%/*}" | ||
esac | ||
|
||
NUM=0 | ||
FAIL=0 | ||
XFAIL=0 | ||
|
||
TMPDIR=`mktemp -d /tmp/runtest.XXXXXX` | ||
trap "rm -rf $TMPDIR" 0 1 2 3 9 15 | ||
|
||
find $* -name test.hal > $TMPDIR/alltests | ||
|
||
while read testname; do | ||
NUM=$(($NUM+1)) | ||
testdir=$(dirname $testname) | ||
echo "Running test: $testdir" 1>&2 | ||
$MYDIR/halrun -f $testname > $testdir/result 2> $testdir/stderr | ||
exitcode=$? | ||
if [ $exitcode -ne 0 ]; then | ||
reason="halrun exited with $exitcode" | ||
else | ||
if [ -e $testdir/checkresult ]; then | ||
$testdir/checkresult $testdir/result | ||
exitcode=$? | ||
reason="checkresult exited with $exitcode" | ||
elif [ -f $testdir/expected ]; then | ||
cmp -s $testdir/expected $testdir/result | ||
exitcode=$? | ||
reason="result differed from expected" | ||
if [ $exitcode -ne 0 ]; then | ||
diff -U1 $testdir/expected $testdir/result > $TMPDIR/diff | ||
SIZE=$(wc -l < $TMPDIR/diff) | ||
if [ $SIZE -lt 15 ]; then | ||
cat $TMPDIR/diff | ||
else | ||
OMIT=$((SIZE-15)) | ||
head -15 $TMPDIR/diff | ||
echo "($OMIT more lines omitted)" | ||
fi | ||
fi | ||
else | ||
exitcode=1 | ||
reason="Neither result nor checkresult existed" | ||
fi | ||
fi | ||
if [ $exitcode -ne 0 ]; then | ||
if [ -f $testdir/xfail ]; then | ||
XFAIL=$(($XFAIL+1)) | ||
echo "** $testdir: XFAIL: $reason" | ||
else | ||
FAIL=$(($FAIL+1)) | ||
echo "** $testdir: FAIL: $reason" | ||
fi | ||
else | ||
if [ -f $testdir/xfail ]; then | ||
echo "** $testdir: XPASS: Passed, but was expected to fail" | ||
fi | ||
fi | ||
done < $TMPDIR/alltests | ||
|
||
SUCC=$((NUM-FAIL-XFAIL)) | ||
if [ $XFAIL -eq 0 ]; then | ||
echo "Runtest: $NUM tests run, $SUCC successful, $FAIL failed" | ||
else | ||
echo "Runtest: $NUM tests run, $SUCC successful, $FAIL failed + $XFAIL expected" | ||
fi | ||
if [ $FAIL -ne 0 ]; then exit 1; else exit 0; fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
The HAL test suite | ||
~~~~~~~~~~~~~~~~~~~ | ||
The tests in these directories serve to test the behavior of HAL components. | ||
|
||
Each subdirectory of this directory may contain a test item. The runtests | ||
script recurses through the directory structure, so multiple tests could | ||
be structured as | ||
tests/ | ||
xyz.0 | ||
xyz.1 | ||
xyz.2 | ||
or | ||
tests/ | ||
xyz/ | ||
0 | ||
1 | ||
2 | ||
|
||
|
||
Two types of tests are supported: Regression tests, in which the output is | ||
tested against a "known good" output, and functional tests, in which the | ||
output is fed to a program that can determine whether it is correct or not | ||
|
||
|
||
Running the tests | ||
~~~~~~~~~~~~~~~~~ | ||
Currently, tests only work with the "run in place" configuration. They | ||
can be run by executing (from the top emc2 directory) | ||
scripts/runtests tests | ||
A subset of the tests can also be run: | ||
scripts/runtests tests/xyz tests/a* | ||
The directories named on the commandline are searched recursively for | ||
'test.hal' files, and a directory with such a file is assumed to contain a | ||
regression test or a functional test. | ||
|
||
|
||
Regression Tests | ||
~~~~~~~~~~~~~~~~ | ||
A regression test should consist of these three files: | ||
README | ||
A human-readable file describing the test | ||
test.hal | ||
A script that will be executed with halrun -f | ||
expected | ||
A file whose contents are compared with the stdout of | ||
halrun -f test.hal | ||
|
||
A typical regression test will load several components, usually including | ||
'threads' and 'sample', then collect samples from some number of calls | ||
to the realtime thread, then exit. | ||
|
||
Regression test "test.hal" files will almost always include the line | ||
setexact_for_test_suite_only | ||
which causes HAL to act as though the requested base_period was available. | ||
Otherwise, results will differ slightly depending on the actual base_period | ||
and regression tests will fail. | ||
|
||
The test passes if the expected and actual output are identical. | ||
Otherwise, the test fails. | ||
|
||
|
||
Functional Tests | ||
~~~~~~~~~~~~~~~~ | ||
A functional test should consist of three files: | ||
README | ||
A human-readable file describing the test | ||
test.hal | ||
A script that will be executed with halrun -f | ||
checkresult | ||
An executable file (such as a shell or python script) | ||
which determines if the stdout of | ||
halrun -f test.hal | ||
indicates success or failure | ||
|
||
Regression test "test.hal" files will often include the line | ||
setexact_for_test_suite_only | ||
which causes HAL to act as though the requested base_period was available. | ||
Otherwise, results will differ slightly depending on the actual base_period, | ||
which could affect whether 'checkresult' gives an accurate result. | ||
|
||
A typical regression test will load several components, usually including | ||
'threads' and 'sample', then collect samples from some number of calls | ||
to the realtime thread, then exit. 'checkresult' will look at the output | ||
and see if it indicates success. | ||
|
||
The test passes if the command "checkresult actual" returns a shell | ||
success value (exit code 0). Otherwise, the test fails. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Tests that 'halrun' on an empty file produces no output |
Empty file.
Empty file.
Oops, something went wrong.