1 // REQUIRES: darwin 2 3 // RUN: %clang_pgogen -o %t.exe %s 4 // RUN: env LLVM_PROFILE_FILE="%c%t.profraw" %run %t.exe %t.bad 2>&1 | FileCheck %s 5 6 // CHECK: __llvm_profile_set_file_object(fd={{[0-9]+}}) not supported 7 // CHECK: Profile data not written to file: already written. 8 9 #include <stdio.h> 10 11 extern int __llvm_profile_is_continuous_mode_enabled(void); 12 extern void __llvm_profile_set_file_object(FILE *, int); 13 extern int __llvm_profile_write_file(void); 14 main(int argc,char ** argv)15int main(int argc, char **argv) { 16 if (!__llvm_profile_is_continuous_mode_enabled()) 17 return 1; 18 19 FILE *f = fopen(argv[1], "a+b"); 20 if (!f) 21 return 1; 22 23 __llvm_profile_set_file_object(f, 0); // Try to set the file to "%t.bad". 24 25 if (__llvm_profile_write_file() != 0) 26 return 1; 27 28 f = fopen(argv[1], "r"); 29 if (!f) 30 return 1; 31 32 fseek(f, 0, SEEK_END); 33 return ftell(f); // Check that the "%t.bad" is empty. 34 } 35