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
17 # run local version of tcc with local libraries and includes
19 RUN_TCC
= $(NATIVE_TARGET
) -run ..
/tcc.c
-B..
24 # make sure that tcc exists
31 libtest
: libtcc_test
$(EXESUF
)
32 @echo
------------ $@
------------
33 .
/libtcc_test lib_path
=..
35 libtcc_test
$(EXESUF
): libtcc_test.c ..
/libtcc.a
36 $(CC
) -o
$@
$^
-I..
$(CFLAGS
) $(LIBS
)
38 # test.ref - generate using gcc
40 cp
-u ..
/include/tcclib.h .
41 $(CC
) -o tcctest.gcc
$< -I.
-w
$(CFLAGS
)
46 @echo
------------ $@
------------
47 $(TCC
) -run tcctest.c
> test.out1
48 @if diff
-u
test.ref
test.out1
; then echo
"Auto Test OK"; fi
50 # iterated test2 (compile tcc then compile tcctest.c !)
52 @echo
------------ $@
------------
53 $(TCC
) $(RUN_TCC
) $(RUN_TCC
) -run tcctest.c
> test.out2
54 @if diff
-u
test.ref
test.out2
; then echo
"Auto Test2 OK"; fi
56 # iterated test3 (compile tcc then compile tcc then compile tcctest.c !)
58 @echo
------------ $@
------------
59 $(TCC
) $(RUN_TCC
) $(RUN_TCC
) $(RUN_TCC
) -run tcctest.c
> test.out3
60 @if diff
-u
test.ref
test.out3
; then echo
"Auto Test3 OK"; fi
64 @echo
------------ $@
------------
66 $(TCC
) -o tcctest1 tcctest.c
67 .
/tcctest1
> test1.out
68 @if diff
-u
test.ref test1.out
; then echo
"Dynamic Auto Test OK"; fi
69 # object + link output
70 $(TCC
) -c
-o tcctest3.o tcctest.c
71 $(TCC
) -o tcctest3 tcctest3.o
72 .
/tcctest3
> test3.out
73 @if diff
-u
test.ref test3.out
; then echo
"Object Auto Test OK"; fi
75 $(TCC
) -static
-o tcctest2 tcctest.c
76 .
/tcctest2
> test2.out
77 @if diff
-u
test.ref test2.out
; then echo
"Static Auto Test OK"; fi
78 # dynamic output + bound check
79 $(TCC
) -b
-o tcctest4 tcctest.c
80 .
/tcctest4
> test4.out
81 @if diff
-u
test.ref test4.out
; then echo
"BCheck Auto Test OK"; fi
83 # memory and bound check auto test
84 BOUNDS_OK
= 1 4 8 10 14
85 BOUNDS_FAIL
= 2 5 7 9 11 12 13 15
88 @echo
------------ $@
------------
89 @for i in
$(BOUNDS_OK
); do \
90 echo
; echo
--- boundtest
$$i ---; \
91 if
$(TCC
) -b
-run boundtest.c
$$i ; then \
92 echo succeded
as expected
; \
94 echo Failed positive
test $$i ; exit
1 ; \
97 for i in
$(BOUNDS_FAIL
); do \
98 echo
; echo
--- boundtest
$$i ---; \
99 if
$(TCC
) -b
-run boundtest.c
$$i ; then \
100 echo Failed negative
test $$i ; exit
1 ;\
102 echo failed
as expected
; \
105 echo
; echo Bound
test OK
109 @echo
------------ $@
------------
110 time .
/ex2
1238 2 3 4 10 13 4
111 time
$(TCC
) -run ..
/examples
/ex2.c
1238 2 3 4 10 13 4
113 time
$(TCC
) -run ..
/examples
/ex3.c
35
115 ex
%: ..
/examples
/ex
%.c
116 $(CC
) -o
$@
$< $(CFLAGS
)
118 # tiny assembler testing
119 asmtest.ref
: asmtest.S
120 $(CC
) -Wa
,-W
-o asmtest.ref.o
-c asmtest.S
121 objdump
-D asmtest.ref.o
> asmtest.ref
124 @echo
------------ $@
------------
126 objdump
-D asmtest.o
> asmtest.out
127 @if diff
-u
--ignore-matching-lines
="file format" asmtest.ref asmtest.out
; then echo
"ASM Auto Test OK"; fi
129 # targets for development
138 $(CC
) -o
$@
-c
$< -O2
-Wall
-g
141 cachegrind .
/tcc_g
-o
/tmp
/linpack
-lm bench
/linpack.c
142 vg_annotate tcc.c
> /tmp
/linpack.cache.log
146 rm -vf
*~
*.o
*.a
*.bin
*.i
*.ref
*.out
*.out?
*.gcc \
147 tcctest
[1234] ex? libtcc_test
$(EXESUF
) tcc_g tcclib.h