Skip to contentSkip to conversation

lib: kunit: add bitfield test conversion to KUnit

PATCH In review Vitor Massaru Iha 3 participants 4 messages Jul 29, 2020 – Oct 10, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib: kunit: add bitfield test conversion to KUnit

This adds the conversion of the runtime tests of test_bitfield, from lib/test_bitfield.c to KUnit tests.

Please apply this commit first (linux-kselftest/kunit-fixes):
3f37d14b8a3152441f36b6bc74000996679f0998 kunit: kunit_config: Fix parsing of CONFIG options with space

Code Style Documentation: [0]

---
 lib/Kconfig.debug                         | 23 ++++--
 lib/Makefile                              |  2 +-
 lib/{test_bitfield.c => bitfield_kunit.c} | 92 ++++++++++-------------
 3 files changed, 57 insertions(+), 60 deletions(-)
 rename lib/{test_bitfield.c => bitfield_kunit.c} (66%)
lib/Kconfig.debug +16 -7
index 9ad9210d70a1..16c5574bf103 100644
@@ -1986,13 +1986,6 @@ config TEST_BITMAP
 
 	  If unsure, say N.
 
-config TEST_BITFIELD
-	tristate "Test bitfield functions at runtime"
-	help
-	  Enable this option to test the bitfield functions at boot.
-
-	  If unsure, say N.
-
 config TEST_UUID
 	tristate "Test functions located in the uuid module at runtime"
 
@@ -2142,6 +2135,22 @@ config TEST_SYSCTL
 
 	  If unsure, say N.
 
+config BITFIELD_KUNIT
+	tristate "KUnit test bitfield functions at runtime"
+	depends on KUNIT
+	help
+	  Enable this option to test the bitfield functions at boot.
+
+	  KUnit tests run during boot and output the results to the debug log
+	  in TAP format (http://testanything.org/). Only useful for kernel devs
+	  running the KUnit test harness, and not intended for inclusion into a
+	  production build.
+
+	  For more information on KUnit and unit tests in general please refer
+	  to the KUnit documentation in Documentation/dev-tools/kunit/.
+
+	  If unsure, say N.
+
 config SYSCTL_KUNIT_TEST
 	tristate "KUnit test for sysctl" if !KUNIT_ALL_TESTS
 	depends on KUNIT
lib/Makefile +1 -1
index b1c42c10073b..56019c34f5ed 100644
@@ -84,7 +84,6 @@ obj-$(CONFIG_TEST_STATIC_KEYS) += test_static_key_base.o
 obj-$(CONFIG_TEST_PRINTF) += test_printf.o
 obj-$(CONFIG_TEST_BITMAP) += test_bitmap.o
 obj-$(CONFIG_TEST_STRSCPY) += test_strscpy.o
-obj-$(CONFIG_TEST_BITFIELD) += test_bitfield.o
 obj-$(CONFIG_TEST_UUID) += test_uuid.o
 obj-$(CONFIG_TEST_XARRAY) += test_xarray.o
 obj-$(CONFIG_TEST_PARMAN) += test_parman.o
@@ -316,5 +315,6 @@ obj-$(CONFIG_GENERIC_LIB_UCMPDI2) += ucmpdi2.o
 obj-$(CONFIG_OBJAGG) += objagg.o
 
 # KUnit tests
+obj-$(CONFIG_BITFIELD_KUNIT) += bitfield_kunit.o
 obj-$(CONFIG_LIST_KUNIT_TEST) += list-test.o
 obj-$(CONFIG_LINEAR_RANGES_TEST) += test_linear_ranges.o
lib/bitfield_kunit.c renamed from lib/test_bitfield.c +40 -52

154 lines not on this page · raw message

base-commit: d43c7fb05765152d4d4a39a8ef957c4ea14d8847

Signature · 1 line
2.26.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Vitor Massaru Iha

This adds the conversion of the runtime tests of test_bitfield, from lib/test_bitfield.c to KUnit tests.

Please apply this commit first (linux-kselftest/kunit-fixes):
3f37d14b8a3152441f36b6bc74000996679f0998 kunit: kunit_config: Fix parsing of CONFIG options with space

Code Style Documentation: [0]

Probably still want a review from Johannes though.

#2 lore raw
Quoted 7 lines · Brendan Higgins
Quoted 6 lines · Vitor Massaru Iha

This adds the conversion of the runtime tests of test_bitfield, from lib/test_bitfield.c to KUnit tests.

Please apply this commit first (linux-kselftest/kunit-fixes):
3f37d14b8a3152441f36b6bc74000996679f0998 kunit: kunit_config: Fix parsing of CONFIG options with space

Quoted 8 lines
Quoted 4 lines

Code Style Documentation: [0]

Probably still want a review from Johannes though.

Huh, sorry, this slipped through the cracks.

Yeah, don't really care, looks fine to me? I'm not familiar with the kunit infrastructure much yet.

Not sure I see much value in converting TEST_BITFIELD_COMPILE to a KUNIT_CASE though, because anyway it will not compile if you enable that? IOW, just leaving the function there without any KUNIT_CASE() reference to it should be fine and saves you an ifdef ...

johannes

#3 lore raw
Quoted 14 lines · Johannes Berg
Quoted 12 lines · Brendan Higgins
Quoted 10 lines · Vitor Massaru Iha

This adds the conversion of the runtime tests of test_bitfield, from lib/test_bitfield.c to KUnit tests.

Please apply this commit first (linux-kselftest/kunit-fixes):
3f37d14b8a3152441f36b6bc74000996679f0998 kunit: kunit_config: Fix parsing of CONFIG options with space

Code Style Documentation: [0]

Quoted 8 lines
Quoted 3 lines

Probably still want a review from Johannes though.

Huh, sorry, this slipped through the cracks.

Yeah, don't really care, looks fine to me? I'm not familiar with the kunit infrastructure much yet.

Cool, well in that case I will apply it.

Quoted 4 lines

Not sure I see much value in converting TEST_BITFIELD_COMPILE to a KUNIT_CASE though, because anyway it will not compile if you enable that? IOW, just leaving the function there without any KUNIT_CASE() reference to it should be fine and saves you an ifdef ...

Well I think it is also the case that we only want to count the test case if it actually has everything to run; that is a point that is somewhat up in the air. David is exploring adding the concept of "skipped" tests to KUnit, but we don't have that yet.

Cheers!
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees