selftests/user_events: Fix failures when user_events is not installed
authorBeau Belgrave <beaub@linux.microsoft.com>
Fri, 8 Sep 2023 20:19:16 +0000 (20:19 +0000)
committerShuah Khan <skhan@linuxfoundation.org>
Mon, 11 Sep 2023 23:04:11 +0000 (17:04 -0600)
commita06023a8f78d3e9e73ca4363ccf3871a06e16ecc
treeb16187c093becfa15cf822c59ef62b858f15a7ba
parent0bb80ecc33a8fb5a682236443c1e740d5c917d1d
selftests/user_events: Fix failures when user_events is not installed

When user_events is not installed the self tests currently fail. Now
that these self tests run by default we need to ensure they don't fail
when user_events was not enabled for the kernel being tested.

Add common methods to detect if tracefs and user_events is enabled. If
either is not enabled skip the test. If tracefs is enabled, but is not
mounted, mount tracefs and fail if there were any errors. Fail if not
run as root.

Fixes: 68b4d2d58389 ("selftests/user_events: Reenable build")
Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
Link: https://lore.kernel.org/all/CA+G9fYuugZ0OMeS6HvpSS4nuf_A3s455ecipGBvER0LJHojKZg@mail.gmail.com/
Signed-off-by: Beau Belgrave <beaub@linux.microsoft.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
tools/testing/selftests/user_events/abi_test.c
tools/testing/selftests/user_events/dyn_test.c
tools/testing/selftests/user_events/ftrace_test.c
tools/testing/selftests/user_events/perf_test.c
tools/testing/selftests/user_events/user_events_selftests.h [new file with mode: 0644]