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
3
4#include <assert.h>
5#include <glob.h>
6#include <stdio.h>
7#include <string.h>
8#include <errno.h>
9#include <string>
10
11
12int 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());
16
17  glob_t globbuf;
18  int res = glob(pattern.c_str(), 0, 0, &globbuf);
19
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  printf("PASS\n");
26  // CHECK: PASS
27  return 0;
28}
29