lib/math: Add int_pow test suite
Subsystems (2)
PATCH v5 1/1 lib/math: Add int_pow test suite
Adds test suite for integer based power function.
---
Changes in v5:
- Fix kernel test bot warning
- Rebase with latest
Changes in v4:
- Address checkpatch warning and make kconfig description longer
- Use GPL-2.0-only for consistency
- Spelling fix fith -> fifth
Changes in v3:
- Fix compiler warning: explicitly define constant as unsigned int
- Add changes in patch revisions
Changes in v2:
- Address review feedback
- Add kconfig entry
- Use correct dir and file convention for KUnit
- Fix typo
- Remove unused static_stub header
- Refactor test suite to use paramerterized test cases
- Add close to max allowable value to in large_result test case
- Add test case with non-power of two exponent
- Fix module license
--- lib/Kconfig.debug | 16 +++++++++++ lib/math/Makefile | 1 + lib/math/tests/Makefile | 3 ++ lib/math/tests/int_pow_kunit.c | 52 ++++++++++++++++++++++++++++++++++ 4 files changed, 72 insertions(+) create mode 100644 lib/math/tests/Makefile create mode 100644 lib/math/tests/int_pow_kunit.c
lib/Kconfig.debug +16 -0
@@ -3051,3 +3051,19 @@ config RUST_KERNEL_DOCTESTS endmenu # "Rust" endmenu # Kernel hacking + +config INT_POW_TEST + tristate "Integer exponentiation (int_pow) test" if !KUNIT_ALL_TESTS + depends on KUNIT + default KUNIT_ALL_TESTS + help + This option enables the KUnit test suite for the int_pow function, + which performs integer exponentiation. The test suite is designed to + verify that the implementation of int_pow correctly computes the power + of a given base raised to a given exponent. + + Enabling this option will include tests that check various scenarios + and edge cases to ensure the accuracy and reliability of the exponentiation + function. + + If unsure, say N
lib/math/Makefile +1 -0
@@ -5,5 +5,6 @@ obj-$(CONFIG_CORDIC) += cordic.o obj-$(CONFIG_PRIME_NUMBERS) += prime_numbers.o obj-$(CONFIG_RATIONAL) += rational.o +obj-$(CONFIG_INT_POW_TEST) += tests/int_pow_kunit.o obj-$(CONFIG_TEST_DIV64) += test_div64.o obj-$(CONFIG_RATIONAL_KUNIT_TEST) += rational-test.o
lib/math/tests/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0-only + +obj-$(CONFIG_INT_POW_TEST) += int_pow_kunit.o
lib/math/tests/int_pow_kunit.c new file +52 -0
52 lines not on this page · raw message
Signature · 1 line
2.46.0
Quoted 18 lines · Luis Felipe Hernandez
Adds test suite for integer based power function.
Signed-off-by Luis Felipe Hernandez <[email protected]>---
Changes in v5:
- Fix kernel test bot warning
- Rebase with latest
Changes in v4:
- Address checkpatch warning and make kconfig description longer
- Use GPL-2.0-only for consistency
- Spelling fix fith -> fifth
Changes in v3:
- Fix compiler warning: explicitly define constant as unsigned int
- Add changes in patch revisions
Changes in v2:
- Address review feedback
- Add kconfig entry
Quoted 8 lines
- Use correct dir and file convention for KUnit
- Fix typo
- Remove unusedstatic_stubheader
- Refactor test suite to use paramerterized test cases
- Add close to max allowable value to inlarge_resulttest case
- Add test case with non-power of two exponent
- Fix module license
---
Looks good to me, thanks!
Cheers,
-- David
Shuah Khan
maintainerQuoted 4 lines · David Gow
Quoted 2 lines · Luis Felipe Hernandez
Adds test suite for integer based power function.
It would be nice to see more details on what this test does> What's the output look like?
I fixed it up with the details from the Kconfig. Please do make sure to add test details in the commit long in the future.
There was a trailing whitespace I had to fix. Run checkpatch to verify that there are no issues with the patch in future.
Quoted 25 lines
Quoted 16 lines
Signed-off-by Luis Felipe Hernandez <[email protected]>---
Changes in v5:
- Fix kernel test bot warning
- Rebase with latest
Changes in v4:
- Address checkpatch warning and make kconfig description longer
- Use GPL-2.0-only for consistency
- Spelling fix fith -> fifth
Changes in v3:
- Fix compiler warning: explicitly define constant as unsigned int
- Add changes in patch revisions
Changes in v2:
- Address review feedback
- Add kconfig entryQuoted 8 lines
- Use correct dir and file convention for KUnit
- Fix typo
- Remove unusedstatic_stubheader
- Refactor test suite to use paramerterized test cases
- Add close to max allowable value to inlarge_resulttest case
- Add test case with non-power of two exponent
- Fix module license
---
Quoted 6 lines
Looks good to me, thanks!
Reviewed-by David Gow <[email protected]>Cheers,
-- David
thanks,
-- Shuah