diff options
Diffstat (limited to 'tests')
38 files changed, 266 insertions, 145 deletions
diff --git a/tests/Makefile b/tests/Makefile index 98ccb1e..270eaa7 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -19,7 +19,7 @@ TESTS = \ test3 \ abitest \ vla_test-run \ - moretests + tests2-dir pp-dir BTESTS = test1b test3b btest @@ -36,7 +36,7 @@ ifneq ($(ARCH),i386) TESTS := $(filter-out $(BTESTS),$(TESTS)) endif ifdef CONFIG_WIN32 - TESTS := w32-prep $(filter-out $(BTESTS),$(TESTS)) + TESTS := $(filter-out $(BTESTS),$(TESTS)) endif ifeq ($(TARGETOS),Darwin) TESTS := $(filter-out hello-exe test3 $(BTESTS),$(TESTS)) @@ -60,9 +60,9 @@ ifeq ($(TARGETOS),Darwin) endif # run local version of tcc with local libraries and includes -TCCFLAGS = -B$(TOP) -I$(TOP) -I$(top_srcdir) -I$(top_srcdir)/include +TCCFLAGS = -B$(TOP) -I$(TOP) -I$(top_srcdir) -I$(top_srcdir)/include -L$(TOP) ifdef CONFIG_WIN32 - TCCFLAGS = -B$(top_srcdir)/win32 -I$(top_srcdir) -I$(top_srcdir)/include -I$(TOP) -L$(TOP) + TCCFLAGS = -B$(top_srcdir)/win32 -I$(top_srcdir) -I$(top_srcdir)/include -L$(TOP) endif XTCCFLAGS = -B$(TOP) -B$(top_srcdir)/win32 -I$(TOP) -I$(top_srcdir) -I$(top_srcdir)/include @@ -97,17 +97,14 @@ hello-run: ../examples/ex1.c libtest: libtcc_test$(EXESUF) $(LIBTCC1) @echo ------------ $@ ------------ - ./libtcc_test$(EXESUF) lib_path=.. + ./libtcc_test$(EXESUF) $(TCCFLAGS) libtcc_test$(EXESUF): libtcc_test.c $(top_builddir)/$(LIBTCC) $(CC) -o $@ $^ $(CPPFLAGS) $(CFLAGS) $(NATIVE_DEFINES) $(LIBS) $(LINK_LIBTCC) $(LDFLAGS) -I$(top_srcdir) -moretests: +%-dir: @echo ------------ $@ ------------ - $(MAKE) -C tests2 - -w32-prep: - cp ../libtcc1.a ../lib + $(MAKE) -k -C $* # test.ref - generate using cc test.ref: tcctest.c @@ -223,9 +220,8 @@ endif abitest: $(ABITESTS) @echo ------------ $@ ------------ - ./abitest-cc$(EXESUF) lib_path=.. include="$(top_srcdir)/include" - if [ "$(CONFIG_arm_eabi)" != "yes" ]; then \ - ./abitest-tcc$(EXESUF) lib_path=.. include="$(top_srcdir)/include"; fi + ./abitest-cc$(EXESUF) $(TCCFLAGS) + if [ "$(CONFIG_arm_eabi)" != "yes" ]; then ./abitest-tcc$(EXESUF) $(TCCFLAGS); fi vla_test$(EXESUF): vla_test.c $(TCC) -o $@ $^ $(CPPFLAGS) $(CFLAGS) @@ -253,5 +249,4 @@ clean: $(MAKE) -C tests2 $@ rm -vf *~ *.o *.a *.bin *.i *.ref *.out *.out? *.out?b *.cc \ *-cc *-tcc *.exe \ - hello libtcc_test vla_test tcctest[1234] ex? tcc_g tcclib.h \ - ../lib/libtcc1.a + hello libtcc_test vla_test tcctest[1234] ex? tcc_g diff --git a/tests/abitest.c b/tests/abitest.c index 9cdeb87..896e97b 100644 --- a/tests/abitest.c +++ b/tests/abitest.c @@ -13,8 +13,24 @@ #define LONG_DOUBLE_LITERAL(x) x ## L #endif -static const char *tccdir = NULL; -static const char *include_dir = NULL; +static int g_argc; +static char **g_argv; + +static void set_options(TCCState *s, int argc, char **argv) +{ + int i; + for (i = 1; i < argc; ++i) { + char *a = argv[i]; + if (a[0] == '-') { + if (a[1] == 'B') + tcc_set_lib_path(s, a+2); + else if (a[1] == 'I') + tcc_add_include_path(s, a+2); + else if (a[1] == 'L') + tcc_add_library_path(s, a+2); + } + } +} typedef int (*callback_type) (void*); @@ -29,12 +45,9 @@ static int run_callback(const char *src, callback_type callback) { s = tcc_new(); if (!s) return -1; - if (tccdir) - tcc_set_lib_path(s, tccdir); - if (include_dir) { - if (tcc_add_include_path(s, include_dir) == -1) - return -1; - } + + set_options(s, g_argc, g_argv); + if (tcc_set_output_type(s, TCC_OUTPUT_MEMORY) == -1) return -1; if (tcc_compile_string(s, src) == -1) @@ -611,13 +624,11 @@ int main(int argc, char **argv) { /* if tcclib.h and libtcc1.a are not installed, where can we find them */ for (i = 1; i < argc; ++i) { - if (!memcmp(argv[i], "lib_path=",9)) - tccdir = argv[i] + 9; - else if (!memcmp(argv[i], "run_test=", 9)) + if (!memcmp(argv[i], "run_test=", 9)) testname = argv[i] + 9; - else if (!memcmp(argv[i], "include=", 8)) - include_dir = argv[i] + 8; - } + } + + g_argv = argv, g_argc = argc; RUN_TEST(ret_int_test); RUN_TEST(ret_longlong_test); diff --git a/tests/libtcc_test.c b/tests/libtcc_test.c index 414cc9b..109e488 100644 --- a/tests/libtcc_test.c +++ b/tests/libtcc_test.c @@ -16,7 +16,7 @@ int add(int a, int b) } char my_program[] = -"#include <stdio.h> // printf()\n" +"#include <tcclib.h>\n" /* include the "Simple libc header for TCC" */ "extern int add(int a, int b);\n" "int fib(int n)\n" "{\n" @@ -37,6 +37,7 @@ char my_program[] = int main(int argc, char **argv) { TCCState *s; + int i; int (*func)(int); s = tcc_new(); @@ -46,8 +47,17 @@ int main(int argc, char **argv) } /* if tcclib.h and libtcc1.a are not installed, where can we find them */ - if (argc == 2 && !memcmp(argv[1], "lib_path=",9)) - tcc_set_lib_path(s, argv[1]+9); + for (i = 1; i < argc; ++i) { + char *a = argv[i]; + if (a[0] == '-') { + if (a[1] == 'B') + tcc_set_lib_path(s, a+2); + else if (a[1] == 'I') + tcc_add_include_path(s, a+2); + else if (a[1] == 'L') + tcc_add_library_path(s, a+2); + } + } /* MUST BE CALLED before any compilation */ tcc_set_output_type(s, TCC_OUTPUT_MEMORY); diff --git a/tests/pp/01.c b/tests/pp/01.c new file mode 100644 index 0000000..2fc3d79 --- /dev/null +++ b/tests/pp/01.c @@ -0,0 +1,6 @@ +#define hash_hash # ## # +#define mkstr(a) # a +#define in_between(a) mkstr(a) +#define join(c, d) in_between(c hash_hash d) +char p[] = join(x, y); +// char p[] = "x ## y"; diff --git a/tests/pp/01.expect b/tests/pp/01.expect new file mode 100644 index 0000000..cf5b153 --- /dev/null +++ b/tests/pp/01.expect @@ -0,0 +1 @@ +char p[] = "x ## y"; diff --git a/tests/pp/02.c b/tests/pp/02.c new file mode 100644 index 0000000..feb1254 --- /dev/null +++ b/tests/pp/02.c @@ -0,0 +1,28 @@ +#define x 3 +#define f(a) f(x * (a)) +#undef x +#define x 2 +#define g f +#define z z[0] +#define h g(~ +#define m(a) a(w) +#define w 0,1 +#define t(a) a +#define p() int +#define q(x) x +#define r(x,y) x ## y +#define str(x) # x +f(y+1) + f(f(z)) % t(t(g)(0) + t)(1); +g(x+(3,4)-w) | h 5) & m +(f)^m(m); +char c[2][6] = { str(hello), str() }; +/* + * f(2 * (y+1)) + f(2 * (f(2 * (z[0])))) % f(2 * (0)) + t(1); + * f(2 * (2+(3,4)-0,1)) | f(2 * (~ 5)) & f(2 * (0,1))^m(0,1); + * char c[2][6] = { "hello", "" }; + */ +#define L21 f(y+1) + f(f(z)) % t(t(g)(0) + t)(1); +#define L22 g(x+(3,4)-w) | h 5) & m\ +(f)^m(m); +L21 +L22 diff --git a/tests/pp/02.expect b/tests/pp/02.expect new file mode 100644 index 0000000..16f42ae --- /dev/null +++ b/tests/pp/02.expect @@ -0,0 +1,5 @@ +f(2 * (y+1)) + f(2 * (f(2 * (z[0])))) % f(2 * (0)) + t(1); +f(2 * (2+(3,4)-0,1)) | f(2 * (~ 5)) & f(2 * (0,1))^m(0,1); +char c[2][6] = { "hello", "" }; +f(2 * (y+1)) + f(2 * (f(2 * (z[0])))) % f(2 * (0)) + t(1); +f(2 * (2+(3,4)-0,1)) | f(2 * (~ 5)) & f(2 * (0,1))^m(0,1); diff --git a/tests/pp/03.c b/tests/pp/03.c new file mode 100644 index 0000000..a659245 --- /dev/null +++ b/tests/pp/03.c @@ -0,0 +1,15 @@ +#define str(s) # s +#define xstr(s) str(s) +#define debug(s, t) printf("x" # s "= %d, x" # t "= %s", \ + x ## s, x ## t) +#define INCFILE(n) vers ## n +#define glue(a, b) a ## b +#define xglue(a, b) glue(a, b) +#define HIGHLOW "hello" +#define LOW LOW ", world" +debug(1, 2); +fputs(str(strncmp("abc\0d", "abc", '\4') // this goes away + == 0) str(: @\n), s); +\#include xstr(INCFILE(2).h) +glue(HIGH, LOW); +xglue(HIGH, LOW) diff --git a/tests/pp/03.expect b/tests/pp/03.expect new file mode 100644 index 0000000..44aad0a --- /dev/null +++ b/tests/pp/03.expect @@ -0,0 +1,5 @@ +printf("x" "1" "= %d, x" "2" "= %s", x1, x2); +fputs("strncmp(\"abc\\0d\", \"abc\", '\\4') == 0" ": @\n", s); +\#include "vers2.h" +"hello"; +"hello" ", world" diff --git a/tests/pp/04.c b/tests/pp/04.c new file mode 100644 index 0000000..0068f37 --- /dev/null +++ b/tests/pp/04.c @@ -0,0 +1,4 @@ +#define foobar 1 +#define C(x,y) x##y +#define D(x) (C(x,bar)) +D(foo) diff --git a/tests/pp/04.expect b/tests/pp/04.expect new file mode 100644 index 0000000..7c67b01 --- /dev/null +++ b/tests/pp/04.expect @@ -0,0 +1 @@ +(1) diff --git a/tests/pp/05.c b/tests/pp/05.c new file mode 100644 index 0000000..7274941 --- /dev/null +++ b/tests/pp/05.c @@ -0,0 +1,7 @@ +#define t(x,y,z) x ## y ## z +#define xxx(s) int s[] = { t(1,2,3), t(,4,5), t(6,,7), t(8,9,), \ + t(10,,), t(,11,), t(,,12), t(,,) }; + +int j[] = { t(1,2,3), t(,4,5), t(6,,7), t(8,9,), + t(10,,), t(,11,), t(,,12), t(,,) }; +xxx(j) diff --git a/tests/pp/05.expect b/tests/pp/05.expect new file mode 100644 index 0000000..9f9be37 --- /dev/null +++ b/tests/pp/05.expect @@ -0,0 +1,3 @@ +int j[] = { 123, 45, 67, 89, + 10, 11, 12, }; +int j[] = { 123, 45, 67, 89, 10, 11, 12, }; diff --git a/tests/pp/06.c b/tests/pp/06.c new file mode 100644 index 0000000..28cfdde --- /dev/null +++ b/tests/pp/06.c @@ -0,0 +1,5 @@ +#define X(a,b, \ + c,d) \ + foo + +X(1,2,3,4) diff --git a/tests/pp/06.expect b/tests/pp/06.expect new file mode 100644 index 0000000..257cc56 --- /dev/null +++ b/tests/pp/06.expect @@ -0,0 +1 @@ +foo diff --git a/tests/pp/07.c b/tests/pp/07.c new file mode 100644 index 0000000..b22b22b --- /dev/null +++ b/tests/pp/07.c @@ -0,0 +1,4 @@ +#define a() YES +#define b() a +b() +b()() diff --git a/tests/pp/07.expect b/tests/pp/07.expect new file mode 100644 index 0000000..ad0e20a --- /dev/null +++ b/tests/pp/07.expect @@ -0,0 +1,2 @@ +a +YES diff --git a/tests/pp/08.c b/tests/pp/08.c new file mode 100644 index 0000000..93018e1 --- /dev/null +++ b/tests/pp/08.c @@ -0,0 +1,4 @@ +// test macro expansion in arguments +#define s_pos s_s.s_pos +#define foo(x) (x) +foo(hej.s_pos) diff --git a/tests/pp/08.expect b/tests/pp/08.expect new file mode 100644 index 0000000..2b2e3ee --- /dev/null +++ b/tests/pp/08.expect @@ -0,0 +1 @@ +(hej.s_s.s_pos) diff --git a/tests/pp/09.c b/tests/pp/09.c new file mode 100644 index 0000000..315b297 --- /dev/null +++ b/tests/pp/09.c @@ -0,0 +1,4 @@ +#define C(a,b,c) a##b##c +#define N(x,y) C(x,_,y) +#define A_O aaaaoooo +N(A,O) diff --git a/tests/pp/09.expect b/tests/pp/09.expect new file mode 100644 index 0000000..adce0f9 --- /dev/null +++ b/tests/pp/09.expect @@ -0,0 +1 @@ +aaaaoooo diff --git a/tests/pp/10.c b/tests/pp/10.c new file mode 100644 index 0000000..f180eff --- /dev/null +++ b/tests/pp/10.c @@ -0,0 +1,10 @@ +#define f(x) x +#define g(x) f(x) f(x +#define i(x) g(x)) g(x +#define h(x) i(x))) i(x +#define k(x) i(x))) i(x)))) +f(x) +g(x)) +i(x))) +h(x)))) +k(x)))) diff --git a/tests/pp/10.expect b/tests/pp/10.expect new file mode 100644 index 0000000..bd18e18 --- /dev/null +++ b/tests/pp/10.expect @@ -0,0 +1,5 @@ +x +x x +x x x x +x x x x x x x x +x x x x x x x x)))) diff --git a/tests/pp/11.c b/tests/pp/11.c new file mode 100644 index 0000000..c0edf62 --- /dev/null +++ b/tests/pp/11.c @@ -0,0 +1,31 @@ +#define D1(s, ...) s +#define D2(s, ...) s D1(__VA_ARGS__) +#define D3(s, ...) s D2(__VA_ARGS__) +#define D4(s, ...) s D3(__VA_ARGS__) + +D1(a) +D2(a, b) +D3(a, b, c) +D4(a, b, c, d) + +x D4(a, b, c, d) y +x D4(a, b, c) y +x D4(a, b) y +x D4(a) y +x D4() y + +#define GNU_COMMA(X,Y...) X,## Y + +x GNU_COMMA(A,B,C) y +x GNU_COMMA(A,B) y +x GNU_COMMA(A) y +x GNU_COMMA() y + +#define __sun_attr___noreturn__ __attribute__((__noreturn__)) +#define ___sun_attr_inner(__a) __sun_attr_##__a +#define __sun_attr__(__a) ___sun_attr_inner __a +#define __NORETURN __sun_attr__((__noreturn__)) +__NORETURN +#define X(...) +#define Y(...) 1 __VA_ARGS__ 2 +Y(X X() ()) diff --git a/tests/pp/11.expect b/tests/pp/11.expect new file mode 100644 index 0000000..6b9806c --- /dev/null +++ b/tests/pp/11.expect @@ -0,0 +1,15 @@ +a +a b +a b c +a b c d +x a b c d y +x a b c y +x a b y +x a y +x y +x A,B,C y +x A,B y +x A y +x y +__attribute__((__noreturn__)) +1 2 diff --git a/tests/pp/Makefile b/tests/pp/Makefile new file mode 100644 index 0000000..c656f9a --- /dev/null +++ b/tests/pp/Makefile @@ -0,0 +1,35 @@ +# +# credits: 01..13.c from the pcc cpp-tests suite +# + +TCC = ../../tcc +TESTS = $(patsubst %.c,%.test,$(wildcard *.c)) + +all test : $(TESTS) + +%.test: %.c %.expect + @echo PPTest $* ... + @$(TCC) -E -P $< >$*.output 2>&1 ; \ + diff -Nu -b -B -I "^#" $(EXTRA_DIFF_OPTS) $*.expect $*.output \ + && rm -f $*.output + +# automatically generate .expect files with gcc: +%.expect : + gcc -E -P $*.c >$*.expect 2>&1 + +# tell make not to delete +.PRECIOUS: %.expect + +clean: + rm -vf *.output + +# 02.test : EXTRA_DIFF_OPTS = -w +# 03.test : EXTRA_DIFF_OPTS = -w +# 04.test : EXTRA_DIFF_OPTS = -w +# 10.test : EXTRA_DIFF_OPTS = -w + +# diff options: +# -b ighore space changes +# -w ighore all whitespace +# -B ignore blank lines +# -I <RE> ignore lines matching RE diff --git a/tests/tcctest.c b/tests/tcctest.c index 49fa587..a822500 100644 --- a/tests/tcctest.c +++ b/tests/tcctest.c @@ -316,6 +316,7 @@ void macro_test(void) printf("__LINE__=%d __FILE__=%s\n", __LINE__, __FILE__); +#if 0 #line 200 printf("__LINE__=%d __FILE__=%s\n", __LINE__, __FILE__); @@ -323,6 +324,7 @@ void macro_test(void) printf("__LINE__=%d __FILE__=%s\n", __LINE__, __FILE__); #line 227 "tcctest.c" +#endif /* not strictly preprocessor, but we test it there */ #ifdef C99_MACROS diff --git a/tests/tests2/65_macro_concat_start.c b/tests/tests2/65_macro_concat_start.c deleted file mode 100644 index d63d67a..0000000 --- a/tests/tests2/65_macro_concat_start.c +++ /dev/null @@ -1,2 +0,0 @@ -#define paste(A,B) ##A B -paste(x,y) diff --git a/tests/tests2/65_macro_concat_start.expect b/tests/tests2/65_macro_concat_start.expect deleted file mode 100644 index 88ed6c5..0000000 --- a/tests/tests2/65_macro_concat_start.expect +++ /dev/null @@ -1 +0,0 @@ -65_macro_concat_start.c:1: error: '##' invalid at start of macro diff --git a/tests/tests2/66_macro_concat_end.c b/tests/tests2/66_macro_concat_end.c deleted file mode 100644 index 55dcaef..0000000 --- a/tests/tests2/66_macro_concat_end.c +++ /dev/null @@ -1,2 +0,0 @@ -#define paste(A,B) A B## -paste(x,y) diff --git a/tests/tests2/66_macro_concat_end.expect b/tests/tests2/66_macro_concat_end.expect deleted file mode 100644 index 224e5c9..0000000 --- a/tests/tests2/66_macro_concat_end.expect +++ /dev/null @@ -1 +0,0 @@ -66_macro_concat_end.c:2: error: '##' invalid at end of macro diff --git a/tests/tests2/68_macro_param_list_err_1.c b/tests/tests2/68_macro_param_list_err_1.c deleted file mode 100644 index fd08dc7..0000000 --- a/tests/tests2/68_macro_param_list_err_1.c +++ /dev/null @@ -1,9 +0,0 @@ -#include <stdio.h> -#define hexCh(c (c >= 10 ? 'a' + c - 10 : '0' + c) - -int main(void) -{ - int c = 0xa; - printf("hex: %c\n", hexCh(c)); - return 0; -} diff --git a/tests/tests2/68_macro_param_list_err_1.expect b/tests/tests2/68_macro_param_list_err_1.expect deleted file mode 100644 index 3246640..0000000 --- a/tests/tests2/68_macro_param_list_err_1.expect +++ /dev/null @@ -1 +0,0 @@ -68_macro_param_list_err_1.c:2: error: '(' may not appear in parameter list diff --git a/tests/tests2/69_macro_param_list_err_2.c b/tests/tests2/69_macro_param_list_err_2.c deleted file mode 100644 index 06f0b41..0000000 --- a/tests/tests2/69_macro_param_list_err_2.c +++ /dev/null @@ -1,9 +0,0 @@ -#include <stdio.h> -#define hexCh(c/3) (c >= 10 ? 'a' + c - 10 : '0' + c) - -int main(void) -{ - int c = 0xa; - printf("hex: %c\n", hexCh(c)); - return 0; -} diff --git a/tests/tests2/69_macro_param_list_err_2.expect b/tests/tests2/69_macro_param_list_err_2.expect deleted file mode 100644 index 6d6b9d1..0000000 --- a/tests/tests2/69_macro_param_list_err_2.expect +++ /dev/null @@ -1 +0,0 @@ -69_macro_param_list_err_2.c:2: error: '/' may not appear in parameter list diff --git a/tests/tests2/72_long_long_constant.c b/tests/tests2/72_long_long_constant.c index a698fd6..6608213 100644 --- a/tests/tests2/72_long_long_constant.c +++ b/tests/tests2/72_long_long_constant.c @@ -13,5 +13,7 @@ int main() printf("Error: 2147483647 < 0\n"); return 2; } + else + printf("long long constant test ok.\n"); return 0; } diff --git a/tests/tests2/72_long_long_constant.expect b/tests/tests2/72_long_long_constant.expect new file mode 100644 index 0000000..dda9e66 --- /dev/null +++ b/tests/tests2/72_long_long_constant.expect @@ -0,0 +1 @@ +long long constant test ok. diff --git a/tests/tests2/Makefile b/tests/tests2/Makefile index a441674..254fa5c 100644 --- a/tests/tests2/Makefile +++ b/tests/tests2/Makefile @@ -19,89 +19,9 @@ endif TCC = $(TOP)/tcc $(TCCFLAGS) -TESTS = \ - 00_assignment.test \ - 01_comment.test \ - 02_printf.test \ - 03_struct.test \ - 04_for.test \ - 05_array.test \ - 06_case.test \ - 07_function.test \ - 08_while.test \ - 09_do_while.test \ - 10_pointer.test \ - 11_precedence.test \ - 12_hashdefine.test \ - 13_integer_literals.test \ - 14_if.test \ - 15_recursion.test \ - 16_nesting.test \ - 17_enum.test \ - 18_include.test \ - 19_pointer_arithmetic.test \ - 20_pointer_comparison.test \ - 21_char_array.test \ - 22_floating_point.test \ - 23_type_coercion.test \ - 24_math_library.test \ - 25_quicksort.test \ - 26_character_constants.test \ - 27_sizeof.test \ - 28_strings.test \ - 29_array_address.test \ - 30_hanoi.test \ - 31_args.test \ - 32_led.test \ - 33_ternary_op.test \ - 34_array_assignment.test \ - 35_sizeof.test \ - 36_array_initialisers.test \ - 37_sprintf.test \ - 38_multiple_array_index.test \ - 39_typedef.test \ - 40_stdio.test \ - 41_hashif.test \ - 42_function_pointer.test \ - 43_void_param.test \ - 44_scoped_declarations.test \ - 45_empty_for.test \ - 46_grep.test \ - 47_switch_return.test \ - 48_nested_break.test \ - 49_bracket_evaluation.test \ - 50_logical_second_arg.test \ - 51_static.test \ - 52_unnamed_enum.test \ - 54_goto.test \ - 55_lshift_type.test \ - 56_btype_excess-1.test \ - 57_btype_excess-2.test \ - 58_function_redefinition.test \ - 59_function_array.test \ - 60_enum_redefinition.test \ - 61_undefined_enum.test \ - 62_enumerator_redefinition.test \ - 63_local_enumerator_redefinition.test \ - 64_macro_nesting.test \ - 65_macro_concat_start.test \ - 66_macro_concat_end.test \ - 67_macro_concat.test \ - 68_macro_param_list_err_1.test \ - 69_macro_param_list_err_2.test \ - 70_floating_point_literals.test \ - 71_macro_empty_arg.test \ - 72_long_long_constant.test \ - 73_arm64.test \ - 74_nocode_wanted.test \ - 75_array_in_struct_init.test \ - 76_dollars_in_identifiers.test \ - 77_push_pop_macro.test \ - 78_vla_label.test \ - 79_vla_continue.test +TESTS = $(patsubst %.c,%.test,$(wildcard *.c)) # 34_array_assignment.test -- array assignment is not in C standard - SKIP = 34_array_assignment.test # some tests do not pass on all platforms, remove them for now @@ -128,16 +48,29 @@ ARGS = FLAGS = 76_dollars_in_identifiers.test : FLAGS = -fdollars-in-identifiers +# Filter some always-warning +FILTER = +ifeq (-$(findstring arm,$(ARCH))-,-arm-) +FILTER = 2>&1 | grep -v 'warning: soft float ABI currently not supported' +endif + all test: $(filter-out $(SKIP),$(TESTS)) -%.test: %.c +%.test: %.c %.expect @echo Test: $*... - - @$(TCC) -run $(FLAGS) $< $(ARGS) 2>&1 | grep -v 'warning: soft float ABI currently not supported: default to softfp' >$*.output || true +# test -run + @$(TCC) $(FLAGS) -run $< $(ARGS) $(FILTER) >$*.output 2>&1 || true @diff -Nbu $*.expect $*.output && rm -f $*.output +# test exe (disabled for speed) +# @($(TCC) $(FLAGS) $< -o $*.exe && ./$*.exe $(ARGS)) $(FiLTER) >$*.output2 2>&1 ; \ +# diff -Nbu $*.expect $*.output2 && rm -f $*.output2 $*.exe + +# automatically generate .expect files with gcc: +%.expect : + (gcc $*.c -o a.exe && ./a.exe $(ARGS)) >$*.expect 2>&1; rm -f a.exe - @($(TCC) $(FLAGS) $< -o $*.exe && ./$*.exe $(ARGS)) 2>&1 | grep -v 'warning: soft float ABI currently not supported: default to softfp' >$*.output2 || true - @diff -Nbu $*.expect $*.output2 && rm -f $*.output2 $*.exe +# tell make not to delete +.PRECIOUS: %.expect clean: - rm -vf fred.txt *.output* *.exe + rm -vf fred.txt *.output a.exe |
