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