Skip to content

Commit

Permalink
selftests: kselftest: Fix build failure with NOLIBC
Browse files Browse the repository at this point in the history
As Mark explains ksft_min_kernel_version() can't be compiled with nolibc,
it doesn't implement uname().

Fixes: 6d029c2 ("selftests/timers/posix_timers: Reimplement check_timer_distribution()")
Reported-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20240412123536.GA32444@redhat.com
Closes: https://lore.kernel.org/all/f0523b3a-ea08-4615-b0fb-5b504a2d39df@sirena.org.uk/
  • Loading branch information
Oleg Nesterov authored and Thomas Gleixner committed Apr 12, 2024
1 parent ed366de commit 1676750
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tools/testing/selftests/kselftest.h
Original file line number Diff line number Diff line change
Expand Up @@ -395,13 +395,18 @@ static inline __noreturn __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 0;
#else
unsigned int major, minor;
struct utsname info;

if (uname(&info) || sscanf(info.release, "%u.%u.", &major, &minor) != 2)
ksft_exit_fail_msg("Can't parse kernel version\n");

return major > min_major || (major == min_major && minor >= min_minor);
#endif
}

#endif /* __KSELFTEST_H */

0 comments on commit 1676750

Please sign in to comment.