[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH 03/12] tests/tcg/tricore: Add macros to easily c
From: |
Bastian Koppelmann |
Subject: |
[Qemu-devel] [RFC PATCH 03/12] tests/tcg/tricore: Add macros to easily create tests and first test 'abs' |
Date: |
Tue, 1 May 2018 16:22:13 +0200 |
This kind of tests is inspired by the riscv-tests repository. This adds
macros that makes it easy to create single instruction self containing
tests.
This is achieved by macros that create a test sequence for an
instruction and check for a supplied correct value. If the value is correct the
next instruction is tested. Otherwise we jump to fail handler that writes is
test number as a status code back to qemu that then exits on that status code.
If all tests pass we write back 0 as a status code and exit.
Signed-off-by: Bastian Koppelmann <address@hidden>
---
tests/tcg/tricore/Makefile | 2 ++
tests/tcg/tricore/macros.h | 53 ++++++++++++++++++++++++++++++++++++++++++++
tests/tcg/tricore/test_abs.S | 8 +++++++
3 files changed, 63 insertions(+)
create mode 100644 tests/tcg/tricore/macros.h
create mode 100644 tests/tcg/tricore/test_abs.S
diff --git a/tests/tcg/tricore/Makefile b/tests/tcg/tricore/Makefile
index 8c168d1062..a0e1f4b20d 100644
--- a/tests/tcg/tricore/Makefile
+++ b/tests/tcg/tricore/Makefile
@@ -8,6 +8,8 @@ ASFLAGS =
SIM = ../../../tricore-softmmu/qemu-system-tricore
SIMFLAGS = -M tricore_testboard -nographic -kernel
+TESTCASES += test_abs.tst
+
all: build
%.pS: %.S
diff --git a/tests/tcg/tricore/macros.h b/tests/tcg/tricore/macros.h
new file mode 100644
index 0000000000..76c133132a
--- /dev/null
+++ b/tests/tcg/tricore/macros.h
@@ -0,0 +1,53 @@
+/* Helpers */
+#define LI(reg, val) \
+ mov.u reg, lo:val; \
+ movh DREG_TEMP_LI, up:val; \
+ or reg, reg, DREG_TEMP_LI; \
+
+/* Address definitions */
+#define TESTDEV_ADDR 0xf0000000
+/* Register definitions */
+#define DREG_RS1 %d0
+#define DREG_CALC_RESULT %d1
+#define DREG_TEMP_LI %d10
+#define DREG_TEMP %d11
+#define DREG_TEST_NUM %d14
+#define DREG_CORRECT_RESULT %d15
+
+#define DREG_DEV_ADDR %a15
+
+/* Test case wrappers */
+#define TEST_CASE(num, testreg, correct, code...) \
+test_ ## num: \
+ code; \
+ LI(DREG_CORRECT_RESULT, correct) \
+ mov DREG_TEST_NUM, num; \
+ jne testreg, DREG_CORRECT_RESULT, fail \
+
+/* Actual test case type
+ * e.g inst %dX, %dY -> TEST_D_D
+ * inst %dX, %dY, %dZ -> TEST_D_DD
+ * inst %eX, %dY, %dZ -> TEST_E_DD
+ */
+#define TEST_D_D(insn, num, result, rs1) \
+ TEST_CASE(num, DREG_CALC_RESULT, result, \
+ LI(DREG_RS1, rs1); \
+ insn DREG_CALC_RESULT, DREG_RS1; \
+ )
+
+/* Pass/Fail handling part */
+#define TEST_PASSFAIL \
+ j pass; \
+fail: \
+ LI(DREG_TEMP, TESTDEV_ADDR) \
+ mov.a DREG_DEV_ADDR, DREG_TEMP; \
+ st.w [DREG_DEV_ADDR], DREG_TEST_NUM;\
+ debug; \
+ j fail; \
+pass: \
+ LI(DREG_TEMP, TESTDEV_ADDR) \
+ mov.a DREG_DEV_ADDR, DREG_TEMP; \
+ mov DREG_TEST_NUM, 0; \
+ st.w [DREG_DEV_ADDR], DREG_TEST_NUM;\
+ debug; \
+ j pass;
diff --git a/tests/tcg/tricore/test_abs.S b/tests/tcg/tricore/test_abs.S
new file mode 100644
index 0000000000..acc143901c
--- /dev/null
+++ b/tests/tcg/tricore/test_abs.S
@@ -0,0 +1,8 @@
+#include "macros.h"
+.text
+.global _start
+_start:
+ TEST_D_D(abs, 1, 0, 0)
+
+ TEST_PASSFAIL
+
--
2.11.0
- [Qemu-devel] [RFC PATCH 00/12] tests/tcg: Add TriCore tests, Bastian Koppelmann, 2018/05/01
- [Qemu-devel] [RFC PATCH 11/12] tests/tcg/tricore: Add msub test, Bastian Koppelmann, 2018/05/01
- [Qemu-devel] [RFC PATCH 05/12] tests/tcg/tricore: Add clz test, Bastian Koppelmann, 2018/05/01
- [Qemu-devel] [RFC PATCH 03/12] tests/tcg/tricore: Add macros to easily create tests and first test 'abs',
Bastian Koppelmann <=
- [Qemu-devel] [RFC PATCH 08/12] tests/tcg/tricore: Add fmul test, Bastian Koppelmann, 2018/05/01
- [Qemu-devel] [RFC PATCH 09/12] tests/tcg/tricore: Add ftoi test, Bastian Koppelmann, 2018/05/01
- [Qemu-devel] [RFC PATCH 06/12] tests/tcg/tricore: Add dvstep test, Bastian Koppelmann, 2018/05/01
- [Qemu-devel] [RFC PATCH 07/12] tests/tcg/tricore: Add fadd test, Bastian Koppelmann, 2018/05/01
- [Qemu-devel] [RFC PATCH 02/12] tests/tcg/tricore: Add build infrastructure, Bastian Koppelmann, 2018/05/01
- Re: [Qemu-devel] [RFC PATCH 02/12] tests/tcg/tricore: Add build infrastructure, Philippe Mathieu-Daudé, 2018/05/01