Browse Source

tools/tests: remove scas requirement

I'm about to break compatibility with scas. Before I do that, I
need to adjusts tests. Instead of running scas to compare results,
we commit expected result as binaries directly in the repo.
pull/10/head
Virgil Dupras 5 years ago
parent
commit
a7afbe091e
12 changed files with 1618 additions and 9 deletions
  1. +1602
    -0
      tools/tests/zasm/allinstrs.asm
  2. BIN
      tools/tests/zasm/allinstrs.asm.expected
  3. +11
    -0
      tools/tests/zasm/geninstrs.py
  4. +2
    -9
      tools/tests/zasm/runtests.sh
  5. BIN
      tools/tests/zasm/test1.asm.expected
  6. BIN
      tools/tests/zasm/test2.asm.expected
  7. +1
    -0
      tools/tests/zasm/test3.asm.expected
  8. BIN
      tools/tests/zasm/test4.asm.expected
  9. +1
    -0
      tools/tests/zasm/test5.asm.expected
  10. BIN
      tools/tests/zasm/test6.asm.expected
  11. BIN
      tools/tests/zasm/test7.asm.expected
  12. +1
    -0
      tools/tests/zasm/test8.asm.expected

+ 1602
- 0
tools/tests/zasm/allinstrs.asm
File diff suppressed because it is too large
View File


BIN
tools/tests/zasm/allinstrs.asm.expected View File


+ 11
- 0
tools/tests/zasm/geninstrs.py View File

@@ -1,6 +1,8 @@
#!/usr/bin/env python3
# Generate almost all possible combination for instructions from instruction
# tables
# When zasm supported instructions change, use this script to update
# allinstrs.asm

import sys

@@ -108,6 +110,11 @@ def genargs(argspec):
grp = argGrpTbl[argspec]
return [argspecTbl[a] for a in grp]

# process a 'n' arg into an 'e' one
def eargs(args):
newargs = ['$+'+s for s in args[:-1]]
return newargs + ['$-'+s for s in args[:-1]]

def p(line):
if line not in BLACKLIST:
print(line)
@@ -131,12 +138,16 @@ def main():
if n in {'BIT', 'SET', 'RES'}:
# we only want to keep 1, 2, 4
args1 = args1[:3]
if n in {'JR', 'DJNZ'} and a1 == 'n':
args1 = eargs(args1)
if n == 'IM':
args1 = [0, 1, 2]
if args1:
for arg1 in args1:
args2 = genargs(a2)
if args2:
if n in {'JR', 'DJNZ'} and a2 == 'n':
args2 = eargs(args2)
for arg2 in args2:
p(f"{n} {arg1}, {arg2}")
else:


+ 2
- 9
tools/tests/zasm/runtests.sh View File

@@ -3,7 +3,6 @@
set -e

TMPFILE=$(mktemp)
SCAS=scas
KERNEL=../../../kernel
APPS=../../../apps
ZASM=../../zasm.sh
@@ -12,7 +11,7 @@ ASMFILE=${APPS}/zasm/instr.asm
cmpas() {
FN=$1
shift 1
EXPECTED=$($SCAS -I ${KERNEL} -I ${APPS} -o - "${FN}" | xxd)
EXPECTED=$(xxd ${FN}.expected)
ACTUAL=$(cat ${FN} | $ZASM "$@" | xxd)
if [ "$ACTUAL" == "$EXPECTED" ]; then
echo ok
@@ -25,15 +24,9 @@ cmpas() {
fi
}

for fn in test*.asm; do
for fn in *.asm; do
echo "Comparing ${fn}"
cmpas $fn "${KERNEL}" "${APPS}"
done

./geninstrs.py $ASMFILE | \
while read line; do
echo $line | tee "${TMPFILE}"
cmpas ${TMPFILE}
done

./errtests.sh

BIN
tools/tests/zasm/test1.asm.expected View File


BIN
tools/tests/zasm/test2.asm.expected View File


+ 1
- 0
tools/tests/zasm/test3.asm.expected View File

@@ -0,0 +1 @@
�0_��0$o�

BIN
tools/tests/zasm/test4.asm.expected View File


+ 1
- 0
tools/tests/zasm/test5.asm.expected View File

@@ -0,0 +1 @@
>D>!>(

BIN
tools/tests/zasm/test6.asm.expected View File


BIN
tools/tests/zasm/test7.asm.expected View File


+ 1
- 0
tools/tests/zasm/test8.asm.expected View File

@@ -0,0 +1 @@


Loading…
Cancel
Save