Skip to content

Commit

Permalink
perf_event_open01: Handle EOPNOTSUPP correctly
Browse files Browse the repository at this point in the history
In case that particular event type is not supported by hardware the
perf_event_open() fails with EOPNOTSUPP which should be translated to
TCONF.

Also this adds the event name to the tst_brkm(TFAIL, ...) branch so that
we can actually see which event has failed.

Fixes #81

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
  • Loading branch information
metan-ucw committed Aug 24, 2016
1 parent 998b77c commit 5615241
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions testcases/kernel/syscalls/perf_event_open/perf_event_open01.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,14 @@ static void verify(struct test_case_t *tc)

TEST(perf_event_open(&pe, 0, -1, -1, 0));
if (TEST_RETURN == -1) {
if (TEST_ERRNO == ENOENT) {
tst_resm(TCONF,
if (TEST_ERRNO == ENOENT || TEST_ERRNO == EOPNOTSUPP) {
tst_resm(TCONF | TTERRNO,
"perf_event_open for %s not supported",
tc->config_name);
} else {
tst_brkm(TFAIL | TTERRNO, cleanup,
"perf_event_open failed unexpectedly");
"perf_event_open %s failed unexpectedly",
tc->config_name);
}
return;
}
Expand Down

1 comment on commit 5615241

@metan-ucw
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The returned errno depends on you kernel version, hardware and requested event type. The perf_event_open01 tries various event types and hence is much more likely that your system is missing support for some. The perf_event_open02 tries only three most common event types and because of that it's less likely to hit the EOPNOTSUPP.

In short, the perf_event_open02 should break the test with TCONF as well for both ENOENT and EOPNOTSUPP. Feel free to send a patch.

Please sign in to comment.