Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / sanitizer_common / TestCases / Posix / readlinkat.c
blob227c6da54afbb0f4bf2ac55457a82a2eda7ab4bb
1 // RUN: %clang -O0 %s -o %t && %run %t
3 // XFAIL: i386-netbsd && asan
5 #include <assert.h>
6 #include <fcntl.h>
7 #include <limits.h>
8 #include <stdio.h>
9 #include <string.h>
10 #include <unistd.h>
12 int main(int argc, char **argv) {
13 char symlink_path[PATH_MAX];
14 snprintf(symlink_path, sizeof(symlink_path), "%s_%d.symlink", argv[0],
15 getpid());
16 remove(symlink_path);
17 int res = symlink(argv[0], symlink_path);
18 assert(!res);
20 char readlinkat_path[PATH_MAX];
21 int res2 = readlinkat(AT_FDCWD, symlink_path, readlinkat_path,
22 sizeof(readlinkat_path));
23 assert(res2 >= 0);
24 readlinkat_path[res2] = '\0';
25 assert(!strcmp(readlinkat_path, argv[0]));
27 return 0;