[asan] Revert r201402, r201404.
[blocksruntime.git] / lib / msan / lit_tests / scandir_null.cc
blob84af7f418d219a0a87b253336320c00385d21e2e
1 // RUN: %clangxx_msan -m64 -O0 %s -o %t && %t %p
2 // RUN: %clangxx_msan -m64 -O0 -D_FILE_OFFSET_BITS=64 %s -o %t && %t %p
3 // RUN: %clangxx_msan -m64 -O3 %s -o %t && %t %p
5 #include <assert.h>
6 #include <glob.h>
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <string.h>
10 #include <errno.h>
12 #include <sys/stat.h>
13 #include <sys/types.h>
14 #include <dirent.h>
15 #include <unistd.h>
17 #include <sanitizer/msan_interface.h>
20 int main(int argc, char *argv[]) {
21 assert(argc == 2);
22 char buf[1024];
23 snprintf(buf, sizeof(buf), "%s/%s", argv[1], "scandir_test_root/");
25 struct dirent **d;
26 int res = scandir(buf, &d, NULL, NULL);
27 assert(res >= 3);
28 assert(__msan_test_shadow(&d, sizeof(*d)) == (size_t)-1);
29 for (int i = 0; i < res; ++i) {
30 assert(__msan_test_shadow(&d[i], sizeof(d[i])) == (size_t)-1);
31 assert(__msan_test_shadow(d[i], d[i]->d_reclen) == (size_t)-1);
33 return 0;