mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-05 03:30:24 +02:00
Add "addi" test
This commit is contained in:
parent
bad7e34c83
commit
021f31f1dc
3 changed files with 37 additions and 1 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,3 +1,5 @@
|
|||
*.o
|
||||
+*
|
||||
/lightning.info
|
||||
/tests/test-addr
|
||||
/tests/test-addi
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
26
tests/test-addi.c
Normal file
26
tests/test-addi.c
Normal file
|
@ -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);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue