Move ASan lit-tests under test/asan
[blocksruntime.git] / test / asan / TestCases / Linux / glob.cc
blob123768b099ed90472918b19bf93abb77518583cb
1 // RUN: %clangxx_asan -O0 %s -o %t && %t %p 2>&1 | FileCheck %s
2 // RUN: %clangxx_asan -O3 %s -o %t && %t %p 2>&1 | FileCheck %s
4 #include <assert.h>
5 #include <glob.h>
6 #include <stdio.h>
7 #include <string.h>
8 #include <errno.h>
9 #include <string>
12 int main(int argc, char *argv[]) {
13 std::string path = argv[1];
14 std::string pattern = path + "/glob_test_root/*a";
15 printf("pattern: %s\n", pattern.c_str());
17 glob_t globbuf;
18 int res = glob(pattern.c_str(), 0, 0, &globbuf);
20 printf("%d %s\n", errno, strerror(errno));
21 assert(res == 0);
22 assert(globbuf.gl_pathc == 2);
23 printf("%zu\n", strlen(globbuf.gl_pathv[0]));
24 printf("%zu\n", strlen(globbuf.gl_pathv[1]));
25 globfree(&globbuf);
26 printf("PASS\n");
27 // CHECK: PASS
28 return 0;