tests: add memory leak test
Also ... tcctest.c: - exclude stuff that gcc doesn't compile on windows. libtcc.c/tccpp.c: - use unsigned for memory sizes to avoid printf format warnings - use "file:line: message" to make IDE error parsers happy. tccgen.c: fix typo
This commit is contained in:
@ -5,7 +5,7 @@
|
||||
TOP = ..
|
||||
include $(TOP)/Makefile
|
||||
VPATH = $(TOPSRC)/tests $(TOPSRC) $(TOP)
|
||||
CFLAGS = -I$(TOPSRC) -I$(TOP)
|
||||
CFLAGS := $(filter-out -W% -g% -O%,$(CFLAGS)) -I$(TOPSRC)
|
||||
|
||||
# what tests to run
|
||||
TESTS = \
|
||||
@ -13,6 +13,7 @@ TESTS = \
|
||||
hello-run \
|
||||
libtest \
|
||||
test3 \
|
||||
memtest \
|
||||
dlltest \
|
||||
abitest \
|
||||
vla_test-run \
|
||||
@ -145,6 +146,12 @@ ifndef CONFIG_WIN32
|
||||
endif
|
||||
@rm tcc2$(EXESUF) libtcc2$(DLLSUF)
|
||||
|
||||
memtest:
|
||||
@echo ------------ $@ ------------
|
||||
$(CC) $(CFLAGS) $(NATIVE_DEFINES) -DONE_SOURCE -DMEM_DEBUG=2 ../tcc.c $(LIBS) -o memtest-tcc$(EXESUF)
|
||||
./memtest-tcc$(EXESUF) $(TCCFLAGS) $(NATIVE_DEFINES) -DONE_SOURCE ../tcc.c $(LIBS)
|
||||
./memtest-tcc$(EXESUF) $(TCCFLAGS) $(NATIVE_DEFINES) -DONE_SOURCE -run ../tcc.c $(TCCFLAGS) tcctest.c
|
||||
|
||||
|
||||
# memory and bound check auto test
|
||||
BOUNDS_OK = 1 4 8 10 14
|
||||
|
||||
@ -3122,6 +3122,7 @@ void other_constraints_test(void)
|
||||
int var;
|
||||
__asm__ volatile ("mov %P1,%0" : "=r" (ret) : "p" (&var));
|
||||
printf ("oc1: %d\n", ret == (unsigned long)&var);
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
/* Test global asm blocks playing with aliases. */
|
||||
@ -3161,6 +3162,7 @@ char * get_asm_string (void)
|
||||
"2:\t.long 1b - 2b, %c0 - 2b\n"
|
||||
".popsection\n" : : "i" ("A string"));
|
||||
char * str = ((char*)bug_table) + bug_table[1];
|
||||
return str;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -3301,12 +3303,15 @@ void asm_test(void)
|
||||
label2:
|
||||
__asm__("btsl %1,%0" : "=m"(set) : "Ir"(20) : "cc");
|
||||
printf("set=0x%x\n", set);
|
||||
val = 0x01020304;
|
||||
printf("swab32(0x%08x) = 0x%0x\n", val, swab32(val));
|
||||
#ifndef _WIN32
|
||||
override_func1();
|
||||
override_func2();
|
||||
/* The base_func ref from the following inline asm should find
|
||||
the global one, not the local decl from this function. */
|
||||
asm volatile(".weak override_func3\n.set override_func3, base_func");
|
||||
override_func3();
|
||||
printf("asmstr: %s\n", get_asm_string());
|
||||
#endif
|
||||
/* Check that we can also load structs of appropriate layout
|
||||
@ -3319,7 +3324,6 @@ void asm_test(void)
|
||||
8 bit. */
|
||||
asm volatile("cmp %1,%2; sete %0" : "=a"(somebool) : "r"(1), "r"(2));
|
||||
if (!somebool)
|
||||
printf("asmbool: failed\n");
|
||||
printf("asmbool: failed\n");
|
||||
#endif
|
||||
val = 43;
|
||||
@ -3677,10 +3681,12 @@ typedef struct gate_struct64 gate_desc;
|
||||
} __attribute__((packed));
|
||||
typedef struct gate_struct64 gate_desc;
|
||||
gate_desc a_gate_desc;
|
||||
void attrib_test(void)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
printf("attr: %d %d %d %d\n", sizeof(struct Spacked),
|
||||
sizeof(spacked), sizeof(Spacked2), sizeof(spacked2));
|
||||
printf("attr: %d %d\n", sizeof(Spacked3), sizeof(spacked3));
|
||||
printf("attr: %d %d\n", sizeof(gate_desc), sizeof(a_gate_desc));
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -63,7 +63,7 @@ all test: $(filter-out $(SKIP),$(TESTS))
|
||||
|
||||
# automatically generate .expect files with gcc:
|
||||
%.expect : %.c
|
||||
(gcc -w $*.c -o a.exe && ./a.exe $(ARGS)) >$*.expect 2>&1; rm -f a.exe
|
||||
(gcc -w $*.c -o a.exe && ./a.exe $(ARGS)) $(FILTER) >$*.expect 2>&1; rm -f a.exe
|
||||
|
||||
# tell make not to delete
|
||||
.PRECIOUS: %.expect
|
||||
|
||||
Reference in New Issue
Block a user