brintos

brintos / llvm-project-archived public Read only

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