llvm-project
47 строк · 1.3 Кб
1// RUN: %clang_pgogen -O2 -o %t.0 %s
2// RUN: %clang_pgogen=%/t.d1 -O2 -o %t.1 %s
3// RUN: %clang_pgogen=%/t.d1/%:t.d2 -O2 -o %t.2 %s
4//
5// RUN: %run %t.0 ""
6// RUN: env LLVM_PROFILE_FILE=%/t.d1/default.profraw %run %t.0 %/t.d1
7// RUN: env LLVM_PROFILE_FILE=%/t.d1/%:t.d2/default.profraw %run %t.0 %/t.d1/%:t.d2
8// RUN: %run %t.1 %/t.d1
9// RUN: %run %t.2 %/t.d1/%:t.d2
10// 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[]) {18const char *expected;19const char *prefix;20if (argc < 2)21return 1;22
23expected = argv[1];24prefix = __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 '\\'.28int slashpos = strlen(prefix);29if (slashpos > 0) {30--slashpos;31if (prefix[slashpos] != '/' && prefix[slashpos] != '\\')32return 1;33}34
35if (strncmp(prefix, expected, slashpos))36return 1;37
38if (argc == 4) {39__llvm_profile_set_filename(argv[2]);40prefix = __llvm_profile_get_path_prefix();41expected = argv[3];42if (strcmp(prefix, expected))43return 1;44}45
46return 0;47}
48