33 lines · c
1// REQUIRES: continuous-mode2 3// RUN: %clang_pgogen -fprofile-continuous -o %t.exe %s4// RUN: env LLVM_PROFILE_FILE="%c%t.profraw" %run %t.exe %t.profraw5// RUN: env LLVM_PROFILE_FILE="%t%c.profraw" %run %t.exe %t.profraw6// RUN: env LLVM_PROFILE_FILE="%t.profraw%c" %run %t.exe %t.profraw7 8#include <string.h>9#include <stdio.h>10 11extern int __llvm_profile_is_continuous_mode_enabled(void);12extern const char *__llvm_profile_get_filename();13extern void __llvm_profile_set_dumped(void);14 15int main(int argc, char **argv) {16 if (!__llvm_profile_is_continuous_mode_enabled())17 return 1;18 19 // Check that the filename is "%t.profraw", followed by a null terminator.20 size_t n = strlen(argv[1]) + 1;21 const char *Filename = __llvm_profile_get_filename();22 23 for (int i = 0; i < n; ++i) {24 if (Filename[i] != argv[1][i]) {25 printf("Difference at: %d, Got: %c, Expected: %c\n", i, Filename[i], argv[1][i]);26 printf("Got: %s\n", Filename);27 printf("Expected: %s\n", argv[1]);28 return 1;29 }30 }31 return 0;32}33