diff --git a/Makefile b/Makefile index cdafe3916..e5d1c2bf5 100644 --- a/Makefile +++ b/Makefile @@ -74,15 +74,18 @@ include ion/Makefile include kandinsky/Makefile include poincare/Makefile +# Quiz should be included at the end +include quiz/Makefile + run: boot.elf $(GDB) -x gdb_script.gdb boot.elf -test: test.elf - $(GDB) -x test/gdb_script.gdb test.elf +#test: test.elf +# $(GDB) -x test/gdb_script.gdb test.elf -test.elf: $(objs) $(tests) test/runner.o - @echo "LD $@" - @$(LD) $(LDFLAGS) $(objs) $(tests) test/runner.o -o $@ +#test.elf: $(objs) $(tests) test/symbols.c test/runner.o +# @echo "LD $@" +# @$(LD) $(LDFLAGS) $(objs) $(tests) test/runner.o -o $@ boot.hex: boot.elf @echo "OBJCOPY $@" @@ -106,4 +109,4 @@ boot.elf: $(objs) clean: @echo "CLEAN" - @rm -f $(objs) $(tests) $(products) + @rm -f $(objs) $(test_objs) $(products) diff --git a/kandinsky/Makefile b/kandinsky/Makefile index 520a07b6b..218be1ad8 100644 --- a/kandinsky/Makefile +++ b/kandinsky/Makefile @@ -1,6 +1,6 @@ SFLAGS += -Ikandinsky/include objs += $(addprefix kandinsky/src/, font.o line.o pixel.o rect.o text.o) -tests += $(addprefix kandinsky/test/, set_pixel.o) +tests += $(addprefix kandinsky/test/, set_pixel.c) FREETYPE_PATH := /usr/local/Cellar/freetype/2.5.5 LIBPNG_PATH := /usr/local/Cellar/libpng/1.6.17 diff --git a/quiz/Makefile b/quiz/Makefile new file mode 100644 index 000000000..e3c9068c9 --- /dev/null +++ b/quiz/Makefile @@ -0,0 +1,10 @@ +symbols_file = $(addprefix quiz/src/, symbols.c) +products += $(symbols_file) + +$(symbols_file): $(tests) + @echo "AWK $@" + @awk -f quiz/src/symbols.awk $(tests) > $@ + +test_objs = $(subst .c,.o, $(subst .cpp,.o,$(tests))) + +test.elf: quiz/src/symbols.o $(test_objs) diff --git a/quiz/README.txt b/quiz/README.txt new file mode 100644 index 000000000..bd2bc270d --- /dev/null +++ b/quiz/README.txt @@ -0,0 +1,8 @@ +Quiz is a simple test framework. + +To write a test using quiz, all you have to do is #include quiz.h, and then +define tests using the TEST(my_test_name) macro. + +You should then add your test files to the "tests" variable in the Makefile. + +Then running "make test" will compile and run your tests! diff --git a/test/gdb_script.gdb b/quiz/gdb_script.gdb similarity index 100% rename from test/gdb_script.gdb rename to quiz/gdb_script.gdb diff --git a/quiz/include/quiz.h b/quiz/include/quiz.h new file mode 100644 index 000000000..17e78f285 --- /dev/null +++ b/quiz/include/quiz.h @@ -0,0 +1 @@ +#define TEST(foo) void test_##foo() diff --git a/test/runner.c b/quiz/runner.c similarity index 100% rename from test/runner.c rename to quiz/runner.c diff --git a/quiz/src/symbols.awk b/quiz/src/symbols.awk new file mode 100644 index 000000000..ad4c3da7b --- /dev/null +++ b/quiz/src/symbols.awk @@ -0,0 +1,11 @@ +BEGIN { + print "void * pointers[] = {" +} + +#FIXME: Is there a way to capture subexpression in awk? The following gsub is +# kind of ugly +/TEST\(([a-z0-9_]+)\)/ { gsub(/(TEST\()|(\))/, "", $1); print "test_" $1 "," } + +END { + print "};" +}