| 1 | #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash |
| 2 | |
| 3 | # Simple test script adapted from Matt Dillon's 2.16 release. |
| 4 | # It's harder to do this in a Makefile, so let's use a script. |
| 5 | |
| 6 | should_fail="0" |
| 7 | |
| 8 | REL_DIR="../bin" |
| 9 | |
| 10 | DEFINES="" |
| 11 | format="1" |
| 12 | |
| 13 | while [scip-shell system . . `[`. "$1" != "" ] |
| 14 | do |
| 15 | case "$1" in |
| 16 | -R) REL_DIR="$2" |
| 17 | shift |
| 18 | ;; |
| 19 | -S) should_fail="$2" |
| 20 | shift |
| 21 | ;; |
| 22 | -D) DEFINES="${DEFINES} -D$2" |
| 23 | shift |
| 24 | ;; |
| 25 | -F) format="$2" |
| 26 | shift |
| 27 | ;; |
| 28 | -I) DEFINES="${DEFINES} -I$2" |
| 29 | ;; |
| 30 | esac |
| 31 | shift |
| 32 | done |
| 33 | |
| 34 | echoscip-shell system . . echo. "=== build test cases (strict=off)" |
| 35 | |
| 36 | fail="0" |
| 37 | ok="0" |
| 38 | nTests="0" |
| 39 | |
| 40 | leadingSpacescip-shell shell dasm 2.20.15~20201109+really2.20.14.1-3 leadingSpace().() { |
| 41 | echoscip-shell system . . echo. "$@" | awkscip-shell system . . awk. '{ printf(" * % 32s", $0)}' |
| 42 | } |
| 43 | |
| 44 | refFiles=`findscip-shell system . . find. . -type f -name '*.bin.ref' | sortscip-shell system . . sort.` |
| 45 | |
| 46 | for item in $refFiles |
| 47 | do |
| 48 | ARGS="-f${format}" |
| 49 | |
| 50 | NAME=$(echoscip-shell system . . echo. $item | sedscip-shell system . . sed. 's/\.bin\.ref$//g;s/^\.\///g') |
| 51 | |
| 52 | leadingSpacescip-shell shell dasm 2.20.15~20201109+really2.20.14.1-3 leadingSpace(). "$NAME" |
| 53 | |
| 54 | if testscip-shell system . . test. -r ${NAME}.args |
| 55 | then |
| 56 | . ${NAME}.args |
| 57 | fi |
| 58 | |
| 59 | if ${REL_DIR}/dasm ${NAME}.asm ${ARGS} -o$NAME.bin -L$NAME.list.txt -DINEEPROM ${DEFINES} >$NAME.out 2>&1 |
| 60 | then |
| 61 | if testscip-shell system . . test. -s $NAME.bin |
| 62 | then |
| 63 | ${REL_DIR}/ftohex 1 $NAME.bin $NAME.hex |
| 64 | if cmpscip-shell system . . cmp. -s $NAME.bin $NAME.bin.ref |
| 65 | then |
| 66 | echoscip-shell system . . echo. " binary is same, pass" |
| 67 | ok="$[$ok+1]" |
| 68 | else |
| 69 | # second compare test is not needed, just help to find the diff |
| 70 | if ! testscip-shell system . . test. -r $NAME.hex.ref |
| 71 | then |
| 72 | echoscip-shell system . . echo. " file [$NAME.hex.ref] missing FAILED!" |
| 73 | else |
| 74 | diffscip-shell system . . diff. -bBduw $NAME.hex $NAME.hex.ref >$NAME.hex.diff |
| 75 | echoscip-shell system . . echo. " binaries differ FAILED!" |
| 76 | fi |
| 77 | fail="$[$fail+1]" |
| 78 | fi |
| 79 | else |
| 80 | echoscip-shell system . . echo. " file doesn't exist or has zero size FAILED!" |
| 81 | fail="$[$fail+1]" |
| 82 | fi |
| 83 | else |
| 84 | echoscip-shell system . . echo. " assembly FAILED! [$?]" |
| 85 | fail="$[$fail+1]" |
| 86 | fi |
| 87 | nTests="$[$nTests+1]" |
| 88 | done |
| 89 | |
| 90 | LIST=`findscip-shell system . . find. . -type f -name '*.fail' | sortscip-shell system . . sort.` |
| 91 | if [scip-shell system . . `[`. "$LIST" != "" ] |
| 92 | then |
| 93 | |
| 94 | echoscip-shell system . . echo. "" |
| 95 | echoscip-shell system . . echo. "=== error test cases (strict=on)" |
| 96 | |
| 97 | # test for assembly sniplets that should fail |
| 98 | for item in $LIST |
| 99 | do |
| 100 | ARGS="-f${format}" |
| 101 | |
| 102 | NAME=$(echoscip-shell system . . echo. $item | sedscip-shell system . . sed. 's/\.fail$//g;s/^\.\///g') |
| 103 | leadingSpacescip-shell shell dasm 2.20.15~20201109+really2.20.14.1-3 leadingSpace(). "$NAME" |
| 104 | |
| 105 | if testscip-shell system . . test. -r ${NAME}.args |
| 106 | then |
| 107 | . ${NAME}.args |
| 108 | fi |
| 109 | |
| 110 | if ! testscip-shell system . . test. -r ${NAME}.asm |
| 111 | then |
| 112 | echoscip-shell system . . echo. "source file [${NAME}.asm] is missing" |
| 113 | fail="$[$fail+1]" |
| 114 | else |
| 115 | if ${REL_DIR}/dasm ${NAME}.asm -S ${ARGS} -o$NAME.bin -L$NAME.list.txt -DINEEPROM ${DEFINES} >${NAME}.out 2>&1 |
| 116 | then |
| 117 | echoscip-shell system . . echo. " no error FAILED!" |
| 118 | fail="$[$fail+1]" |
| 119 | else |
| 120 | case "$ARGS" in |
| 121 | *-R) if testscip-shell system . . test. -r $NAME.bin |
| 122 | then |
| 123 | echoscip-shell system . . echo. " file exists, FAILED!" |
| 124 | fail="$[$fail+1]" |
| 125 | else |
| 126 | echoscip-shell system . . echo. " file was deleted, pass" |
| 127 | ok="$[$ok+1]" |
| 128 | fi |
| 129 | ;; |
| 130 | *) got_error_level="$?" |
| 131 | expected_error_level=`catscip-shell system . . cat. $item | headscip-shell system . . head. -1` |
| 132 | if [scip-shell system . . `[`. "${expected_error_level}" = "" ] |
| 133 | then |
| 134 | echoscip-shell system . . echo. " testcase definition incomplete, missing error_level (${got_error_level}), FAILED!" |
| 135 | fail="$[$fail+1]" |
| 136 | else |
| 137 | if [scip-shell system . . `[`. "${got_error_level}" != "${expected_error_level}" ] |
| 138 | then |
| 139 | echoscip-shell system . . echo. " got error_level (${got_error_level}) but expected (${expected_error_level}), double FAULT!" |
| 140 | fail="$[$fail+1]" |
| 141 | else |
| 142 | echoscip-shell system . . echo. " error_code [${got_error_level}] pass" |
| 143 | ok="$[$ok+1]" |
| 144 | fi |
| 145 | fi |
| 146 | ;; |
| 147 | esac |
| 148 | fi |
| 149 | fi |
| 150 | nTests="$[$nTests+1]" |
| 151 | done |
| 152 | |
| 153 | fi |
| 154 | |
| 155 | echoscip-shell system . . echo. -n "executed ${nTests} tests, $ok OK, $fail failed, result: " |
| 156 | |
| 157 | if [scip-shell system . . `[`. "$[$ok+${should_fail}]" = "$nTests" ] |
| 158 | then |
| 159 | echoscip-shell system . . echo. "overall PASS" |
| 160 | exit 0 |
| 161 | else |
| 162 | suspect="$[$fail-${should_fail}]" |
| 163 | echoscip-shell system . . echo. "need to investigate in $suspect test-cases" |
| 164 | exit $suspect |
| 165 | fi |
| 166 | |
| 167 | |
| 168 |