1#!/bin/sh23TMSIM="${TMSIM:-$(pwd)/../../tmsim}"4if [ ! -x "${TMSIM}" ]; then5 echo "Couldn't find tmsim executable: '${TMSIM}'" 1>&26 exit 17fi89outfile=$(mktemp ${TMPDIR:-/tmp}/tmsimXXXXXX)10trap "rm -f '${outfile}'" INT EXIT1112exitstatus=013exresfile=1415for test in *; do16 [ -d "${test}" ] || continue1718 name=${test##*/}19 printf "Running test case '%s': " "${name}"2021 exitstatus=022 read -r exitstatus < "${test}/exit"2324 (cd "${name}" && "${TMSIM}" input 2>"${outfile}")25 ret=$?2627 if ! cmp -s "${outfile}" "${test}/output"; then28 printf "FAIL: Output didn't match.\n\n" 2>&129 diff -u "${outfile}" "${test}/output"30 exit 131 fi3233 if [ ${ret} -ne ${exitstatus} ]; then34 printf "FAIL: Expected '%d', got '%d'.\n" \35 "${exitstatus}" "${ret}"36 exit37 fi3839 printf "OK.\n"40done