Skip to contentSkip to conversation

lib/math: Add int_sqrt test suite

PATCH Superseded Luis Felipe Hernandez 2 participants 2 messages Oct 24, 2024

Subsystems (2)

v1 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib/math: Add int_sqrt test suite

Adds test suite for integer based square root function.

The test suite is designed to verify the correctness of the int_sqrt math library function.

---
 lib/Kconfig.debug               | 17 ++++++++++++
 lib/math/Makefile               |  1 +
 lib/math/tests/Makefile         |  1 +
 lib/math/tests/int_sqrt_kunit.c | 48 +++++++++++++++++++++++++++++++++
 4 files changed, 67 insertions(+)
 create mode 100644 lib/math/tests/int_sqrt_kunit.c
lib/Kconfig.debug +17 -0
index 7312ae7c3cc5..a7e63dae9281 100644
@@ -2993,6 +2993,23 @@ config TEST_OBJPOOL
 
 	  If unsure, say N.
 
+config INT_SQRT_KUNIT_TEST
+	tristate "Integer square root test test" if !KUNIT_ALL_TESTS
+	depends on KUNIT
+	default KUNIT_ALL_TESTS
+	help
+	  This option enables the KUnit test suite for the int_sqrt function,
+	  which performs square root calculation. The test suite is designed to
+	  verify that the implementation of int_sqrt correctly computes the
+	  square root of a number.
+
+	  Enabling this option will include tests that check various scenarios
+	  and edge cases to ensure the accuracy and reliability of the square root
+	  function.
+
+	  If unsure, say N
+
+
 endif # RUNTIME_TESTING_MENU
 
 config ARCH_USE_MEMTEST
lib/math/Makefile +1 -0
index 3ef11305f8d2..c7b043ffb249 100644
@@ -9,3 +9,4 @@ 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-y  += tests/
\ No newline at end of file
lib/math/tests/Makefile +1 -0
index 6a169123320a..e1a79f093b2d 100644
@@ -1,3 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0-only
 
 obj-$(CONFIG_INT_POW_TEST) += int_pow_kunit.o
+obj-$(CONFIG_INT_SQRT_KUNIT_TEST) += int_sqrt_kunit.o
lib/math/tests/int_sqrt_kunit.c new file +48 -0

48 lines not on this page · raw message

Signature · 1 line
2.47.0
#1 lore raw
Quoted 4 lines · Luis Felipe Hernandez

Adds test suite for integer based square root function.

The test suite is designed to verify the correctness of the int_sqrt math library function.

...

Quoted 5 lines

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-y += tests/
\ No newline at end of file

^^^ Please, fix this.

...

Quoted 1 line

+#include <kunit/test.h>

+ limits.h

Quoted 1 line

+#include <linux/math.h>

+ module.h
+ string.h

Signature · 2 lines
With Best Regards,
Andy Shevchenko