source: EcnlProtoTool/trunk/tcc-0.9.26/tests/Makefile@ 279

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

ファイルを追加、更新。

File size: 5.5 KB
RevLine 
[279]1#
2# Tiny C Compiler Makefile - tests
3#
4
5TOP = ..
6include $(TOP)/Makefile
7VPATH = $(top_srcdir)/tests
8
9# what tests to run
10TESTS = \
11 hello-exe \
12 hello-run \
13 libtest \
14 test3 \
15 moretests
16
17# test4 -- problem with -static
18# asmtest -- minor differences with gcc
19# btest -- works on i386 (including win32)
20# test3 -- win32 does not know how to printf long doubles
21
22# bounds-checking is supported only on i386
23ifneq ($(ARCH),i386)
24 TESTS := $(filter-out btest,$(TESTS))
25endif
26ifdef CONFIG_WIN32
27 TESTS := $(filter-out test3,$(TESTS))
28endif
29ifeq ($(TARGETOS),Darwin)
30 TESTS := $(filter-out hello-exe test3 btest,$(TESTS))
31endif
32
33ifdef DISABLE_STATIC
34 export LD_LIBRARY_PATH:=$(CURDIR)/..
35endif
36
37ifeq ($(TARGETOS),Darwin)
38 CFLAGS+=-Wl,-flat_namespace,-undefined,warning
39 export MACOSX_DEPLOYMENT_TARGET:=10.2
40 NATIVE_DEFINES+=-D_ANSI_SOURCE
41endif
42
43# run local version of tcc with local libraries and includes
44TCCFLAGS = -B$(TOP)
45ifdef CONFIG_WIN32
46 TCCFLAGS = -B$(top_srcdir)/win32 -I$(top_srcdir)/include -L$(TOP)
47endif
48
49TCC = $(TOP)/tcc $(TCCFLAGS)
50RUN_TCC = $(NATIVE_DEFINES) -DONE_SOURCE -run $(TOP)/tcc.c $(TCCFLAGS)
51
52DISAS = objdump -d
53
54# libtcc test
55ifdef LIBTCC1
56 LIBTCC1:=$(TOP)/$(LIBTCC1)
57endif
58
59all test : $(TESTS)
60
61hello-exe: ../examples/ex1.c
62 @echo ------------ $@ ------------
63 $(TCC) $< -o hello$(EXESUF) || ($(TOP)/tcc -vv; exit 1) && ./hello$(EXESUF)
64
65hello-run: ../examples/ex1.c
66 @echo ------------ $@ ------------
67 $(TCC) -run $<
68
69libtest: libtcc_test$(EXESUF) $(LIBTCC1)
70 @echo ------------ $@ ------------
71 ./libtcc_test$(EXESUF) lib_path=..
72
73libtcc_test$(EXESUF): libtcc_test.c $(top_builddir)/$(LIBTCC)
74 $(CC) -o $@ $^ $(CPPFLAGS) $(CFLAGS) $(NATIVE_DEFINES) $(LIBS) $(LINK_LIBTCC) $(LDFLAGS)
75
76moretests:
77 @echo ------------ $@ ------------
78 $(MAKE) -C tests2
79
80# test.ref - generate using gcc
81# copy only tcclib.h so GCC's stddef and stdarg will be used
82test.ref: tcctest.c
83 cp ../include/tcclib.h .
84 gcc -o tcctest.gcc $< -I. $(CPPFLAGS) -w $(CFLAGS) $(NATIVE_DEFINES) -std=gnu99 -O0 -fno-omit-frame-pointer $(LDFLAGS)
85 ./tcctest.gcc > $@
86
87# auto test
88test1: test.ref
89 @echo ------------ $@ ------------
90 $(TCC) -run tcctest.c > test.out1
91 @if diff -u test.ref test.out1 ; then echo "Auto Test OK"; fi
92
93# iterated test2 (compile tcc then compile tcctest.c !)
94test2: test.ref
95 @echo ------------ $@ ------------
96 $(TCC) $(RUN_TCC) $(RUN_TCC) -run tcctest.c > test.out2
97 @if diff -u test.ref test.out2 ; then echo "Auto Test2 OK"; fi
98
99# iterated test3 (compile tcc then compile tcc then compile tcctest.c !)
100test3: test.ref
101 @echo ------------ $@ ------------
102 $(TCC) $(RUN_TCC) $(RUN_TCC) $(RUN_TCC) -run tcctest.c > test.out3
103 @if diff -u test.ref test.out3 ; then echo "Auto Test3 OK"; fi
104
105# binary output test
106test4: test.ref
107 @echo ------------ $@ ------------
108# object + link output
109 $(TCC) -c -o tcctest3.o tcctest.c
110 $(TCC) -o tcctest3 tcctest3.o
111 ./tcctest3 > test3.out
112 @if diff -u test.ref test3.out ; then echo "Object Auto Test OK"; fi
113# dynamic output
114 $(TCC) -o tcctest1 tcctest.c
115 ./tcctest1 > test1.out
116 @if diff -u test.ref test1.out ; then echo "Dynamic Auto Test OK"; fi
117# dynamic output + bound check
118 $(TCC) -b -o tcctest4 tcctest.c
119 ./tcctest4 > test4.out
120 @if diff -u test.ref test4.out ; then echo "BCheck Auto Test OK"; fi
121# static output
122 $(TCC) -static -o tcctest2 tcctest.c
123 ./tcctest2 > test2.out
124 @if diff -u test.ref test2.out ; then echo "Static Auto Test OK"; fi
125
126# memory and bound check auto test
127BOUNDS_OK = 1 4 8 10 14
128BOUNDS_FAIL= 2 5 7 9 11 12 13 15
129
130btest: boundtest.c
131 @echo ------------ $@ ------------
132 @for i in $(BOUNDS_OK); do \
133 echo ; echo --- boundtest $$i ---; \
134 if $(TCC) -b -run boundtest.c $$i ; then \
135 echo succeded as expected; \
136 else\
137 echo Failed positive test $$i ; exit 1 ; \
138 fi ;\
139 done ;\
140 for i in $(BOUNDS_FAIL); do \
141 echo ; echo --- boundtest $$i ---; \
142 if $(TCC) -b -run boundtest.c $$i ; then \
143 echo Failed negative test $$i ; exit 1 ;\
144 else\
145 echo failed as expected; \
146 fi ;\
147 done ;\
148 echo; echo Bound test OK
149
150# speed test
151speedtest: ex2 ex3
152 @echo ------------ $@ ------------
153 time ./ex2 1238 2 3 4 10 13 4
154 time $(TCC) -run $(top_srcdir)/examples/ex2.c 1238 2 3 4 10 13 4
155 time ./ex3 35
156 time $(TCC) -run $(top_srcdir)/examples/ex3.c 35
157
158weaktest: test.ref
159 $(TCC) -c tcctest.c -o weaktest.tcc.o $(CPPFLAGS) $(CFLAGS)
160 $(CC) -c tcctest.c -o weaktest.gcc.o -I. $(CPPFLAGS) -w $(CFLAGS)
161 objdump -t weaktest.tcc.o | grep ' w ' | sed -e 's/.* \([a-zA-Z0-9_]*\)$$/\1/' | LC_ALL=C sort > weaktest.tcc.o.txt
162 objdump -t weaktest.gcc.o | grep ' w ' | sed -e 's/.* \([a-zA-Z0-9_]*\)$$/\1/' | LC_ALL=C sort > weaktest.gcc.o.txt
163 diff weaktest.gcc.o.txt weaktest.tcc.o.txt && echo "Weak Auto Test OK"
164
165ex%: $(top_srcdir)/examples/ex%.c
166 $(CC) -o $@ $< $(CPPFLAGS) $(CFLAGS) $(LDFLAGS)
167
168# tiny assembler testing
169asmtest.ref: asmtest.S
170 $(CC) -Wa,-W -o asmtest.ref.o -c asmtest.S
171 objdump -D asmtest.ref.o > asmtest.ref
172
173asmtest: asmtest.ref
174 @echo ------------ $@ ------------
175 $(TCC) -c asmtest.S
176 objdump -D asmtest.o > asmtest.out
177 @if diff -u --ignore-matching-lines="file format" asmtest.ref asmtest.out ; then echo "ASM Auto Test OK"; fi
178
179# targets for development
180%.bin: %.c tcc
181 $(TCC) -g -o $@ $<
182 $(DISAS) $@
183
184instr: instr.o
185 objdump -d instr.o
186
187instr.o: instr.S
188 $(CC) -o $@ -c $< -O2 -Wall -g
189
190cache: tcc_g
191 cachegrind ./tcc_g -o /tmp/linpack -lm bench/linpack.c
192 vg_annotate tcc.c > /tmp/linpack.cache.log
193
194# clean
195clean:
196 $(MAKE) -C tests2 $@
197 rm -vf *~ *.o *.a *.bin *.i *.ref *.out *.out? *.out?b *.gcc *.exe \
198 hello libtcc_test tcctest[1234] ex? tcc_g tcclib.h
199
Note: See TracBrowser for help on using the repository browser.