diff options
author | Teresa Johnson <tejohnson@google.com> | 2018-07-19 19:03:50 +0000 |
---|---|---|
committer | Teresa Johnson <tejohnson@google.com> | 2018-07-19 19:03:50 +0000 |
commit | 3640f73c3f31b32f2eed19dead7b4eb53db2107f (patch) | |
tree | 1beb4410a0866755e012d0765ee4ea6399678b59 /test/profile | |
parent | 2ae0202ef135697860741f591c41433a3d329c9e (diff) |
[profile] Add interface to get profile filename
Summary:
Add __llvm_profile_get_filename interface to get the profile filename,
which can be used for identifying which profile file belongs to an app
when multiple binaries are instrumented and dumping profiles into the
same directory. The filename includes the path.
Reviewers: davidxl
Subscribers: delcypher, #sanitizers, llvm-commits
Differential Revision: https://reviews.llvm.org/D49529
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@337482 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/profile')
-rw-r--r-- | test/profile/instrprof-get-filename.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/test/profile/instrprof-get-filename.c b/test/profile/instrprof-get-filename.c new file mode 100644 index 000000000..031b75f12 --- /dev/null +++ b/test/profile/instrprof-get-filename.c @@ -0,0 +1,39 @@ +// Test __llvm_profile_get_filename. +// RUN: %clang_pgogen -O2 -o %t %s +// RUN: %run %t + +#include <stdio.h> +#include <string.h> + +const char *__llvm_profile_get_filename(); +void __llvm_profile_set_filename(const char *); + +int main(int argc, const char *argv[]) { + int i; + const char *filename; + const char *new_filename = "/path/to/test.profraw"; + + filename = __llvm_profile_get_filename(); + if (strncmp(filename, "default_", 8)) { + fprintf(stderr, + "Error: got filename %s, expected it to start with 'default_'\n", + filename); + return 1; + } + if (strcmp(filename + strlen(filename) - strlen(".profraw"), ".profraw")) { + fprintf(stderr, + "Error: got filename %s, expected it to end with '.profraw'\n", + filename); + return 1; + } + + __llvm_profile_set_filename(new_filename); + filename = __llvm_profile_get_filename(); + if (strcmp(filename, new_filename)) { + fprintf(stderr, "Error: got filename %s, expected '%s'\n", filename, + new_filename); + return 1; + } + + return 0; +} |