Skip to content

Commit c7bb5cf

Browse files
tamirdakpm00
authored andcommitted
xarray: port tests to kunit
Minimally rewrite the XArray unit tests to use kunit. This integrates nicely with existing kunit tools which produce nicer human-readable output compared to the existing machinery. Running the xarray tests before this change requires an obscure invocation ``` tools/testing/kunit/kunit.py run --arch arm64 --make_options LLVM=1 \ --kconfig_add CONFIG_TEST_XARRAY=y --raw_output=all nothing ``` which on failure produces ``` BUG at check_reserve:513 ... XArray: 6782340 of 6782364 tests passed ``` and exits 0. Running the xarray tests after this change requires a simpler invocation ``` tools/testing/kunit/kunit.py run --arch arm64 --make_options LLVM=1 \ xarray ``` which on failure produces (colors omitted) ``` [09:50:53] ====================== check_reserve ====================== [09:50:53] [FAILED] param-0 [09:50:53] # check_reserve: EXPECTATION FAILED at lib/test_xarray.c:536 [09:50:53] xa_erase(xa, 12345678) != NULL ... [09:50:53] # module: test_xarray [09:50:53] # xarray: pass:26 fail:3 skip:0 total:29 [09:50:53] # Totals: pass:28 fail:3 skip:0 total:31 [09:50:53] ===================== [FAILED] xarray ====================== ``` and exits 1. Use of richer kunit assertions is intentionally omitted to reduce the scope of the change. [[email protected]: fix cocci warning] Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/ Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Tamir Duberstein <[email protected]> Cc: Bill Wendling <[email protected]> Cc: Christophe Leroy <[email protected]> Cc: Geert Uytterhoeven <[email protected]> Cc: Justin Stitt <[email protected]> Cc: Madhavan Srinivasan <[email protected]> Cc: Michael Ellerman <[email protected]> Cc: Nathan Chancellor <[email protected]> Cc: Naveen N Rao <[email protected]> Cc: Nicholas Piggin <[email protected]> Cc: Nick Desaulniers <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 7a77edf commit c7bb5cf

16 files changed

+410
-294
lines changed

arch/m68k/configs/amiga_defconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,6 @@ CONFIG_TEST_PRINTF=m
629629
CONFIG_TEST_SCANF=m
630630
CONFIG_TEST_BITMAP=m
631631
CONFIG_TEST_UUID=m
632-
CONFIG_TEST_XARRAY=m
633632
CONFIG_TEST_MAPLE_TREE=m
634633
CONFIG_TEST_RHASHTABLE=m
635634
CONFIG_TEST_IDA=m

arch/m68k/configs/apollo_defconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,6 @@ CONFIG_TEST_PRINTF=m
586586
CONFIG_TEST_SCANF=m
587587
CONFIG_TEST_BITMAP=m
588588
CONFIG_TEST_UUID=m
589-
CONFIG_TEST_XARRAY=m
590589
CONFIG_TEST_MAPLE_TREE=m
591590
CONFIG_TEST_RHASHTABLE=m
592591
CONFIG_TEST_IDA=m

arch/m68k/configs/atari_defconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,6 @@ CONFIG_TEST_PRINTF=m
606606
CONFIG_TEST_SCANF=m
607607
CONFIG_TEST_BITMAP=m
608608
CONFIG_TEST_UUID=m
609-
CONFIG_TEST_XARRAY=m
610609
CONFIG_TEST_MAPLE_TREE=m
611610
CONFIG_TEST_RHASHTABLE=m
612611
CONFIG_TEST_IDA=m

arch/m68k/configs/bvme6000_defconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,6 @@ CONFIG_TEST_PRINTF=m
578578
CONFIG_TEST_SCANF=m
579579
CONFIG_TEST_BITMAP=m
580580
CONFIG_TEST_UUID=m
581-
CONFIG_TEST_XARRAY=m
582581
CONFIG_TEST_MAPLE_TREE=m
583582
CONFIG_TEST_RHASHTABLE=m
584583
CONFIG_TEST_IDA=m

arch/m68k/configs/hp300_defconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,6 @@ CONFIG_TEST_PRINTF=m
588588
CONFIG_TEST_SCANF=m
589589
CONFIG_TEST_BITMAP=m
590590
CONFIG_TEST_UUID=m
591-
CONFIG_TEST_XARRAY=m
592591
CONFIG_TEST_MAPLE_TREE=m
593592
CONFIG_TEST_RHASHTABLE=m
594593
CONFIG_TEST_IDA=m

arch/m68k/configs/mac_defconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,6 @@ CONFIG_TEST_PRINTF=m
605605
CONFIG_TEST_SCANF=m
606606
CONFIG_TEST_BITMAP=m
607607
CONFIG_TEST_UUID=m
608-
CONFIG_TEST_XARRAY=m
609608
CONFIG_TEST_MAPLE_TREE=m
610609
CONFIG_TEST_RHASHTABLE=m
611610
CONFIG_TEST_IDA=m

arch/m68k/configs/multi_defconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,6 @@ CONFIG_TEST_PRINTF=m
692692
CONFIG_TEST_SCANF=m
693693
CONFIG_TEST_BITMAP=m
694694
CONFIG_TEST_UUID=m
695-
CONFIG_TEST_XARRAY=m
696695
CONFIG_TEST_MAPLE_TREE=m
697696
CONFIG_TEST_RHASHTABLE=m
698697
CONFIG_TEST_IDA=m

arch/m68k/configs/mvme147_defconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,6 @@ CONFIG_TEST_PRINTF=m
578578
CONFIG_TEST_SCANF=m
579579
CONFIG_TEST_BITMAP=m
580580
CONFIG_TEST_UUID=m
581-
CONFIG_TEST_XARRAY=m
582581
CONFIG_TEST_MAPLE_TREE=m
583582
CONFIG_TEST_RHASHTABLE=m
584583
CONFIG_TEST_IDA=m

arch/m68k/configs/mvme16x_defconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,6 @@ CONFIG_TEST_PRINTF=m
579579
CONFIG_TEST_SCANF=m
580580
CONFIG_TEST_BITMAP=m
581581
CONFIG_TEST_UUID=m
582-
CONFIG_TEST_XARRAY=m
583582
CONFIG_TEST_MAPLE_TREE=m
584583
CONFIG_TEST_RHASHTABLE=m
585584
CONFIG_TEST_IDA=m

arch/m68k/configs/q40_defconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,6 @@ CONFIG_TEST_PRINTF=m
595595
CONFIG_TEST_SCANF=m
596596
CONFIG_TEST_BITMAP=m
597597
CONFIG_TEST_UUID=m
598-
CONFIG_TEST_XARRAY=m
599598
CONFIG_TEST_MAPLE_TREE=m
600599
CONFIG_TEST_RHASHTABLE=m
601600
CONFIG_TEST_IDA=m

arch/m68k/configs/sun3_defconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,6 @@ CONFIG_TEST_PRINTF=m
575575
CONFIG_TEST_SCANF=m
576576
CONFIG_TEST_BITMAP=m
577577
CONFIG_TEST_UUID=m
578-
CONFIG_TEST_XARRAY=m
579578
CONFIG_TEST_MAPLE_TREE=m
580579
CONFIG_TEST_RHASHTABLE=m
581580
CONFIG_TEST_IDA=m

arch/m68k/configs/sun3x_defconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,6 @@ CONFIG_TEST_PRINTF=m
576576
CONFIG_TEST_SCANF=m
577577
CONFIG_TEST_BITMAP=m
578578
CONFIG_TEST_UUID=m
579-
CONFIG_TEST_XARRAY=m
580579
CONFIG_TEST_MAPLE_TREE=m
581580
CONFIG_TEST_RHASHTABLE=m
582581
CONFIG_TEST_IDA=m

arch/powerpc/configs/ppc64_defconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,6 @@ CONFIG_TEST_PRINTF=m
451451
CONFIG_TEST_SCANF=m
452452
CONFIG_TEST_BITMAP=m
453453
CONFIG_TEST_UUID=m
454-
CONFIG_TEST_XARRAY=m
455454
CONFIG_TEST_MAPLE_TREE=m
456455
CONFIG_TEST_RHASHTABLE=m
457456
CONFIG_TEST_IDA=m

lib/Kconfig.debug

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2456,8 +2456,22 @@ config TEST_BITMAP
24562456
config TEST_UUID
24572457
tristate "Test functions located in the uuid module at runtime"
24582458

2459-
config TEST_XARRAY
2460-
tristate "Test the XArray code at runtime"
2459+
config XARRAY_KUNIT
2460+
tristate "KUnit test XArray code at runtime" if !KUNIT_ALL_TESTS
2461+
depends on KUNIT
2462+
default KUNIT_ALL_TESTS
2463+
help
2464+
Enable this option to test the Xarray code at boot.
2465+
2466+
KUnit tests run during boot and output the results to the debug log
2467+
in TAP format (http://testanything.org/). Only useful for kernel devs
2468+
running the KUnit test harness, and not intended for inclusion into a
2469+
production build.
2470+
2471+
For more information on KUnit and unit tests in general please refer
2472+
to the KUnit documentation in Documentation/dev-tools/kunit/.
2473+
2474+
If unsure, say N.
24612475

24622476
config TEST_MAPLE_TREE
24632477
tristate "Test the Maple Tree code at runtime or module load"

lib/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ GCOV_PROFILE_test_bitmap.o := n
9494
endif
9595

9696
obj-$(CONFIG_TEST_UUID) += test_uuid.o
97-
obj-$(CONFIG_TEST_XARRAY) += test_xarray.o
9897
obj-$(CONFIG_TEST_MAPLE_TREE) += test_maple_tree.o
9998
obj-$(CONFIG_TEST_PARMAN) += test_parman.o
10099
obj-$(CONFIG_TEST_KMOD) += test_kmod.o
@@ -375,6 +374,7 @@ CFLAGS_bitfield_kunit.o := $(DISABLE_STRUCTLEAK_PLUGIN)
375374
obj-$(CONFIG_BITFIELD_KUNIT) += bitfield_kunit.o
376375
obj-$(CONFIG_CHECKSUM_KUNIT) += checksum_kunit.o
377376
obj-$(CONFIG_UTIL_MACROS_KUNIT) += util_macros_kunit.o
377+
obj-$(CONFIG_XARRAY_KUNIT) += test_xarray.o
378378
obj-$(CONFIG_LIST_KUNIT_TEST) += list-test.o
379379
obj-$(CONFIG_HASHTABLE_KUNIT_TEST) += hashtable_test.o
380380
obj-$(CONFIG_LINEAR_RANGES_TEST) += test_linear_ranges.o

0 commit comments

Comments
 (0)