From e600b4729cee5f624b6f1f457c07aa75aa0ed278 Mon Sep 17 00:00:00 2001 From: Tom Harley Date: Wed, 1 Feb 2023 20:48:40 +0000 Subject: Fix unit tests Now the unit tests will run again! :) --- common.mak | 5 +++-- examples/nq/Makefile | 1 + examples/unit/Makefile | 7 +++---- examples/unit/test_framework.c | 20 ++++++++++++++++++-- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/common.mak b/common.mak index e9b8059..6b117a0 100644 --- a/common.mak +++ b/common.mak @@ -1,8 +1,9 @@ -LLC ?= llc +#LLC ?= llc -filetype obj +LLC ?= clang -c SINC ?= sinc %.o: %.ll - $(LLC) -filetype obj $(LLCFLAGS) -o $@ $< + $(LLC) $(LLCFLAGS) -o $@ $< %.ll: %.sin $(SINC) -l $(SINCFLAGS) -o $@ $< diff --git a/examples/nq/Makefile b/examples/nq/Makefile index 271c4a4..0078902 100644 --- a/examples/nq/Makefile +++ b/examples/nq/Makefile @@ -1,5 +1,6 @@ CC = clang CXX = clang++ +SINC = ../../sinc DEBUG = -g -O0 diff --git a/examples/unit/Makefile b/examples/unit/Makefile index aadf541..a663eb3 100644 --- a/examples/unit/Makefile +++ b/examples/unit/Makefile @@ -1,9 +1,8 @@ CC = clang -SINC = ../../sinter +SINC = ../../sinc -w 32 TRGT = $(patsubst %.sin,%,$(wildcard test*.sin)) -LDFLAGS = -L$(HOME)/usr/lib -LDLIBS = -lgc +LDLIBS += -lgc include ../../common.mak @@ -13,7 +12,7 @@ default: all all: $(TRGT) -$(TRGT): test_framework.o ../../common.o +$(TRGT): test_framework.o clean: $(RM) *.o *.ll $(TRGT) diff --git a/examples/unit/test_framework.c b/examples/unit/test_framework.c index 22ededd..0a86efc 100644 --- a/examples/unit/test_framework.c +++ b/examples/unit/test_framework.c @@ -1,9 +1,19 @@ #include +#include + +#include void *test(void); -void *inter_main(void) { - return test(); +int main(void) { + test(); + return 0; +} + +void *gc_alloc(size_t size) { + void *p = GC_MALLOC(size); + assert(p); + return p; } void *assert_equals(void *a, void *b, void *c) { @@ -11,3 +21,9 @@ void *assert_equals(void *a, void *b, void *c) { assert(ia == ib); return c; } + +void *assert_string_equals(void *a, void *b, void *c) { + char *sa = (char *) a, *sb = (char *) b; + assert(!strcmp(sa, sb)); + return c; +} -- cgit v1.2.1