diff options
Diffstat (limited to 'tests/Makefile')
-rw-r--r-- | tests/Makefile | 123 |
1 files changed, 66 insertions, 57 deletions
diff --git a/tests/Makefile b/tests/Makefile index e5c3294..6e0f728 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -4,77 +4,84 @@ TOP = .. include $(TOP)/Makefile +VPATH = $(top_srcdir)/tests # what tests to run -TESTS = libtest \ - test1 \ - test2 \ - test3 \ - speedtest \ - btest \ - weaktest - - # test4 # this test does not seem to work on any platform - # asmtest # this test does not seem to work on any platform - -# these should work too -# TESTS += test1 test2 speedtest btest weaktest - -# some tests do not pass on all platforms, remove them for now -ifeq ($(TARGETOS),Linux) - TESTS := $(filter-out btest,$(TESTS)) - TESTS := $(filter-out weaktest,$(TESTS)) +TESTS = \ + hello-exe \ + hello-run \ + libtest \ + test3 \ + moretests + +# test4 -- problem with -static +# asmtest -- minor differences with gcc +# btest -- works on i386 (including win32) +# test3 -- win32 does not know how to printf long doubles + +# bounds-checking is supported only on i386 +ifneq ($(ARCH),i386) + TESTS := $(filter-out btest,$(TESTS)) +endif +ifdef CONFIG_WIN32 + TESTS := $(filter-out test3,$(TESTS)) endif ifeq ($(TARGETOS),Darwin) - TESTS := $(filter-out test1,$(TESTS)) - TESTS := $(filter-out test2,$(TESTS)) - TESTS := $(filter-out test3,$(TESTS)) - TESTS := $(filter-out btest,$(TESTS)) - TESTS := $(filter-out weaktest,$(TESTS)) + TESTS := $(filter-out hello-exe test3 btest,$(TESTS)) endif ifdef DISABLE_STATIC -export LD_LIBRARY_PATH:=$(CURDIR)/.. + export LD_LIBRARY_PATH:=$(CURDIR)/.. endif ifeq ($(TARGETOS),Darwin) -CFLAGS+=-Wl,-flat_namespace,-undefined,warning -export MACOSX_DEPLOYMENT_TARGET:=10.2 -NATIVE_DEFINES+=-D_ANSI_SOURCE + CFLAGS+=-Wl,-flat_namespace,-undefined,warning + export MACOSX_DEPLOYMENT_TARGET:=10.2 + NATIVE_DEFINES+=-D_ANSI_SOURCE endif # run local version of tcc with local libraries and includes -TCC = ../tcc -B.. $(NATIVE_DEFINES) +TCCFLAGS = -B$(TOP) ifdef CONFIG_WIN32 - TCC := $(TCC) -I $(TOP)/win32/include -L$(TOP) + TCCFLAGS = -B$(top_srcdir)/win32 -I$(top_srcdir)/include -L$(TOP) endif -RUN_TCC = $(NATIVE_DEFINES) -run -DONE_SOURCE ../tcc.c -B.. -DISAS=objdump -d -all test : $(TESTS) +TCC = $(TOP)/tcc $(TCCFLAGS) +RUN_TCC = $(NATIVE_DEFINES) -DONE_SOURCE -run $(TOP)/tcc.c $(TCCFLAGS) -# make sure that tcc exists -test1 test2 test3 test4 btest speedtest asmtest weaktest : ../tcc -../%: - $(MAKE) -C .. $* +DISAS = objdump -d # libtcc test ifdef LIBTCC1 -LIBTCC1:=$(TOP)/$(LIBTCC1) + LIBTCC1:=$(TOP)/$(LIBTCC1) endif +all test : $(TESTS) + +hello-exe: ../examples/ex1.c + @echo ------------ $@ ------------ + $(TCC) $< -o hello$(EXESUF) || ($(TOP)/tcc -vv; exit 1) && ./hello$(EXESUF) + +hello-run: ../examples/ex1.c + @echo ------------ $@ ------------ + $(TCC) -run $< + libtest: libtcc_test$(EXESUF) $(LIBTCC1) @echo ------------ $@ ------------ ./libtcc_test$(EXESUF) lib_path=.. -libtcc_test$(EXESUF): libtcc_test.c ../$(LIBTCC) - $(CC) -o $@ $^ -I.. $(CFLAGS) $(NATIVE_DEFINES) $(LIBS) $(LINK_LIBTCC) +libtcc_test$(EXESUF): libtcc_test.c $(top_builddir)/$(LIBTCC) + $(CC) -o $@ $^ $(CPPFLAGS) $(CFLAGS) $(NATIVE_DEFINES) $(LIBS) $(LINK_LIBTCC) $(LDFLAGS) + +moretests: + @echo ------------ $@ ------------ + $(MAKE) -C tests2 # test.ref - generate using gcc # copy only tcclib.h so GCC's stddef and stdarg will be used test.ref: tcctest.c cp ../include/tcclib.h . - $(CC) -o tcctest.gcc $< -I. -w $(CFLAGS) $(NATIVE_DEFINES) -std=gnu99 + gcc -o tcctest.gcc $< -I. $(CPPFLAGS) -w $(CFLAGS) $(NATIVE_DEFINES) -std=gnu99 -O0 -fno-omit-frame-pointer $(LDFLAGS) ./tcctest.gcc > $@ # auto test @@ -98,29 +105,29 @@ test3: test.ref # binary output test test4: test.ref @echo ------------ $@ ------------ -# dynamic output - $(TCC) -o tcctest1 tcctest.c - ./tcctest1 > test1.out - @if diff -u test.ref test1.out ; then echo "Dynamic Auto Test OK"; fi # object + link output $(TCC) -c -o tcctest3.o tcctest.c $(TCC) -o tcctest3 tcctest3.o ./tcctest3 > test3.out @if diff -u test.ref test3.out ; then echo "Object Auto Test OK"; fi -# static output - $(TCC) -static -o tcctest2 tcctest.c - ./tcctest2 > test2.out - @if diff -u test.ref test2.out ; then echo "Static Auto Test OK"; fi +# dynamic output + $(TCC) -o tcctest1 tcctest.c + ./tcctest1 > test1.out + @if diff -u test.ref test1.out ; then echo "Dynamic Auto Test OK"; fi # dynamic output + bound check $(TCC) -b -o tcctest4 tcctest.c ./tcctest4 > test4.out @if diff -u test.ref test4.out ; then echo "BCheck Auto Test OK"; fi +# static output + $(TCC) -static -o tcctest2 tcctest.c + ./tcctest2 > test2.out + @if diff -u test.ref test2.out ; then echo "Static Auto Test OK"; fi # memory and bound check auto test BOUNDS_OK = 1 4 8 10 14 BOUNDS_FAIL= 2 5 7 9 11 12 13 15 -btest: boundtest.c ../bcheck.o +btest: boundtest.c @echo ------------ $@ ------------ @for i in $(BOUNDS_OK); do \ echo ; echo --- boundtest $$i ---; \ @@ -144,19 +151,19 @@ btest: boundtest.c ../bcheck.o speedtest: ex2 ex3 @echo ------------ $@ ------------ time ./ex2 1238 2 3 4 10 13 4 - time $(TCC) -run ../examples/ex2.c 1238 2 3 4 10 13 4 + time $(TCC) -run $(top_srcdir)/examples/ex2.c 1238 2 3 4 10 13 4 time ./ex3 35 - time $(TCC) -run ../examples/ex3.c 35 + time $(TCC) -run $(top_srcdir)/examples/ex3.c 35 weaktest: test.ref - $(TCC) -c tcctest.c -o weaktest.tcc.o - $(CC) -c tcctest.c -o weaktest.gcc.o -I. -w $(CFLAGS) + $(TCC) -c tcctest.c -o weaktest.tcc.o $(CPPFLAGS) $(CFLAGS) + $(CC) -c tcctest.c -o weaktest.gcc.o -I. $(CPPFLAGS) -w $(CFLAGS) objdump -t weaktest.tcc.o | grep ' w ' | sed -e 's/.* \([a-zA-Z0-9_]*\)$$/\1/' | LC_ALL=C sort > weaktest.tcc.o.txt objdump -t weaktest.gcc.o | grep ' w ' | sed -e 's/.* \([a-zA-Z0-9_]*\)$$/\1/' | LC_ALL=C sort > weaktest.gcc.o.txt diff weaktest.gcc.o.txt weaktest.tcc.o.txt && echo "Weak Auto Test OK" -ex%: ../examples/ex%.c - $(CC) -o $@ $< $(CFLAGS) +ex%: $(top_srcdir)/examples/ex%.c + $(CC) -o $@ $< $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) # tiny assembler testing asmtest.ref: asmtest.S @@ -186,5 +193,7 @@ cache: tcc_g # clean clean: - rm -vf *~ *.o *.a *.bin *.i *.ref *.out *.out? *.gcc \ - tcctest[1234] ex? libtcc_test$(EXESUF) tcc_g tcclib.h + $(MAKE) -C tests2 $@ + rm -vf *~ *.o *.a *.bin *.i *.ref *.out *.out? *.out?b *.gcc *.exe \ + hello libtcc_test tcctest[1234] ex? tcc_g tcclib.h + |