From a4a323c2bbf74ff62e067dac3d6c5db84c179b51 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Thu, 4 May 2017 19:41:45 +0200 Subject: [PATCH] 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. --- GNUmakefile | 1 + libc/include/stdio.h | 1 + make/check-tinycc.make | 19 ++++++++ make/mescc-guile.make | 3 +- make/reset.make | 1 + tinycc/tinycc.make | 102 +++++++++++++++++++++++++++++++++++++++++ 6 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 make/check-tinycc.make create mode 100644 tinycc/tinycc.make diff --git a/GNUmakefile b/GNUmakefile index 416e0cd7..1e49e07c 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -14,6 +14,7 @@ SUBDIRS:=\ scaffold\ scripts\ tests\ + tinycc\ # include make/common.make diff --git a/libc/include/stdio.h b/libc/include/stdio.h index 87842e35..40817e4c 100644 --- a/libc/include/stdio.h +++ b/libc/include/stdio.h @@ -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 diff --git a/make/check-tinycc.make b/make/check-tinycc.make new file mode 100644 index 00000000..6fd8c10e --- /dev/null +++ b/make/check-tinycc.make @@ -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)/$( $(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 diff --git a/make/reset.make b/make/reset.make index e274d9c2..34cc41cd 100644 --- a/make/reset.make +++ b/make/reset.make @@ -4,6 +4,7 @@ CPP_FLAGS:= CROSS:= DEFINES:= EXPECT:= +EXT:= GO_FILES:= INCLUDES:= LD_FLAGS:= diff --git a/tinycc/tinycc.make b/tinycc/tinycc.make new file mode 100644 index 00000000..c9f1e705 --- /dev/null +++ b/tinycc/tinycc.make @@ -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