]> granicus.if.org Git - strace/blob - tests/readlink.c
tests: convert readlink.test and readlinkat.test from match_awk to match_diff
[strace] / tests / readlink.c
1 #ifdef HAVE_CONFIG_H
2 # include "config.h"
3 #endif
4
5 #include <stdio.h>
6 #include <unistd.h>
7 #include <sys/syscall.h>
8
9 int
10 main(void)
11 {
12 #ifdef __NR_readlink
13         static const char fname[] = "readlink.link";
14         unsigned char buf[31];
15         long rc;
16         unsigned int i;
17
18         rc = syscall(__NR_readlink, fname, buf, sizeof(buf));
19         if (rc < 0)
20                 return 77;
21
22         printf("readlink(\"");
23         for (i = 0; fname[i]; ++i)
24                 printf("\\x%02x", (int) (unsigned char) fname[i]);
25         printf("\", \"");
26         for (i = 0; i < 3; ++i)
27                 printf("\\x%02x", (int) buf[i]);
28         printf("\"..., %zu) = %ld\n", sizeof(buf), rc);
29
30         puts("+++ exited with 0 +++");
31         return 0;
32 #else
33         return 77;
34 #endif
35 }