Introducing quiz, the testing framework

This commit is contained in:
Romain Goyet
2015-09-03 22:44:25 +02:00
parent 304a8f1927
commit c494fabc23
8 changed files with 40 additions and 7 deletions

View File

@@ -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)

View File

@@ -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

10
quiz/Makefile Normal file
View File

@@ -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)

8
quiz/README.txt Normal file
View File

@@ -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!

1
quiz/include/quiz.h Normal file
View File

@@ -0,0 +1 @@
#define TEST(foo) void test_##foo()

11
quiz/src/symbols.awk Normal file
View File

@@ -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 "};"
}