From d5f4df09ff4a84dda5b03525285f03be7723376b Mon Sep 17 00:00:00 2001 From: grischka Date: Tue, 5 Feb 2013 14:27:38 +0100 Subject: tests: cleanup tests: - add "hello" to test first basic compilation to file/memory - add "more" test (tests2 suite) - remove some tests tests2: - move into tests dir - Convert some files from DOS to unix LF - remove 2>&1 redirection win32: - tccrun.c: modify exception filter to exit correctly (needed for btest) - tcctest.c: exclude weak_test() (feature does not exist on win32) --- tests/tests2/16_nesting.expect | 36 ++++---- tests/tests2/17_enum.expect | 6 +- tests/tests2/18_include.expect | 6 +- tests/tests2/18_include.h | 2 +- tests/tests2/44_scoped_declarations.c | 34 ++++---- tests/tests2/45_empty_for.c | 36 ++++---- tests/tests2/50_logical_second_arg.c | 58 ++++++------- tests/tests2/54_goto.c | 112 ++++++++++++------------ tests/tests2/Makefile | 155 ++++++++++++++++------------------ 9 files changed, 220 insertions(+), 225 deletions(-) (limited to 'tests/tests2') diff --git a/tests/tests2/16_nesting.expect b/tests/tests2/16_nesting.expect index 625ee13..5a3431e 100644 --- a/tests/tests2/16_nesting.expect +++ b/tests/tests2/16_nesting.expect @@ -1,18 +1,18 @@ -0 0 0 -0 0 1 -0 0 2 -0 1 0 -0 1 1 -0 1 2 -0 2 0 -0 2 1 -0 2 2 -1 0 0 -1 0 1 -1 0 2 -1 1 0 -1 1 1 -1 1 2 -1 2 0 -1 2 1 -1 2 2 +0 0 0 +0 0 1 +0 0 2 +0 1 0 +0 1 1 +0 1 2 +0 2 0 +0 2 1 +0 2 2 +1 0 0 +1 0 1 +1 0 2 +1 1 0 +1 1 1 +1 1 2 +1 2 0 +1 2 1 +1 2 2 diff --git a/tests/tests2/17_enum.expect b/tests/tests2/17_enum.expect index bef4be6..0c4e153 100644 --- a/tests/tests2/17_enum.expect +++ b/tests/tests2/17_enum.expect @@ -1,3 +1,3 @@ -0 1 2 3 54 73 74 75 -12 -54 +0 1 2 3 54 73 74 75 +12 +54 diff --git a/tests/tests2/18_include.expect b/tests/tests2/18_include.expect index 87729df..58c6d29 100644 --- a/tests/tests2/18_include.expect +++ b/tests/tests2/18_include.expect @@ -1,3 +1,3 @@ -including -included -done +including +included +done diff --git a/tests/tests2/18_include.h b/tests/tests2/18_include.h index 01f894d..dc86080 100644 --- a/tests/tests2/18_include.h +++ b/tests/tests2/18_include.h @@ -1 +1 @@ -printf("included\n"); +printf("included\n"); diff --git a/tests/tests2/44_scoped_declarations.c b/tests/tests2/44_scoped_declarations.c index 2febf98..f38664f 100644 --- a/tests/tests2/44_scoped_declarations.c +++ b/tests/tests2/44_scoped_declarations.c @@ -1,17 +1,17 @@ -#include - -int main() -{ - int a; - - for (a = 0; a < 2; a++) - { - int b = a; - } - - printf("it's all good\n"); - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ +#include + +int main() +{ + int a; + + for (a = 0; a < 2; a++) + { + int b = a; + } + + printf("it's all good\n"); + + return 0; +} + +/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ diff --git a/tests/tests2/45_empty_for.c b/tests/tests2/45_empty_for.c index b14e9d4..7cef513 100644 --- a/tests/tests2/45_empty_for.c +++ b/tests/tests2/45_empty_for.c @@ -1,18 +1,18 @@ -#include - -int main() -{ - int Count = 0; - - for (;;) - { - Count++; - printf("%d\n", Count); - if (Count >= 10) - break; - } - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ +#include + +int main() +{ + int Count = 0; + + for (;;) + { + Count++; + printf("%d\n", Count); + if (Count >= 10) + break; + } + + return 0; +} + +/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ diff --git a/tests/tests2/50_logical_second_arg.c b/tests/tests2/50_logical_second_arg.c index 5fa0bb9..ddec08c 100644 --- a/tests/tests2/50_logical_second_arg.c +++ b/tests/tests2/50_logical_second_arg.c @@ -1,29 +1,29 @@ -#include - -int fred() -{ - printf("fred\n"); - return 0; -} - -int joe() -{ - printf("joe\n"); - return 1; -} - -int main() -{ - printf("%d\n", fred() && joe()); - printf("%d\n", fred() || joe()); - printf("%d\n", joe() && fred()); - printf("%d\n", joe() || fred()); - printf("%d\n", fred() && (1 + joe())); - printf("%d\n", fred() || (0 + joe())); - printf("%d\n", joe() && (0 + fred())); - printf("%d\n", joe() || (1 + fred())); - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ +#include + +int fred() +{ + printf("fred\n"); + return 0; +} + +int joe() +{ + printf("joe\n"); + return 1; +} + +int main() +{ + printf("%d\n", fred() && joe()); + printf("%d\n", fred() || joe()); + printf("%d\n", joe() && fred()); + printf("%d\n", joe() || fred()); + printf("%d\n", fred() && (1 + joe())); + printf("%d\n", fred() || (0 + joe())); + printf("%d\n", joe() && (0 + fred())); + printf("%d\n", joe() || (1 + fred())); + + return 0; +} + +/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ diff --git a/tests/tests2/54_goto.c b/tests/tests2/54_goto.c index 9509e83..2e151bb 100644 --- a/tests/tests2/54_goto.c +++ b/tests/tests2/54_goto.c @@ -1,56 +1,56 @@ -#include - -void fred() -{ - printf("In fred()\n"); - goto done; - printf("In middle\n"); -done: - printf("At end\n"); -} - -void joe() -{ - int b = 5678; - - printf("In joe()\n"); - - { - int c = 1234; - printf("c = %d\n", c); - goto outer; - printf("uh-oh\n"); - } - -outer: - - printf("done\n"); -} - -void henry() -{ - int a; - - printf("In henry()\n"); - goto inner; - - { - int b; -inner: - b = 1234; - printf("b = %d\n", b); - } - - printf("done\n"); -} - -int main() -{ - fred(); - joe(); - henry(); - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ +#include + +void fred() +{ + printf("In fred()\n"); + goto done; + printf("In middle\n"); +done: + printf("At end\n"); +} + +void joe() +{ + int b = 5678; + + printf("In joe()\n"); + + { + int c = 1234; + printf("c = %d\n", c); + goto outer; + printf("uh-oh\n"); + } + +outer: + + printf("done\n"); +} + +void henry() +{ + int a; + + printf("In henry()\n"); + goto inner; + + { + int b; +inner: + b = 1234; + printf("b = %d\n", b); + } + + printf("done\n"); +} + +int main() +{ + fred(); + joe(); + henry(); + + return 0; +} + +/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ diff --git a/tests/tests2/Makefile b/tests/tests2/Makefile index d328ce7..bf7511f 100644 --- a/tests/tests2/Makefile +++ b/tests/tests2/Makefile @@ -1,103 +1,98 @@ -TOP = .. +TOP = ../.. include $(TOP)/Makefile -VPATH = $(top_srcdir)/tests2 +VPATH = $(top_srcdir)/tests/tests2 -ifeq ($(TARGETOS),Darwin) - CFLAGS+=-Wl,-flat_namespace,-undefined,warning - TCCFLAGS=-D_ANSI_SOURCE - export MACOSX_DEPLOYMENT_TARGET:=10.2 +TCCFLAGS = -B$(TOP) +ifdef CONFIG_WIN32 + TCCFLAGS = -B$(top_srcdir)/win32 -I$(top_srcdir)/include -L$(TOP) endif -ifdef CONFIG_WIN32 - TCCFLAGS=-I $(TOP)/win32/include -L$(TOP) +ifeq ($(TARGETOS),Darwin) + CFLAGS += -Wl,-flat_namespace,-undefined,warning + TCCFLAGS += -D_ANSI_SOURCE + export MACOSX_DEPLOYMENT_TARGET:=10.2 endif -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 \ - 31_args.test \ - 32_led.test \ - 33_ternary_op.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 \ - 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 +TCC_RUN = $(TOP)/tcc $(TCCFLAGS) -run - # 30_hanoi.test \ # seg fault in the code, gcc as well - # 34_array_assignment.test \ # array assignment is not in C standard - # 46_grep.test \ # does not compile even with gcc +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 \ + 31_args.test \ + 32_led.test \ + 33_ternary_op.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 \ + 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 + +# 30_hanoi.test -- seg fault in the code, gcc as well +# 34_array_assignment.test -- array assignment is not in C standard +# 46_grep.test -- does not compile even with gcc # some tests do not pass on all platforms, remove them for now ifeq ($(TARGETOS),Darwin) - TESTS := $(filter-out 40_stdio.test,$(TESTS)) + TESTS := $(filter-out 40_stdio.test,$(TESTS)) endif ifdef CONFIG_WIN32 - TESTS := $(filter-out 24_math_library.test,$(TESTS)) - TESTS := $(filter-out 28_strings.test,$(TESTS)) + TESTS := $(filter-out 24_math_library.test 28_strings.test,$(TESTS)) endif %.test: %.c %.expect @echo Test: $*... @if [ "x`echo $* | grep args`" != "x" ]; \ - then \ - ../tcc -B.. $(TCCFLAGS) -run $< - arg1 arg2 arg3 arg4 2>&1 >$*.output; \ - else \ - ../tcc -B.. $(TCCFLAGS) -run $< 2>&1 >$*.output; \ + then $(TCC_RUN) $< - arg1 arg2 arg3 arg4 >$*.output; \ + else $(TCC_RUN) $< >$*.output; \ fi @if diff -bu $(<:.c=.expect) $*.output ; \ - then \ - rm -f $*.output \ - else \ - echo "ERROR: test $*"; \ + then rm -f $*.output; \ + else exit 1; \ fi -all: test - -test: $(TESTS) - -# vim: set expandtab ts=4 sw=4 sts=4 tw=80 : +all test: $(TESTS) clean: - rm -vf fred.txt + rm -vf fred.txt *.output -- cgit v1.3.1