History

Add Windows support for tests of inline functions - test 104

Christian Jullien committed 7 years ago

Commit 78ee3eb1 parent cb73be51 file · +46 −11Browse files

Unified · Split

tests/tests2/104_inline_test.c+46−11
@@ -3,9 +3,44 @@ · 2 unmodified lines
33 #include <signal.h>
44 #include <errno.h>
55
6−extern char const cfileContents[];
7−char c[]="/tmp/tcc-XXXXXX.c";
8−char o[]="/tmp/tcc-XXXXXX.o";
6+#if defined(_WIN32)
7+#endif
8+
9+#if __linux__ || __APPLE__
10+#define SYS_WHICH_NM "which nm >/dev/null 2>&1"
11+#define TCC_COMPILER "../../tcc"
12+#define SYS_AWK
13+
14+char c[]="/tmp/tcc-XXXXXX"; char o[]="/tmp/tcc-XXXXXX";
15+static int mktempfile(char *buf)
16+{
17+ return mkstemps(buf,0);
18+}
19+#elif defined(_WIN32)
20+#define SYS_WHICH_NM "which nm >nul 2>&1"
21+
22+#if defined(_WIN64)
23+#define TCC_COMPILER "..\\..\\win32\\x86_64-win32-tcc"
24+#else
25+#define TCC_COMPILER "..\\..\\win32\\i386-win32-tcc"
26+#endif
27+
28+char c[1024]; char o[1024];
29+static int mktempfile(char *buf)
30+{
31+ /*
32+ * WARNING, this simplified 'mktemp' like function
33+ * create two temporary Windows files having always
34+ * the same name. It is enought for tcc test suite.
35+ */
36+ if (buf == c) {
37+ sprintf(c, "%s\\tcc-temp1", getenv("LOCALAPPDATA"));
38+ } else {
39+ sprintf(o, "%s\\tcc-temp2", getenv("LOCALAPPDATA"));
40+ }
41+}
42+#endif
43+
944 void rmh(int Sig)
1045 {
1146 remove(c);
@@ -24,22 +59,23 @@ int str2file(char const *fnm, char const *str) · 12 unmodified lines
2459 int main(int C, char **V)
2560 {
2661 int r=0;
27− if (system("which nm >/dev/null 2>&1")){ return 0; }
62+ if (system(SYS_WHICH_NM)){ return 0; }
2863 signal(SIGINT,SIG_IGN);
2964 signal(SIGTERM,SIG_IGN);
30− if(0>mkstemps(c,2)) return perror("mkstemps"),1;
31− if(0>mkstemps(o,2)){
65+ if(0>mktempfile(c)) return perror("mkstemps"),1;
66+ if(0>mktempfile(o)){
3267 if(0>remove(c)) perror("remove");
3368 return perror("mkstemps"),1;
3469 }
3570 signal(SIGINT,rmh);
3671 signal(SIGTERM,rmh);
72+ extern char const cfileContents[];
3773 if(0>str2file(c, cfileContents)) { perror("write");r=1;goto out;}
3874 char buf[1024];
39− sprintf(buf, "%s -c %s -o %s", V[1]?V[1]:"../../tcc", c, o); if(0!=system(buf)){ r=1;goto out;}
40− sprintf(buf, "nm -Ptx %s > %s", o, c); if(system(buf)) {r=1;goto out;}
41− sprintf(buf, "awk '{ if($2 == \"T\") print $1 }' %s > %s", c, o); if(system(buf)) {r=1;goto out;}
42− sprintf(buf, "sort %s", o); if(system(buf)) {r=1;goto out;}
75+ sprintf(buf, "%s -c -xc %s -o %s", V[1]?V[1]:TCC_COMPILER, c, o); if(0!=system(buf)){ r=1;goto out;}
76+ sprintf(buf, "nm -Ptx %s > %s", o, c); if(system(buf)) {r=1;goto out;}
77+ sprintf(buf, "gawk '{ if($2 == \"T\") print $1 }' %s > %s", c, o); if(system(buf)) {r=1;goto out;}
78+ sprintf(buf, "sort %s", o); if(system(buf)) {r=1;goto out;}
4379 out:
4480 remove(c);
4581 remove(o);
@@ -175,4 +211,3 @@ char const cfileContents[]= · 129 unmodified lines
175211 "}\n"
176212 "\n"
177213 ;
178−

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t