mirror of
https://github.com/mirror/tinycc.git
synced 2025-01-15 05:20:06 +08:00
test 104: adjust to (unwritten) tests2 suite conventions
... which IMO are: 1) files don't need a _test suffix because all files in the directory are tests ;) 2) we test the BEHAVIOR of the program, rather than its binary bit contents. Ok, but nobody said a test can't use two files ;) (where the 104+_ construct is meant to prevent the file from being picked up by the makefile as a test on its own).
This commit is contained in:
parent
5dfcc7506c
commit
e6d8f9a8bb
54
tests/tests2/104+_inline.c
Normal file
54
tests/tests2/104+_inline.c
Normal file
@ -0,0 +1,54 @@
|
||||
|
||||
#define GOT(f) \
|
||||
__attribute__((weak)) void f(void); \
|
||||
printf("%d %s\n", !!f, #f);
|
||||
|
||||
int printf(const char*, ...);
|
||||
|
||||
void check_exports()
|
||||
{
|
||||
// 0
|
||||
GOT(inline_inline_2decl_only)
|
||||
GOT(inline_inline_undeclared)
|
||||
GOT(inline_inline_predeclared)
|
||||
GOT(inline_inline_postdeclared)
|
||||
GOT(inline_inline_prepostdeclared)
|
||||
GOT(inline_inline_undeclared2)
|
||||
GOT(inline_inline_predeclared2)
|
||||
GOT(inline_inline_postdeclared2)
|
||||
GOT(inline_inline_prepostdeclared2)
|
||||
|
||||
// 1
|
||||
GOT(extern_extern_postdeclared)
|
||||
GOT(extern_extern_postdeclared2)
|
||||
GOT(extern_extern_predeclared)
|
||||
GOT(extern_extern_predeclared2)
|
||||
GOT(extern_extern_prepostdeclared)
|
||||
GOT(extern_extern_prepostdeclared2)
|
||||
GOT(extern_extern_undeclared)
|
||||
GOT(extern_extern_undeclared2)
|
||||
GOT(extern_postdeclared)
|
||||
GOT(extern_postdeclared2)
|
||||
GOT(extern_predeclared)
|
||||
GOT(extern_predeclared2)
|
||||
GOT(extern_prepostdeclared)
|
||||
GOT(extern_undeclared)
|
||||
GOT(extern_undeclared2)
|
||||
GOT(inst2_extern_inline_postdeclared)
|
||||
GOT(inst2_extern_inline_predeclared)
|
||||
GOT(inst3_extern_inline_predeclared)
|
||||
GOT(inst_extern_inline_postdeclared)
|
||||
GOT(inst_extern_inline_predeclared)
|
||||
GOT(main)
|
||||
GOT(noinst_extern_inline_func)
|
||||
GOT(noinst_extern_inline_postdeclared)
|
||||
GOT(noinst_extern_inline_postdeclared2)
|
||||
GOT(noinst_extern_inline_undeclared)
|
||||
|
||||
// 0
|
||||
GOT(noinst_static_inline_postdeclared)
|
||||
GOT(noinst2_static_inline_postdeclared)
|
||||
GOT(noinst_static_inline_predeclared)
|
||||
GOT(noinst2_static_inline_predeclared)
|
||||
GOT(static_func)
|
||||
}
|
132
tests/tests2/104_inline.c
Normal file
132
tests/tests2/104_inline.c
Normal file
@ -0,0 +1,132 @@
|
||||
inline void inline_inline_2decl_only(void);
|
||||
inline void inline_inline_2decl_only(void);
|
||||
|
||||
inline void inline_inline_undeclared(void){}
|
||||
|
||||
inline void inline_inline_predeclared(void);
|
||||
inline void inline_inline_predeclared(void){}
|
||||
|
||||
inline void inline_inline_postdeclared(void){}
|
||||
inline void inline_inline_postdeclared(void);
|
||||
|
||||
inline void inline_inline_prepostdeclared(void);
|
||||
inline void inline_inline_prepostdeclared(void){}
|
||||
inline void inline_inline_prepostdeclared(void);
|
||||
|
||||
inline void inline_inline_undeclared2(void){}
|
||||
|
||||
inline void inline_inline_predeclared2(void);
|
||||
inline void inline_inline_predeclared2(void);
|
||||
inline void inline_inline_predeclared2(void){}
|
||||
|
||||
inline void inline_inline_postdeclared2(void){}
|
||||
inline void inline_inline_postdeclared2(void);
|
||||
inline void inline_inline_postdeclared2(void);
|
||||
|
||||
inline void inline_inline_prepostdeclared2(void);
|
||||
inline void inline_inline_prepostdeclared2(void);
|
||||
inline void inline_inline_prepostdeclared2(void){}
|
||||
inline void inline_inline_prepostdeclared2(void);
|
||||
inline void inline_inline_prepostdeclared2(void);
|
||||
|
||||
extern void extern_extern_undeclared(void){}
|
||||
|
||||
extern void extern_extern_predeclared(void);
|
||||
extern void extern_extern_predeclared(void){}
|
||||
|
||||
extern void extern_extern_postdeclared(void){}
|
||||
extern void extern_extern_postdeclared(void);
|
||||
|
||||
extern void extern_extern_prepostdeclared(void);
|
||||
extern void extern_extern_prepostdeclared(void){}
|
||||
extern void extern_extern_prepostdeclared(void);
|
||||
|
||||
extern void extern_extern_undeclared2(void){}
|
||||
|
||||
extern void extern_extern_predeclared2(void);
|
||||
extern void extern_extern_predeclared2(void);
|
||||
extern void extern_extern_predeclared2(void){}
|
||||
|
||||
extern void extern_extern_postdeclared2(void){}
|
||||
extern void extern_extern_postdeclared2(void);
|
||||
extern void extern_extern_postdeclared2(void);
|
||||
|
||||
extern void extern_extern_prepostdeclared2(void);
|
||||
extern void extern_extern_prepostdeclared2(void);
|
||||
extern void extern_extern_prepostdeclared2(void){}
|
||||
extern void extern_extern_prepostdeclared2(void);
|
||||
extern void extern_extern_prepostdeclared2(void);
|
||||
|
||||
void extern_undeclared(void){}
|
||||
|
||||
void extern_predeclared(void);
|
||||
void extern_predeclared(void){}
|
||||
|
||||
void extern_postdeclared(void){}
|
||||
void extern_postdeclared(void);
|
||||
|
||||
void extern_prepostdeclared(void);
|
||||
void extern_prepostdeclared(void){}
|
||||
void extern_prepostdeclared(void);
|
||||
|
||||
void extern_undeclared2(void){}
|
||||
|
||||
void extern_predeclared2(void);
|
||||
void extern_predeclared2(void);
|
||||
void extern_predeclared2(void){}
|
||||
|
||||
void extern_postdeclared2(void){}
|
||||
void extern_postdeclared2(void);
|
||||
void extern_postdeclared2(void);
|
||||
|
||||
|
||||
extern inline void noinst_extern_inline_undeclared(void){}
|
||||
|
||||
extern inline void noinst_extern_inline_postdeclared(void){}
|
||||
inline void noinst_extern_inline_postdeclared(void);
|
||||
|
||||
extern inline void noinst_extern_inline_postdeclared2(void){}
|
||||
inline void noinst_extern_inline_postdeclared2(void);
|
||||
inline void noinst_extern_inline_postdeclared2(void);
|
||||
|
||||
extern inline void inst_extern_inline_postdeclared(void){}
|
||||
extern inline void inst_extern_inline_postdeclared(void);
|
||||
inline void inst2_extern_inline_postdeclared(void){}
|
||||
void inst2_extern_inline_postdeclared(void);
|
||||
|
||||
void inst_extern_inline_predeclared(void);
|
||||
extern inline void inst_extern_inline_predeclared(void){}
|
||||
void inst2_extern_inline_predeclared(void);
|
||||
inline void inst2_extern_inline_predeclared(void){}
|
||||
extern inline void inst3_extern_inline_predeclared(void);
|
||||
inline void inst3_extern_inline_predeclared(void){}
|
||||
|
||||
static inline void noinst_static_inline_postdeclared(void){}
|
||||
static inline void noinst_static_inline_postdeclared(void);
|
||||
static inline void noinst2_static_inline_postdeclared(void){}
|
||||
static void noinst2_static_inline_postdeclared(void);
|
||||
|
||||
static void noinst_static_inline_predeclared(void);
|
||||
static inline void noinst_static_inline_predeclared(void){}
|
||||
static void noinst2_static_inline_predeclared(void);
|
||||
static inline void noinst2_static_inline_predeclared(void){}
|
||||
|
||||
static void static_func(void);
|
||||
void static_func(void) { }
|
||||
|
||||
inline void noinst_extern_inline_func(void);
|
||||
void noinst_extern_inline_func(void) { }
|
||||
|
||||
int main()
|
||||
{
|
||||
inline_inline_undeclared(); inline_inline_predeclared(); inline_inline_postdeclared();
|
||||
inline_inline_undeclared2(); inline_inline_predeclared2(); inline_inline_postdeclared2();
|
||||
noinst_static_inline_predeclared();
|
||||
noinst2_static_inline_predeclared();
|
||||
noinst_static_inline_predeclared();
|
||||
noinst2_static_inline_predeclared();
|
||||
|
||||
void check_exports();
|
||||
check_exports();
|
||||
return 0;
|
||||
}
|
39
tests/tests2/104_inline.expect
Normal file
39
tests/tests2/104_inline.expect
Normal file
@ -0,0 +1,39 @@
|
||||
0 inline_inline_2decl_only
|
||||
0 inline_inline_undeclared
|
||||
0 inline_inline_predeclared
|
||||
0 inline_inline_postdeclared
|
||||
0 inline_inline_prepostdeclared
|
||||
0 inline_inline_undeclared2
|
||||
0 inline_inline_predeclared2
|
||||
0 inline_inline_postdeclared2
|
||||
0 inline_inline_prepostdeclared2
|
||||
1 extern_extern_postdeclared
|
||||
1 extern_extern_postdeclared2
|
||||
1 extern_extern_predeclared
|
||||
1 extern_extern_predeclared2
|
||||
1 extern_extern_prepostdeclared
|
||||
1 extern_extern_prepostdeclared2
|
||||
1 extern_extern_undeclared
|
||||
1 extern_extern_undeclared2
|
||||
1 extern_postdeclared
|
||||
1 extern_postdeclared2
|
||||
1 extern_predeclared
|
||||
1 extern_predeclared2
|
||||
1 extern_prepostdeclared
|
||||
1 extern_undeclared
|
||||
1 extern_undeclared2
|
||||
1 inst2_extern_inline_postdeclared
|
||||
1 inst2_extern_inline_predeclared
|
||||
1 inst3_extern_inline_predeclared
|
||||
1 inst_extern_inline_postdeclared
|
||||
1 inst_extern_inline_predeclared
|
||||
1 main
|
||||
1 noinst_extern_inline_func
|
||||
1 noinst_extern_inline_postdeclared
|
||||
1 noinst_extern_inline_postdeclared2
|
||||
1 noinst_extern_inline_undeclared
|
||||
0 noinst_static_inline_postdeclared
|
||||
0 noinst2_static_inline_postdeclared
|
||||
0 noinst_static_inline_predeclared
|
||||
0 noinst2_static_inline_predeclared
|
||||
0 static_func
|
@ -1,180 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int str2file(const char *str, const char *fname)
|
||||
{
|
||||
FILE *f = fopen(fname, "wb");
|
||||
return !(f && fputs(str, f) >= 0 && fclose(f) == 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Wrap this sh script, which is compared to .expect (x.c is cFileContents):
|
||||
* tcc -c x.c && nm -Ptx x.o | awk '{ if($2 == "T") print $1 }' | LC_ALL=C sort
|
||||
* FIXME: Makefile should do it directly without this wrapper.
|
||||
*
|
||||
* Uses: sh, nm, awk, sort.
|
||||
* Good enough: we use fixed temp files at CWD to avoid abs path conversions
|
||||
* between *nix/Windows representations (shell, FILE APIs, tcc CLI arguments).
|
||||
*/
|
||||
#define TMP_SCRIPT "tmp-t104.sh"
|
||||
#define TMP_C "tmp-t104.c"
|
||||
#define TMP_O "tmp-t104.o"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
extern char const cfileContents[];
|
||||
const char *tcc;
|
||||
char script[1024];
|
||||
int r = 1;
|
||||
/* errors at system(..) or the script show at the diff to .expect */
|
||||
|
||||
/* TESTED_TCC is path/to/tcc + arguments */
|
||||
if (!(tcc = argc > 1 ? argv[1] : getenv("TESTED_TCC")))
|
||||
return fputs("unknown tcc executable", stderr), 1;
|
||||
|
||||
sprintf(script,
|
||||
"%s -c "TMP_C" -o "TMP_O" || exit 1\n"
|
||||
"nm -Ptx "TMP_O" | awk '{ if($2 == \"T\") print $1 }' | LC_ALL=C sort\n"
|
||||
, tcc);
|
||||
|
||||
if (str2file(cfileContents, TMP_C) || str2file(script, TMP_SCRIPT))
|
||||
perror("create "TMP_C"/"TMP_SCRIPT);
|
||||
else
|
||||
r = system("sh "TMP_SCRIPT);
|
||||
|
||||
remove(TMP_SCRIPT);
|
||||
remove(TMP_C);
|
||||
remove(TMP_O);
|
||||
return r;
|
||||
}
|
||||
|
||||
char const cfileContents[]=
|
||||
"inline void inline_inline_2decl_only(void);\n"
|
||||
"inline void inline_inline_2decl_only(void);\n"
|
||||
"\n"
|
||||
"inline void inline_inline_undeclared(void){}\n"
|
||||
"\n"
|
||||
"inline void inline_inline_predeclared(void);\n"
|
||||
"inline void inline_inline_predeclared(void){}\n"
|
||||
"\n"
|
||||
"inline void inline_inline_postdeclared(void){}\n"
|
||||
"inline void inline_inline_postdeclared(void);\n"
|
||||
"\n"
|
||||
"inline void inline_inline_prepostdeclared(void);\n"
|
||||
"inline void inline_inline_prepostdeclared(void){}\n"
|
||||
"inline void inline_inline_prepostdeclared(void);\n"
|
||||
"\n"
|
||||
"inline void inline_inline_undeclared2(void){}\n"
|
||||
"\n"
|
||||
"inline void inline_inline_predeclared2(void);\n"
|
||||
"inline void inline_inline_predeclared2(void);\n"
|
||||
"inline void inline_inline_predeclared2(void){}\n"
|
||||
"\n"
|
||||
"inline void inline_inline_postdeclared2(void){}\n"
|
||||
"inline void inline_inline_postdeclared2(void);\n"
|
||||
"inline void inline_inline_postdeclared2(void);\n"
|
||||
"\n"
|
||||
"inline void inline_inline_prepostdeclared2(void);\n"
|
||||
"inline void inline_inline_prepostdeclared2(void);\n"
|
||||
"inline void inline_inline_prepostdeclared2(void){}\n"
|
||||
"inline void inline_inline_prepostdeclared2(void);\n"
|
||||
"inline void inline_inline_prepostdeclared2(void);\n"
|
||||
"\n"
|
||||
"extern void extern_extern_undeclared(void){}\n"
|
||||
"\n"
|
||||
"extern void extern_extern_predeclared(void);\n"
|
||||
"extern void extern_extern_predeclared(void){}\n"
|
||||
"\n"
|
||||
"extern void extern_extern_postdeclared(void){}\n"
|
||||
"extern void extern_extern_postdeclared(void);\n"
|
||||
"\n"
|
||||
"extern void extern_extern_prepostdeclared(void);\n"
|
||||
"extern void extern_extern_prepostdeclared(void){}\n"
|
||||
"extern void extern_extern_prepostdeclared(void);\n"
|
||||
"\n"
|
||||
"extern void extern_extern_undeclared2(void){}\n"
|
||||
"\n"
|
||||
"extern void extern_extern_predeclared2(void);\n"
|
||||
"extern void extern_extern_predeclared2(void);\n"
|
||||
"extern void extern_extern_predeclared2(void){}\n"
|
||||
"\n"
|
||||
"extern void extern_extern_postdeclared2(void){}\n"
|
||||
"extern void extern_extern_postdeclared2(void);\n"
|
||||
"extern void extern_extern_postdeclared2(void);\n"
|
||||
"\n"
|
||||
"extern void extern_extern_prepostdeclared2(void);\n"
|
||||
"extern void extern_extern_prepostdeclared2(void);\n"
|
||||
"extern void extern_extern_prepostdeclared2(void){}\n"
|
||||
"extern void extern_extern_prepostdeclared2(void);\n"
|
||||
"extern void extern_extern_prepostdeclared2(void);\n"
|
||||
"\n"
|
||||
"void extern_undeclared(void){}\n"
|
||||
"\n"
|
||||
"void extern_predeclared(void);\n"
|
||||
"void extern_predeclared(void){}\n"
|
||||
"\n"
|
||||
"void extern_postdeclared(void){}\n"
|
||||
"void extern_postdeclared(void);\n"
|
||||
"\n"
|
||||
"void extern_prepostdeclared(void);\n"
|
||||
"void extern_prepostdeclared(void){}\n"
|
||||
"void extern_prepostdeclared(void);\n"
|
||||
"\n"
|
||||
"void extern_undeclared2(void){}\n"
|
||||
"\n"
|
||||
"void extern_predeclared2(void);\n"
|
||||
"void extern_predeclared2(void);\n"
|
||||
"void extern_predeclared2(void){}\n"
|
||||
"\n"
|
||||
"void extern_postdeclared2(void){}\n"
|
||||
"void extern_postdeclared2(void);\n"
|
||||
"void extern_postdeclared2(void);\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"extern inline void noinst_extern_inline_undeclared(void){}\n"
|
||||
"\n"
|
||||
"extern inline void noinst_extern_inline_postdeclared(void){}\n"
|
||||
"inline void noinst_extern_inline_postdeclared(void);\n"
|
||||
"\n"
|
||||
"extern inline void noinst_extern_inline_postdeclared2(void){}\n"
|
||||
"inline void noinst_extern_inline_postdeclared2(void);\n"
|
||||
"inline void noinst_extern_inline_postdeclared2(void);\n"
|
||||
"\n"
|
||||
"extern inline void inst_extern_inline_postdeclared(void){}\n"
|
||||
"extern inline void inst_extern_inline_postdeclared(void);\n"
|
||||
"inline void inst2_extern_inline_postdeclared(void){}\n"
|
||||
"void inst2_extern_inline_postdeclared(void);\n"
|
||||
"\n"
|
||||
"void inst_extern_inline_predeclared(void);\n"
|
||||
"extern inline void inst_extern_inline_predeclared(void){}\n"
|
||||
"void inst2_extern_inline_predeclared(void);\n"
|
||||
"inline void inst2_extern_inline_predeclared(void){}\n"
|
||||
"extern inline void inst3_extern_inline_predeclared(void);\n"
|
||||
"inline void inst3_extern_inline_predeclared(void){}\n"
|
||||
"\n"
|
||||
"static inline void noinst_static_inline_postdeclared(void){}\n"
|
||||
"static inline void noinst_static_inline_postdeclared(void);\n"
|
||||
"static inline void noinst2_static_inline_postdeclared(void){}\n"
|
||||
"static void noinst2_static_inline_postdeclared(void);\n"
|
||||
"\n"
|
||||
"static void noinst_static_inline_predeclared(void);\n"
|
||||
"static inline void noinst_static_inline_predeclared(void){}\n"
|
||||
"static void noinst2_static_inline_predeclared(void);\n"
|
||||
"static inline void noinst2_static_inline_predeclared(void){}\n"
|
||||
"\n"
|
||||
"static void static_func(void);\n"
|
||||
"void static_func(void) { }\n"
|
||||
"\n"
|
||||
"inline void noinst_extern_inline_func(void);\n"
|
||||
"void noinst_extern_inline_func(void) { }\n"
|
||||
"int main()\n"
|
||||
"{\n"
|
||||
" inline_inline_undeclared(); inline_inline_predeclared(); inline_inline_postdeclared();\n"
|
||||
" inline_inline_undeclared2(); inline_inline_predeclared2(); inline_inline_postdeclared2();\n"
|
||||
" noinst_static_inline_predeclared();\n"
|
||||
" noinst2_static_inline_predeclared();\n"
|
||||
" noinst_static_inline_predeclared();\n"
|
||||
" noinst2_static_inline_predeclared();\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
;
|
@ -1,25 +0,0 @@
|
||||
extern_extern_postdeclared
|
||||
extern_extern_postdeclared2
|
||||
extern_extern_predeclared
|
||||
extern_extern_predeclared2
|
||||
extern_extern_prepostdeclared
|
||||
extern_extern_prepostdeclared2
|
||||
extern_extern_undeclared
|
||||
extern_extern_undeclared2
|
||||
extern_postdeclared
|
||||
extern_postdeclared2
|
||||
extern_predeclared
|
||||
extern_predeclared2
|
||||
extern_prepostdeclared
|
||||
extern_undeclared
|
||||
extern_undeclared2
|
||||
inst2_extern_inline_postdeclared
|
||||
inst2_extern_inline_predeclared
|
||||
inst3_extern_inline_predeclared
|
||||
inst_extern_inline_postdeclared
|
||||
inst_extern_inline_predeclared
|
||||
main
|
||||
noinst_extern_inline_func
|
||||
noinst_extern_inline_postdeclared
|
||||
noinst_extern_inline_postdeclared2
|
||||
noinst_extern_inline_undeclared
|
@ -3,9 +3,6 @@ include $(TOP)/Makefile
|
||||
SRC = $(TOPSRC)/tests/tests2
|
||||
VPATH = $(SRC)
|
||||
|
||||
# used by 104_inline_test.c
|
||||
export TESTED_TCC = $(TCC)
|
||||
|
||||
TESTS = $(patsubst %.c,%.test,\
|
||||
$(sort $(notdir $(wildcard $(SRC)/??_*.c)))\
|
||||
$(sort $(notdir $(wildcard $(SRC)/???_*.c))))
|
||||
@ -59,6 +56,10 @@ GEN-ALWAYS =
|
||||
# using the ms compiler for the really ms-compatible bitfields
|
||||
95_bitfields_ms.test : GEN = $(GEN-MSC)
|
||||
|
||||
# this test compiles/links two files:
|
||||
104_inline.test : FLAGS += 104+_inline.c
|
||||
104_inline.test : GEN = $(GEN-TCC)
|
||||
|
||||
# Filter source directory in warnings/errors (out-of-tree builds)
|
||||
FILTER = 2>&1 | sed 's,$(SRC)/,,g'
|
||||
# Filter some always-warning
|
||||
|
Loading…
Reference in New Issue
Block a user