blob: 3135df2278507b675fa560dbab0b467bf3dd28ff [file] [log] [blame]
JayRJoshi39ab1202016-03-23 19:08:35 +05301#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
11int
12main(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
37SKIP_MAIN_UNDEFINED("__NR_getcwd");
38
39#endif