blob: b365e8446c2f912d7ef30c2a577cb6378c443ed1 [file] [log] [blame]
Lorenzo Colitti26dafcd2019-09-26 23:40:02 +09001#!/bin/bash
2
3# Find out where we are and what we're called.
4cd $(dirname $0)
5testname=$(basename $(basename $0 .sh))
6
7# All's well that ends well.
8retcode=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.
12for 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
29done
30
31# Report pass/fail to the test runner.
32exit $retcode