test: Run 33/55 tests of ../tinycc/tests/test2 if avaiable.

* make/check-tinycc.make: New file.
* tinycc/tinycc.make: New file.
* GNUmakefile (SUBDIRS): Add tinycc.
This commit is contained in:
Jan Nieuwenhuizen 2017-05-04 19:41:45 +02:00
parent c43e285de5
commit a4a323c2bb
6 changed files with 126 additions and 1 deletions

View file

@ -14,6 +14,7 @@ SUBDIRS:=\
scaffold\
scripts\
tests\
tinycc\
#
include make/common.make

View file

@ -24,6 +24,7 @@ char **g_environment;
int g_stdin;
#define EOF -1
#define NULL 0
#define STDIN 0
#define STDOUT 1
#define STDERR 2

19
make/check-tinycc.make Normal file
View file

@ -0,0 +1,19 @@
ifeq ($(TEST),)
TEST:=$(TARGET)-check
$(TEST): EXT:=$(EXT)
$(TEST): EXPECT:=$(EXPECT)
$(TEST): $(OUT)/$(TARGET)
ifeq ($(EXPECT),)
$< - arg1 arg2 arg3 arg4 > $(<:.$(EXT)=.stdout)
else
$<; r=$$?; [ $$r = $(EXPECT) ]
endif
$(QUIETx)if diff -bu $(TINYCC_TEST2)/$(<F:.$(EXT)=.expect) $(<:.$(EXT)=.stdout); \
then rm -f $(<:.$(EXT)=.stdout); \
else exit 1; \
fi
endif
CHECK+=$(TEST)
$(TEST): TEST:=$(TEST)
$(DIR)-check: $(TEST)
include make/reset.make

View file

@ -1,9 +1,10 @@
CLEAN+=$(OUT)/$(TARGET)
$(OUT)/$(TARGET): C_INCLUDE_PATH:=$(INCLUDES)
$(OUT)/$(TARGET): $(MAKEFILE_LIST)
$(OUT)/$(TARGET): $(INSTALL_GO_FILES)
$(OUT)/$(TARGET): $(C_FILES)
@echo " mescc.scm $(notdir $<) -> $(notdir $@)"
@rm -f $@
$(QUIET)guile/mescc.scm $< > $@ || rm -f $@
$(QUIET) INCLUDES=$(C_INCLUDE_PATH) guile/mescc.scm $< > $@ || rm -f $@
@[ -f $@ ] && chmod +x $@ ||:
include make/reset.make

View file

@ -4,6 +4,7 @@ CPP_FLAGS:=
CROSS:=
DEFINES:=
EXPECT:=
EXT:=
GO_FILES:=
INCLUDES:=
LD_FLAGS:=

102
tinycc/tinycc.make Normal file
View file

@ -0,0 +1,102 @@
TINYCC_ROOT:=../tinycc
TINYCC_TEST2:=$(TINYCC_ROOT)/tests/tests2
TINYCC_TESTS:=\
00_assignment\
01_comment\
02_printf\
03_struct\
04_for\
05_array\
06_case\
07_function\
08_while\
09_do_while\
10_pointer\
11_precedence\
12_hashdefine\
13_integer_literals\
14_if\
15_recursion\
16_nesting\
17_enum\
18_include\
19_pointer_arithmetic\
20_pointer_comparison\
21_char_array\
25_quicksort\
29_array_address\
33_ternary_op\
35_sizeof\
41_hashif\
43_void_param\
44_scoped_declarations\
47_switch_return\
48_nested_break\
54_goto\
#
TINYCC_NYACC:=\
26_character_constants\
#
TINYCC_FLOAT:=\
22_floating_point\
23_type_coercion\
24_math_library\
27_sizeof\
#
# Does not compile/run with GCC
TINYCC_GCC:=\
30_hanoi\
34_array_assignment\
#
TINYCC_REST:=\
28_strings\
31_args\
32_led\
36_array_initialisers\
37_sprintf\
38_multiple_array_index\
39_typedef\
40_stdio\
42_function_pointer\
45_empty_for\
46_grep\
49_bracket_evaluation\
50_logical_second_arg\
51_static\
52_unnamed_enum\
55_lshift_type\
#
define tinycc-test
EXT:=mlibc
TARGET:=$(1).mlibc
C_FILES:=$$(TINYCC_TEST2)/$(1).c
INCLUDES:=$$(TINYCC_TEST2)
include make/bin-mlibc.make
EXT:=mlibc
TARGET:=$(1).mlibc
include make/check-tinycc.make
EXT:=guile
TARGET:=$(1).guile
C_FILES:=$$(TINYCC_TEST2)/$(1).c
INCLUDES:=$$(TINYCC_TEST2)
include make/mescc-guile.make
EXT:=guile
TARGET:=$(1).guile
include make/check-tinycc.make
endef
ifeq ($(wildcard $(TINYCC_TEST2)/00_assignment.c),$(TINYCC_TEST2)/00_assignment.c)
$(foreach t,$(TINYCC_TESTS),$(eval $(call tinycc-test,$(t))))
else
tinycc-check:
@echo skipping tinycc tests: $(TINYCC_TEST2)/00_assignment.c not available
endif