lib/math: Add int_log test suite

This commit introduces KUnit tests for the intlog2 and intlog10
functions, which compute logarithms in base 2 and base 10, respectively.
The tests cover a range of inputs to ensure the correctness of these
functions across common and edge cases.

Signed-off-by: Bruno Sobreira França <brunofrancadevsec@gmail.com>
Reviewed-by: David Gow <davidgow@google.com>
Reviewed-by: Rae Moar <rmoar@google.com>
Link: https://lore.kernel.org/r/20241202075545.3648096-3-davidgow@google.com
Signed-off-by: Kees Cook <kees@kernel.org>
This commit is contained in:
Bruno Sobreira França
2024-12-02 15:55:39 +08:00
committed by Kees Cook
parent 3e50ba8fc8
commit 84ec093f55
3 changed files with 86 additions and 0 deletions

View File

@@ -3197,6 +3197,17 @@ config INT_SQRT_KUNIT_TEST
If unsure, say N
config INT_LOG_KUNIT_TEST
tristate "Integer log (int_log) test" if !KUNIT_ALL_TESTS
depends on KUNIT
default KUNIT_ALL_TESTS
help
This option enables the KUnit test suite for the int_log library, which
provides two functions to compute the integer logarithm in base 2 and
base 10, called respectively as intlog2 and intlog10.
If unsure, say N
endif # RUNTIME_TESTING_MENU
config ARCH_USE_MEMTEST