Kill mega-sena.sh
[lcapit-junk-code.git] / emu8086 / tests / run-tests
blobfd650301b3a46d1d4247c69d4556c61d97ae1eb6
1 #!/bin/sh
3 # This script runs the entire emu8086 test-suite.
5 # Luiz Fernando Nogueira Capitulino
6 # <lcapitulino@gmail.com>
8 TEST_GROUPS="control data-transfer arithmetic"
9 EMU_JAR_FILE="emu8086.jar"
10 GROUP_ORDER="order.txt"
11 RUN_JAR="java -jar $EMU_JAR_FILE -b"
13 run_test()
15 dtest=$1
16 script="$dtest/test.e"
17 output="$dtest/output.txt"
18 expected="$dtest/expected.txt"
20 $RUN_JAR $script > $output 2>&1
21 ret=$?
22 if [ $ret -eq 0 ]; then
23 cmp -s $expected $output
24 ret=$?
27 return $ret
30 success=0
31 failed=0
32 runs=0
34 run_group()
36 group=$1
37 order="$group/$GROUP_ORDER"
39 if [ ! -f $order ]; then
40 printf "\nERROR: group \"$group\" doesn't have a order file\n"
41 exit 1
44 for file in $(cat $order); do
45 dtest="$group/$file"
46 if [ -d "$dtest" ]; then
47 make -s -C $dtest
48 printf " %25s: " $file
49 run_test $dtest
50 if [ $? -eq 0 ]; then
51 printf "PASSED\n"
52 ((success++))
53 else
54 printf "FAILED\n"
55 ((failed++))
57 ((runs++))
59 done
62 run_suite()
64 printf "\nRunning tests:\n"
66 for group in $TEST_GROUPS; do
67 printf "\n\t$group\n"
68 run_group $group
69 done
71 # Print report
72 printf "\n\n"
73 printf "Checks: %d, " $runs
74 per=$(echo "(100 * $success / $runs)" | bc)
75 printf "Passed: %d (%d%%), " $success $per
76 per=$(echo "(100 * $failed / $runs)" | bc)
77 printf "Failed: %d (%d%%)" $failed $per
78 printf "\n\n"
82 ## Starts here
85 if [ ! -f "$EMU_JAR_FILE" ]; then
86 printf "ERROR: hm? Wanna run tests without the program?\n"
87 exit 1
90 if [ -n "$*" ]; then
91 # Run the tests specified in the cmd-line
92 TEST_GROUPS="$*"
95 run_suite