2 # Tiny C Compiler Makefile - tests
8 # these should work too
9 # TESTS += test1 test2 speedtest btest
11 # these don't work as they should
12 # TESTS += test4 asmtest
15 include $(TOP
)/Makefile
18 export LD_LIBRARY_PATH
:=$(CURDIR
)/..
21 # run local version of tcc with local libraries and includes
23 RUN_TCC
= $(NATIVE_DEFINES
) -run ..
/tcc.c
-B..
28 # make sure that tcc exists
29 test1 test2 test3 test4 btest speedtest asmtest
: ..
/tcc
34 libtest
: libtcc_test
$(EXESUF
) ..
/libtcc1.a
35 @echo
------------ $@
------------
36 .
/libtcc_test
$(EXESUF
) lib_path
=..
38 libtcc_test
$(EXESUF
): libtcc_test.c ..
/$(LIBTCC
)
39 $(CC
) -o
$@
$^
-I..
$(CFLAGS
) $(LIBS
) $(LINK_LIBTCC
)
41 # test.ref - generate using gcc
43 $(CC
) -o tcctest.gcc
$< -w
$(CFLAGS
) -I..
/include
48 @echo
------------ $@
------------
49 $(TCC
) -run tcctest.c
> test.out1
50 @if diff
-u
test.ref
test.out1
; then echo
"Auto Test OK"; fi
52 # iterated test2 (compile tcc then compile tcctest.c !)
54 @echo
------------ $@
------------
55 $(TCC
) $(RUN_TCC
) $(RUN_TCC
) -run tcctest.c
> test.out2
56 @if diff
-u
test.ref
test.out2
; then echo
"Auto Test2 OK"; fi
58 # iterated test3 (compile tcc then compile tcc then compile tcctest.c !)
60 @echo
------------ $@
------------
61 $(TCC
) $(RUN_TCC
) $(RUN_TCC
) $(RUN_TCC
) -run tcctest.c
> test.out3
62 @if diff
-u
test.ref
test.out3
; then echo
"Auto Test3 OK"; fi
66 @echo
------------ $@
------------
68 $(TCC
) -o tcctest1 tcctest.c
69 .
/tcctest1
> test1.out
70 @if diff
-u
test.ref test1.out
; then echo
"Dynamic Auto Test OK"; fi
71 # object + link output
72 $(TCC
) -c
-o tcctest3.o tcctest.c
73 $(TCC
) -o tcctest3 tcctest3.o
74 .
/tcctest3
> test3.out
75 @if diff
-u
test.ref test3.out
; then echo
"Object Auto Test OK"; fi
77 $(TCC
) -static
-o tcctest2 tcctest.c
78 .
/tcctest2
> test2.out
79 @if diff
-u
test.ref test2.out
; then echo
"Static Auto Test OK"; fi
80 # dynamic output + bound check
81 $(TCC
) -b
-o tcctest4 tcctest.c
82 .
/tcctest4
> test4.out
83 @if diff
-u
test.ref test4.out
; then echo
"BCheck Auto Test OK"; fi
85 # memory and bound check auto test
86 BOUNDS_OK
= 1 4 8 10 14
87 BOUNDS_FAIL
= 2 5 7 9 11 12 13 15
89 btest
: boundtest.c ..
/bcheck.o
90 @echo
------------ $@
------------
91 @for i in
$(BOUNDS_OK
); do \
92 echo
; echo
--- boundtest
$$i ---; \
93 if
$(TCC
) -b
-run boundtest.c
$$i ; then \
94 echo succeded
as expected
; \
96 echo Failed positive
test $$i ; exit
1 ; \
99 for i in
$(BOUNDS_FAIL
); do \
100 echo
; echo
--- boundtest
$$i ---; \
101 if
$(TCC
) -b
-run boundtest.c
$$i ; then \
102 echo Failed negative
test $$i ; exit
1 ;\
104 echo failed
as expected
; \
107 echo
; echo Bound
test OK
111 @echo
------------ $@
------------
112 time .
/ex2
1238 2 3 4 10 13 4
113 time
$(TCC
) -run ..
/examples
/ex2.c
1238 2 3 4 10 13 4
115 time
$(TCC
) -run ..
/examples
/ex3.c
35
117 ex
%: ..
/examples
/ex
%.c
118 $(CC
) -o
$@
$< $(CFLAGS
)
120 # tiny assembler testing
121 asmtest.ref
: asmtest.S
122 $(CC
) -Wa
,-W
-o asmtest.ref.o
-c asmtest.S
123 objdump
-D asmtest.ref.o
> asmtest.ref
126 @echo
------------ $@
------------
128 objdump
-D asmtest.o
> asmtest.out
129 @if diff
-u
--ignore-matching-lines
="file format" asmtest.ref asmtest.out
; then echo
"ASM Auto Test OK"; fi
131 # targets for development
140 $(CC
) -o
$@
-c
$< -O2
-Wall
-g
143 cachegrind .
/tcc_g
-o
/tmp
/linpack
-lm bench
/linpack.c
144 vg_annotate tcc.c
> /tmp
/linpack.cache.log
148 rm -vf
*~
*.o
*.a
*.bin
*.i
*.ref
*.out
*.out?
*.gcc \
149 tcctest
[1234] ex? libtcc_test
$(EXESUF
) tcc_g tcclib.h