summaryrefslogtreecommitdiff
path: root/test/asan/TestCases/Linux/glob.cc
blob: 123768b099ed90472918b19bf93abb77518583cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// RUN: %clangxx_asan -O0 %s -o %t && %t %p 2>&1 | FileCheck %s
// RUN: %clangxx_asan -O3 %s -o %t && %t %p 2>&1 | FileCheck %s

#include <assert.h>
#include <glob.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <string>


int main(int argc, char *argv[]) {
  std::string path = argv[1];
  std::string pattern = path + "/glob_test_root/*a";
  printf("pattern: %s\n", pattern.c_str());

  glob_t globbuf;
  int res = glob(pattern.c_str(), 0, 0, &globbuf);

  printf("%d %s\n", errno, strerror(errno));
  assert(res == 0);
  assert(globbuf.gl_pathc == 2);
  printf("%zu\n", strlen(globbuf.gl_pathv[0]));
  printf("%zu\n", strlen(globbuf.gl_pathv[1]));
  globfree(&globbuf);
  printf("PASS\n");
  // CHECK: PASS
  return 0;
}