diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/tests2/95_bitfields.c | 2 | ||||
| -rw-r--r-- | tests/tests2/95_bitfields_ms.expect | 16 | ||||
| -rw-r--r-- | tests/tests2/96_nodata_wanted.c | 74 | ||||
| -rw-r--r-- | tests/tests2/96_nodata_wanted.expect | 24 | ||||
| -rw-r--r-- | tests/tests2/Makefile | 91 |
5 files changed, 158 insertions, 49 deletions
diff --git a/tests/tests2/95_bitfields.c b/tests/tests2/95_bitfields.c index 1ec9781..7edbeed 100644 --- a/tests/tests2/95_bitfields.c +++ b/tests/tests2/95_bitfields.c @@ -58,7 +58,7 @@ struct M P __s { long long x : 45; long long : 2; - long long y : 35; + long long y : 30; unsigned long long z : 38; char a; short b; }; diff --git a/tests/tests2/95_bitfields_ms.expect b/tests/tests2/95_bitfields_ms.expect index f4eb2d3..6b5c3f9 100644 --- a/tests/tests2/95_bitfields_ms.expect +++ b/tests/tests2/95_bitfields_ms.expect @@ -23,8 +23,8 @@ values : 03 ffffffff 0f fffffff8 78 align/size : 4 8 ---- TEST 5 - MS-BITFIELDS ---- -bits in use : 00000000FFFF00FF0000003FFFFFFFFF00000007FFFFFFFF00001FFFFFFFFFFF -bits as set : 0000000000770044000000000000007800000007F00000000000000123456789 +bits in use : 00000000FFFF00FF0000003FFFFFFFFF000000003FFFFFFF00001FFFFFFFFFFF +bits as set : 0000000000770044000000000000007800000000300000000000000123456789 values : 0000000123456789 fffffffff0000000 0000000000000078 44 77 align/size : 8 32 @@ -61,8 +61,8 @@ values : 03 ffffffff 0f fffffff8 78 align/size : 1 8 ---- TEST 5 - MS-BITFIELDS - PACKED ---- -bits in use : FFFFFF0000003FFFFFFFFF00000007FFFFFFFF00001FFFFFFFFFFF -bits as set : 007744000000000000007800000007F00000000000000123456789 +bits in use : FFFFFF0000003FFFFFFFFF000000003FFFFFFF00001FFFFFFFFFFF +bits as set : 007744000000000000007800000000300000000000000123456789 values : 0000000123456789 fffffffff0000000 0000000000000078 44 77 align/size : 1 27 @@ -99,8 +99,8 @@ values : 03 ffffffff 0f fffffff8 78 align/size : 4 8 ---- TEST 5 - MS-BITFIELDS - WITH ALIGN ---- -bits in use : 00000000FFFF00FF0000003FFFFFFFFF00000007FFFFFFFF00001FFFFFFFFFFF -bits as set : 0000000000770044000000000000007800000007F00000000000000123456789 +bits in use : 00000000FFFF00FF0000003FFFFFFFFF000000003FFFFFFF00001FFFFFFFFFFF +bits as set : 0000000000770044000000000000007800000000300000000000000123456789 values : 0000000123456789 fffffffff0000000 0000000000000078 44 77 align/size : 8 32 @@ -137,8 +137,8 @@ values : 03 ffffffff 0f fffffff8 78 align/size : 1 8 ---- TEST 5 - MS-BITFIELDS - PACKED - WITH ALIGN ---- -bits in use : FFFFFF0000003FFFFFFFFF00000007FFFFFFFF00001FFFFFFFFFFF -bits as set : 007744000000000000007800000007F00000000000000123456789 +bits in use : FFFFFF0000003FFFFFFFFF000000003FFFFFFF00001FFFFFFFFFFF +bits as set : 007744000000000000007800000000300000000000000123456789 values : 0000000123456789 fffffffff0000000 0000000000000078 44 77 align/size : 1 27 diff --git a/tests/tests2/96_nodata_wanted.c b/tests/tests2/96_nodata_wanted.c new file mode 100644 index 0000000..6f7f3c2 --- /dev/null +++ b/tests/tests2/96_nodata_wanted.c @@ -0,0 +1,74 @@ +/*****************************************************************************/ +/* test 'nodata_wanted' data output suppression */ + +/*-* test 1: initializer not computable 1 */ +void foo() { + if (1) { + static short w = (int)&foo; /* error */ + } +} + +/*-* test 2: initializer not computable 2 */ +void foo() { + if (0) { + static short w = (int)&foo; /* error */ + } +} + +/*-* test 3: initializer not computable 3 */ +void foo(); +static short w = (int)&foo; /* error */ + + +/*-* test 4: 2 cast warnings */ +void foo() { + short w = &foo; /* no error */ +} + +/*-* test 5; nodata_wanted test */ +#include <stdio.h> + +#define DATA_LBL(s) \ + __asm__(".global d"#s",t"#s"\n.data\nd"#s":\n.text\nt"#s":\n"); \ + extern char d##s[],t##s[]; + +#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); + +int main() +{ + printf("suppression off\n"); + DATA_LBL(s1); + if (1) { + PROG + } + DATA_LBL(e1); + printf(" data length is %s\n", de1 - ds1 ? "not 0":"0"); + //printf(" text length is %s\n", te1 - ts1 ? "not 0":"0"); + + printf("suppression on\n"); + DATA_LBL(s2); + if (0) { + PROG + } + DATA_LBL(e2); + printf(" data length is %x\n", de2 - ds2); + //printf(" text length is %X\n", te2 - ts2); + return 0; +} + +/*-* test 6: some test */ +int main() +{ + return 34; +} diff --git a/tests/tests2/96_nodata_wanted.expect b/tests/tests2/96_nodata_wanted.expect new file mode 100644 index 0000000..0db4ba2 --- /dev/null +++ b/tests/tests2/96_nodata_wanted.expect @@ -0,0 +1,24 @@ +/*-* test 1: initializer not computable 1 */ +test 1:3: error: initializer element is not computable at load time + +/*-* test 2: initializer not computable 2 */ +test 2:3: error: initializer element is not computable at load time + +/*-* test 3: initializer not computable 3 */ +test 3:2: error: initializer element is not computable at load time + +/*-* test 4: 2 cast warnings */ +test 4:2: warning: assignment makes integer from pointer without a cast +test 4:2: warning: nonportable conversion from pointer to char/short + +/*-* test 5; nodata_wanted test */ +suppression off + static data: 8 - 8.0 - 8.0 - main - static string + static bitfields: 333 44 555555 6 7 + data length is not 0 +suppression on + data length is 0 +returns 0 + +/*-* test 6: some test */ +returns 34 diff --git a/tests/tests2/Makefile b/tests/tests2/Makefile index 44f20f7..832aa49 100644 --- a/tests/tests2/Makefile +++ b/tests/tests2/Makefile @@ -5,29 +5,6 @@ VPATH = $(SRC) TESTS = $(patsubst %.c,%.test,$(sort $(notdir $(wildcard $(SRC)/*.c)))) -# Some tests might need arguments -ARGS = -31_args.test : ARGS = arg1 arg2 arg3 arg4 arg5 -46_grep.test : ARGS = '[^* ]*[:a:d: ]+\:\*-/: $$' $(SRC)/46_grep.c - -# And some tests don't test the right thing with -run -NORUN = -42_function_pointer.test : NORUN = true - -# Some tests might need different flags -FLAGS = -76_dollars_in_identifiers.test : FLAGS += -fdollars-in-identifiers - -# Always generate certain .expects (don't put these in the GIT), -GEN-ALWAYS = 95_bitfields.expect - -# Filter source directory in warnings/errors (out-of-tree builds) -FILTER = 2>&1 | sed 's,$(SRC)/,,g' -# Filter some always-warning -ifeq (-$(findstring arm,$(ARCH))-,-arm-) -FILTER += 2>&1 | grep -v 'warning: soft float ABI currently not supported' -endif - # some tests do not pass on all platforms, remove them for now SKIP = 34_array_assignment.test # array assignment is not in C standard ifeq ($(CONFIG_arm_eabi),yes) # not ARM soft-float @@ -50,46 +27,80 @@ ifeq (-$(CONFIG_WIN32)-$(CONFIG_i386)$(CONFIG_arm)-,--yes-) SKIP += 95_bitfields_ms.test # type_align is differnt on 32bit-non-windows endif +# Some tests might need arguments +ARGS = +31_args.test : ARGS = arg1 arg2 arg3 arg4 arg5 +46_grep.test : ARGS = '[^* ]*[:a:d: ]+\:\*-/: $$' $(SRC)/46_grep.c + +# And some tests don't test the right thing with -run +NORUN = +42_function_pointer.test : NORUN = true + +# Some tests might need different flags +FLAGS = +76_dollars_in_identifiers.test : FLAGS += -fdollars-in-identifiers + +# run the source file cut into snippets +96_nodata_wanted.test : FLAGS = -dT + +# Always generate certain .expects (don't put these in the GIT), +GEN-ALWAYS = +GEN-ALWAYS += 95_bitfields.expect + +# using the ms compiler for the really ms-compatible bitfields +95_bitfields_ms.test : GEN = $(GEN-MSC) + +# Filter source directory in warnings/errors (out-of-tree builds) +FILTER = 2>&1 | sed 's,$(SRC)/,,g' +# Filter some always-warning +ifeq (-$(findstring arm,$(ARCH))-,-arm-) +FILTER += 2>&1 | grep -v 'warning: soft float ABI currently not supported' +endif + all test tests2.all: $(filter-out $(SKIP),$(TESTS)) ; %.test: %.c %.expect @echo Test: $*... - @$(if $(NORUN),\ - ($(TCC) $(FLAGS) $< -o a.exe && ./a.exe $(ARGS)),\ - $(TCC) $(FLAGS) -run $< $(ARGS)\ - ) $(FILTER) >$*.output 2>&1 || true - @diff -Nbu $(filter %.expect,$^) $*.output \ - && rm -f $*.output $(filter $*.expect,$(GEN-ALWAYS)) + @$(if $(NORUN),$(T1),$(T2)) $(if $(NODIFF),,$(T3)) -F1 = $(or $(filter $1_%,$(TESTS)),$1_???.test) -F2 = $1 UPDATE="$(patsubst %.test,%.expect,$1)" +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 \ + && rm -f $*.output $(filter $*.expect,$(GEN-ALWAYS)) # run single test and update .expect file, e.g. "make tests2.37+" tests2.%+: @$(MAKE) $(call F2,$(call F1,$*)) --no-print-directory +# just run tcc to see the output, e.g. "make tests2.37-" +tests2.%-: + @$(MAKE) $(call F1,$*) NODIFF=true --no-print-directory + # run single test, e.g. "make tests2.37" tests2.%: @$(MAKE) $(call F1,$*) --no-print-directory +F1 = $(or $(filter $1_%,$(TESTS)),$1_???.test) +F2 = $1 UPDATE="$(patsubst %.test,%.expect,$1)" + # automatically generate .expect files with gcc: %.expect : @echo Generating: $@ - @$(CC) -w -std=gnu99 $(FLAGS) $(SRC)/$*.c -o a.exe - @./a.exe $(ARGS) $(FILTER) >$@ 2>&1 - @rm -f a.exe + @$(call GEN,$(SRC)/$*.c) $(FILTER) >$@ 2>&1 + @rm -f *.exe *.obj *.pdb -# using the ms compiler for the really ms-compatible bitfields +# using TCC for .expect if -dT in FLAGS +GEN = $(if $(findstring -dT,$(FLAGS)),$(GEN-TCC),$(GEN-CC)) +GEN-CC = $(CC) -w -std=gnu99 $(FLAGS) $1 -o a.exe && ./a.exe $(ARGS) +GEN-TCC = $(TCC) $(FLAGS) -run $1 $(ARGS) +GEN-MSC = $(MS-CC) $1 && ./$(basename $@).exe MS-CC = cl -95_bitfields_ms.expect : - @echo Generating: $@ - @$(MS-CC) $(basename $@).c - @./$(basename $@).exe >$@ 2>&1 - @rm -f *.exe *.obj *.pdb # tell make not to delete .PRECIOUS: %.expect +# force .expect generation for these files $(sort $(GEN-ALWAYS) $(UPDATE)) : force force: |
