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
3#include <signal.h>3#include <signal.h>
4#include <errno.h>4#include <errno.h>
5 5
6extern char const cfileContents[];6#if defined(_WIN32)
7char c[]="/tmp/tcc-XXXXXX.c";7#endif
8char o[]="/tmp/tcc-XXXXXX.o";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
14char c[]="/tmp/tcc-XXXXXX"; char o[]="/tmp/tcc-XXXXXX";
15static 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
28char c[1024]; char o[1024];
29static 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
9void rmh(int Sig)44void rmh(int Sig)
10{45{
11 remove(c);46 remove(c);
@@ -24,22 +59,23 @@ int str2file(char const *fnm, char const *str) · 12 unmodified lines
24int main(int C, char **V)59int main(int C, char **V)
25{60{
26 int r=0;61 int r=0;
27 if (system("which nm >/dev/null 2>&1")){ return 0; }62 if (system(SYS_WHICH_NM)){ return 0; }
28 signal(SIGINT,SIG_IGN);63 signal(SIGINT,SIG_IGN);
29 signal(SIGTERM,SIG_IGN);64 signal(SIGTERM,SIG_IGN);
30 if(0>mkstemps(c,2)) return perror("mkstemps"),1;65 if(0>mktempfile(c)) return perror("mkstemps"),1;
31 if(0>mkstemps(o,2)){66 if(0>mktempfile(o)){
32 if(0>remove(c)) perror("remove");67 if(0>remove(c)) perror("remove");
33 return perror("mkstemps"),1;68 return perror("mkstemps"),1;
34 }69 }
35 signal(SIGINT,rmh);70 signal(SIGINT,rmh);
36 signal(SIGTERM,rmh);71 signal(SIGTERM,rmh);
72 extern char const cfileContents[];
37 if(0>str2file(c, cfileContents)) { perror("write");r=1;goto out;}73 if(0>str2file(c, cfileContents)) { perror("write");r=1;goto out;}
38 char buf[1024];74 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;}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;}
40 sprintf(buf, "nm -Ptx %s > %s", o, c); if(system(buf)) {r=1;goto out;}76 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;}77 sprintf(buf, "gawk '{ 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;}78 sprintf(buf, "sort %s", o); if(system(buf)) {r=1;goto out;}
43out:79out:
44 remove(c);80 remove(c);
45 remove(o);81 remove(o);
@@ -175,4 +211,3 @@ char const cfileContents[]= · 129 unmodified lines
175"}\n"211"}\n"
176"\n"212"\n"
177;213;
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