blob: ef47fc83c0da1fe61b3a1f62b68d978b8b8955ea [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.
Lorenzo Colitti82f4e342020-07-09 00:01:57 +090011# Each testcase is composed of program, packet, output, and optionally, starting data and/or age.
Lorenzo Colitti26dafcd2019-09-26 23:40:02 +090012for 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 Colitti82f4e342020-07-09 00:01:57 +090022 if [[ -f testdata/$testcase.age ]]; then
23 args="$args --age $(cat testdata/$testcase.age)"
24 fi
Lorenzo Colitti26dafcd2019-09-26 23:40:02 +090025
Lorenzo Colittic8fcf5e2020-08-24 16:39:11 +090026 if diff --color -u <(./apf_run $args) <(cat $outputpath); then
Lorenzo Colitti26dafcd2019-09-26 23:40:02 +090027 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