tests/tcg/tricore: Add recursion test for CSAs
authorBastian Koppelmann <kbastian@mail.uni-paderborn.de>
Fri, 26 May 2023 06:19:46 +0000 (08:19 +0200)
committerBastian Koppelmann <kbastian@mail.uni-paderborn.de>
Wed, 7 Jun 2023 16:20:51 +0000 (18:20 +0200)
Signed-off-by: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
Message-Id: <20230526061946.54514-7-kbastian@mail.uni-paderborn.de>

tests/tcg/tricore/Makefile.softmmu-target
tests/tcg/tricore/c/test_context_save_areas.c [new file with mode: 0644]

index f051444991fb16ab4cfcc815a996586fac47c0be..aff7c1b5802b46989663de02d38c30c83c6a1cb6 100644 (file)
@@ -4,7 +4,7 @@ C_TESTS_PATH = $(TESTS_PATH)/c
 
 LDFLAGS = -T$(TESTS_PATH)/link.ld --mcpu=tc162
 ASFLAGS = -mtc162
-CFLAGS = -mtc162 -c
+CFLAGS = -mtc162 -c -I$(TESTS_PATH)
 
 TESTS += test_abs.asm.tst
 TESTS += test_bmerge.asm.tst
@@ -23,6 +23,7 @@ TESTS += test_msub.asm.tst
 TESTS += test_muls.asm.tst
 
 TESTS += test_boot_to_main.c.tst
+TESTS += test_context_save_areas.c.tst
 
 QEMU_OPTS += -M tricore_testboard -cpu tc27x -nographic -kernel
 
diff --git a/tests/tcg/tricore/c/test_context_save_areas.c b/tests/tcg/tricore/c/test_context_save_areas.c
new file mode 100644 (file)
index 0000000..a300ee2
--- /dev/null
@@ -0,0 +1,15 @@
+#include "testdev_assert.h"
+
+static int fib(int n)
+{
+    if (n == 1 || n == 2) {
+        return 1;
+    }
+    return fib(n - 2) + fib(n - 1);
+}
+
+int main(int argc, char **argv)
+{
+    testdev_assert(fib(10) == 55);
+    return 0;
+}