]> granicus.if.org Git - strace/blob - tests/getcwd.c
Mpersify RTC_* ioctl parser
[strace] / tests / getcwd.c
1 #include "tests.h"
2
3 #include <sys/syscall.h>
4
5 #ifdef __NR_getcwd
6
7 # include <stdio.h>
8 # include <unistd.h>
9 # include <sys/param.h>
10
11 int
12 main(void)
13 {
14         long res;
15         char cur_dir[PATH_MAX + 1];
16
17         res = syscall(__NR_getcwd, cur_dir, sizeof(cur_dir));
18
19         if (res <= 0)
20                 perror_msg_and_fail("getcwd");
21
22         printf("getcwd(\"");
23         print_quoted_string(cur_dir);
24         printf("\", %zu) = %ld\n", sizeof(cur_dir), res);
25
26         syscall(__NR_getcwd, cur_dir, 0);
27
28         printf("getcwd(%p, 0) = -1 ERANGE (%m)\n", cur_dir);
29
30         puts("+++ exited with 0 +++");
31
32         return 0;
33 }
34
35 #else
36
37 SKIP_MAIN_UNDEFINED("__NR_getcwd");
38
39 #endif