diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/Makefile | 18 | ||||
| -rw-r--r-- | tests/tests2/95_bitfields.c | 9 | ||||
| -rw-r--r-- | tests/tests2/95_bitfields.expect | 149 | ||||
| -rw-r--r-- | tests/tests2/95_bitfields_ms.expect | 3 | ||||
| -rw-r--r-- | tests/tests2/96_nodata_wanted.c | 82 | ||||
| -rw-r--r-- | tests/tests2/96_nodata_wanted.expect | 21 | ||||
| -rw-r--r-- | tests/tests2/Makefile | 6 |
7 files changed, 225 insertions, 63 deletions
diff --git a/tests/Makefile b/tests/Makefile index 00d2c9e..39dee7f 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -55,7 +55,7 @@ ifdef CONFIG_WIN32 PATH := $(CURDIR)/$(TOP)$(SEP)$(PATH) # for libtcc_test to find libtcc.dll endif -RUN_TCC = $(NATIVE_DEFINES) -DONE_SOURCE -run $(TOPSRC)/tcc.c $(TCCFLAGS) +RUN_TCC = $(NATIVE_DEFINES) -run $(TOPSRC)/tcc.c $(TCCFLAGS) DISAS = objdump -d DUMPTCC = (set -x; $(TOP)/tcc -vv; ldd $(TOP)/tcc; exit 1) @@ -129,23 +129,23 @@ test4: tcctest.c test.ref # use tcc to create libtcc.so/.dll and the tcc(.exe) frontend and run them dlltest: @echo ------------ $@ ------------ - $(TCC) -DONE_SOURCE $(NATIVE_DEFINES) -DLIBTCC_AS_DLL $(TOPSRC)/libtcc.c $(LIBS) -shared -o libtcc2$(DLLSUF) - $(TCC) $(NATIVE_DEFINES) $(TOPSRC)/tcc.c libtcc2$(DLLSUF) $(LIBS) -Wl,-rpath=. -o tcc2$(EXESUF) + $(TCC) $(NATIVE_DEFINES) -DLIBTCC_AS_DLL $(TOPSRC)/libtcc.c $(LIBS) -shared -o libtcc2$(DLLSUF) + $(TCC) $(NATIVE_DEFINES) -DONE_SOURCE=0 $(TOPSRC)/tcc.c libtcc2$(DLLSUF) $(LIBS) -Wl,-rpath=. -o tcc2$(EXESUF) ./tcc2$(EXESUF) $(TCCFLAGS) $(RUN_TCC) -run $(TOPSRC)/examples/ex1.c ifndef CONFIG_WIN32 @echo ------------ $@ with PIC ------------ - $(CC) $(CFLAGS) -fPIC -DONE_SOURCE $(NATIVE_DEFINES) -DLIBTCC_AS_DLL -c $(TOPSRC)/libtcc.c + $(CC) $(CFLAGS) -fPIC $(NATIVE_DEFINES) -DLIBTCC_AS_DLL -c $(TOPSRC)/libtcc.c $(TCC) libtcc.o $(LIBS) -shared -o libtcc2$(DLLSUF) - $(TCC) $(NATIVE_DEFINES) $(TOPSRC)/tcc.c libtcc2$(DLLSUF) $(LIBS) -Wl,-rpath=. -o tcc2$(EXESUF) + $(TCC) $(NATIVE_DEFINES) -DONE_SOURCE=0 $(TOPSRC)/tcc.c libtcc2$(DLLSUF) $(LIBS) -Wl,-rpath=. -o tcc2$(EXESUF) ./tcc2$(EXESUF) $(TCCFLAGS) $(RUN_TCC) -run $(TOPSRC)/examples/ex1.c endif @rm tcc2$(EXESUF) libtcc2$(DLLSUF) memtest: @echo ------------ $@ ------------ - $(CC) $(CFLAGS) $(NATIVE_DEFINES) -DONE_SOURCE -DMEM_DEBUG=2 $(TOPSRC)/tcc.c $(LIBS) -o memtest-tcc$(EXESUF) - ./memtest-tcc$(EXESUF) $(TCCFLAGS) $(NATIVE_DEFINES) -DONE_SOURCE $(TOPSRC)/tcc.c $(LIBS) - ./memtest-tcc$(EXESUF) $(TCCFLAGS) $(NATIVE_DEFINES) -DONE_SOURCE -run $(TOPSRC)/tcc.c $(TCCFLAGS) $(TOPSRC)/tests/tcctest.c + $(CC) $(CFLAGS) $(NATIVE_DEFINES) -DMEM_DEBUG=2 $(TOPSRC)/tcc.c $(LIBS) -o memtest-tcc$(EXESUF) + ./memtest-tcc$(EXESUF) $(TCCFLAGS) $(NATIVE_DEFINES) $(TOPSRC)/tcc.c $(LIBS) + ./memtest-tcc$(EXESUF) $(TCCFLAGS) $(NATIVE_DEFINES) -run $(TOPSRC)/tcc.c $(TCCFLAGS) $(TOPSRC)/tests/tcctest.c # memory and bound check auto test @@ -210,7 +210,7 @@ abitest-cc$(EXESUF): abitest.c $(LIBTCC) $(CC) -o $@ $^ $(CFLAGS) $(LIBS) -w abitest-tcc$(EXESUF): abitest.c libtcc.c - $(TCC) -o $@ $^ $(NATIVE_DEFINES) -DONE_SOURCE $(LIBS) + $(TCC) -o $@ $^ $(NATIVE_DEFINES) $(LIBS) ABITESTS := abitest-cc$(EXESUF) ifneq ($(CONFIG_arm_eabi),yes) # not ARM soft-float diff --git a/tests/tests2/95_bitfields.c b/tests/tests2/95_bitfields.c index 7edbeed..683becf 100644 --- a/tests/tests2/95_bitfields.c +++ b/tests/tests2/95_bitfields.c @@ -87,8 +87,10 @@ # define P #endif +printf("\n\n" + 2*top); #define TEST 1 #include SELF +top = 0; #define TEST 2 #include SELF #define TEST 3 @@ -99,7 +101,6 @@ #include SELF #define TEST 6 #include SELF -printf("\n\n"); #if PACK # pragma pack(pop) @@ -174,7 +175,7 @@ void dump(void *p, int s) #define TEST_STRUCT(v1,v2,v3,v4,v5) { \ struct __s _s, *s = & _s; \ - printf("---- TEST %d%s%s%s ----\n", \ + printf("\n---- TEST %d%s%s%s ----\n" + top, \ TEST, MS_BF?" - MS-BITFIELDS":"", \ PACK?" - PACKED":"", \ ALIGN?" - WITH ALIGN":""); \ @@ -184,7 +185,7 @@ void dump(void *p, int s) s->x = v1, s->y = v2, s->z = v3, s->a += v4, ++s->a, s->b = v5; \ printf("bits as set : "), dump(s, sizeof *s); \ printf("values :"), pv(x), pv(y), pv(z), pv(a), pv(b), printf("\n"); \ - printf("align/size : %d %d\n\n", alignof(struct __s),sizeof(struct __s)); \ + printf("align/size : %d %d\n", alignof(struct __s),sizeof(struct __s)); \ } #ifdef _MSC_VER @@ -203,6 +204,8 @@ void dump(void *p, int s) #define SELF "95_bitfields.c" +int top = 1; + int main() { #define MS_BF MS_BITFIELDS diff --git a/tests/tests2/95_bitfields.expect b/tests/tests2/95_bitfields.expect new file mode 100644 index 0000000..6a8fd9a --- /dev/null +++ b/tests/tests2/95_bitfields.expect @@ -0,0 +1,149 @@ +---- TEST 1 ---- +bits in use : 0000001FFFFFFFFF007F0FFF +bits as set : 000000076055555500440333 +values : 333 44 555555 06 07 +align/size : 4 12 + +---- TEST 2 ---- +bits in use : 000000000000003F7FFFFFFFFFFFFFFF00000000003F0FFF +bits as set : 0000000000000025123456789ABCDEF000000000001E0003 +values : 03 1e 123456789abcdef0 05 fffffffe +align/size : 8 24 + +---- TEST 3 ---- +bits in use : 001F1F1F000003FF +bits as set : 000E0619000002F5 +values : 15 17 19 06 0e +align/size : 4 8 + +---- TEST 4 ---- +bits in use : 0007FFFF00000027 +bits as set : 00078F0F00000023 +values : 03 ffffffff 0f fffffff8 78 +align/size : 4 8 + +---- TEST 5 ---- +bits in use : FFFFFF3FFFFFFFFF000000003FFFFFFF00001FFFFFFFFFFF +bits as set : 007744000000007800000000300000000000000123456789 +values : 0000000123456789 f0000000 0000000000000078 44 77 +align/size : 8 24 + +---- TEST 6 ---- +bits in use : 0000007000FFFFFFFFFFFFFF +bits as set : 00000030002001FD00000004 +values : 01 02 03 04 fffffffd +align/size : 4 12 + + + +---- TEST 1 - PACKED ---- +bits in use : FFFFFFFFFFFFFF +bits as set : 3B02AAAAAC4333 +values : 333 44 555555 06 07 +align/size : 1 7 + +---- TEST 2 - PACKED ---- +bits in use : 7FFFFFFFFFFFFFFFFFFFFF +bits as set : 4A48D159E26AF37BC1E003 +values : 03 1e 123456789abcdef0 05 fffffffe +align/size : 1 11 + +---- TEST 3 - PACKED ---- +bits in use : 7FFF000003FF +bits as set : 38D9000002F5 +values : 15 17 19 06 0e +align/size : 1 6 + +---- TEST 4 - PACKED ---- +bits in use : 07FFFF00000027 +bits as set : 078F0F00000023 +values : 03 ffffffff 0f fffffff8 78 +align/size : 1 7 + +---- TEST 5 - PACKED ---- +bits in use : FFFFFF07FFFFFFFFFFFFFFFF9FFFFFFFFFFF +bits as set : 007744000000000F18000000000123456789 +values : 0000000123456789 f0000000 0000000000000078 44 77 +align/size : 1 18 + +---- TEST 6 - PACKED ---- +bits in use : 007000FFFFFFFFFFFFFF +bits as set : 0030002001FD00000004 +values : 01 02 03 04 fffffffd +align/size : 1 10 + + + +---- TEST 1 - WITH ALIGN ---- +bits in use : 000000000000001FFFFFFFFF007F0FFF +bits as set : 00000000000000076055555500440333 +values : 333 44 555555 06 07 +align/size : 16 16 + +---- TEST 2 - WITH ALIGN ---- +bits in use : 0000000000000000000000000000003F7FFFFFFFFFFFFFFF00000000003F0FFF +bits as set : 00000000000000000000000000000025123456789ABCDEF000000000001E0003 +values : 03 1e 123456789abcdef0 05 fffffffe +align/size : 16 32 + +---- TEST 3 - WITH ALIGN ---- +bits in use : 0000000000000000000000000000001F000000000000000000001F1F000003FF +bits as set : 0000000000000000000000000000000E000000000000000000000619000002F5 +values : 15 17 19 06 0e +align/size : 16 32 + +---- TEST 4 - WITH ALIGN ---- +bits in use : 0007FFFF00000027 +bits as set : 00078F0F00000023 +values : 03 ffffffff 0f fffffff8 78 +align/size : 4 8 + +---- TEST 5 - WITH ALIGN ---- +bits in use : FFFFFF3FFFFFFFFF000000003FFFFFFF00001FFFFFFFFFFF +bits as set : 007744000000007800000000300000000000000123456789 +values : 0000000123456789 f0000000 0000000000000078 44 77 +align/size : 8 24 + +---- TEST 6 - WITH ALIGN ---- +bits in use : 0000007000FFFFFFFFFFFFFF +bits as set : 00000030002001FD00000004 +values : 01 02 03 04 fffffffd +align/size : 4 12 + + + +---- TEST 1 - PACKED - WITH ALIGN ---- +bits in use : 000000000000000000FFFFFFFFFFFFFF +bits as set : 0000000000000000003B02AAAAAC4333 +values : 333 44 555555 06 07 +align/size : 16 16 + +---- TEST 2 - PACKED - WITH ALIGN ---- +bits in use : 3F01FFFFFFFFFFFFFFFFFFFF +bits as set : 250048D159E26AF37BC1E003 +values : 03 1e 123456789abcdef0 05 fffffffe +align/size : 1 12 + +---- TEST 3 - PACKED - WITH ALIGN ---- +bits in use : 1F03FF000003FF +bits as set : 0E00D9000002F5 +values : 15 17 19 06 0e +align/size : 1 7 + +---- TEST 4 - PACKED - WITH ALIGN ---- +bits in use : 07FFFF00000027 +bits as set : 078F0F00000023 +values : 03 ffffffff 0f fffffff8 78 +align/size : 1 7 + +---- TEST 5 - PACKED - WITH ALIGN ---- +bits in use : FFFFFF07FFFFFFFFFFFFFFFF9FFFFFFFFFFF +bits as set : 007744000000000F18000000000123456789 +values : 0000000123456789 f0000000 0000000000000078 44 77 +align/size : 1 18 + +---- TEST 6 - PACKED - WITH ALIGN ---- +bits in use : 007000FFFFFFFFFFFFFF +bits as set : 0030002001FD00000004 +values : 01 02 03 04 fffffffd +align/size : 1 10 diff --git a/tests/tests2/95_bitfields_ms.expect b/tests/tests2/95_bitfields_ms.expect index 6b5c3f9..8ccafb7 100644 --- a/tests/tests2/95_bitfields_ms.expect +++ b/tests/tests2/95_bitfields_ms.expect @@ -147,6 +147,3 @@ bits in use : 00000000700000FFFFFFFFFFFFFF bits as set : 000000003000002001FD00000004 values : 01 02 03 04 fffffffd align/size : 1 14 - - - diff --git a/tests/tests2/96_nodata_wanted.c b/tests/tests2/96_nodata_wanted.c index 1f022c9..b594938 100644 --- a/tests/tests2/96_nodata_wanted.c +++ b/tests/tests2/96_nodata_wanted.c @@ -25,50 +25,60 @@ void foo() { short w = &foo; /* 2 cast warnings */ } -#elif defined test_data_suppression -#include <stdio.h> +#elif defined test_data_suppression_off || defined test_data_suppression_on -#define ASMLABELS(s) \ - __asm__(".global d"#s",t"#s"\n.data\nd"#s":\n.text\nt"#s":\n") +#if defined test_data_suppression_on +# define SKIP 1 +#else +# define SKIP 0 +#endif -#define PROG \ - static void *p = (void*)&main;\ - static char cc[] = "static string";\ - static double d = 8.0;\ - static struct __attribute__((packed)) {\ - unsigned x : 12;\ - unsigned char y : 7;\ - unsigned z : 28, a: 4, b: 5;\ - } s = { 0x333,0x44,0x555555,6,7 };\ - printf(" static data: %d - %.1f - %.1f - %s - %s\n",\ - sizeof 8.0, 8.0, d, __FUNCTION__, cc);\ - printf(" static bitfields: %x %x %x %x %x\n", s.x, s.y, s.z, s.a, s.b); +#include <stdio.h> +/* some gcc headers #define __attribute__ to empty if it's not gcc */ +#undef __attribute__ int main() { - extern char ds1[],ts1[]; - extern char ds2[],ts2[]; - extern char de1[],te1[]; - extern char de2[],te2[]; + __label__ ts0, te0, ts1, te1; + int tl, dl; - printf("suppression off\n"); - if (1) { - ASMLABELS(s1); - PROG - ASMLABELS(e1); - } - printf(" data length is %s\n", de1 - ds1 ? "not 0":"0"); - printf(" text length is %s\n", te1 - ts1 ? "not 0":"0"); + static char ds0 = 0; + static char de0 = 0; + /* get reference size of empty jmp */ +ts0:; + if (!SKIP) {} +te0:; + dl = -(&de0 - &ds0); + tl = -(&&te0 - &&ts0); - printf("suppression on\n"); - if (0) { - ASMLABELS(s2); - PROG - ASMLABELS(e2); + /* test data and code suppression */ + static char ds1 = 0; +ts1:; + if (!SKIP) { + static void *p = (void*)&main; + static char cc[] = "static string"; + static double d = 8.0; + + static struct __attribute__((packed)) { + unsigned x : 12; + unsigned char y : 7; + unsigned z : 28, a: 4, b: 5; + } s = { 0x333,0x44,0x555555,6,7 }; + + printf("data:\n"); + printf(" %d - %.1f - %.1f - %s - %s\n", + sizeof 8.0, 8.0, d, __FUNCTION__, cc); + printf(" %x %x %x %x %x\n", + s.x, s.y, s.z, s.a, s.b); } - printf(" data length is %x\n", de2 - ds2); - printf(" text length is %X\n", te2 - ts2); - return 0; +te1:; + static char de1 = 0; + + dl += &de1 - &ds1; + tl += &&te1 - &&ts1; + printf("size of data/text:\n %s/%s\n", + dl ? "non-zero":"zero", tl ? "non-zero":"zero"); + printf("# %d/%d\n", dl, tl); } #endif diff --git a/tests/tests2/96_nodata_wanted.expect b/tests/tests2/96_nodata_wanted.expect index 9fd35ca..6e54f24 100644 --- a/tests/tests2/96_nodata_wanted.expect +++ b/tests/tests2/96_nodata_wanted.expect @@ -11,12 +11,15 @@ 96_nodata_wanted.c:25: warning: assignment makes integer from pointer without a cast 96_nodata_wanted.c:25: warning: nonportable conversion from pointer to char/short -[test_data_suppression] -suppression off - static data: 8 - 8.0 - 8.0 - main - static string - static bitfields: 333 44 555555 6 7 - data length is not 0 - text length is not 0 -suppression on - data length is 0 - text length is 0 +[test_data_suppression_off] +data: + 8 - 8.0 - 8.0 - main - static string + 333 44 555555 6 7 +size of data/text: + non-zero/non-zero +# 111/193 + +[test_data_suppression_on] +size of data/text: + zero/zero +# 0/0 diff --git a/tests/tests2/Makefile b/tests/tests2/Makefile index 4dd1591..c75db8c 100644 --- a/tests/tests2/Makefile +++ b/tests/tests2/Makefile @@ -24,7 +24,7 @@ ifeq (-$(findstring gcc,$(CC))-,--) SKIP += $(patsubst %.expect,%.test,$(GEN-ALWAYS)) endif ifeq (-$(CONFIG_WIN32)-$(CONFIG_i386)$(CONFIG_arm)-,--yes-) - SKIP += 95_bitfields_ms.test # type_align is differnt on 32bit-non-windows + SKIP += 95_bitfields%.test # type_align is differnt on 32bit-non-windows endif # Some tests might need arguments @@ -46,7 +46,7 @@ FLAGS = # Always generate certain .expects (don't put these in the GIT), GEN-ALWAYS = -GEN-ALWAYS += 95_bitfields.expect +# GEN-ALWAYS += 95_bitfields.expect # does not work # using the ms compiler for the really ms-compatible bitfields 95_bitfields_ms.test : GEN = $(GEN-MSC) @@ -67,7 +67,7 @@ all test tests2.all: $(filter-out $(SKIP),$(TESTS)) ; T1 = $(TCC) $(FLAGS) $< -o a.exe && ./a.exe $(ARGS) T2 = $(TCC) $(FLAGS) -run $< $(ARGS) T3 = $(FILTER) >$*.output 2>&1 || true \ - && diff -Nbu $(filter %.expect,$^) $*.output \ + && diff -Nbu -I "^\#" $(filter %.expect,$^) $*.output \ && rm -f $*.output $(filter $*.expect,$(GEN-ALWAYS)) # run single test and update .expect file, e.g. "make tests2.37+" |
