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. |
Lorenzo Colitti | 82f4e34 | 2020-07-09 00:01:57 +0900 | [diff] [blame] | 11 | # Each testcase is composed of program, packet, output, and optionally, starting data and/or age. |
Lorenzo Colitti | 26dafcd | 2019-09-26 23:40:02 +0900 | [diff] [blame] | 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 |
Lorenzo Colitti | 82f4e34 | 2020-07-09 00:01:57 +0900 | [diff] [blame] | 22 | if [[ -f testdata/$testcase.age ]]; then |
| 23 | args="$args --age $(cat testdata/$testcase.age)" |
| 24 | fi |
Lorenzo Colitti | 26dafcd | 2019-09-26 23:40:02 +0900 | [diff] [blame] | 25 | |
Lorenzo Colitti | c8fcf5e | 2020-08-24 16:39:11 +0900 | [diff] [blame] | 26 | if diff --color -u <(./apf_run $args) <(cat $outputpath); then |
Lorenzo Colitti | 26dafcd | 2019-09-26 23:40:02 +0900 | [diff] [blame] | 27 | echo $testname: $testcase: PASS |
| 28 | else |
| 29 | echo $testname: $testcase: FAIL |
| 30 | retcode=1 |
| 31 | fi |
| 32 | done |
| 33 | |
| 34 | # Report pass/fail to the test runner. |
| 35 | exit $retcode |