1#!/bin/sh
2
3TMSIM="${TMSIM:-$(pwd)/../../tmsim}"
4if [ ! -x "${TMSIM}" ]; then
5 echo "Couldn't find tmsim executable: '${TMSIM}'" 1>&2
6 exit 1
7fi
8
9outfile=$(mktemp ${TMPDIR:-/tmp}/tmsimXXXXXX)
10trap "rm -f '${outfile}'" INT EXIT
11
12exitstatus=0
13exresfile=
14
15for test in *; do
16 [ -d "${test}" ] || continue
17
18 name=${test##*/}
19 printf "Running test case '%s': " "${name}"
20
21 exitstatus=0
22 read -r exitstatus < "${test}/exit"
23
24 (cd "${name}" && "${TMSIM}" input 2>"${outfile}")
25 ret=$?
26
27 if ! cmp -s "${outfile}" "${test}/output"; then
28 printf "FAIL: Output didn't match.\n\n" 2>&1
29 diff -u "${outfile}" "${test}/output"
30 exit 1
31 fi
32
33 if [ ${ret} -ne ${exitstatus} ]; then
34 printf "FAIL: Expected '%d', got '%d'.\n" \
35 "${exitstatus}" "${ret}"
36 exit
37 fi
38
39 printf "OK.\n"
40done