2 include $(TOP
)/Makefile
3 SRC
= $(TOPSRC
)/tests
/tests2
6 TESTS
= $(patsubst %.c
,%.
test,\
7 $(sort $(notdir $(wildcard $(SRC
)/??_
*.c
)))\
8 $(sort $(notdir $(wildcard $(SRC
)/???_
*.c
))))
10 # some tests do not pass on all platforms, remove them for now
11 SKIP
= 34_array_assignment.
test # array assignment is not in C standard
12 ifeq ($(CONFIG_arm_eabi
),yes
) # not ARM soft-float
13 SKIP
+= 22_floating_point.
test
16 SKIP
+= 40_stdio.
test 42_function_pointer.
test
17 SKIP
+= 113_btdll.
test # no shared lib support yet
22 ifeq (,$(filter i386
,$(ARCH
)))
23 SKIP
+= 98_al_ax_extend.
test 99_fastcall.
test
25 ifeq (,$(filter i386 x86_64
,$(ARCH
)))
26 SKIP
+= 85_asm-outside-function.
test # x86 asm
27 SKIP
+= 113_btdll.
test # dll support needed
29 ifeq (,$(filter i386 x86_64 arm arm64 riscv64
,$(ARCH
)))
30 SKIP
+= 112_backtrace.
test
31 SKIP
+= 114_bound_signal.
test
32 SKIP
+= 115_bound_setjmp.
test
33 SKIP
+= 116_bound_setjmp2.
test
35 ifeq (-$(CONFIG_musl
)-,-yes-
)
36 SKIP
+= 112_backtrace.
test
38 ifeq (-$(findstring gcc
,$(CC
))-,--)
39 SKIP
+= $(patsubst %.expect
,%.
test,$(GEN-ALWAYS
))
41 ifeq (-$(CONFIG_WIN32
)-$(CONFIG_i386
)$(CONFIG_arm
)-,--yes-
)
42 SKIP
+= 95_bitfields
%.
test # type_align is different on 32bit-non-windows
44 ifeq (-$(CONFIG_WIN32
)-,-yes-
)
45 SKIP
+= 106_pthread.
test # No pthread support
46 SKIP
+= 114_bound_signal.
test # No pthread support
49 # Some tests might need arguments
51 31_args.
test : ARGS
= arg1 arg2 arg3 arg4 arg5
52 46_grep.
test : ARGS
= '[^* ]*[:a:d: ]+\:\*-/: $$' $(SRC
)/46_grep.c
54 # And some tests don't test the right thing with -run
56 42_function_pointer.
test : NORUN
= true
58 # Some tests might need different flags
60 76_dollars_in_identifiers.
test : FLAGS
+= -fdollars-in-identifiers
62 # These tests run several snippets from the same file one by one
63 60_errors_and_warnings.
test : FLAGS
+= -dt
64 96_nodata_wanted.
test : FLAGS
+= -dt
66 # Always generate certain .expects (don't put these in the GIT),
68 # GEN-ALWAYS += 95_bitfields.expect # does not work
70 # using the ms compiler for the really ms-compatible bitfields
71 95_bitfields_ms.
test : GEN
= $(GEN-MSC
)
73 # this test compiles/links two files:
74 104_inline.
test : FLAGS
+= $(subst 104,104+,$1)
75 104_inline.
test : GEN
= $(GEN-TCC
)
77 # this test needs pthread
78 106_pthread.
test: FLAGS
+= -pthread
79 106_pthread.
test: NORUN
= true
81 # constructor/destructor
82 108_constructor.
test: NORUN
= true
84 112_backtrace.
test: FLAGS
+= -dt
-b
85 112_backtrace.
test 113_btdll.
test: FILTER
+= \
86 -e
's;[0-9A-Fa-fx]\{5,\};........;g' \
87 -e
's;0x[0-9A-Fa-f]\{1,\};0x?;g'
89 # this test creates two DLLs and an EXE
90 113_btdll.
test: T1
= \
91 $(TCC
) -bt
$1 -shared
-D DLL
=1 -o a1
$(DLLSUF
) && \
92 $(TCC
) -bt
$1 -shared
-D DLL
=2 -o a2
$(DLLSUF
) && \
93 $(TCC
) -bt
$1 a1
$(DLLSUF
) a2
$(DLLSUF
) -Wl
,-rpath
=.
-o a.exe
&& \
96 114_bound_signal.
test: FLAGS
+= -b
97 115_bound_setjmp.
test: FLAGS
+= -b
98 116_bound_setjmp2.
test: FLAGS
+= -b
99 117_builtins.
test: T1
= ( $(TCC
) -run
$1 && $(TCC
) -b
-run
$1 )
101 # Filter source directory in warnings/errors (out-of-tree builds)
102 FILTER
= 2>&1 | sed
-e
's,$(SRC)/,,g'
104 all test tests2.
all: $(filter-out $(SKIP
),$(TESTS
))
105 @
$(MAKE
) clean --no-print-directory
-s
111 T1
= $(TCC
) $(FLAGS
) $(T2
) $(ARGS
)
112 T2
= $(if
$(NORUN
),$1 -o a.exe
&& .
/a.exe
,-run
$1)
113 T3
= $(FILTER
) >$*.output
2>&1 || true \
114 && diff
-Nbu
$(filter %.expect
,$^
) $*.output \
115 && rm -f
$*.output
$(filter $*.expect
,$(GEN-ALWAYS
))
117 # run single test and update .expect file, e.g. "make tests2.37+"
119 @
$(MAKE
) $(call F2
,$(call F1
,$*)) --no-print-directory
121 # just run tcc to see the output, e.g. "make tests2.37-"
123 @
$(MAKE
) $(call F1
,$*) T3
= --no-print-directory
125 # run single test, e.g. "make tests2.37"
127 @
$(MAKE
) $(call F1
,$*) --no-print-directory
129 F1
= $(or
$(filter $1_%,$(TESTS
)),$1_???.
test)
130 F2
= $1 UPDATE
="$(patsubst %.test,%.expect,$1)"
132 # automatically generate .expect files with gcc:
135 @
$(call GEN
,$(SRC
)/$*.c
) $(FILTER
) >$@
2>&1
136 @
rm -f
*.exe
*.obj
*.pdb
138 # using TCC for .expect if -dt in FLAGS
139 GEN
= $(if
$(filter -dt
-bt
-b
,$(FLAGS
)),$(GEN-TCC
),$(GEN-CC
))
140 GEN-CC
= $(CC
) -w
-std
=gnu99
$(FLAGS
) $1 -o a.exe
&& .
/a.exe
$(ARGS
)
142 GEN-MSC
= $(MS-CC
) $1 && .
/$(basename $@
).exe
145 # tell make not to delete
148 # force .expect generation for these files
149 $(sort $(GEN-ALWAYS
) $(UPDATE
)) : force
153 rm -f fred.txt
*.output a.exe
*.dll
*.so
*.def
$(GEN-ALWAYS
)