1#!/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 program, packet, output, and optionally, starting data and/or age. 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 if [[ -f testdata/$testcase.age ]]; then 23 args="$args --age $(cat testdata/$testcase.age)" 24 fi 25 26 if diff --color -u <(apf_run $args) <(cat $outputpath); then 27 echo $testname: $testcase: PASS 28 else 29 echo $testname: $testcase: FAIL 30 retcode=1 31 fi 32done 33 34# Report pass/fail to the test runner. 35exit $retcode 36