Skip to content

Commit

Permalink
Fix test failure in test_libbcc (iovisor#603)
Browse files Browse the repository at this point in the history
On some systems, was seeing a failure at tests/cc/test_c_api.cc:172 due
to failure to open the /tmp/perf-pid.map file. Looking through the code,
narrowed it down to an invalid use of c_str() on a temporary
std::string. Fix it by storing the string in a variable.

Signed-off-by: Brenden Blanco <[email protected]>
  • Loading branch information
drzaeus77 authored and 4ast committed Jul 8, 2016
1 parent 966edb2 commit 52cd371
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tests/cc/test_c_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ static string perf_map_path(pid_t pid) {
static int child_func(void *arg) {
unsigned long long map_addr = (unsigned long long)arg;

const char *path = perf_map_path(getpid()).c_str();
FILE *file = fopen(path, "w");
string path = perf_map_path(getpid());
FILE *file = fopen(path.c_str(), "w");
if (file == NULL) {
return -1;
}
Expand All @@ -134,7 +134,7 @@ static int child_func(void *arg) {

sleep(5);

unlink(path);
unlink(path.c_str());
return 0;
}

Expand Down

0 comments on commit 52cd371

Please sign in to comment.