brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.0 KiB · 031b75f Raw
40 lines · c
1// Test __llvm_profile_get_filename.2// RUN: %clang_pgogen -O2 -o %t %s3// RUN: %run %t4 5#include <stdio.h>6#include <string.h>7 8const char *__llvm_profile_get_filename();9void __llvm_profile_set_filename(const char *);10 11int main(int argc, const char *argv[]) {12  int i;13  const char *filename;14  const char *new_filename = "/path/to/test.profraw";15 16  filename = __llvm_profile_get_filename();17  if (strncmp(filename, "default_", 8)) {18    fprintf(stderr,19            "Error: got filename %s, expected it to start with 'default_'\n",20            filename);21    return 1;22  }23  if (strcmp(filename + strlen(filename) - strlen(".profraw"), ".profraw")) {24    fprintf(stderr,25            "Error: got filename %s, expected it to end with '.profraw'\n",26            filename);27    return 1;28  }29 30  __llvm_profile_set_filename(new_filename);31  filename = __llvm_profile_get_filename();32  if (strcmp(filename, new_filename)) {33    fprintf(stderr, "Error: got filename %s, expected '%s'\n", filename,34            new_filename);35    return 1;36  }37 38  return 0;39}40