1 #! /bin/sh 2 3 YASM_TEST_SUITE=1 4 export YASM_TEST_SUITE 5 6 case `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= ;; 11 esac 12 13 mkdir results >/dev/null 2>&1 14 15 # 16 # Verify that all test cases match 17 # 18 19 passedct=0 20 failedct=0 21 22 echo $ECHO_N "Test $1: $ECHO_C" 23 for asm in ${srcdir}/$2/*.asm 24 do 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,'` 31 if test \! -f ${eg}; then 32 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} 72 if diff -w ${og} results/${oh} >/dev/null; then 73 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 91 done 92 93 ct=`expr $failedct + $passedct` 94 per=`expr 100 \* $passedct / $ct` 95 96 echo " +$passedct-$failedct/$ct $per%" 97 i=0 98 while test $i -lt $failedct; do 99 eval "failure=\$failed$i" 100 echo " ** $failure" 101 i=`expr $i + 1` 102 done 103 104 exit $failedct 105