compiler

Unnamed Compiled Systems Language Project
git clone http://frotz.net/git/compiler.git
Log | Files | Refs

commit 2f3f71dcc8b38f2bb6541f85c6d064c2f4c0b234
parent 7e853c4c8d785762fc4ece704d9e9277bb9eaa46
Author: Brian Swetland <swetland@frotz.net>
Date:   Thu,  2 Dec 2021 14:28:22 -0800

adjust test running

- only run tests on 'make runtests'
- run tests against compiler2 as well as compiler
- exit emulator immediately on jump-to-bogus-addr

Diffstat:
MMakefile | 15++++++++++++++-
Mexternal/oberon-risc-emu/risc5emu.c | 3++-
Atest/runtest2.sh | 50++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 66 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile @@ -1,5 +1,7 @@ -all: bin/compiler bin/compiler2 bin/fs bin/r5d bin/r5e bin/mkinstab out/test/summary.txt +all: bin/compiler bin/compiler2 bin/fs bin/r5d bin/r5e bin/mkinstab + +runtests: out/test/summary.txt clean: rm -rf bin out @@ -72,8 +74,19 @@ out/test/%.txt: test/%.src bin/compiler bin/r5d test/runtest.sh @rm -f $@ @test/runtest.sh $< $@ +out/test2/%.txt: test/%.src test/%.log bin/compiler2 bin/r5d test/runtest.sh + @mkdir -p out/test2 + @rm -f $@ + @test/runtest2.sh $< $@ + +out/test2/%.txt: test/%.src bin/compiler2 bin/r5d test/runtest.sh + @mkdir -p out/test2 + @rm -f $@ + @test/runtest2.sh $< $@ + SRCTESTS := $(sort $(wildcard test/*.src)) ALLTESTS := $(patsubst test/%.src,out/test/%.txt,$(SRCTESTS)) +ALLTESTS += $(patsubst test/%.src,out/test2/%.txt,$(SRCTESTS)) out/test/summary.txt: $(ALLTESTS) @cat $(ALLTESTS) > out/test/summary.txt diff --git a/external/oberon-risc-emu/risc5emu.c b/external/oberon-risc-emu/risc5emu.c @@ -91,7 +91,8 @@ void risc_single_step(struct RISC *risc) { ir = risc->RAM[risc->PC]; } else { fprintf(stderr, "Branched into the void (PC=0x%08X), resetting...\n", risc->PC); - risc_reset(risc); + exit(-1); + //risc_reset(risc); return; } diff --git a/test/runtest2.sh b/test/runtest2.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +## Copyright 2020, Brian Swetland <swetland@frotz.net> +## Licensed under the Apache License, Version 2.0. + +src="$1" +txt="$2" +bin="${txt%.txt}.bin" +lst="${txt%.txt}.lst" +log="${txt%.txt}.log" +msg="${txt%.txt}.msg" +gold="${src%.src}.log" + +#echo "RUNTEST2: $src: compiling..." +#echo bin/compiler2 -o "$bin" -l "$lst" "$src" "$msg" +if bin/compiler2 -o "$bin" -l "$lst" "$src" 2> "$msg"; then + # success! + if [[ "$txt" == *"-err"* ]]; then + # but this was an error test, so... + echo "RUNTEST2: $src: FAIL: compiler did not detect error" + echo "FAIL: $src" > "$txt" + else + #echo "RUNTEST: $src: running..." + if bin/r5e "$bin" > "$log"; then + if diff "$log" "$gold" >/dev/null ; then + echo "RUNTEST2: $src: PASS" + echo "PASS: $src" > "$txt" + else + echo "RUNTEST2: $src: FAIL: output differs from expected" + diff "$log" "$gold" | head + echo "FAIL: %src" > "$txt" + fi + else + echo "RUNTEST2: $src: FAIL: emulator crashed" + echo "FAIL: %src" > "$txt" + fi + fi +else + # failure + if [[ "$txt" == *"-err"* ]]; then + # but this was an error test, so... + echo "RUNTEST2: $src: PASS" + echo "PASS: $src" > "$txt" + else + echo "RUNTEST2: $src: FAIL: compiler error" + echo "FAIL: $src" > "$txt" + cat "$msg" + fi +fi +