guile-commits
[Top][All Lists]
Advanced

[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);
+}



reply via email to

[Prev in Thread] Current Thread [Next in Thread]