Skip to content

Commit 4b56c21

Browse files
sunlimingrostedt
authored andcommitted
selftests/user_events: Clear the events after perf self-test
When the self test is completed, perf self-test left the user events not to be cleared. Clear the events by unregister and delete the event. Link: https://lkml.kernel.org/r/[email protected] Acked-by: Beau Belgrave <[email protected]> Acked-by: Masami Hiramatsu (Google) <[email protected]> Signed-off-by: sunliming <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent 3e7269d commit 4b56c21

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

tools/testing/selftests/user_events/perf_test.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,32 @@ static int get_offset(void)
8181
return offset;
8282
}
8383

84+
static int clear(int *check)
85+
{
86+
struct user_unreg unreg = {0};
87+
88+
unreg.size = sizeof(unreg);
89+
unreg.disable_bit = 31;
90+
unreg.disable_addr = (__u64)check;
91+
92+
int fd = open(data_file, O_RDWR);
93+
94+
if (fd == -1)
95+
return -1;
96+
97+
if (ioctl(fd, DIAG_IOCSUNREG, &unreg) == -1)
98+
if (errno != ENOENT)
99+
return -1;
100+
101+
if (ioctl(fd, DIAG_IOCSDEL, "__test_event") == -1)
102+
if (errno != ENOENT)
103+
return -1;
104+
105+
close(fd);
106+
107+
return 0;
108+
}
109+
84110
FIXTURE(user) {
85111
int data_fd;
86112
int check;
@@ -93,6 +119,9 @@ FIXTURE_SETUP(user) {
93119

94120
FIXTURE_TEARDOWN(user) {
95121
close(self->data_fd);
122+
123+
if (clear(&self->check) != 0)
124+
printf("WARNING: Clear didn't work!\n");
96125
}
97126

98127
TEST_F(user, perf_write) {

0 commit comments

Comments
 (0)