test: Run 33/55 tests of ../tinycc/tests/test2 if avaiable.
authorJan Nieuwenhuizen <janneke@gnu.org>
Thu, 4 May 2017 17:41:45 +0000 (19:41 +0200)
committerJan Nieuwenhuizen <janneke@gnu.org>
Thu, 4 May 2017 17:41:45 +0000 (19:41 +0200)
* make/check-tinycc.make: New file.
* tinycc/tinycc.make: New file.
* GNUmakefile (SUBDIRS): Add tinycc.

GNUmakefile
libc/include/stdio.h
make/check-tinycc.make [new file with mode: 0644]
make/mescc-guile.make
make/reset.make
tinycc/tinycc.make [new file with mode: 0644]

index 416e0cd753dad90862e37e91ad8a54ba21ce6446..1e49e07cfe0c99dd667174afecd430133b6b9387 100644 (file)
@@ -14,6 +14,7 @@ SUBDIRS:=\
  scaffold\
  scripts\
  tests\
+ tinycc\
 #
 
 include make/common.make
index 87842e35451716da4650c5dac6e41d622c44d88a..40817e4c9ad31ac9350e15c495b57e2c01776bda 100644 (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
diff --git a/make/check-tinycc.make b/make/check-tinycc.make
new file mode 100644 (file)
index 0000000..6fd8c10
--- /dev/null
@@ -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
index 5350f1d0be04eeb956ccdf39ab3e3b4f59578447..485f156a86b65187714705ab0cb942e74786b206 100644 (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
index e274d9c21bdd8b328bb1441852e5d37c06ab14b2..34cc41cd7bb354cb2b10d225e0a6a38c2a31be8b 100644 (file)
@@ -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 (file)
index 0000000..c9f1e70
--- /dev/null
@@ -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