1 // XFAIL: aix 2 // RUN: %clang_pgogen -O2 -o %t.0 %s 3 // RUN: %clang_pgogen=%/t.d1 -O2 -o %t.1 %s 4 // RUN: %clang_pgogen=%/t.d1/%:t.d2 -O2 -o %t.2 %s 5 // 6 // RUN: %run %t.0 "" 7 // RUN: env LLVM_PROFILE_FILE=%/t.d1/default.profraw %run %t.0 %/t.d1 8 // RUN: env LLVM_PROFILE_FILE=%/t.d1/%:t.d2/default.profraw %run %t.0 %/t.d1/%:t.d2 9 // RUN: %run %t.1 %/t.d1 10 // RUN: %run %t.2 %/t.d1/%:t.d2 11 // RUN: %run %t.2 %/t.d1/%:t.d2 %/t.d1/%:t.d2/%:t.d3/blah.profraw %/t.d1/%:t.d2/%:t.d3/ 12 13 #include <string.h> 14 15 const char *__llvm_profile_get_path_prefix(); 16 void __llvm_profile_set_filename(const char*); 17 main(int argc,const char * argv[])18int main(int argc, const char *argv[]) { 19 const char *expected; 20 const char *prefix; 21 if (argc < 2) 22 return 1; 23 24 expected = argv[1]; 25 prefix = __llvm_profile_get_path_prefix(); 26 27 // The last character should be a trailing slash. Ignore it in the comparison 28 // since it could be '/' or '\\'. 29 int slashpos = strlen(prefix); 30 if (slashpos > 0) { 31 --slashpos; 32 if (prefix[slashpos] != '/' && prefix[slashpos] != '\\') 33 return 1; 34 } 35 36 if (strncmp(prefix, expected, slashpos)) 37 return 1; 38 39 if (argc == 4) { 40 __llvm_profile_set_filename(argv[2]); 41 prefix = __llvm_profile_get_path_prefix(); 42 expected = argv[3]; 43 if (strcmp(prefix, expected)) 44 return 1; 45 } 46 47 return 0; 48 } 49