From bcb508498caa64a7c92a1c11bc85acdefa6209cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Mon, 1 Jan 2018 20:46:28 +0100 Subject: Add cpu_trap test --- tests/cpu_trap/Makefile | 5 +++++ tests/cpu_trap/test.sh | 14 ++++++++++++++ tests/cpu_trap/trap.S | 8 ++++++++ tests/machine-unit-tests/test.sh | 2 +- tests/test.sh | 3 ++- 5 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 tests/cpu_trap/Makefile create mode 100755 tests/cpu_trap/test.sh create mode 100644 tests/cpu_trap/trap.S diff --git a/tests/cpu_trap/Makefile b/tests/cpu_trap/Makefile new file mode 100644 index 0000000..920fa45 --- /dev/null +++ b/tests/cpu_trap/Makefile @@ -0,0 +1,5 @@ +include ../test.mk + +SRC_cpu_trap = trap.S + +$(eval $(call MIPS_ELF,cpu_trap)) diff --git a/tests/cpu_trap/test.sh b/tests/cpu_trap/test.sh new file mode 100755 index 0000000..430af14 --- /dev/null +++ b/tests/cpu_trap/test.sh @@ -0,0 +1,14 @@ +#!/bin/sh +TEST_NAME="cpu_trap" + +# Load common test shell functions +. "$(dirname "$0")/../test.sh" + +# Build cli binary +qtmips_make sub-qtmips_cli + +# Compile mips binary +mips_make_test + +# Run test +qtmips_run qtmips_cli/qtmips_cli --fail-match O "$TEST_DIR/cpu_trap" diff --git a/tests/cpu_trap/trap.S b/tests/cpu_trap/trap.S new file mode 100644 index 0000000..9581f7e --- /dev/null +++ b/tests/cpu_trap/trap.S @@ -0,0 +1,8 @@ +.text +.globl _start + +_start: + addi $1, $0, 1 +loop: + add $1, $1, $1 + j loop diff --git a/tests/machine-unit-tests/test.sh b/tests/machine-unit-tests/test.sh index 8378eff..4e5eae0 100755 --- a/tests/machine-unit-tests/test.sh +++ b/tests/machine-unit-tests/test.sh @@ -12,4 +12,4 @@ mips_make_test cd "$TEST_DIR" # Run unit tests -qtmips_run qtmips_machine/tests/tst_machine || echo_fail "Test $TEST_NAME failed!" +qtmips_run qtmips_machine/tests/tst_machine diff --git a/tests/test.sh b/tests/test.sh index 7f83246..36b6b77 100644 --- a/tests/test.sh +++ b/tests/test.sh @@ -109,7 +109,8 @@ qtmips_make() { qtmips_run() { local BIN="$BUILD_DIR/$1" shift - LD_LIBRARY_PATH="$BUILD_DIR/qtmips_machine" "$BIN" "$@" + LD_LIBRARY_PATH="$BUILD_DIR/qtmips_machine" "$BIN" "$@" || \ + echo_fail "QtMips execution exited with non-zero code ($?): $@" } ## Mips elf binary compilation ################################################## -- cgit v1.2.3