summaryrefslogtreecommitdiff
path: root/impl/test/run
blob: d15fb68730610e0270aa5f59d0e14b6796d5cf26 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
NUM=1
FAILED=0

echo "Testing binary: $1 in directory $DIR"
while [ -f "$DIR/$NUM.eqns" ]
do
  cat "$DIR/$NUM.soln" | sort > "/tmp/$NUM.soln.tmp"
  mv "/tmp/$NUM.soln.tmp" "$DIR/$NUM.soln" 2> /dev/null
  OUTPUT=$(timeout 5s $1 "$DIR/$NUM.eqns" 2> /dev/null)
  if [ $? -eq 124 ]; then
    OUTPUT="did not terminate"
  fi
  DIFF=$(echo "$OUTPUT" | sort | diff - "$DIR/$NUM.soln")
  if [ ! -z "$DIFF" ]; then
    echo "=================="
    echo "Test #$NUM failed:"
    echo "$OUTPUT" | sort | sdiff - "$DIR/$NUM.soln"
    echo
    FAILED=$(($FAILED + 1))
  fi
  NUM=$(($NUM + 1))
done

if [ "$FAILED" -eq "0" ]; then
  echo "All tests passed."
fi
if [ ! "$FAILED" -eq "0" ]; then
  echo "$FAILED tests failed."
fi