Changeset 331 for EcnlProtoTool/trunk/tcc-0.9.27/tests/Makefile
- Timestamp:
- Jan 21, 2018, 12:10:09 AM (6 years ago)
- Location:
- EcnlProtoTool/trunk/tcc-0.9.27
- Files:
-
- 1 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
EcnlProtoTool/trunk/tcc-0.9.27/tests/Makefile
r279 r331 5 5 TOP = .. 6 6 include $(TOP)/Makefile 7 VPATH = $(top_srcdir)/tests 7 VPATH = $(TOPSRC)/tests $(TOPSRC) $(TOP) 8 CFLAGS := $(filter-out -W% -g% -O%,$(CFLAGS)) -I$(TOPSRC) $(LDFLAGS) 8 9 9 10 # what tests to run … … 13 14 libtest \ 14 15 test3 \ 15 moretests 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 25 BTESTS = test1b test3b btest 16 26 17 27 # test4 -- problem with -static 18 # asmtest -- minor differences with gcc28 # asmtest / asmtest2 -- minor differences with gcc 19 29 # btest -- works on i386 (including win32) 20 # test3 -- win32 does not know how to printf long doubles21 30 22 31 # bounds-checking is supported only on i386 23 32 ifneq ($(ARCH),i386) 24 TESTS := $(filter-out btest,$(TESTS))33 TESTS := $(filter-out $(BTESTS),$(TESTS)) 25 34 endif 26 35 ifdef CONFIG_WIN32 36 TESTS := $(filter-out $(BTESTS),$(TESTS)) 37 endif 38 ifdef CONFIG_OSX # -run only 39 TESTS := hello-run libtest tests2-dir pp-dir 40 endif 41 ifeq (,$(filter arm64 i386 x86_64,$(ARCH))) 42 TESTS := $(filter-out vla_test-run,$(TESTS)) 43 endif 44 ifeq ($(CONFIG_arm_eabi),yes) 27 45 TESTS := $(filter-out test3,$(TESTS)) 28 46 endif 29 ifeq ($(TARGETOS),Darwin) 30 TESTS := $(filter-out hello-exe test3 btest,$(TESTS)) 31 endif 32 33 ifdef DISABLE_STATIC 34 export LD_LIBRARY_PATH:=$(CURDIR)/.. 35 endif 36 37 ifeq ($(TARGETOS),Darwin) 38 CFLAGS+=-Wl,-flat_namespace,-undefined,warning 39 export MACOSX_DEPLOYMENT_TARGET:=10.2 40 NATIVE_DEFINES+=-D_ANSI_SOURCE 41 endif 42 43 # run local version of tcc with local libraries and includes 44 TCCFLAGS = -B$(TOP) 45 ifdef CONFIG_WIN32 46 TCCFLAGS = -B$(top_srcdir)/win32 -I$(top_srcdir)/include -L$(TOP) 47 endif 48 49 TCC = $(TOP)/tcc $(TCCFLAGS) 50 RUN_TCC = $(NATIVE_DEFINES) -DONE_SOURCE -run $(TOP)/tcc.c $(TCCFLAGS) 51 47 ifeq (,$(filter i386 x86_64,$(ARCH))) 48 TESTS := $(filter-out dlltest asm-c-connect-test,$(TESTS)) 49 endif 50 ifndef CONFIG_cross 51 TESTS := $(filter-out cross-%,$(TESTS)) 52 endif 53 54 ifeq ($(OS),Windows_NT) # for libtcc_test to find libtcc.dll 55 PATH := $(CURDIR)/$(TOP)$(if $(findstring :\,$(PATH)),;,:)$(PATH) 56 endif 57 58 RUN_TCC = $(NATIVE_DEFINES) -run $(TOPSRC)/tcc.c $(TCCFLAGS) 52 59 DISAS = objdump -d 53 54 # libtcc test 55 ifdef LIBTCC1 56 LIBTCC1:=$(TOP)/$(LIBTCC1) 57 endif 58 59 all test : $(TESTS) 60 DUMPTCC = (set -x; $(TOP)/tcc -vv; ldd $(TOP)/tcc; exit 1) 61 62 all test : clean-s $(TESTS) 60 63 61 64 hello-exe: ../examples/ex1.c 62 65 @echo ------------ $@ ------------ 63 $(TCC) $< -o hello$(EXESUF) || ($(TOP)/tcc -vv; exit 1) && ./hello$(EXESUF)66 $(TCC) $< -o hello$(EXESUF) && ./hello$(EXESUF) || $(DUMPTCC) 64 67 65 68 hello-run: ../examples/ex1.c 66 69 @echo ------------ $@ ------------ 67 $(TCC) -run $< 68 69 libtest: libtcc_test$(EXESUF) $(LIBTCC1) 70 @echo ------------ $@ ------------ 71 ./libtcc_test$(EXESUF) lib_path=.. 72 73 libtcc_test$(EXESUF): libtcc_test.c $(top_builddir)/$(LIBTCC) 74 $(CC) -o $@ $^ $(CPPFLAGS) $(CFLAGS) $(NATIVE_DEFINES) $(LIBS) $(LINK_LIBTCC) $(LDFLAGS) 75 76 moretests: 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 70 $(TCC) -run $< || $(DUMPTCC) 71 72 libtest: libtcc_test$(EXESUF) 73 @echo ------------ $@ ------------ 74 ./libtcc_test$(EXESUF) $(TCCFLAGS) 75 76 libtcc_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 82 84 test.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 $(CC) -o tcctest.gcc $< $(NATIVE_DEFINES) $(CFLAGS) -w -O0 -std=gnu99 -fno-omit-frame-pointer 85 86 ./tcctest.gcc > $@ 86 87 87 88 # auto test 88 test1 :test.ref89 @echo ------------ $@ ------------ 90 $(TCC) -run tcctest.c> test.out191 @ if diff -u test.ref test.out1 ; then echo "Auto Test OK"; fi89 test1 test1b: tcctest.c test.ref 90 @echo ------------ $@ ------------ 91 $(TCC) -run $< > test.out1 92 @diff -u test.ref test.out1 && echo "Auto Test OK" 92 93 93 94 # iterated test2 (compile tcc then compile tcctest.c !) 94 test2 :test.ref95 @echo ------------ $@ ------------ 96 $(TCC) $(RUN_TCC) $(RUN_TCC) -run tcctest.c> test.out297 @ if diff -u test.ref test.out2 ; then echo "Auto Test2 OK"; fi95 test2 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" 98 99 99 100 # iterated test3 (compile tcc then compile tcc then compile tcctest.c !) 100 test3: 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 101 test3 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 106 test%b : TCCFLAGS += -b 104 107 105 108 # binary output test 106 test4: t est.ref109 test4: tcctest.c test.ref 107 110 @echo ------------ $@ ------------ 108 111 # object + link output 109 $(TCC) -c -o tcctest3.o tcctest.c112 $(TCC) -c -o tcctest3.o $< 110 113 $(TCC) -o tcctest3 tcctest3.o 111 114 ./tcctest3 > test3.out 112 115 @if diff -u test.ref test3.out ; then echo "Object Auto Test OK"; fi 113 116 # dynamic output 114 $(TCC) -o tcctest1 tcctest.c117 $(TCC) -o tcctest1 $< 115 118 ./tcctest1 > test1.out 116 119 @if diff -u test.ref test1.out ; then echo "Dynamic Auto Test OK"; fi 117 120 # dynamic output + bound check 118 $(TCC) -b -o tcctest4 tcctest.c121 $(TCC) -b -o tcctest4 $< 119 122 ./tcctest4 > test4.out 120 123 @if diff -u test.ref test4.out ; then echo "BCheck Auto Test OK"; fi 121 124 # static output 122 $(TCC) -static -o tcctest2 tcctest.c125 $(TCC) -static -o tcctest2 $< 123 126 ./tcctest2 > test2.out 124 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 130 dlltest: 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 135 ifndef 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 141 endif 142 @rm tcc2$(EXESUF) libtcc2$(DLLSUF) 143 144 memtest: 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 125 150 126 151 # memory and bound check auto test … … 132 157 @for i in $(BOUNDS_OK); do \ 133 158 echo ; echo --- boundtest $$i ---; \ 134 if $(TCC) -b -run boundtest.c$$i ; then \135 echo succe ded as expected; \159 if $(TCC) -b -run $< $$i ; then \ 160 echo succeeded as expected; \ 136 161 else\ 137 162 echo Failed positive test $$i ; exit 1 ; \ … … 140 165 for i in $(BOUNDS_FAIL); do \ 141 166 echo ; echo --- boundtest $$i ---; \ 142 if $(TCC) -b -run boundtest.c$$i ; then \167 if $(TCC) -b -run $< $$i ; then \ 143 168 echo Failed negative test $$i ; exit 1 ;\ 144 169 else\ … … 152 177 @echo ------------ $@ ------------ 153 178 time ./ex2 1238 2 3 4 10 13 4 154 time $(TCC) -run $( top_srcdir)/examples/ex2.c 1238 2 3 4 10 13 4179 time $(TCC) -run $(TOPSRC)/examples/ex2.c 1238 2 3 4 10 13 4 155 180 time ./ex3 35 156 time $(TCC) -run $( top_srcdir)/examples/ex3.c 35157 158 weaktest: t est.ref159 $(TCC) -c tcctest.c -o weaktest.tcc.o $(CPPFLAGS) $(CFLAGS)160 $(CC) -c tcctest.c -o weaktest.gcc.o -I. $(CPPFLAGS) -w $(CFLAGS)181 time $(TCC) -run $(TOPSRC)/examples/ex3.c 35 182 183 weaktest: 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 161 186 objdump -t weaktest.tcc.o | grep ' w ' | sed -e 's/.* \([a-zA-Z0-9_]*\)$$/\1/' | LC_ALL=C sort > weaktest.tcc.o.txt 162 187 objdump -t weaktest.gcc.o | grep ' w ' | sed -e 's/.* \([a-zA-Z0-9_]*\)$$/\1/' | LC_ALL=C sort > weaktest.gcc.o.txt 163 188 diff weaktest.gcc.o.txt weaktest.tcc.o.txt && echo "Weak Auto Test OK" 164 189 165 ex%: $( top_srcdir)/examples/ex%.c166 $(CC) -o $@ $< $(C PPFLAGS) $(CFLAGS) $(LDFLAGS)190 ex%: $(TOPSRC)/examples/ex%.c 191 $(CC) -o $@ $< $(CFLAGS) 167 192 168 193 # tiny assembler testing … … 171 196 objdump -D asmtest.ref.o > asmtest.ref 172 197 173 asmtest : asmtest.ref174 @echo ------------ $@ ------------ 175 $(TCC) -c asmtest.S198 asmtest asmtest2: asmtest.ref 199 @echo ------------ $@ ------------ 200 $(TCC) $(MAYBE_RUN_TCC) -c asmtest.S 176 201 objdump -D asmtest.o > asmtest.out 177 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 205 asmtest2: MAYBE_RUN_TCC = $(RUN_TCC) 206 207 # Check that code generated by libtcc is binary compatible with 208 # that generated by CC 209 abitest-cc$(EXESUF): abitest.c $(LIBTCC) 210 $(CC) -o $@ $^ $(CFLAGS) $(LIBS) -w 211 212 abitest-tcc$(EXESUF): abitest.c libtcc.c 213 $(TCC) -o $@ $^ $(NATIVE_DEFINES) $(LIBS) 214 215 ABITESTS := abitest-cc$(EXESUF) 216 ifneq ($(CONFIG_arm_eabi),yes) # not ARM soft-float 217 ABITESTS += abitest-tcc$(EXESUF) 218 endif 219 220 abitest: $(ABITESTS) 221 @echo ------------ $@ ------------ 222 ./abitest-cc$(EXESUF) $(TCCFLAGS) 223 ifneq ($(CONFIG_arm_eabi),yes) # not ARM soft-float 224 ./abitest-tcc$(EXESUF) $(TCCFLAGS) 225 endif 226 227 vla_test$(EXESUF): vla_test.c 228 $(TCC) -o $@ $^ 229 230 vla_test-run: vla_test$(EXESUF) 231 @echo ------------ $@ ------------ 232 ./vla_test$(EXESUF) 233 234 asm-c-connect$(EXESUF): asm-c-connect-1.c asm-c-connect-2.c 235 $(TCC) -o $@ $^ 236 237 asm-c-connect-%.o: asm-c-connect-%.c 238 $(TCC) -c -o $@ $< 239 240 asm-c-connect-sep$(EXESUF): asm-c-connect-1.o asm-c-connect-2.o 241 $(TCC) -o $@ $^ 242 243 asm-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 249 cross-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" 178 262 179 263 # targets for development … … 194 278 # clean 195 279 clean: 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 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 288 clean-s: 289 @$(MAKE) -s --no-print-directory clean
Note:
See TracChangeset
for help on using the changeset viewer.