Message ID | 20240412123536.GA32444@redhat.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 16767502aa990cca2cb7d1372b31d328c4c85b40 |
Headers | show |
Series | selftests: fix build failure with NOLIBC | expand |
On Fri, Apr 12, 2024 at 02:35:36PM +0200, Oleg Nesterov wrote: > As Mark explains ksft_min_kernel_version() can't be compiled with nolibc, > it doesn't implement uname(). > > Fixes: 6d029c25b71f ("selftests/timers/posix_timers: Reimplement check_timer_distribution()") > Reported-by: Mark Brown <broonie@kernel.org> > Closes: https://lore.kernel.org/all/f0523b3a-ea08-4615-b0fb-5b504a2d39df@sirena.org.uk/ > Signed-off-by: Oleg Nesterov <oleg@redhat.com> Makes sense to me given that there's not likely to be any immediate users. Reviewed-by: Mark Brown <broonie@kernel.org>
diff --git a/tools/testing/selftests/kselftest.h b/tools/testing/selftests/kselftest.h index 973b18e156b2..0d9ed3255f5e 100644 --- a/tools/testing/selftests/kselftest.h +++ b/tools/testing/selftests/kselftest.h @@ -392,6 +392,11 @@ static inline __printf(1, 2) int ksft_exit_skip(const char *msg, ...) static inline int ksft_min_kernel_version(unsigned int min_major, unsigned int min_minor) { +#ifdef NOLIBC + ksft_print_msg("NOLIBC: Can't check kernel version: " + "Function not implemented\n"); + return -1; +#else unsigned int major, minor; struct utsname info; @@ -399,6 +404,7 @@ static inline int ksft_min_kernel_version(unsigned int min_major, ksft_exit_fail_msg("Can't parse kernel version\n"); return major > min_major || (major == min_major && minor >= min_minor); +#endif } #endif /* __KSELFTEST_H */ diff --git a/tools/testing/selftests/timers/posix_timers.c b/tools/testing/selftests/timers/posix_timers.c index d86a0e00711e..878496d2a656 100644 --- a/tools/testing/selftests/timers/posix_timers.c +++ b/tools/testing/selftests/timers/posix_timers.c @@ -241,7 +241,7 @@ static int check_timer_distribution(void) if (!ctd_failed) ksft_test_result_pass("check signal distribution\n"); - else if (ksft_min_kernel_version(6, 3)) + else if (ksft_min_kernel_version(6, 3) > 0) ksft_test_result_fail("check signal distribution\n"); else ksft_test_result_skip("check signal distribution (old kernel)\n");
As Mark explains ksft_min_kernel_version() can't be compiled with nolibc, it doesn't implement uname(). Fixes: 6d029c25b71f ("selftests/timers/posix_timers: Reimplement check_timer_distribution()") Reported-by: Mark Brown <broonie@kernel.org> Closes: https://lore.kernel.org/all/f0523b3a-ea08-4615-b0fb-5b504a2d39df@sirena.org.uk/ Signed-off-by: Oleg Nesterov <oleg@redhat.com> --- tools/testing/selftests/kselftest.h | 6 ++++++ tools/testing/selftests/timers/posix_timers.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-)