aboutsummaryrefslogtreecommitdiff
path: root/tests/Makefile
diff options
context:
space:
mode:
authorjiang <30155751@qq.com>2014-04-29 16:05:16 +0800
committerjiang <30155751@qq.com>2014-04-29 16:05:16 +0800
commit2a8905c93b4f67a21e3dbf297c3e93c598831528 (patch)
tree6f7491150cfe01700c9863946906203adad0de13 /tests/Makefile
parent02e2fe3c260415f4cb1cbcaca9b2403a17f7ff2e (diff)
parente20c1eb99e1003c1e59522c136dbb15c52d7cc7c (diff)
downloadtinycc-2a8905c93b4f67a21e3dbf297c3e93c598831528.tar.gz
tinycc-2a8905c93b4f67a21e3dbf297c3e93c598831528.tar.bz2
So that the generated code, and more short
Diffstat (limited to 'tests/Makefile')
-rw-r--r--tests/Makefile95
1 files changed, 57 insertions, 38 deletions
diff --git a/tests/Makefile b/tests/Makefile
index 08dfa42..e3824ba 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -5,7 +5,7 @@
TOP = ..
include $(TOP)/Makefile
SRCDIR = $(top_srcdir)/tests
-VPATH = $(SRCDIR)
+VPATH = $(SRCDIR) $(top_srcdir)
# what tests to run
TESTS = \
@@ -13,24 +13,30 @@ TESTS = \
hello-run \
libtest \
test3 \
+ $(BTESTS) \
abitest \
vla_test-run \
moretests
+BTESTS = test1b test3b btest
+
+ifdef CONFIG_CROSS
+ TESTS += hello-cross
+endif
+
# 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))
+ TESTS := $(filter-out $(BTESTS),$(TESTS))
endif
ifdef CONFIG_WIN32
- TESTS := $(filter-out test3,$(TESTS))
+ TESTS := w32-prep $(filter-out $(BTESTS),$(TESTS))
endif
ifeq ($(TARGETOS),Darwin)
- TESTS := $(filter-out hello-exe test3 btest,$(TESTS))
+ TESTS := $(filter-out hello-exe test3 $(BTESTS),$(TESTS))
endif
ifeq ($(ARCH),i386)
else ifneq ($(ARCH),x86-64)
@@ -52,6 +58,7 @@ TCCFLAGS = -B$(TOP) -I$(TOP) -I$(top_srcdir) -I$(top_srcdir)/include
ifdef CONFIG_WIN32
TCCFLAGS = -B$(top_srcdir)/win32 -I$(top_srcdir) -I$(top_srcdir)/include -I$(TOP) -L$(TOP)
endif
+XTCCFLAGS = -B$(TOP) -B$(top_srcdir)/win32 -I$(TOP) -I$(top_srcdir) -I$(top_srcdir)/include
TCC = $(TOP)/tcc $(TCCFLAGS)
RUN_TCC = $(NATIVE_DEFINES) -DONE_SOURCE -run $(top_srcdir)/tcc.c $(TCCFLAGS)
@@ -69,6 +76,15 @@ hello-exe: ../examples/ex1.c
@echo ------------ $@ ------------
$(TCC) $< -o hello$(EXESUF) || ($(TOP)/tcc -vv; exit 1) && ./hello$(EXESUF)
+hello-cross: ../examples/ex1.c
+ @echo ------------ $@ ------------
+ for XTCC in $(PROGS_CROSS) ; \
+ do echo -n "Test of $$XTCC... "; \
+ out=$$($(TOP)/$$XTCC $(XTCCFLAGS) -c $< 2>&1); \
+ test $$? -ne 0 && { echo "Failed\n$$out\n" ; $(TOP)/$$XTCC -vv; exit 1; } ; \
+ echo "Success"; \
+ done
+
hello-run: ../examples/ex1.c
@echo ------------ $@ ------------
$(TCC) -run $<
@@ -84,48 +100,52 @@ moretests:
@echo ------------ $@ ------------
$(MAKE) -C tests2
-# test.ref - generate using gcc
-# copy only tcclib.h so GCC's stddef and stdarg will be used
+w32-prep:
+ cp ../libtcc1.a ../lib
+
+# test.ref - generate using cc
test.ref: tcctest.c
- gcc -o tcctest.gcc $< -I$(top_srcdir) $(CPPFLAGS) -w $(CFLAGS) $(NATIVE_DEFINES) -std=gnu99 -O0 -fno-omit-frame-pointer $(LDFLAGS)
- ./tcctest.gcc > $@
+ $(CC) -o tcctest.cc $< -I$(top_srcdir) $(CPPFLAGS) -w $(CFLAGS) $(NATIVE_DEFINES) -std=gnu99 -O0 -fno-omit-frame-pointer $(LDFLAGS)
+ ./tcctest.cc > $@
# auto test
-test1: test.ref
+test1 test1b: tcctest.c test.ref
@echo ------------ $@ ------------
- $(TCC) -run $(SRCDIR)/tcctest.c > test.out1
- @if diff -u test.ref test.out1 ; then echo "Auto Test OK"; fi
+ $(TCC) -run $< > test.out1
+ @diff -u test.ref test.out1 && echo "Auto Test OK"
# iterated test2 (compile tcc then compile tcctest.c !)
-test2: test.ref
+test2 test2b: tcctest.c test.ref
@echo ------------ $@ ------------
- $(TCC) $(RUN_TCC) $(RUN_TCC) -run $(SRCDIR)/tcctest.c > test.out2
- @if diff -u test.ref test.out2 ; then echo "Auto Test2 OK"; fi
+ $(TCC) $(RUN_TCC) $(RUN_TCC) -run $< > test.out2
+ @diff -u test.ref test.out2 && echo "Auto Test2 OK"
# iterated test3 (compile tcc then compile tcc then compile tcctest.c !)
-test3: test.ref
+test3 test3b: tcctest.c test.ref
@echo ------------ $@ ------------
- $(TCC) $(RUN_TCC) $(RUN_TCC) $(RUN_TCC) -run $(SRCDIR)/tcctest.c > test.out3
- @if diff -u test.ref test.out3 ; then echo "Auto Test3 OK"; fi
+ $(TCC) $(RUN_TCC) $(RUN_TCC) $(RUN_TCC) -run $< > test.out3
+ @diff -u test.ref test.out3 && echo "Auto Test3 OK"
+
+test%b : TCCFLAGS += -b
# binary output test
-test4: test.ref
+test4: tcctest.c test.ref
@echo ------------ $@ ------------
# object + link output
- $(TCC) -c -o tcctest3.o $(SRCDIR)/tcctest.c
+ $(TCC) -c -o tcctest3.o $<
$(TCC) -o tcctest3 tcctest3.o
./tcctest3 > test3.out
@if diff -u test.ref test3.out ; then echo "Object Auto Test OK"; fi
# dynamic output
- $(TCC) -o tcctest1 $(SRCDIR)/tcctest.c
+ $(TCC) -o tcctest1 $<
./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 $(SRCDIR)/tcctest.c
+ $(TCC) -b -o tcctest4 $<
./tcctest4 > test4.out
@if diff -u test.ref test4.out ; then echo "BCheck Auto Test OK"; fi
# static output
- $(TCC) -static -o tcctest2 $(SRCDIR)/tcctest.c
+ $(TCC) -static -o tcctest2 $<
./tcctest2 > test2.out
@if diff -u test.ref test2.out ; then echo "Static Auto Test OK"; fi
@@ -137,15 +157,15 @@ btest: boundtest.c
@echo ------------ $@ ------------
@for i in $(BOUNDS_OK); do \
echo ; echo --- boundtest $$i ---; \
- if $(TCC) -b -run boundtest.c $$i ; then \
- echo succeded as expected; \
+ if $(TCC) -b -run $< $$i ; then \
+ echo succeeded as expected; \
else\
echo Failed positive test $$i ; exit 1 ; \
fi ;\
done ;\
for i in $(BOUNDS_FAIL); do \
echo ; echo --- boundtest $$i ---; \
- if $(TCC) -b -run boundtest.c $$i ; then \
+ if $(TCC) -b -run $< $$i ; then \
echo Failed negative test $$i ; exit 1 ;\
else\
echo failed as expected; \
@@ -161,12 +181,12 @@ speedtest: ex2 ex3
time ./ex3 35
time $(TCC) -run $(top_srcdir)/examples/ex3.c 35
-weaktest: test.ref
- $(TCC) -c tcctest.c -o weaktest.tcc.o $(CPPFLAGS) $(CFLAGS)
- $(CC) -c tcctest.c -o weaktest.gcc.o -I. $(CPPFLAGS) -w $(CFLAGS)
+weaktest: tcctest.c test.ref
+ $(TCC) -c $< -o weaktest.tcc.o $(CPPFLAGS) $(CFLAGS)
+ $(CC) -c $< -o weaktest.cc.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"
+ objdump -t weaktest.cc.o | grep ' w ' | sed -e 's/.* \([a-zA-Z0-9_]*\)$$/\1/' | LC_ALL=C sort > weaktest.cc.o.txt
+ diff weaktest.cc.o.txt weaktest.tcc.o.txt && echo "Weak Auto Test OK"
ex%: $(top_srcdir)/examples/ex%.c
$(CC) -o $@ $< $(CPPFLAGS) $(CFLAGS) $(LDFLAGS)
@@ -187,8 +207,8 @@ asmtest: asmtest.ref
abitest-cc$(EXESUF): abitest.c $(top_builddir)/$(LIBTCC)
$(CC) -o $@ $^ $(CPPFLAGS) $(CFLAGS) $(NATIVE_DEFINES) $(LIBS) $(LINK_LIBTCC) $(LDFLAGS) -I$(top_srcdir)
-abitest-tcc$(EXESUF): abitest.c $(top_builddir)/$(LIBTCC)
- $(TCC) -o $@ $^ $(CPPFLAGS) $(CFLAGS) $(NATIVE_DEFINES) $(LIBS) $(LINK_LIBTCC) $(LDFLAGS) -I$(top_srcdir)
+abitest-tcc$(EXESUF): abitest.c libtcc.c
+ $(TCC) -o $@ $^ $(CPPFLAGS) $(CFLAGS) $(NATIVE_DEFINES) -DONE_SOURCE $(LIBS) $(LDFLAGS) -I$(top_srcdir)
abitest: abitest-cc$(EXESUF) abitest-tcc$(EXESUF)
@echo ------------ $@ ------------
@@ -219,8 +239,7 @@ cache: tcc_g
# clean
clean:
$(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
-
-Makefile: $(SRCDIR)/Makefile
- cp $< $@
+ rm -vf *~ *.o *.a *.bin *.i *.ref *.out *.out? *.out?b *.cc \
+ *-cc *-tcc *.exe \
+ hello libtcc_test vla_test tcctest[1234] ex? tcc_g tcclib.h \
+ ../lib/libtcc1.a