1a1c2a5547d815a4ce116f04ebd3cef1716ab791cEvgeniy Stepanov// RUN: %clangxx_msan -m64 -O0 %s -o %t && %t %p 2>&1 | FileCheck %s
257876cfc5357e2a04d17c56ee51e69c593a536beEvgeniy Stepanov// RUN: %clangxx_msan -m64 -O0 -D_FILE_OFFSET_BITS=64 %s -o %t && %t %p 2>&1 | FileCheck %s
3a1c2a5547d815a4ce116f04ebd3cef1716ab791cEvgeniy Stepanov// RUN: %clangxx_msan -m64 -O3 %s -o %t && %t %p 2>&1 | FileCheck %s
4a1c2a5547d815a4ce116f04ebd3cef1716ab791cEvgeniy Stepanov
5a1c2a5547d815a4ce116f04ebd3cef1716ab791cEvgeniy Stepanov#include <assert.h>
6a1c2a5547d815a4ce116f04ebd3cef1716ab791cEvgeniy Stepanov#include <glob.h>
7a1c2a5547d815a4ce116f04ebd3cef1716ab791cEvgeniy Stepanov#include <stdio.h>
8a1c2a5547d815a4ce116f04ebd3cef1716ab791cEvgeniy Stepanov#include <string.h>
9a1c2a5547d815a4ce116f04ebd3cef1716ab791cEvgeniy Stepanov#include <errno.h>
10a1c2a5547d815a4ce116f04ebd3cef1716ab791cEvgeniy Stepanov
11a1c2a5547d815a4ce116f04ebd3cef1716ab791cEvgeniy Stepanovint main(int argc, char *argv[]) {
12a1c2a5547d815a4ce116f04ebd3cef1716ab791cEvgeniy Stepanov  assert(argc == 2);
13a1c2a5547d815a4ce116f04ebd3cef1716ab791cEvgeniy Stepanov  char buf[1024];
14a1c2a5547d815a4ce116f04ebd3cef1716ab791cEvgeniy Stepanov  snprintf(buf, sizeof(buf), "%s/%s", argv[1], "glob_test_root/*a");
15a1c2a5547d815a4ce116f04ebd3cef1716ab791cEvgeniy Stepanov
16a1c2a5547d815a4ce116f04ebd3cef1716ab791cEvgeniy Stepanov  glob_t globbuf;
17a1c2a5547d815a4ce116f04ebd3cef1716ab791cEvgeniy Stepanov  int res = glob(buf, 0, 0, &globbuf);
18a1c2a5547d815a4ce116f04ebd3cef1716ab791cEvgeniy Stepanov
19a1c2a5547d815a4ce116f04ebd3cef1716ab791cEvgeniy Stepanov  printf("%d %s\n", errno, strerror(errno));
20a1c2a5547d815a4ce116f04ebd3cef1716ab791cEvgeniy Stepanov  assert(res == 0);
21a1c2a5547d815a4ce116f04ebd3cef1716ab791cEvgeniy Stepanov  assert(globbuf.gl_pathc == 2);
22a1c2a5547d815a4ce116f04ebd3cef1716ab791cEvgeniy Stepanov  printf("%zu\n", strlen(globbuf.gl_pathv[0]));
23a1c2a5547d815a4ce116f04ebd3cef1716ab791cEvgeniy Stepanov  printf("%zu\n", strlen(globbuf.gl_pathv[1]));
24a1c2a5547d815a4ce116f04ebd3cef1716ab791cEvgeniy Stepanov  printf("PASS\n");
25a1c2a5547d815a4ce116f04ebd3cef1716ab791cEvgeniy Stepanov  // CHECK: PASS
26a1c2a5547d815a4ce116f04ebd3cef1716ab791cEvgeniy Stepanov  return 0;
27a1c2a5547d815a4ce116f04ebd3cef1716ab791cEvgeniy Stepanov}
28