Lorenzo Colitti | 26dafcd | 2019-09-26 23:40:02 +0900 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # Find out where we are and what we're called. |
| 4 | cd $(dirname $0) |
| 5 | testname=$(basename $(basename $0 .sh)) |
| 6 | |
| 7 | # All's well that ends well. |
| 8 | retcode=0 |
| 9 | |
| 10 | # Loop through testcases and run each one. |
| 11 | # Each testcase is composed of a program, a packet, optionally the starting data, and the output. |
| 12 | for prog in testdata/*.program; do |
| 13 | testcase=$(basename $prog .program) |
| 14 | prog=$(cat testdata/$testcase.program) |
| 15 | pkt=$(cat testdata/$testcase.packet) |
| 16 | outputpath=testdata/$testcase.output |
| 17 | |
| 18 | args="--trace --program $prog --packet $pkt" |
| 19 | if [[ -f testdata/$testcase.data ]]; then |
| 20 | args="$args --data $(cat testdata/$testcase.data)" |
| 21 | fi |
| 22 | |
| 23 | if diff --color -u <(apf_run $args) <(cat $outputpath); then |
| 24 | echo $testname: $testcase: PASS |
| 25 | else |
| 26 | echo $testname: $testcase: FAIL |
| 27 | retcode=1 |
| 28 | fi |
| 29 | done |
| 30 | |
| 31 | # Report pass/fail to the test runner. |
| 32 | exit $retcode |