[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 30/86: Add "addi" test
From: |
Andy Wingo |
Subject: |
[Guile-commits] 30/86: Add "addi" test |
Date: |
Wed, 3 Apr 2019 11:38:53 -0400 (EDT) |
wingo pushed a commit to branch lightening
in repository guile.
commit 021f31f1dc494b4f4bb4cd6788d00751371459b7
Author: Andy Wingo <address@hidden>
Date: Mon Mar 25 12:31:51 2019 +0100
Add "addi" test
---
.gitignore | 2 ++
tests/Makefile | 10 +++++++++-
tests/test-addi.c | 26 ++++++++++++++++++++++++++
3 files changed, 37 insertions(+), 1 deletion(-)
diff --git a/.gitignore b/.gitignore
index 8bec7c7..dc7bc25 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,5 @@
*.o
+*
/lightning.info
+/tests/test-addr
+/tests/test-addi
diff --git a/tests/Makefile b/tests/Makefile
index ee41e5e..ead09bd 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -1,10 +1,18 @@
-TESTS = addr
+TESTS = addr addi
CC = gcc
CFLAGS = -Wall -O0 -g
all: $(addprefix test-,$(TESTS))
+check: all
+ @echo "Running unit tests..."
+ @set -e; for test in $(TESTS); do \
+ echo "Testing: $$test"; \
+ ./test-$$test; \
+ done
+ @echo "Success."
+
jit.o: ../jit.h ../jit/*.c
$(CC) $(CFLAGS) $(CPPFLAGS) -flto -I.. -o jit.o -c ../jit/jit.c
diff --git a/tests/test-addi.c b/tests/test-addi.c
new file mode 100644
index 0000000..586dc1c
--- /dev/null
+++ b/tests/test-addi.c
@@ -0,0 +1,26 @@
+#include "test.h"
+
+static void
+run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
+{
+ jit_begin(j, arena_base, arena_size);
+
+ jit_arg_abi_t abi[] = { JIT_ARG_ABI_INT32 };
+ jit_arg_t args[1];
+ jit_receive(j, 1, abi, args);
+ ASSERT(args[0].kind == JIT_ARG_LOC_GPR);
+ jit_addi(j, JIT_R0, args[0].loc.gpr, 69);
+ jit_retr(j, JIT_R0);
+
+ size_t size = 0;
+ void* ret = jit_end(j, &size);
+
+ int (*f)(int) = ret;
+ ASSERT(f(42) == 111);
+}
+
+int
+main (int argc, char *argv[])
+{
+ return main_helper(argc, argv, run_test);
+}
- [Guile-commits] 03/86: Strip "get-jit-size" feature from lightning., (continued)
- [Guile-commits] 03/86: Strip "get-jit-size" feature from lightning., Andy Wingo, 2019/04/03
- [Guile-commits] 25/86: Remove needless PUBLIC/HIDDEN definitions, Andy Wingo, 2019/04/03
- [Guile-commits] 19/86: Update call/receive machinery, Andy Wingo, 2019/04/03
- [Guile-commits] 10/86: Remove autotools, Andy Wingo, 2019/04/03
- [Guile-commits] 21/86: "extern"-related cleanup, and further implementation, Andy Wingo, 2019/04/03
- [Guile-commits] 27/86: Make _rvs array static-const, Andy Wingo, 2019/04/03
- [Guile-commits] 11/86: Rename include to jit.h, move all files to jit/, Andy Wingo, 2019/04/03
- [Guile-commits] 33/86: Flesh out README, Andy Wingo, 2019/04/03
- [Guile-commits] 36/86: Add more tests, Andy Wingo, 2019/04/03
- [Guile-commits] 18/86: Add endian.h, Andy Wingo, 2019/04/03
- [Guile-commits] 30/86: Add "addi" test,
Andy Wingo <=
- [Guile-commits] 31/86: Better loading of args to registers; add tests, Andy Wingo, 2019/04/03
- [Guile-commits] 26/86: Inline private.h into jit.c, Andy Wingo, 2019/04/03
- [Guile-commits] 32/86: Convert tests to jit_load_args, Andy Wingo, 2019/04/03
- [Guile-commits] 34/86: Add note about current status, Andy Wingo, 2019/04/03
- [Guile-commits] 14/86: Simplify file names, Andy Wingo, 2019/04/03
- [Guile-commits] 39/86: Add remr tests, Andy Wingo, 2019/04/03
- [Guile-commits] 37/86: Tests for some div operations, Andy Wingo, 2019/04/03
- [Guile-commits] 35/86: Add new tests, Andy Wingo, 2019/04/03
- [Guile-commits] 28/86: Beginnings of port of x86 to new design, Andy Wingo, 2019/04/03
- [Guile-commits] 44/86: Add mov_addr test, Andy Wingo, 2019/04/03