Skip to content

Commit 1676750

Browse files
oleg-nesterovKAGA-KOKO
authored andcommitted
selftests: kselftest: Fix build failure with NOLIBC
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 <[email protected]> Signed-off-by: Oleg Nesterov <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/r/[email protected] Closes: https://lore.kernel.org/all/[email protected]/
1 parent ed366de commit 1676750

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

tools/testing/selftests/kselftest.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,13 +395,18 @@ static inline __noreturn __printf(1, 2) int ksft_exit_skip(const char *msg, ...)
395395
static inline int ksft_min_kernel_version(unsigned int min_major,
396396
unsigned int min_minor)
397397
{
398+
#ifdef NOLIBC
399+
ksft_print_msg("NOLIBC: Can't check kernel version: Function not implemented\n");
400+
return 0;
401+
#else
398402
unsigned int major, minor;
399403
struct utsname info;
400404

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

404408
return major > min_major || (major == min_major && minor >= min_minor);
409+
#endif
405410
}
406411

407412
#endif /* __KSELFTEST_H */

0 commit comments

Comments
 (0)