1 // UNSUPPORTED: target={{.*windows.*}}
2 // RUN: %clang_pgogen -o %t.bin %s -DTESTPATH=\"%t.dir\"
11 void __llvm_profile_set_dir_mode(unsigned Mode
);
12 unsigned __llvm_profile_get_dir_mode(void);
13 void __llvm_profile_recursive_mkdir(char *Path
);
15 static int test(unsigned Mode
, const char *TestDir
) {
18 /* Create a dir and set the mode accordingly. */
19 char *Dir
= strdup(TestDir
);
22 __llvm_profile_set_dir_mode(Mode
);
23 __llvm_profile_recursive_mkdir(Dir
);
25 if (Mode
!= __llvm_profile_get_dir_mode())
29 // "If the parent directory has the set-group-ID bit set, then so will the
30 // newly created directory." So we mask off S_ISGID below; this test cannot
31 // control its parent directory.
32 const unsigned Expected
= ~umask(0) & Mode
;
34 if (stat(Dir
, &DirSt
) == -1)
36 // AIX has some extended definition of high order bits for st_mode, avoid trying to comparing those by masking them off.
37 else if (((DirSt
.st_mode
& ~S_ISGID
) & 0xFFFF) != Expected
) {
38 printf("Modes do not match: Expected %o but found %o (%s)\n", Expected
,
49 if (test(S_IFDIR
| 0777, TESTPATH
"/foo/bar/baz/") ||
50 test(S_IFDIR
| 0666, TESTPATH
"/foo/bar/qux/"))