lib/math: Add Kunit test suite for gcd()
PATCH 1/1 lib/math: Add Kunit test suite for gcd()
Add a KUnit test suite for the gcd() function.
This test suite verifies the correctness of gcd() across various scenarios, including edge cases.
Signed-off-by Yu-Chun Lin <[email protected]>
--- lib/Kconfig.debug | 13 +++++++++ lib/math/Makefile | 3 +- lib/math/tests/Makefile | 1 + lib/math/tests/gcd_kunit.c | 56 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 lib/math/tests/gcd_kunit.c
lib/Kconfig.debug +13 -0
@@ -3211,6 +3211,19 @@ config INT_SQRT_KUNIT_TEST If unsure, say N +config GCD_KUNIT_TEST + tristate "Greatest common divisor test" if !KUNIT_ALL_TESTS + depends on KUNIT + default KUNIT_ALL_TESTS + help + This option enables the KUnit test suite for the gcd() function, + which computes the greatest common divisor of two numbers. + + This test suite verifies the correctness of gcd() across various + scenarios, including edge cases. + + If unsure, say N + endif # RUNTIME_TESTING_MENU config ARCH_USE_MEMTEST
lib/math/Makefile +2 -1
@@ -9,4 +9,5 @@ obj-$(CONFIG_INT_POW_TEST) += tests/int_pow_kunit.o obj-$(CONFIG_TEST_DIV64) += test_div64.o obj-$(CONFIG_TEST_MULDIV64) += test_mul_u64_u64_div_u64.o obj-$(CONFIG_RATIONAL_KUNIT_TEST) += rational-test.o -obj-$(CONFIG_INT_SQRT_KUNIT_TEST) += tests/int_sqrt_kunit.o +obj-$(CONFIG_INT_SQRT_KUNIT_TEST) += tests/int_sqrt_kunit.o +obj-$(CONFIG_GCD_KUNIT_TEST) += tests/gcd_kunit.o
lib/math/tests/Makefile +1 -0
@@ -2,3 +2,4 @@ obj-$(CONFIG_INT_POW_TEST) += int_pow_kunit.o obj-$(CONFIG_INT_SQRT_KUNIT_TEST) += int_sqrt_kunit.o +obj-$(CONFIG_GCD_KUNIT_TEST) += gcd_kunit.o
lib/math/tests/gcd_kunit.c new file +56 -0
56 lines not on this page · raw message
Signature · 1 line
2.43.0
Quoted 5 lines · Yu-Chun Lin
Add a KUnit test suite for the
gcd()function.
This test suite verifies the correctness ofgcd()across various scenarios, including edge cases.Signed-off-by Yu-Chun Lin <[email protected]>
LGTM. Thanks!
Reviewed-by Kuan-Wei Chiu <[email protected]>
Regards,
Kuan-Wei