tests: - add "hello" to test first basic compilation to file/memory - add "more" test (tests2 suite) - remove some tests tests2: - move into tests dir - Convert some files from DOS to unix LF - remove 2>&1 redirection win32: - tccrun.c: modify exception filter to exit correctly (needed for btest) - tcctest.c: exclude weak_test() (feature does not exist on win32)
Unified · Split
| @@ -350,12 +350,10 @@ tcc-doc.info: tcc-doc.texi · 349 unmodified lines | ||
| 350 | 350 | export LIBTCC1 |
| 351 | 351 | |
| 352 | 352 | %est: |
| 353 | − $(MAKE) -C tests2 $@ | |
| 354 | 353 | $(MAKE) -C tests $@ |
| 355 | 354 | |
| 356 | 355 | clean: |
| 357 | 356 | rm -vf $(PROGS) tcc_p$(EXESUF) tcc.pod *~ *.o *.a *.so* *.out *.exe libtcc_test$(EXESUF) |
| 358 | − $(MAKE) -C tests2 $@ | |
| 359 | 357 | $(MAKE) -C tests $@ |
| 360 | 358 | ifneq ($(LIBTCC1),) |
| 361 | 359 | $(MAKE) -C lib $@ |
| @@ -500,7 +500,7 @@ echo "SRC_PATH=$source_path" >>config.mak · 499 unmodified lines | ||
| 500 | 500 | |
| 501 | 501 | # build tree in object directory if source path is different from current one |
| 502 | 502 | if test "$source_path_used" = "yes" ; then |
| 503 | − FILES="Makefile lib/Makefile tests/Makefile tests2/Makefile" | |
| 503 | + FILES="Makefile lib/Makefile tests/Makefile tests/tests2/Makefile" | |
| 504 | 504 | for f in $FILES ; do |
| 505 | 505 | dir=`fn_dirname "$f"` |
| 506 | 506 | test -d "$dir" || mkdir -p "$dir" |
| @@ -615,8 +615,7 @@ static long __stdcall cpu_exception_handler(EXCEPTION_POINTERS *ex_info) · 614 unmodified lines | ||
| 615 | 615 | rt_error(uc, "exception caught"); |
| 616 | 616 | break; |
| 617 | 617 | } |
| 618 | − exit(-1); | |
| 619 | − return EXCEPTION_CONTINUE_SEARCH; | |
| 618 | + return EXCEPTION_EXECUTE_HANDLER; | |
| 620 | 619 | } |
| 621 | 620 | |
| 622 | 621 | /* Generate a stack backtrace when a CPU exception occurs. */ |
| @@ -7,73 +7,61 @@ include $(TOP)/Makefile · 6 unmodified lines | ||
| 7 | 7 | VPATH = $(top_srcdir)/tests |
| 8 | 8 | |
| 9 | 9 | # what tests to run |
| 10 | −TESTS = libtest \ | |
| 11 | − test1 \ | |
| 12 | − test2 \ | |
| 13 | − test3 \ | |
| 14 | − speedtest \ | |
| 15 | − btest \ | |
| 16 | − test1b\ | |
| 17 | − test2b\ | |
| 18 | − test3b\ | |
| 19 | − weaktest | |
| 20 | − | |
| 21 | − # test4 # this test does not seem to work on any platform | |
| 22 | − # asmtest # this test does not seem to work on any platform | |
| 10 | +TESTS = \ | |
| 11 | + hello \ | |
| 12 | + libtest \ | |
| 13 | + test3 \ | |
| 14 | + moretests | |
| 15 | + | |
| 16 | +# test4 -- problem with -static | |
| 17 | +# asmtest -- minor differences with gcc | |
| 18 | +# btest -- works on i386 (including win32) | |
| 19 | +# test3 -- win32 does not know how to printf long doubles | |
| 23 | 20 | |
| 24 | 21 | # bounds-checking is supported only on i386 |
| 25 | 22 | ifneq ($(ARCH),i386) |
| 26 | − TESTS := $(filter-out btest,$(TESTS)) | |
| 27 | − TESTS := $(filter-out test1b,$(TESTS)) | |
| 28 | − TESTS := $(filter-out test2b,$(TESTS)) | |
| 29 | − TESTS := $(filter-out test3b,$(TESTS)) | |
| 23 | + TESTS := $(filter-out btest,$(TESTS)) | |
| 30 | 24 | endif |
| 31 | − | |
| 32 | −# these should work too | |
| 33 | −# TESTS += test1 test2 speedtest btest weaktest | |
| 34 | − | |
| 35 | −# some tests do not pass on all platforms, remove them for now | |
| 36 | −ifeq ($(TARGETOS),Linux) | |
| 37 | − TESTS := $(filter-out weaktest,$(TESTS)) | |
| 25 | +ifdef CONFIG_WIN32 | |
| 26 | + TESTS := $(filter-out test3,$(TESTS)) | |
| 38 | 27 | endif |
| 39 | 28 | ifeq ($(TARGETOS),Darwin) |
| 40 | − TESTS := $(filter-out test1,$(TESTS)) | |
| 41 | − TESTS := $(filter-out test2,$(TESTS)) | |
| 42 | − TESTS := $(filter-out test3,$(TESTS)) | |
| 43 | − TESTS := $(filter-out btest,$(TESTS)) | |
| 44 | − TESTS := $(filter-out weaktest,$(TESTS)) | |
| 29 | + TESTS := $(filter-out test3 btest,$(TESTS)) | |
| 45 | 30 | endif |
| 46 | 31 | |
| 47 | 32 | ifdef DISABLE_STATIC |
| 48 | −export LD_LIBRARY_PATH:=$(CURDIR)/.. | |
| 33 | + export LD_LIBRARY_PATH:=$(CURDIR)/.. | |
| 49 | 34 | endif |
| 50 | 35 | |
| 51 | 36 | ifeq ($(TARGETOS),Darwin) |
| 52 | −CFLAGS+=-Wl,-flat_namespace,-undefined,warning | |
| 53 | −export MACOSX_DEPLOYMENT_TARGET:=10.2 | |
| 54 | −NATIVE_DEFINES+=-D_ANSI_SOURCE | |
| 37 | + CFLAGS+=-Wl,-flat_namespace,-undefined,warning | |
| 38 | + export MACOSX_DEPLOYMENT_TARGET:=10.2 | |
| 39 | + NATIVE_DEFINES+=-D_ANSI_SOURCE | |
| 55 | 40 | endif |
| 56 | 41 | |
| 57 | 42 | # run local version of tcc with local libraries and includes |
| 58 | −TCC = ../tcc -B.. $(NATIVE_DEFINES) | |
| 43 | +TCCFLAGS = -B$(TOP) | |
| 59 | 44 | ifdef CONFIG_WIN32 |
| 60 | − TCC := $(TCC) -I $(top_srcdir)/win32/include -L$(top_build) | |
| 45 | + TCCFLAGS = -B$(top_srcdir)/win32 -I$(top_srcdir)/include -L$(TOP) | |
| 61 | 46 | endif |
| 62 | −RUN_TCC = $(NATIVE_DEFINES) -run -DONE_SOURCE ../tcc.c -B.. | |
| 63 | −DISAS=objdump -d | |
| 64 | 47 | |
| 65 | −all test : $(TESTS) | |
| 48 | +TCC = $(TOP)/tcc $(TCCFLAGS) | |
| 49 | +RUN_TCC = $(NATIVE_DEFINES) -DONE_SOURCE -run $(TOP)/tcc.c $(TCCFLAGS) | |
| 66 | 50 | |
| 67 | −# make sure that tcc exists | |
| 68 | −test1 test2 test3 test4 btest speedtest asmtest weaktest : ../tcc | |
| 69 | −../%: | |
| 70 | − $(MAKE) -C .. $* | |
| 51 | +DISAS = objdump -d | |
| 71 | 52 | |
| 72 | 53 | # libtcc test |
| 73 | 54 | ifdef LIBTCC1 |
| 74 | −LIBTCC1:=$(TOP)/$(LIBTCC1) | |
| 55 | + LIBTCC1:=$(TOP)/$(LIBTCC1) | |
| 75 | 56 | endif |
| 76 | 57 | |
| 58 | +all test : $(TESTS) | |
| 59 | + | |
| 60 | +hello: ../examples/ex1.c | |
| 61 | + @echo ------------ $@ ------------ | |
| 62 | + $(TCC) $< -o $@$(EXESUF) && ./$@$(EXESUF) | |
| 63 | + $(TCC) -run $< | |
| 64 | + | |
| 77 | 65 | libtest: libtcc_test$(EXESUF) $(LIBTCC1) |
| 78 | 66 | @echo ------------ $@ ------------ |
| 79 | 67 | ./libtcc_test$(EXESUF) lib_path=.. |
| @@ -81,6 +69,10 @@ libtest: libtcc_test$(EXESUF) $(LIBTCC1) · 1 unmodified line | ||
| 81 | 69 | libtcc_test$(EXESUF): libtcc_test.c $(top_builddir)/$(LIBTCC) |
| 82 | 70 | $(CC) -o $@ $^ $(CPPFLAGS) $(CFLAGS) $(NATIVE_DEFINES) $(LIBS) $(LINK_LIBTCC) $(LDFLAGS) |
| 83 | 71 | |
| 72 | +moretests: | |
| 73 | + @echo ------------ $@ ------------ | |
| 74 | + $(MAKE) -C tests2 | |
| 75 | + | |
| 84 | 76 | # test.ref - generate using gcc |
| 85 | 77 | # copy only tcclib.h so GCC's stddef and stdarg will be used |
| 86 | 78 | test.ref: tcctest.c |
| @@ -94,59 +86,44 @@ test1: test.ref · 7 unmodified lines | ||
| 94 | 86 | $(TCC) -run tcctest.c > test.out1 |
| 95 | 87 | @if diff -u test.ref test.out1 ; then echo "Auto Test OK"; fi |
| 96 | 88 | |
| 97 | −test1b: test.ref | |
| 98 | − @echo ------------ $@ ------------ | |
| 99 | − $(TCC) -b -run tcctest.c > test.out1b | |
| 100 | − @if diff -u test.ref test.out1b ; then echo "Auto Test OK"; fi | |
| 101 | − | |
| 102 | 89 | # iterated test2 (compile tcc then compile tcctest.c !) |
| 103 | 90 | test2: test.ref |
| 104 | 91 | @echo ------------ $@ ------------ |
| 105 | 92 | $(TCC) $(RUN_TCC) $(RUN_TCC) -run tcctest.c > test.out2 |
| 106 | 93 | @if diff -u test.ref test.out2 ; then echo "Auto Test2 OK"; fi |
| 107 | 94 | |
| 108 | −test2b: test.ref ../bcheck.o | |
| 109 | − @echo ------------ $@ ------------ | |
| 110 | − $(TCC) -b $(RUN_TCC) $(RUN_TCC) -run tcctest.c > test.out2b | |
| 111 | − @if diff -u test.ref test.out2b ; then echo "Auto Test2b OK"; fi | |
| 112 | − | |
| 113 | 95 | # iterated test3 (compile tcc then compile tcc then compile tcctest.c !) |
| 114 | 96 | test3: test.ref |
| 115 | 97 | @echo ------------ $@ ------------ |
| 116 | 98 | $(TCC) $(RUN_TCC) $(RUN_TCC) $(RUN_TCC) -run tcctest.c > test.out3 |
| 117 | 99 | @if diff -u test.ref test.out3 ; then echo "Auto Test3 OK"; fi |
| 118 | 100 | |
| 119 | −test3b: test.ref | |
| 120 | − @echo ------------ $@ ------------ | |
| 121 | − $(TCC) -b $(RUN_TCC) $(RUN_TCC) $(RUN_TCC) -run tcctest.c > test.out3b | |
| 122 | − @if diff -u test.ref test.out3b ; then echo "Auto Test3 OK"; fi | |
| 123 | − | |
| 124 | 101 | # binary output test |
| 125 | 102 | test4: test.ref |
| 126 | 103 | @echo ------------ $@ ------------ |
| 127 | −# dynamic output | |
| 128 | − $(TCC) -o tcctest1 tcctest.c | |
| 129 | − ./tcctest1 > test1.out | |
| 130 | − @if diff -u test.ref test1.out ; then echo "Dynamic Auto Test OK"; fi | |
| 131 | 104 | # object + link output |
| 132 | 105 | $(TCC) -c -o tcctest3.o tcctest.c |
| 133 | 106 | $(TCC) -o tcctest3 tcctest3.o |
| 134 | 107 | ./tcctest3 > test3.out |
| 135 | 108 | @if diff -u test.ref test3.out ; then echo "Object Auto Test OK"; fi |
| 136 | −# static output | |
| 137 | − $(TCC) -static -o tcctest2 tcctest.c | |
| 138 | − ./tcctest2 > test2.out | |
| 139 | − @if diff -u test.ref test2.out ; then echo "Static Auto Test OK"; fi | |
| 109 | +# dynamic output | |
| 110 | + $(TCC) -o tcctest1 tcctest.c | |
| 111 | + ./tcctest1 > test1.out | |
| 112 | + @if diff -u test.ref test1.out ; then echo "Dynamic Auto Test OK"; fi | |
| 140 | 113 | # dynamic output + bound check |
| 141 | 114 | $(TCC) -b -o tcctest4 tcctest.c |
| 142 | 115 | ./tcctest4 > test4.out |
| 143 | 116 | @if diff -u test.ref test4.out ; then echo "BCheck Auto Test OK"; fi |
| 117 | +# static output | |
| 118 | + $(TCC) -static -o tcctest2 tcctest.c | |
| 119 | + ./tcctest2 > test2.out | |
| 120 | + @if diff -u test.ref test2.out ; then echo "Static Auto Test OK"; fi | |
| 144 | 121 | |
| 145 | 122 | # memory and bound check auto test |
| 146 | 123 | BOUNDS_OK = 1 4 8 10 14 |
| 147 | 124 | BOUNDS_FAIL= 2 5 7 9 11 12 13 15 |
| 148 | 125 | |
| 149 | −btest: boundtest.c ../bcheck.o | |
| 126 | +btest: boundtest.c | |
| 150 | 127 | @echo ------------ $@ ------------ |
| 151 | 128 | @for i in $(BOUNDS_OK); do \ |
| 152 | 129 | echo ; echo --- boundtest $$i ---; \ |
| @@ -212,5 +189,6 @@ cache: tcc_g · 59 unmodified lines | ||
| 212 | 189 | |
| 213 | 190 | # clean |
| 214 | 191 | clean: |
| 215 | − rm -vf *~ *.o *.a *.bin *.i *.ref *.out *.out? *.out?b *.gcc \ | |
| 216 | − tcctest[1234] ex? libtcc_test$(EXESUF) tcc_g tcclib.h | |
| 192 | + $(MAKE) -C tests2 $@ | |
| 193 | + rm -vf *~ *.o *.a *.bin *.i *.ref *.out *.out? *.out?b *.gcc *.exe \ | |
| 194 | + hello libtcc_test tcctest[1234] ex? tcc_g tcclib.h | |
| @@ -594,7 +594,9 @@ int main(int argc, char **argv) · 593 unmodified lines | ||
| 594 | 594 | local_label_test(); |
| 595 | 595 | asm_test(); |
| 596 | 596 | builtin_test(); |
| 597 | +#ifndef _WIN32 | |
| 597 | 598 | weak_test(); |
| 599 | +#endif | |
| 598 | 600 | global_data_test(); |
| 599 | 601 | cmp_comparison_test(); |
| 600 | 602 | math_cmp_test(); |
| @@ -2464,7 +2466,7 @@ void builtin_test(void) · 1863 unmodified lines | ||
| 2464 | 2466 | printf("res = %d\n", __builtin_constant_p(constant_p_var)); |
| 2465 | 2467 | } |
| 2466 | 2468 | |
| 2467 | − | |
| 2469 | +#ifndef _WIN32 | |
| 2468 | 2470 | extern int __attribute__((weak)) weak_f1(void); |
| 2469 | 2471 | extern int __attribute__((weak)) weak_f2(void); |
| 2470 | 2472 | extern int weak_f3(void); |
| @@ -2520,6 +2522,7 @@ int __attribute__((weak)) weak_f2() { return 222; } · 49 unmodified lines | ||
| 2520 | 2522 | int __attribute__((weak)) weak_f3() { return 333; } |
| 2521 | 2523 | int __attribute__((weak)) weak_v2 = 222; |
| 2522 | 2524 | int __attribute__((weak)) weak_v3 = 333; |
| 2525 | +#endif | |
| 2523 | 2526 | |
| 2524 | 2527 | void const_func(const int a) |
| 2525 | 2528 | { |
| @@ -1,18 +1,18 @@ | ||
| 1 | −0 0 0 | |
| 2 | −0 0 1 | |
| 3 | −0 0 2 | |
| 4 | −0 1 0 | |
| 5 | −0 1 1 | |
| 6 | −0 1 2 | |
| 7 | −0 2 0 | |
| 8 | −0 2 1 | |
| 9 | −0 2 2 | |
| 10 | −1 0 0 | |
| 11 | −1 0 1 | |
| 12 | −1 0 2 | |
| 13 | −1 1 0 | |
| 14 | −1 1 1 | |
| 15 | −1 1 2 | |
| 16 | −1 2 0 | |
| 17 | −1 2 1 | |
| 18 | −1 2 2 | |
| 1 | +0 0 0 | |
| 2 | +0 0 1 | |
| 3 | +0 0 2 | |
| 4 | +0 1 0 | |
| 5 | +0 1 1 | |
| 6 | +0 1 2 | |
| 7 | +0 2 0 | |
| 8 | +0 2 1 | |
| 9 | +0 2 2 | |
| 10 | +1 0 0 | |
| 11 | +1 0 1 | |
| 12 | +1 0 2 | |
| 13 | +1 1 0 | |
| 14 | +1 1 1 | |
| 15 | +1 1 2 | |
| 16 | +1 2 0 | |
| 17 | +1 2 1 | |
| 18 | +1 2 2 | |
| @@ -1,3 +1,3 @@ | ||
| 1 | −0 1 2 3 54 73 74 75 | |
| 2 | −12 | |
| 3 | −54 | |
| 1 | +0 1 2 3 54 73 74 75 | |
| 2 | +12 | |
| 3 | +54 | |
| @@ -1,3 +1,3 @@ | ||
| 1 | −including | |
| 2 | −included | |
| 3 | −done | |
| 1 | +including | |
| 2 | +included | |
| 3 | +done | |
| @@ -1 +1 @@ | ||
| 1 | −printf("included\n"); | |
| 1 | +printf("included\n"); | |
| @@ -1,17 +1,17 @@ | ||
| 1 | −#include <stdio.h> | |
| 2 | − | |
| 3 | −int main() | |
| 4 | −{ | |
| 5 | − int a; | |
| 6 | − | |
| 7 | − for (a = 0; a < 2; a++) | |
| 8 | − { | |
| 9 | − int b = a; | |
| 10 | − } | |
| 11 | − | |
| 12 | − printf("it's all good\n"); | |
| 13 | − | |
| 14 | − return 0; | |
| 15 | −} | |
| 16 | − | |
| 17 | −/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ | |
| 1 | +#include <stdio.h> | |
| 2 | + | |
| 3 | +int main() | |
| 4 | +{ | |
| 5 | + int a; | |
| 6 | + | |
| 7 | + for (a = 0; a < 2; a++) | |
| 8 | + { | |
| 9 | + int b = a; | |
| 10 | + } | |
| 11 | + | |
| 12 | + printf("it's all good\n"); | |
| 13 | + | |
| 14 | + return 0; | |
| 15 | +} | |
| 16 | + | |
| 17 | +/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ | |
| @@ -1,18 +1,18 @@ | ||
| 1 | −#include <stdio.h> | |
| 2 | − | |
| 3 | −int main() | |
| 4 | −{ | |
| 5 | − int Count = 0; | |
| 6 | − | |
| 7 | − for (;;) | |
| 8 | − { | |
| 9 | − Count++; | |
| 10 | − printf("%d\n", Count); | |
| 11 | − if (Count >= 10) | |
| 12 | − break; | |
| 13 | − } | |
| 14 | − | |
| 15 | − return 0; | |
| 16 | −} | |
| 17 | − | |
| 18 | −/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ | |
| 1 | +#include <stdio.h> | |
| 2 | + | |
| 3 | +int main() | |
| 4 | +{ | |
| 5 | + int Count = 0; | |
| 6 | + | |
| 7 | + for (;;) | |
| 8 | + { | |
| 9 | + Count++; | |
| 10 | + printf("%d\n", Count); | |
| 11 | + if (Count >= 10) | |
| 12 | + break; | |
| 13 | + } | |
| 14 | + | |
| 15 | + return 0; | |
| 16 | +} | |
| 17 | + | |
| 18 | +/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ | |
| @@ -1,29 +1,29 @@ | ||
| 1 | −#include <stdio.h> | |
| 2 | − | |
| 3 | −int fred() | |
| 4 | −{ | |
| 5 | − printf("fred\n"); | |
| 6 | − return 0; | |
| 7 | −} | |
| 8 | − | |
| 9 | −int joe() | |
| 10 | −{ | |
| 11 | − printf("joe\n"); | |
| 12 | − return 1; | |
| 13 | −} | |
| 14 | − | |
| 15 | −int main() | |
| 16 | −{ | |
| 17 | − printf("%d\n", fred() && joe()); | |
| 18 | − printf("%d\n", fred() || joe()); | |
| 19 | − printf("%d\n", joe() && fred()); | |
| 20 | − printf("%d\n", joe() || fred()); | |
| 21 | − printf("%d\n", fred() && (1 + joe())); | |
| 22 | − printf("%d\n", fred() || (0 + joe())); | |
| 23 | − printf("%d\n", joe() && (0 + fred())); | |
| 24 | − printf("%d\n", joe() || (1 + fred())); | |
| 25 | − | |
| 26 | − return 0; | |
| 27 | −} | |
| 28 | − | |
| 29 | −/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ | |
| 1 | +#include <stdio.h> | |
| 2 | + | |
| 3 | +int fred() | |
| 4 | +{ | |
| 5 | + printf("fred\n"); | |
| 6 | + return 0; | |
| 7 | +} | |
| 8 | + | |
| 9 | +int joe() | |
| 10 | +{ | |
| 11 | + printf("joe\n"); | |
| 12 | + return 1; | |
| 13 | +} | |
| 14 | + | |
| 15 | +int main() | |
| 16 | +{ | |
| 17 | + printf("%d\n", fred() && joe()); | |
| 18 | + printf("%d\n", fred() || joe()); | |
| 19 | + printf("%d\n", joe() && fred()); | |
| 20 | + printf("%d\n", joe() || fred()); | |
| 21 | + printf("%d\n", fred() && (1 + joe())); | |
| 22 | + printf("%d\n", fred() || (0 + joe())); | |
| 23 | + printf("%d\n", joe() && (0 + fred())); | |
| 24 | + printf("%d\n", joe() || (1 + fred())); | |
| 25 | + | |
| 26 | + return 0; | |
| 27 | +} | |
| 28 | + | |
| 29 | +/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ | |
| @@ -1,56 +1,56 @@ | ||
| 1 | −#include <stdio.h> | |
| 2 | − | |
| 3 | −void fred() | |
| 4 | −{ | |
| 5 | − printf("In fred()\n"); | |
| 6 | − goto done; | |
| 7 | − printf("In middle\n"); | |
| 8 | −done: | |
| 9 | − printf("At end\n"); | |
| 10 | −} | |
| 11 | − | |
| 12 | −void joe() | |
| 13 | −{ | |
| 14 | − int b = 5678; | |
| 15 | − | |
| 16 | − printf("In joe()\n"); | |
| 17 | − | |
| 18 | − { | |
| 19 | − int c = 1234; | |
| 20 | − printf("c = %d\n", c); | |
| 21 | − goto outer; | |
| 22 | − printf("uh-oh\n"); | |
| 23 | − } | |
| 24 | − | |
| 25 | −outer: | |
| 26 | − | |
| 27 | − printf("done\n"); | |
| 28 | −} | |
| 29 | − | |
| 30 | −void henry() | |
| 31 | −{ | |
| 32 | − int a; | |
| 33 | − | |
| 34 | − printf("In henry()\n"); | |
| 35 | − goto inner; | |
| 36 | − | |
| 37 | − { | |
| 38 | − int b; | |
| 39 | −inner: | |
| 40 | − b = 1234; | |
| 41 | − printf("b = %d\n", b); | |
| 42 | − } | |
| 43 | − | |
| 44 | − printf("done\n"); | |
| 45 | −} | |
| 46 | − | |
| 47 | −int main() | |
| 48 | −{ | |
| 49 | − fred(); | |
| 50 | − joe(); | |
| 51 | − henry(); | |
| 52 | − | |
| 53 | − return 0; | |
| 54 | −} | |
| 55 | − | |
| 56 | −/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ | |
| 1 | +#include <stdio.h> | |
| 2 | + | |
| 3 | +void fred() | |
| 4 | +{ | |
| 5 | + printf("In fred()\n"); | |
| 6 | + goto done; | |
| 7 | + printf("In middle\n"); | |
| 8 | +done: | |
| 9 | + printf("At end\n"); | |
| 10 | +} | |
| 11 | + | |
| 12 | +void joe() | |
| 13 | +{ | |
| 14 | + int b = 5678; | |
| 15 | + | |
| 16 | + printf("In joe()\n"); | |
| 17 | + | |
| 18 | + { | |
| 19 | + int c = 1234; | |
| 20 | + printf("c = %d\n", c); | |
| 21 | + goto outer; | |
| 22 | + printf("uh-oh\n"); | |
| 23 | + } | |
| 24 | + | |
| 25 | +outer: | |
| 26 | + | |
| 27 | + printf("done\n"); | |
| 28 | +} | |
| 29 | + | |
| 30 | +void henry() | |
| 31 | +{ | |
| 32 | + int a; | |
| 33 | + | |
| 34 | + printf("In henry()\n"); | |
| 35 | + goto inner; | |
| 36 | + | |
| 37 | + { | |
| 38 | + int b; | |
| 39 | +inner: | |
| 40 | + b = 1234; | |
| 41 | + printf("b = %d\n", b); | |
| 42 | + } | |
| 43 | + | |
| 44 | + printf("done\n"); | |
| 45 | +} | |
| 46 | + | |
| 47 | +int main() | |
| 48 | +{ | |
| 49 | + fred(); | |
| 50 | + joe(); | |
| 51 | + henry(); | |
| 52 | + | |
| 53 | + return 0; | |
| 54 | +} | |
| 55 | + | |
| 56 | +/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ | |
| @@ -1,103 +1,98 @@ | ||
| 1 | −TOP = .. | |
| 1 | +TOP = ../.. | |
| 2 | 2 | include $(TOP)/Makefile |
| 3 | −VPATH = $(top_srcdir)/tests2 | |
| 3 | +VPATH = $(top_srcdir)/tests/tests2 | |
| 4 | 4 | |
| 5 | −ifeq ($(TARGETOS),Darwin) | |
| 6 | − CFLAGS+=-Wl,-flat_namespace,-undefined,warning | |
| 7 | − TCCFLAGS=-D_ANSI_SOURCE | |
| 8 | − export MACOSX_DEPLOYMENT_TARGET:=10.2 | |
| 5 | +TCCFLAGS = -B$(TOP) | |
| 6 | +ifdef CONFIG_WIN32 | |
| 7 | + TCCFLAGS = -B$(top_srcdir)/win32 -I$(top_srcdir)/include -L$(TOP) | |
| 9 | 8 | endif |
| 10 | 9 | |
| 11 | −ifdef CONFIG_WIN32 | |
| 12 | − TCCFLAGS=-I $(TOP)/win32/include -L$(TOP) | |
| 10 | +ifeq ($(TARGETOS),Darwin) | |
| 11 | + CFLAGS += -Wl,-flat_namespace,-undefined,warning | |
| 12 | + TCCFLAGS += -D_ANSI_SOURCE | |
| 13 | + export MACOSX_DEPLOYMENT_TARGET:=10.2 | |
| 13 | 14 | endif |
| 14 | 15 | |
| 15 | −TESTS= 00_assignment.test \ | |
| 16 | − 01_comment.test \ | |
| 17 | − 02_printf.test \ | |
| 18 | − 03_struct.test \ | |
| 19 | − 04_for.test \ | |
| 20 | − 05_array.test \ | |
| 21 | − 06_case.test \ | |
| 22 | − 07_function.test \ | |
| 23 | − 08_while.test \ | |
| 24 | − 09_do_while.test \ | |
| 25 | − 10_pointer.test \ | |
| 26 | − 11_precedence.test \ | |
| 27 | − 12_hashdefine.test \ | |
| 28 | − 13_integer_literals.test \ | |
| 29 | − 14_if.test \ | |
| 30 | − 15_recursion.test \ | |
| 31 | − 16_nesting.test \ | |
| 32 | − 17_enum.test \ | |
| 33 | − 18_include.test \ | |
| 34 | − 19_pointer_arithmetic.test \ | |
| 35 | − 20_pointer_comparison.test \ | |
| 36 | − 21_char_array.test \ | |
| 37 | − 22_floating_point.test \ | |
| 38 | − 23_type_coercion.test \ | |
| 39 | − 24_math_library.test \ | |
| 40 | − 25_quicksort.test \ | |
| 41 | − 26_character_constants.test \ | |
| 42 | − 27_sizeof.test \ | |
| 43 | − 28_strings.test \ | |
| 44 | − 29_array_address.test \ | |
| 45 | − 31_args.test \ | |
| 46 | − 32_led.test \ | |
| 47 | − 33_ternary_op.test \ | |
| 48 | − 35_sizeof.test \ | |
| 49 | − 36_array_initialisers.test \ | |
| 50 | − 37_sprintf.test \ | |
| 51 | − 38_multiple_array_index.test \ | |
| 52 | − 39_typedef.test \ | |
| 53 | − 40_stdio.test \ | |
| 54 | − 41_hashif.test \ | |
| 55 | − 42_function_pointer.test \ | |
| 56 | − 43_void_param.test \ | |
| 57 | − 44_scoped_declarations.test \ | |
| 58 | − 45_empty_for.test \ | |
| 59 | − 47_switch_return.test \ | |
| 60 | − 48_nested_break.test \ | |
| 61 | − 49_bracket_evaluation.test \ | |
| 62 | − 50_logical_second_arg.test \ | |
| 63 | − 51_static.test \ | |
| 64 | − 52_unnamed_enum.test \ | |
| 65 | − 54_goto.test \ | |
| 66 | − 55_lshift_type.test | |
| 16 | +TCC_RUN = $(TOP)/tcc $(TCCFLAGS) -run | |
| 67 | 17 | |
| 68 | − # 30_hanoi.test \ # seg fault in the code, gcc as well | |
| 69 | − # 34_array_assignment.test \ # array assignment is not in C standard | |
| 70 | − # 46_grep.test \ # does not compile even with gcc | |
| 18 | +TESTS = \ | |
| 19 | + 00_assignment.test \ | |
| 20 | + 01_comment.test \ | |
| 21 | + 02_printf.test \ | |
| 22 | + 03_struct.test \ | |
| 23 | + 04_for.test \ | |
| 24 | + 05_array.test \ | |
| 25 | + 06_case.test \ | |
| 26 | + 07_function.test \ | |
| 27 | + 08_while.test \ | |
| 28 | + 09_do_while.test \ | |
| 29 | + 10_pointer.test \ | |
| 30 | + 11_precedence.test \ | |
| 31 | + 12_hashdefine.test \ | |
| 32 | + 13_integer_literals.test \ | |
| 33 | + 14_if.test \ | |
| 34 | + 15_recursion.test \ | |
| 35 | + 16_nesting.test \ | |
| 36 | + 17_enum.test \ | |
| 37 | + 18_include.test \ | |
| 38 | + 19_pointer_arithmetic.test \ | |
| 39 | + 20_pointer_comparison.test \ | |
| 40 | + 21_char_array.test \ | |
| 41 | + 22_floating_point.test \ | |
| 42 | + 23_type_coercion.test \ | |
| 43 | + 24_math_library.test \ | |
| 44 | + 25_quicksort.test \ | |
| 45 | + 26_character_constants.test \ | |
| 46 | + 27_sizeof.test \ | |
| 47 | + 28_strings.test \ | |
| 48 | + 29_array_address.test \ | |
| 49 | + 31_args.test \ | |
| 50 | + 32_led.test \ | |
| 51 | + 33_ternary_op.test \ | |
| 52 | + 35_sizeof.test \ | |
| 53 | + 36_array_initialisers.test \ | |
| 54 | + 37_sprintf.test \ | |
| 55 | + 38_multiple_array_index.test \ | |
| 56 | + 39_typedef.test \ | |
| 57 | + 40_stdio.test \ | |
| 58 | + 41_hashif.test \ | |
| 59 | + 42_function_pointer.test \ | |
| 60 | + 43_void_param.test \ | |
| 61 | + 44_scoped_declarations.test \ | |
| 62 | + 45_empty_for.test \ | |
| 63 | + 47_switch_return.test \ | |
| 64 | + 48_nested_break.test \ | |
| 65 | + 49_bracket_evaluation.test \ | |
| 66 | + 50_logical_second_arg.test \ | |
| 67 | + 51_static.test \ | |
| 68 | + 52_unnamed_enum.test \ | |
| 69 | + 54_goto.test \ | |
| 70 | + 55_lshift_type.test | |
| 71 | + | |
| 72 | +# 30_hanoi.test -- seg fault in the code, gcc as well | |
| 73 | +# 34_array_assignment.test -- array assignment is not in C standard | |
| 74 | +# 46_grep.test -- does not compile even with gcc | |
| 71 | 75 | |
| 72 | 76 | # some tests do not pass on all platforms, remove them for now |
| 73 | 77 | ifeq ($(TARGETOS),Darwin) |
| 74 | − TESTS := $(filter-out 40_stdio.test,$(TESTS)) | |
| 78 | + TESTS := $(filter-out 40_stdio.test,$(TESTS)) | |
| 75 | 79 | endif |
| 76 | 80 | ifdef CONFIG_WIN32 |
| 77 | − TESTS := $(filter-out 24_math_library.test,$(TESTS)) | |
| 78 | − TESTS := $(filter-out 28_strings.test,$(TESTS)) | |
| 81 | + TESTS := $(filter-out 24_math_library.test 28_strings.test,$(TESTS)) | |
| 79 | 82 | endif |
| 80 | 83 | |
| 81 | 84 | %.test: %.c %.expect |
| 82 | 85 | @echo Test: $*... |
| 83 | 86 | @if [ "x`echo $* | grep args`" != "x" ]; \ |
| 84 | − then \ | |
| 85 | − ../tcc -B.. $(TCCFLAGS) -run $< - arg1 arg2 arg3 arg4 2>&1 >$*.output; \ | |
| 86 | − else \ | |
| 87 | − ../tcc -B.. $(TCCFLAGS) -run $< 2>&1 >$*.output; \ | |
| 87 | + then $(TCC_RUN) $< - arg1 arg2 arg3 arg4 >$*.output; \ | |
| 88 | + else $(TCC_RUN) $< >$*.output; \ | |
| 88 | 89 | fi |
| 89 | 90 | @if diff -bu $(<:.c=.expect) $*.output ; \ |
| 90 | − then \ | |
| 91 | − rm -f $*.output \ | |
| 92 | − else \ | |
| 93 | − echo "ERROR: test $*"; \ | |
| 91 | + then rm -f $*.output; \ | |
| 92 | + else exit 1; \ | |
| 94 | 93 | fi |
| 95 | 94 | |
| 96 | −all: test | |
| 97 | − | |
| 98 | −test: $(TESTS) | |
| 99 | − | |
| 100 | −# vim: set expandtab ts=4 sw=4 sts=4 tw=80 : | |
| 95 | +all test: $(TESTS) | |
| 101 | 96 | |
| 102 | 97 | clean: |
| 103 | − rm -vf fred.txt | |
| 98 | + rm -vf fred.txt *.output | |