Revision 3b46e624 tests/linux-test.c
b/tests/linux-test.c | ||
---|---|---|
93 | 93 |
|
94 | 94 |
if (getcwd(cur_dir, sizeof(cur_dir)) == NULL) |
95 | 95 |
error("getcwd"); |
96 |
|
|
96 |
|
|
97 | 97 |
chk_error(mkdir(TESTPATH, 0755)); |
98 |
|
|
98 |
|
|
99 | 99 |
chk_error(chdir(TESTPATH)); |
100 |
|
|
100 |
|
|
101 | 101 |
/* open/read/write/close/readv/writev/lseek */ |
102 | 102 |
|
103 | 103 |
fd = chk_error(open("file1", O_WRONLY | O_TRUNC | O_CREAT, 0644)); |
... | ... | |
124 | 124 |
error("read"); |
125 | 125 |
if (memcmp(buf, buf2, FILE_BUF_SIZE) != 0) |
126 | 126 |
error("memcmp"); |
127 |
|
|
127 |
|
|
128 | 128 |
#define FOFFSET 16 |
129 | 129 |
ret = chk_error(lseek(fd, FOFFSET, SEEK_SET)); |
130 | 130 |
if (ret != 16) |
... | ... | |
138 | 138 |
error("readv"); |
139 | 139 |
if (memcmp(buf + FOFFSET, buf3, FILE_BUF_SIZE - FOFFSET) != 0) |
140 | 140 |
error("memcmp"); |
141 |
|
|
141 |
|
|
142 | 142 |
chk_error(close(fd)); |
143 | 143 |
|
144 | 144 |
/* access */ |
... | ... | |
171 | 171 |
chk_error(ftruncate(fd, 50)); |
172 | 172 |
chk_error(fstat(fd, &st)); |
173 | 173 |
chk_error(close(fd)); |
174 |
|
|
174 |
|
|
175 | 175 |
if (st.st_size != 50) |
176 | 176 |
error("stat size"); |
177 | 177 |
if (!S_ISREG(st.st_mode)) |
178 | 178 |
error("stat mode"); |
179 |
|
|
179 |
|
|
180 | 180 |
/* symlink/lstat */ |
181 | 181 |
chk_error(symlink("file2", "file3")); |
182 | 182 |
chk_error(lstat("file3", &st)); |
183 | 183 |
if (!S_ISLNK(st.st_mode)) |
184 | 184 |
error("stat mode"); |
185 |
|
|
185 |
|
|
186 | 186 |
/* getdents */ |
187 | 187 |
dir = opendir(TESTPATH); |
188 | 188 |
if (!dir) |
... | ... | |
241 | 241 |
ti = tv2.tv_sec - tv.tv_sec; |
242 | 242 |
if (ti >= 2) |
243 | 243 |
error("gettimeofday"); |
244 |
|
|
244 |
|
|
245 | 245 |
chk_error(getrusage(RUSAGE_SELF, &rusg1)); |
246 | 246 |
for(i = 0;i < 10000; i++); |
247 | 247 |
chk_error(getrusage(RUSAGE_SELF, &rusg2)); |
... | ... | |
327 | 327 |
chk_error(getsockopt(server_fd, SOL_SOCKET, SO_TYPE, &val, &len)); |
328 | 328 |
if (val != SOCK_STREAM) |
329 | 329 |
error("getsockopt"); |
330 |
|
|
330 |
|
|
331 | 331 |
pid = chk_error(fork()); |
332 | 332 |
if (pid == 0) { |
333 | 333 |
client_fd = client_socket(); |
... | ... | |
465 | 465 |
sigemptyset(&act.sa_mask); |
466 | 466 |
act.sa_flags = 0; |
467 | 467 |
chk_error(sigaction(SIGALRM, &act, NULL)); |
468 |
|
|
468 |
|
|
469 | 469 |
it.it_interval.tv_sec = 0; |
470 | 470 |
it.it_interval.tv_usec = 10 * 1000; |
471 | 471 |
it.it_value.tv_sec = 0; |
... | ... | |
475 | 475 |
if (oit.it_value.tv_sec != it.it_value.tv_sec || |
476 | 476 |
oit.it_value.tv_usec != it.it_value.tv_usec) |
477 | 477 |
error("itimer"); |
478 |
|
|
478 |
|
|
479 | 479 |
while (alarm_count < 5) { |
480 | 480 |
usleep(10 * 1000); |
481 | 481 |
} |
... | ... | |
498 | 498 |
if (setjmp(jmp_env) == 0) { |
499 | 499 |
*(uint8_t *)0 = 0; |
500 | 500 |
} |
501 |
|
|
501 |
|
|
502 | 502 |
act.sa_handler = SIG_DFL; |
503 | 503 |
sigemptyset(&act.sa_mask); |
504 | 504 |
act.sa_flags = 0; |
Also available in: Unified diff