1 tst note{ check for win32 .exe botches }end output{
7 cp(const char* from, const char* to)
15 if ((fd = _open(from, O_RDONLY|O_BINARY)) < 0)
17 if (_fstat(fd, &fs) || (td = _open(to, O_CREAT|O_WRONLY|O_TRUNC|O_BINARY, fs.st_mode & 0777)) < 0)
22 while ((n = _read(fd, buf, sizeof(buf))) > 0 && _write(td, buf, n) == n);
28 main(int argc, char** argv)
35 snprintf(buf, sizeof(buf), "rm -rf /tmp/iff-%d", getpid());
36 if (_mkdir(buf+7, 0755))
40 if (cp("/bin/cat.exe", "foo.exe"))
43 if (_access("foo", X_OK))
44 fix++,printf("#define _win32_botch_access 1\n");
45 if (_chmod("foo", 0755))
46 fix++,printf("#define _win32_botch_chmod 1\n");
47 if (cp("/bin/cat", "bam") || _access("bam.exe", X_OK))
48 fix++,printf("#define _win32_botch_copy 1\n");
49 if (_getpagesize() != 64 * 1024)
50 fix++,printf("#define _win32_botch_getpagesize 1\n");
52 if (_link("foo", "bar") || _access("bar.exe", X_OK))
53 fix++,printf("#define _win32_botch_link 1\n");
56 cp("foo.exe", "bar.exe");
57 if ((fd = _open("foo", O_RDONLY)) < 0)
58 fix++,printf("#define _win32_botch_open 1\n");
61 if (_pathconf("huh", _PC_NAME_MAX) >= 0)
62 fix++,printf("#define _win32_botch_pathconf 1\n");
63 if (_rename("foo", "aha") || _access("aha.exe", X_OK))
64 fix++,printf("#define _win32_botch_rename 1\n");
66 _rename("foo.exe", "aha.exe");
67 if (_stat("bar", &st))
69 fix++,printf("#define _win32_botch_stat 1\n");
70 if (sizeof(st.st_ino) == 8)
71 printf("#define _stat _stat64\n");
73 if (_truncate("aha", 0))
74 fix++,printf("#define _win32_botch_truncate 1\n");
76 fix++,printf("#define _win32_botch_unlink 1\n");
78 fix++,printf("#define _win32_botch_utime 1\n");
81 printf("#define _win32_botch_execve 1\n");
82 printf("#define _win32_botch 1\n");
90 tst win32_botch_alarm note{ win32 alarm(2) return botched }end noexecute{
95 static int sigalrm = 0;
103 main(int argc, char** argv)
105 signal(SIGALRM, handler);
108 return sigalrm != 1 || alarm(0) != 0;