lib/tests: extend KUnit test for bitops with more cases
Subsystems (2)
PATCH 1/1 lib/tests: extend KUnit test for bitops with more cases
Extend a KUnit test suite for the bitops API to cover more APIs from include/asm-generic/bitops/instrumented-atomic.h.
- change_bit()
- test_and_set_bit()
- test_and_clear_bit()
- test_and_change_bit()
Verified on x86_64, i386, and arm64 architectures.
Sample KUnit output:
KTAP version 1
# Subtest: test_change_bit
ok 1 BITOPS_4
ok 2 BITOPS_7
ok 3 BITOPS_11
ok 4 BITOPS_31
ok 5 BITOPS_88
# test_change_bit: pass:5 fail:0 skip:0 total:5
ok 2 test_change_bit
KTAP version 1
# Subtest: test_test_and_set_bit_test_and_clear_bit
ok 1 BITOPS_4
ok 2 BITOPS_7
ok 3 BITOPS_11
ok 4 BITOPS_31
ok 5 BITOPS_88
# test_test_and_set_bit_test_and_clear_bit: pass:5 fail:0 skip:0 total:5 ok 3 test_test_and_set_bit_test_and_clear_bit
KTAP version 1
# Subtest: test_test_and_change_bit
ok 1 BITOPS_4
ok 2 BITOPS_7
ok 3 BITOPS_11
ok 4 BITOPS_31
ok 5 BITOPS_88
# test_test_and_change_bit: pass:5 fail:0 skip:0 total:5
ok 4 test_test_and_change_bit
---
Note that this patch is built on top of bitmap-for-next.
--- lib/Kconfig.debug | 4 +-- lib/tests/bitops_kunit.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 2 deletions(-)
lib/Kconfig.debug +2 -2
@@ -2660,8 +2660,8 @@ config BITOPS_KUNIT This option enables the KUnit test for the bitops library which provides functions for bit operations. - Note that this is a partial copy of the original test_bitops module. - For the full coverage, enable TEST_BITOPS. + Note that this is derived from the original test_bitops module. + For micro-benchmarks and compiler warning checks, enable TEST_BITOPS. If unsure, say N.
lib/tests/bitops_kunit.c +63 -0
75 lines not on this page · raw message
---
base-commit: c39f47e6c43954822a36952f47c0da027aca9c2b
change-id: 20260122-kunit-bitops-new-tests-bede7e41bac5
Best regards,
Signature · 1 line
Ryota Sakamoto <[email protected]>
Yury Norov
AppliedQuoted 40 lines · Ryota Sakamoto
Extend a KUnit test suite for the bitops API to cover more APIs from
include/asm-generic/bitops/instrumented-atomic.h.-
change_bit()
-test_and_set_bit()
-test_and_clear_bit()
-test_and_change_bit()Verified on
x86_64, i386, and arm64 architectures.Sample KUnit output:
KTAP version 1
# Subtest:test_change_bit
ok 1BITOPS_4
ok 2BITOPS_7
ok 3BITOPS_11
ok 4BITOPS_31
ok 5BITOPS_88
#test_change_bit: pass:5 fail:0 skip:0 total:5
ok 2test_change_bit
KTAP version 1
# Subtest:test_test_and_set_bit_test_and_clear_bit
ok 1BITOPS_4
ok 2BITOPS_7
ok 3BITOPS_11
ok 4BITOPS_31
ok 5BITOPS_88
#test_test_and_set_bit_test_and_clear_bit: pass:5 fail:0 skip:0 total:5 ok 3test_test_and_set_bit_test_and_clear_bit
KTAP version 1
# Subtest:test_test_and_change_bit
ok 1BITOPS_4
ok 2BITOPS_7
ok 3BITOPS_11
ok 4BITOPS_31
ok 5BITOPS_88
#test_test_and_change_bit: pass:5 fail:0 skip:0 total:5
ok 4test_test_and_change_bit
Quoted 1 line
Signed-off-by Ryota Sakamoto <[email protected]>
Applied, thanks!