aboutsummaryrefslogtreecommitdiff
path: root/tests/tests2/Makefile
blob: c1bf5e671023ce176926aaeb891d5b6a850c59d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
TOP = ../..
include $(TOP)/Makefile
VPATH = $(top_srcdir)/tests/tests2

TCCFLAGS = -B$(TOP) -I$(top_srcdir)/include
ifdef CONFIG_WIN32
 TCCFLAGS = -B$(top_srcdir)/win32 -I$(top_srcdir)/include -L$(TOP)
endif

ifeq ($(TARGETOS),Darwin)
 CFLAGS += -Wl,-flat_namespace,-undefined,warning
 TCCFLAGS += -D_ANSI_SOURCE
 export MACOSX_DEPLOYMENT_TARGET:=10.2
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 \
 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 \
 56_btype_excess-1.test \
 57_btype_excess-2.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))
endif
ifdef CONFIG_WIN32
  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) $< -norunsrc -run $(notdir $<) - arg1 arg2 arg3 arg4 >$*.output 2>&1; \
	else $(TCC) -run $< >$*.output 2>&1; \
	fi || true
	@if diff -bu $(<:.c=.expect) $*.output ; \
	then rm -f $*.output; \
	else exit 1; \
	fi

all test: $(TESTS)

clean:
	rm -vf fred.txt *.output