Commit f8e8763c authored by Benoit Perrot's avatar Benoit Perrot
Browse files

Distribute tests suite.

parent ffe657ca
2003-08-11 Benot Perrot <benoit@lrde.epita.fr>
* tests/Makefile.am: Distribute tests machinery.
* tests/common.mk: Distribute variables and rules used by
the test suite.
* tests/generate-ref.mk: Distribute reference output files generators.
* tests/mipsy-check: Distribute main test script.
* tests/lexical/invalid-string-hexa.s,
* tests/lexical/invalid-string-octal.s,
* tests/lexical/unlimited-regs.s,
* tests/lexical/unrecognized-escape.s,
* tests/lexical/unterminated-string.s,
* tests/lexical/Makefile.am:
Distribute tests that fail at scan level.
* tests/syntax/too-many-operands.s,
* tests/syntax/asciiz-wrong-param.s,
* tests/syntax/Makefile.am:
Distribute tests that fail at parse level.
* tests/solve/undefined-labels.s,
* tests/solve/Makefile.am:
Distribute tests that fail at solve-time.
* tests/runtime/abs.s,
* tests/runtime/neg.s,
* tests/runtime/no-main.s,
* tests/runtime/Makefile.am:
Distribute tests that fail at run-time.
* tests/unlimited/simple-exp.s,
* tests/unlimited/Makefile.am:
Distribute tests that use unlimited registers.
* tests/good/add-sub.s,
* tests/good/and-or-nor-xor.s,
* tests/good/exit.s,
* tests/good/extended-euclide.s,
* tests/good/gtcd.s,
* tests/good/modular-exponent.s,
* tests/good/neg.s,
* tests/good/not.s,
* tests/good/print.s,
* tests/good/print_int.s,
* tests/good/read_int.s, tests/good/read_int.in,
* tests/good/seq-sne.s,
* tests/good/shift.s,
* tests/good/Makefile.am:
Distribute tests that execute normally.
* configure.ac, Makefile.am:
Distribute tests suite.
2003-07-29 Benot Perrot <benoit@lrde.epita.fr>
* dev/mipsy.xml, src/inst/program_builder.cc:
......
ACLOCAL_AMFLAGS = -I config
SUBDIRS = config src doc
SUBDIRS = config src doc tests
EXTRA_DIST = \
dev/license.hh \
......
......@@ -48,16 +48,14 @@ AC_CONFIG_FILES([
src/vm/Makefile
src/task/Makefile
doc/Makefile
tests/Makefile
tests/lexical/Makefile
tests/syntax/Makefile
tests/solve/Makefile
tests/runtime/Makefile
tests/unlimited/Makefile
tests/good/Makefile
])
# Consider tests directory
if test -d tests; then
AC_CONFIG_SUBDIRS([tests])
TESTSDIR=tests
else
TESTSDIR=
fi
AC_SUBST(TESTSDIR)
# Instantiate the output files.
AC_OUTPUT
SUBDIRS = lexical syntax solve runtime unlimited good
EXTRA_DIST = generate-ref.mk common.mk mipsy-check
### Common variables
REF_FILES = $(ASM_FILES:.s=.ref)
OUT_FILES = $(ASM_FILES:.s=.out)
CLEANFILES = *~ $(REF_FILES) $(OUT_FILES)
### Machinery
EXTRA_DIST = check-$(MODULE)
check_SCRIPTS = check-$(MODULE)
TESTS_ENVIRONMENT = \
top_builddir="$(top_builddir)" \
top_srcdir="$(top_srcdir)" \
srcdir="$(srcdir)"
TESTS = check-$(MODULE)
### Build reference output
MIPSY = mipsy
.s.ref:
input=`echo $< | sed 's/s$$/in/g'`; \
if test ! -f $$input; then \
input=/dev/null; \
fi; \
$(MIPSY) $(PSYFLAGS) $< <$$input >$@
BUILT_SOURCES := $(BUILT_SOURCES) $(REF_FILES)
### Sources
ASM_FILES = \
exit.s \
print_int.s \
print.s \
read_int.s \
add-sub.s \
and-or-nor-xor.s \
neg.s \
not.s \
seq-sne.s \
shift.s \
gtcd.s \
extended-euclide.s \
modular-exponent.s
INPUT_FILES = \
read_int.in
dist_noinst_DATA = $(ASM_FILES) $(INPUT_FILES)
### Machinery
MODULE=good
include ../common.mk
include ../generate-ref.mk
### runtime library
.text
exit:
li $v0, 10
syscall
print:
li $v0, 4
syscall
jr $ra
print_int:
li $v0, 1
syscall
jr $ra
.data
eol:
.asciiz "\n"
.text
main:
### test instructions: add, addi, addu, addui
li $t0, 42
li $t1, 2055
li $t2, 0x7fffffff
li $t3, 0x7ffff7d0
## signed addition
add $a0, $t0, $t1
jal print_int
la $a0, eol
jal print
addi $a0, $t0, 2055
jal print_int
la $a0, eol
jal print
## unsigned addition, no overflow-checking
addu $a0, $t2, $t3
jal print_int
la $a0, eol
jal print
addiu $a0, $t2, 0x7ffff7d0
jal print_int
la $a0, eol
jal print
### test instructions: sub, sub immediate, subu, subu immediate
li $t0, 2139
li $t1, 42
li $t2, 0x80000000
li $t3, 0x7ffff7cf
## signed substraction
sub $a0, $t1, $t0
jal print_int
la $a0, eol
jal print
sub $a0, $t0, 42
jal print_int
la $a0, eol
jal print
## unsigned substraction, no overflow-checking
subu $a0, $t2, $t3
jal print_int
la $a0, eol
jal print
subu $a0, $t2, 0x7ffff7cf
jal print_int
la $a0, eol
jal print
end:
j exit
### runtime library
.text
exit:
li $v0, 10
syscall
print:
li $v0, 4
syscall
jr $ra
print_int:
li $v0, 1
syscall
jr $ra
.data
eol:
.asciiz "\n"
.text
main:
### test instructions: and, andi
li $t0, 0x0
li $t1, 0x2
li $t2, 0xf
li $t3, 0x9
andi $a0, $t1, 0xffffffff
jal print_int
and $a0, $t0, $t1
jal print_int
and $a0, $t2, $t3
jal print_int
andi $a0, $t2, 0x7
jal print_int
la $a0, eol
jal print
### test instructions: or
li $t0, 0
li $t1, 2097
li $t2, 0x821
li $t3, 0x010
or $a0, $t0, $t1
jal print_int
la $a0, eol
jal print
or $a0, $t2, $t3
jal print_int
la $a0, eol
jal print
or $t4, $t1, $t3
or $a0, $t4, $t2
jal print_int
la $a0, eol
jal print
### test instructions: nor
li $t0, 0
li $t1, 1
nor $a0, $t0, $t0
jal print_int
la $a0, eol
jal print
nor $a0, $t0, $t1
jal print_int
la $a0, eol
jal print
nor $a0, $t1, $t0
jal print_int
la $a0, eol
jal print
nor $a0, $t1, $t1
jal print_int
la $a0, eol
jal print
### test instructions: xor, xori
li $t0, 0xf
li $t1, 0x83e
xor $a0, $t0, $t1
jal print_int
la $a0, eol
jal print
xori $a0, $t0, 0xf
jal print_int
la $a0, eol
jal print
xori $a0, $t0, 0xf0
jal print_int
la $a0, eol
jal print
end:
j exit
### test exit syscall
.text
main:
li $v0, 10
syscall
### runtime library
.text
exit:
li $v0, 10
syscall
print:
li $v0, 4
syscall
jr $ra
print_int:
li $v0, 1
syscall
jr $ra
.data
eol:
.asciiz "\n"
### xeucl(a, b, trace)
.data
Sxeucl_th: # table header
.asciiz " x\t| y\t| g\t| u\t| v\t| w\t| q\n"
Sxeucl_td1: # table data, first cell
.asciiz " "
Sxeucl_tdn: # table data, other cells
.asciiz "\t| "
.text
xeucl:
li $s0, 1 # x in $s0
li $s1, 0 # y in $s1
move $s2, $a0 # g = a in $s2
li $s3, 0 # u in $s3
li $s4, 1 # v in $s4
move $s5, $a1 # w = b in $s5
move $s7, $a2 # trace in $s7
sw $ra, ($fp) # return address in ($fp)
beqz $s7, Lxeucl_loop
beqz $s5, Lxeucl_loop_end
la $a0, Sxeucl_th
jal print
Lxeucl_loop:
beqz $s5, Lxeucl_loop_end
div $s6, $s2, $s5 # q = g / w in $s6
beqz $s7, Lxeucl_loop_trace_end
Lxeucl_loop_trace:
la $a0, Sxeucl_td1 # trace x
jal print
move $a0, $s0
jal print_int
la $a0, Sxeucl_tdn # trace y
jal print
move $a0, $s1
jal print_int
la $a0, Sxeucl_tdn # trace g
jal print
move $a0, $s2
jal print_int
la $a0, Sxeucl_tdn # trace u
jal print
move $a0, $s3
jal print_int
la $a0, Sxeucl_tdn # trace v
jal print
move $a0, $s4
jal print_int
la $a0, Sxeucl_tdn # trace w
jal print
move $a0, $s5
jal print_int
la $a0, Sxeucl_tdn # trace q
jal print
move $a0, $s6
jal print_int
li $a0, eol
jal print
Lxeucl_loop_trace_end:
mul $t0, $s6, $s3
sub $t1, $s0, $t0
move $s0, $s3 #
move $s3, $t1 # (x, u) := (u, x - q * u)
mul $t0, $s6, $s4
sub $t1, $s1, $t0
move $s1, $s4 #
move $s4, $t1 # (y, v) := (v, y - q * v)
mul $t0, $s6, $s5
sub $t1, $s2, $t0
move $s2, $s5 #
move $s5, $t1 # (g, w) := (w, g - q * w)
j Lxeucl_loop
Lxeucl_loop_end:
move $v0, $s0
move $v1, $s1
lw $ra, ($fp)
jr $ra
### xeucl(101, 17, 1): compute and trace extended euclide's algorithm
main:
li $a0, 101
li $a1, 17
li $a2, 1
jal xeucl
move $s0, $v0
move $s1, $v1
move $a0, $s0
jal print_int
la $a0, eol
jal print
move $a0, $s1
jal print_int
la $a0, eol
jal print
end:
j exit
### runtime library
.text
exit:
li $v0, 10
syscall
print:
li $v0, 4
syscall
jr $ra
print_int:
li $v0, 1
syscall
jr $ra
.data
eol:
.asciiz "\n"
### gtcd(a, b, trace)
.data
Sgtcd_th: # table header
.asciiz " a\t| b\t| a mod b\n---------------------------\n"
Sgtcd_td1: # table data, first cell
.asciiz " "
Sgtcd_tdn: # table data, other cells
.asciiz "\t| "
.text
gtcd:
move $s0, $a0 # a in $s0
move $s1, $a1 # b in $s1
move $s3, $a2 # trace in $s3
move $s7, $ra # return address in $s7
beqz $s3, Lgtcd_loop
beqz $s1, Lgtcd_loop_end
la $a0, Sgtcd_th
jal print
Lgtcd_loop:
beqz $s1, Lgtcd_loop_end
rem $s2, $s0, $s1
beqz $s3, Lgtcd_loop_trace_end
Lgtcd_loop_trace:
la $a0, Sgtcd_td1 # trace a
jal print
move $a0, $s0
jal print_int
la $a0, Sgtcd_tdn # trace b
jal print
move $a0, $s1
jal print_int
la $a0, Sgtcd_tdn # trace a % b
jal print
move $a0, $s2
jal print_int
li $a0, eol # end of trace
jal print
Lgtcd_loop_trace_end:
move $s0, $s1
move $s1, $s2
j Lgtcd_loop
Lgtcd_loop_end:
move $v0, $s0
jr $s7
### gtcd(2097, 42, 1): compute and trace gtcd(2097, 42)
main:
li $a0, 2097
li $a1, 42
li $a2, 1
jal gtcd
move $a0, $v0
jal print_int
li $a0, eol
jal print
end:
j exit
### runtime library
.text
exit:
li $v0, 10
syscall
print:
li $v0, 4
syscall
jr $ra
print_int:
li $v0, 1
syscall
jr $ra
.data
eol:
.asciiz "\n"
### modexp(g, e, m, trace)
.data
Smodexp_th: # table header
.asciiz " e_i\t| h\t| g\n------------------------\n"
Smodexp_td1: # table data, first cell
.asciiz " "
Smodexp_tdn: # table data, other cells
.asciiz "\t| "
.text
modexp:
move $s0, $a0 # g in $s0
move $s1, $a1 # e in $s1
move $s2, $a2 # m in $s2
li $s3, 1 # h = 1 in $s3
move $s6, $a3 # trace in $s6
move $s7, $ra # return address in $s7
beqz $s6, Lmodexp_loop
beqz $s1, Lmodexp_loop_end
la $a0, Smodexp_th
jal print
Lmodexp_loop:
beqz $s1, Lmodexp_loop_end
and $s4, $s1, 0x1 # e_i in $s4
beqz $s4, Lmodexp_loop_0
mul $t0, $s0, $s3
rem $s3, $t0, $s2 # h := g * h mod m
Lmodexp_loop_0:
mul $t0, $s0, $s0
rem $s0, $t0, $s2
beqz $s6, Lmodexp_loop_trace_end
Lmodexp_loop_trace:
la $a0, Smodexp_td1 # trace e_i
jal print
move $a0, $s4
jal print_int
la $a0, Smodexp_tdn # trace h
jal print
move $a0, $s3
jal print_int
la $a0, Smodexp_tdn # trace g
jal print
move $a0, $s0
jal print_int
la $a0, eol
jal print
Lmodexp_loop_trace_end:
srl $s1, $s1, 1
j Lmodexp_loop
Lmodexp_loop_end:
move $v0, $s3
jr $s7
### modexp(8, 23, 19, 1): compute and trace 8 ^ 23 [19]
main:
li $a0, 8
li $a1, 23