blob: b9698e500cadea794662a571f482a6dae9667763 [file] [log] [blame]
ajwong@chromium.org45afe012009-10-23 19:20:20 +00001#! /bin/sh
ajwong@chromium.org45afe012009-10-23 19:20:20 +00002
3YASM_TEST_SUITE=1
4export YASM_TEST_SUITE
5
6case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
7 *c*,-n*) ECHO_N= ECHO_C='
8' ECHO_T=' ' ;;
9 *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;;
10 *) ECHO_N= ECHO_C='\c' ECHO_T= ;;
11esac
12
13mkdir results >/dev/null 2>&1
14
15#
16# Verify that all test cases match
17#
18
19passedct=0
20failedct=0
21
22echo $ECHO_N "Test $1: $ECHO_C"
23for asm in ${srcdir}/$2/*.asm
24do
25 a=`echo ${asm} | sed 's,^.*/,,;s,.asm$,,'`
26 o=${a}$5
27 oh=${a}.hx
28 og=`echo ${asm} | sed 's,.asm$,.hex,'`
29 e=${a}.ew
30 eg=`echo ${asm} | sed 's,.asm$,.errwarn,'`
hbono@chromium.orga1b52332011-01-13 05:35:22 +000031 if test \! -f ${eg}; then
ajwong@chromium.org45afe012009-10-23 19:20:20 +000032 eg=/dev/null
33 fi
34
35 # Run within a subshell to prevent signal messages from displaying.
36 sh -c "cat ${asm} | ./yasm $4 -o results/${o} - 2>results/${e}" >/dev/null 2>/dev/null
37 status=$?
38 if test $status -gt 128; then
39 # We should never get a coredump!
40 echo $ECHO_N "C$ECHO_C"
41 eval "failed$failedct='C: ${a} crashed!'"
42 failedct=`expr $failedct + 1`
43 elif test $status -gt 0; then
44 echo ${asm} | grep err >/dev/null
45 if test $? -gt 0; then
46 # YASM detected errors but shouldn't have!
47 echo $ECHO_N "E$ECHO_C"
48 eval "failed$failedct='E: ${a} returned an error code!'"
49 failedct=`expr $failedct + 1`
50 else
51 # We got errors, check to see if they match:
52 if diff -w ${eg} results/${e} >/dev/null; then
53 # Error/warnings match, it passes!
54 echo $ECHO_N ".$ECHO_C"
55 passedct=`expr $passedct + 1`
56 else
57 # Error/warnings don't match.
58 echo $ECHO_N "W$ECHO_C"
59 eval "failed$failedct='W: ${a} did not match errors and warnings!'"
60 failedct=`expr $failedct + 1`
61 fi
62 fi
63 else
64 echo ${asm} | grep -v err >/dev/null
65 if test $? -gt 0; then
66 # YASM didn't detect errors but should have!
67 echo $ECHO_N "E$ECHO_C"
68 eval "failed$failedct='E: ${a} did not return an error code!'"
69 failedct=`expr $failedct + 1`
70 else
71 ./test_hd results/${o} > results/${oh}
hbono@chromium.orga1b52332011-01-13 05:35:22 +000072 if diff -w ${og} results/${oh} >/dev/null; then
ajwong@chromium.org45afe012009-10-23 19:20:20 +000073 if diff -w ${eg} results/${e} >/dev/null; then
74 # Both object file and error/warnings match, it passes!
75 echo $ECHO_N ".$ECHO_C"
76 passedct=`expr $passedct + 1`
77 else
78 # Error/warnings don't match.
79 echo $ECHO_N "W$ECHO_C"
80 eval "failed$failedct='W: ${a} did not match errors and warnings!'"
81 failedct=`expr $failedct + 1`
82 fi
83 else
84 # Object file doesn't match.
85 echo $ECHO_N "O$ECHO_C"
86 eval "failed$failedct='O: ${a} did not match object file!'"
87 failedct=`expr $failedct + 1`
88 fi
89 fi
90 fi
91done
92
93ct=`expr $failedct + $passedct`
94per=`expr 100 \* $passedct / $ct`
95
96echo " +$passedct-$failedct/$ct $per%"
97i=0
98while test $i -lt $failedct; do
99 eval "failure=\$failed$i"
100 echo " ** $failure"
101 i=`expr $i + 1`
102done
103
104exit $failedct