| 1 | // FIXME: https://code.google.com/p/address-sanitizer/issues/detail?id=316 |
|---|---|
| 2 | // XFAIL: android |
| 3 | // UNSUPPORTED: ios |
| 4 | // |
| 5 | // RUN: %clangxx_asan -O0 %s -o %t && %run %t %p 2>&1 | FileCheck %s |
| 6 | // RUN: %clangxx_asan -O3 %s -o %t && %run %t %p 2>&1 | FileCheck %s |
| 7 | |
| 8 | #include <assert.h> |
| 9 | #include <glob.h> |
| 10 | #include <stdio.h> |
| 11 | #include <string.h> |
| 12 | #include <errno.h> |
| 13 | #include <string> |
| 14 | |
| 15 | |
| 16 | int main(int argc, char *argv[]) { |
| 17 | std::string path = argv[1]; |
| 18 | std::string pattern = path + "/glob_test_root/*a"; |
| 19 | printf(format: "pattern: %s\n", pattern.c_str()); |
| 20 | |
| 21 | glob_t globbuf; |
| 22 | int res = glob(pattern: pattern.c_str(), flags: 0, errfunc: 0, pglob: &globbuf); |
| 23 | |
| 24 | printf(format: "%d %s\n", errno, strerror(errno)); |
| 25 | assert(res == 0); |
| 26 | assert(globbuf.gl_pathc == 2); |
| 27 | printf(format: "%zu\n", strlen(s: globbuf.gl_pathv[0])); |
| 28 | printf(format: "%zu\n", strlen(s: globbuf.gl_pathv[1])); |
| 29 | globfree(pglob: &globbuf); |
| 30 | printf(format: "PASS\n"); |
| 31 | // CHECK: PASS |
| 32 | return 0; |
| 33 | } |
| 34 |
