source: EcnlProtoTool/trunk/tcc-0.9.27/tests/Makefile@ 331

Last change on this file since 331 was 331, checked in by coas-nagasima, 6 years ago

prototoolに関連するプロジェクトをnewlibからmuslを使うよう変更・更新
ntshellをnewlibの下位の実装から、muslのsyscallの実装に変更・更新
以下のOSSをアップデート
・mruby-1.3.0
・musl-1.1.18
・onigmo-6.1.3
・tcc-0.9.27
以下のOSSを追加
・openssl-1.1.0e
・curl-7.57.0
・zlib-1.2.11
以下のmrbgemsを追加
・iij/mruby-digest
・iij/mruby-env
・iij/mruby-errno
・iij/mruby-iijson
・iij/mruby-ipaddr
・iij/mruby-mock
・iij/mruby-require
・iij/mruby-tls-openssl

File size: 9.4 KB
Line 
1#
2# Tiny C Compiler Makefile - tests
3#
4
5TOP = ..
6include $(TOP)/Makefile
7VPATH = $(TOPSRC)/tests $(TOPSRC) $(TOP)
8CFLAGS := $(filter-out -W% -g% -O%,$(CFLAGS)) -I$(TOPSRC) $(LDFLAGS)
9
10# what tests to run
11TESTS = \
12 hello-exe \
13 hello-run \
14 libtest \
15 test3 \
16 memtest \
17 dlltest \
18 abitest \
19 asm-c-connect-test \
20 vla_test-run \
21 cross-test \
22 tests2-dir \
23 pp-dir
24
25BTESTS = test1b test3b btest
26
27# test4 -- problem with -static
28# asmtest / asmtest2 -- minor differences with gcc
29# btest -- works on i386 (including win32)
30
31# bounds-checking is supported only on i386
32ifneq ($(ARCH),i386)
33 TESTS := $(filter-out $(BTESTS),$(TESTS))
34endif
35ifdef CONFIG_WIN32
36 TESTS := $(filter-out $(BTESTS),$(TESTS))
37endif
38ifdef CONFIG_OSX # -run only
39 TESTS := hello-run libtest tests2-dir pp-dir
40endif
41ifeq (,$(filter arm64 i386 x86_64,$(ARCH)))
42 TESTS := $(filter-out vla_test-run,$(TESTS))
43endif
44ifeq ($(CONFIG_arm_eabi),yes)
45 TESTS := $(filter-out test3,$(TESTS))
46endif
47ifeq (,$(filter i386 x86_64,$(ARCH)))
48 TESTS := $(filter-out dlltest asm-c-connect-test,$(TESTS))
49endif
50ifndef CONFIG_cross
51 TESTS := $(filter-out cross-%,$(TESTS))
52endif
53
54ifeq ($(OS),Windows_NT) # for libtcc_test to find libtcc.dll
55 PATH := $(CURDIR)/$(TOP)$(if $(findstring :\,$(PATH)),;,:)$(PATH)
56endif
57
58RUN_TCC = $(NATIVE_DEFINES) -run $(TOPSRC)/tcc.c $(TCCFLAGS)
59DISAS = objdump -d
60DUMPTCC = (set -x; $(TOP)/tcc -vv; ldd $(TOP)/tcc; exit 1)
61
62all test : clean-s $(TESTS)
63
64hello-exe: ../examples/ex1.c
65 @echo ------------ $@ ------------
66 $(TCC) $< -o hello$(EXESUF) && ./hello$(EXESUF) || $(DUMPTCC)
67
68hello-run: ../examples/ex1.c
69 @echo ------------ $@ ------------
70 $(TCC) -run $< || $(DUMPTCC)
71
72libtest: libtcc_test$(EXESUF)
73 @echo ------------ $@ ------------
74 ./libtcc_test$(EXESUF) $(TCCFLAGS)
75
76libtcc_test$(EXESUF): libtcc_test.c $(LIBTCC)
77 $(CC) -o $@ $^ $(CFLAGS) $(LIBS)
78
79%-dir:
80 @echo ------------ $@ ------------
81 $(MAKE) -k -C $*
82
83# test.ref - generate using cc
84test.ref: tcctest.c
85 $(CC) -o tcctest.gcc $< $(NATIVE_DEFINES) $(CFLAGS) -w -O0 -std=gnu99 -fno-omit-frame-pointer
86 ./tcctest.gcc > $@
87
88# auto test
89test1 test1b: tcctest.c test.ref
90 @echo ------------ $@ ------------
91 $(TCC) -run $< > test.out1
92 @diff -u test.ref test.out1 && echo "Auto Test OK"
93
94# iterated test2 (compile tcc then compile tcctest.c !)
95test2 test2b: tcctest.c test.ref
96 @echo ------------ $@ ------------
97 $(TCC) $(RUN_TCC) $(RUN_TCC) -run $< > test.out2
98 @diff -u test.ref test.out2 && echo "Auto Test2 OK"
99
100# iterated test3 (compile tcc then compile tcc then compile tcctest.c !)
101test3 test3b: tcctest.c test.ref
102 @echo ------------ $@ ------------
103 $(TCC) $(RUN_TCC) $(RUN_TCC) $(RUN_TCC) -run $< > test.out3
104 @diff -u test.ref test.out3 && echo "Auto Test3 OK"
105
106test%b : TCCFLAGS += -b
107
108# binary output test
109test4: tcctest.c test.ref
110 @echo ------------ $@ ------------
111# object + link output
112 $(TCC) -c -o tcctest3.o $<
113 $(TCC) -o tcctest3 tcctest3.o
114 ./tcctest3 > test3.out
115 @if diff -u test.ref test3.out ; then echo "Object Auto Test OK"; fi
116# dynamic output
117 $(TCC) -o tcctest1 $<
118 ./tcctest1 > test1.out
119 @if diff -u test.ref test1.out ; then echo "Dynamic Auto Test OK"; fi
120# dynamic output + bound check
121 $(TCC) -b -o tcctest4 $<
122 ./tcctest4 > test4.out
123 @if diff -u test.ref test4.out ; then echo "BCheck Auto Test OK"; fi
124# static output
125 $(TCC) -static -o tcctest2 $<
126 ./tcctest2 > test2.out
127 @if diff -u test.ref test2.out ; then echo "Static Auto Test OK"; fi
128
129# use tcc to create libtcc.so/.dll and the tcc(.exe) frontend and run them
130dlltest:
131 @echo ------------ $@ ------------
132 $(TCC) $(NATIVE_DEFINES) -DLIBTCC_AS_DLL $(TOPSRC)/libtcc.c $(LIBS) -shared -o libtcc2$(DLLSUF)
133 $(TCC) $(NATIVE_DEFINES) -DONE_SOURCE=0 $(TOPSRC)/tcc.c libtcc2$(DLLSUF) $(LIBS) -Wl,-rpath=. -o tcc2$(EXESUF)
134 ./tcc2$(EXESUF) $(TCCFLAGS) $(RUN_TCC) -run $(TOPSRC)/examples/ex1.c
135ifndef CONFIG_WIN32
136 @echo ------------ $@ with PIC ------------
137 $(CC) $(CFLAGS) -fPIC $(NATIVE_DEFINES) -DLIBTCC_AS_DLL -c $(TOPSRC)/libtcc.c
138 $(TCC) libtcc.o $(LIBS) -shared -o libtcc2$(DLLSUF)
139 $(TCC) $(NATIVE_DEFINES) -DONE_SOURCE=0 $(TOPSRC)/tcc.c libtcc2$(DLLSUF) $(LIBS) -Wl,-rpath=. -o tcc2$(EXESUF)
140 ./tcc2$(EXESUF) $(TCCFLAGS) $(RUN_TCC) -run $(TOPSRC)/examples/ex1.c
141endif
142 @rm tcc2$(EXESUF) libtcc2$(DLLSUF)
143
144memtest:
145 @echo ------------ $@ ------------
146 $(CC) $(CFLAGS) $(NATIVE_DEFINES) -DMEM_DEBUG=2 $(TOPSRC)/tcc.c $(LIBS) -o memtest-tcc$(EXESUF)
147 ./memtest-tcc$(EXESUF) $(TCCFLAGS) $(NATIVE_DEFINES) $(TOPSRC)/tcc.c $(LIBS)
148 ./memtest-tcc$(EXESUF) $(TCCFLAGS) $(NATIVE_DEFINES) -run $(TOPSRC)/tcc.c $(TCCFLAGS) $(TOPSRC)/tests/tcctest.c
149
150
151# memory and bound check auto test
152BOUNDS_OK = 1 4 8 10 14
153BOUNDS_FAIL= 2 5 7 9 11 12 13 15
154
155btest: boundtest.c
156 @echo ------------ $@ ------------
157 @for i in $(BOUNDS_OK); do \
158 echo ; echo --- boundtest $$i ---; \
159 if $(TCC) -b -run $< $$i ; then \
160 echo succeeded as expected; \
161 else\
162 echo Failed positive test $$i ; exit 1 ; \
163 fi ;\
164 done ;\
165 for i in $(BOUNDS_FAIL); do \
166 echo ; echo --- boundtest $$i ---; \
167 if $(TCC) -b -run $< $$i ; then \
168 echo Failed negative test $$i ; exit 1 ;\
169 else\
170 echo failed as expected; \
171 fi ;\
172 done ;\
173 echo; echo Bound test OK
174
175# speed test
176speedtest: ex2 ex3
177 @echo ------------ $@ ------------
178 time ./ex2 1238 2 3 4 10 13 4
179 time $(TCC) -run $(TOPSRC)/examples/ex2.c 1238 2 3 4 10 13 4
180 time ./ex3 35
181 time $(TCC) -run $(TOPSRC)/examples/ex3.c 35
182
183weaktest: tcctest.c test.ref
184 $(TCC) -c $< -o weaktest.tcc.o
185 $(CC) -c $< -o weaktest.gcc.o $(NATIVE_DEFINES) $(CFLAGS) -w -O0 -std=gnu99 -fno-omit-frame-pointer
186 objdump -t weaktest.tcc.o | grep ' w ' | sed -e 's/.* \([a-zA-Z0-9_]*\)$$/\1/' | LC_ALL=C sort > weaktest.tcc.o.txt
187 objdump -t weaktest.gcc.o | grep ' w ' | sed -e 's/.* \([a-zA-Z0-9_]*\)$$/\1/' | LC_ALL=C sort > weaktest.gcc.o.txt
188 diff weaktest.gcc.o.txt weaktest.tcc.o.txt && echo "Weak Auto Test OK"
189
190ex%: $(TOPSRC)/examples/ex%.c
191 $(CC) -o $@ $< $(CFLAGS)
192
193# tiny assembler testing
194asmtest.ref: asmtest.S
195 $(CC) -Wa,-W -o asmtest.ref.o -c asmtest.S
196 objdump -D asmtest.ref.o > asmtest.ref
197
198asmtest asmtest2: asmtest.ref
199 @echo ------------ $@ ------------
200 $(TCC) $(MAYBE_RUN_TCC) -c asmtest.S
201 objdump -D asmtest.o > asmtest.out
202 @if diff -u --ignore-matching-lines="file format" asmtest.ref asmtest.out ; then echo "ASM Auto Test OK"; fi
203
204# test assembler with tcc compiled by itself
205asmtest2: MAYBE_RUN_TCC = $(RUN_TCC)
206
207# Check that code generated by libtcc is binary compatible with
208# that generated by CC
209abitest-cc$(EXESUF): abitest.c $(LIBTCC)
210 $(CC) -o $@ $^ $(CFLAGS) $(LIBS) -w
211
212abitest-tcc$(EXESUF): abitest.c libtcc.c
213 $(TCC) -o $@ $^ $(NATIVE_DEFINES) $(LIBS)
214
215ABITESTS := abitest-cc$(EXESUF)
216ifneq ($(CONFIG_arm_eabi),yes) # not ARM soft-float
217 ABITESTS += abitest-tcc$(EXESUF)
218endif
219
220abitest: $(ABITESTS)
221 @echo ------------ $@ ------------
222 ./abitest-cc$(EXESUF) $(TCCFLAGS)
223ifneq ($(CONFIG_arm_eabi),yes) # not ARM soft-float
224 ./abitest-tcc$(EXESUF) $(TCCFLAGS)
225endif
226
227vla_test$(EXESUF): vla_test.c
228 $(TCC) -o $@ $^
229
230vla_test-run: vla_test$(EXESUF)
231 @echo ------------ $@ ------------
232 ./vla_test$(EXESUF)
233
234asm-c-connect$(EXESUF): asm-c-connect-1.c asm-c-connect-2.c
235 $(TCC) -o $@ $^
236
237asm-c-connect-%.o: asm-c-connect-%.c
238 $(TCC) -c -o $@ $<
239
240asm-c-connect-sep$(EXESUF): asm-c-connect-1.o asm-c-connect-2.o
241 $(TCC) -o $@ $^
242
243asm-c-connect-test: asm-c-connect$(EXESUF) asm-c-connect-sep$(EXESUF)
244 @echo ------------ $@ ------------
245 ./asm-c-connect$(EXESUF) > asm-c-connect.out1 && cat asm-c-connect.out1
246 ./asm-c-connect-sep$(EXESUF) > asm-c-connect.out2 && cat asm-c-connect.out2
247 @diff -u asm-c-connect.out1 asm-c-connect.out2 && echo "ok"
248
249cross-test :
250 @echo ------------ $@ ------------
251 $(TOP)/i386-tcc$(EXESUF) $(TCCFLAGS-unx) -c $(TOPSRC)/examples/ex3.c && echo "ok"
252 $(TOP)/i386-win32-tcc$(EXESUF) $(TCCFLAGS-win) $(TOPSRC)/examples/ex3.c && echo "ok"
253 $(TOP)/x86_64-tcc$(EXESUF) $(TCCFLAGS-unx) -c $(TOPSRC)/examples/ex3.c && echo "ok"
254 $(TOP)/x86_64-win32-tcc$(EXESUF) $(TCCFLAGS-win) $(TOPSRC)/examples/ex3.c && echo "ok"
255 $(TOP)/arm-tcc$(EXESUF) $(TCCFLAGS-unx) -c $(TOPSRC)/examples/ex3.c && echo "ok"
256 $(TOP)/arm-wince-tcc$(EXESUF) $(TCCFLAGS-win) -c $(TOPSRC)/examples/ex3.c && echo "ok"
257 $(TOP)/arm64-tcc$(EXESUF) $(TCCFLAGS-unx) -c $(TOPSRC)/examples/ex3.c && echo "ok"
258 $(TOP)/c67-tcc$(EXESUF) $(TCCFLAGS-unx) -c $(TOPSRC)/examples/ex3.c && echo "ok"
259 $(TOP)/i386-win32-tcc$(EXESUF) $(TCCFLAGS-win) $(TOPSRC)/win32/examples/hello_win.c && echo "ok"
260 $(TOP)/x86_64-win32-tcc$(EXESUF) $(TCCFLAGS-win) $(TOPSRC)/win32/examples/hello_win.c && echo "ok"
261 $(TOP)/arm-wince-tcc$(EXESUF) $(TCCFLAGS-win) -c $(TOPSRC)/win32/examples/hello_win.c && echo "ok"
262
263# targets for development
264%.bin: %.c tcc
265 $(TCC) -g -o $@ $<
266 $(DISAS) $@
267
268instr: instr.o
269 objdump -d instr.o
270
271instr.o: instr.S
272 $(CC) -o $@ -c $< -O2 -Wall -g
273
274cache: tcc_g
275 cachegrind ./tcc_g -o /tmp/linpack -lm bench/linpack.c
276 vg_annotate tcc.c > /tmp/linpack.cache.log
277
278# clean
279clean:
280 rm -f *~ *.o *.a *.bin *.i *.ref *.out *.out? *.out?b *.cc *.gcc
281 rm -f *-cc *-gcc *-tcc *.exe hello libtcc_test vla_test tcctest[1234]
282 rm -f asm-c-connect$(EXESUF)
283 rm -f ex? tcc_g weaktest.*.txt *.def
284 @$(MAKE) -C tests2 $@
285 @$(MAKE) -C pp $@
286
287# silent clean, used before running tests
288clean-s:
289 @$(MAKE) -s --no-print-directory clean
Note: See TracBrowser for help on using the repository browser.