From: Nico Pache npache@redhat.com
Enable KUNIT tests for redhat kernel-modules-internal
This commit will enable KUNIT tests to be compiled as modules and packaged into the kernel-modules-internal package.
Signed-off-by: Nico Pache npache@redhat.com
diff --git a/redhat/configs/common/debug/CONFIG_KASAN_KUNIT_TEST b/redhat/configs/common/debug/CONFIG_KASAN_KUNIT_TEST new file mode 100644 index blahblah..blahblah 100644 --- /dev/null +++ b/redhat/configs/common/debug/CONFIG_KASAN_KUNIT_TEST @@ -0,0 +1 @@ +CONFIG_KASAN_KUNIT_TEST=m diff --git a/redhat/configs/common/debug/CONFIG_TEST_LIST_SORT b/redhat/configs/common/debug/CONFIG_TEST_LIST_SORT index blahblah..blahblah 100644 --- a/redhat/configs/common/debug/CONFIG_TEST_LIST_SORT +++ b/redhat/configs/common/debug/CONFIG_TEST_LIST_SORT @@ -1 +1 @@ -CONFIG_TEST_LIST_SORT=y +CONFIG_TEST_LIST_SORT=m diff --git a/redhat/configs/common/generic/CONFIG_BITFIELD_KUNIT b/redhat/configs/common/generic/CONFIG_BITFIELD_KUNIT new file mode 100644 index blahblah..blahblah 100644 --- /dev/null +++ b/redhat/configs/common/generic/CONFIG_BITFIELD_KUNIT @@ -0,0 +1 @@ +# CONFIG_BITFIELD_KUNIT is not set diff --git a/redhat/configs/common/generic/CONFIG_BITS_TEST b/redhat/configs/common/generic/CONFIG_BITS_TEST new file mode 100644 index blahblah..blahblah 100644 --- /dev/null +++ b/redhat/configs/common/generic/CONFIG_BITS_TEST @@ -0,0 +1 @@ +# CONFIG_BITS_TEST is not set diff --git a/redhat/configs/common/generic/CONFIG_CMDLINE_KUNIT_TEST b/redhat/configs/common/generic/CONFIG_CMDLINE_KUNIT_TEST new file mode 100644 index blahblah..blahblah 100644 --- /dev/null +++ b/redhat/configs/common/generic/CONFIG_CMDLINE_KUNIT_TEST @@ -0,0 +1 @@ +# CONFIG_CMDLINE_KUNIT_TEST is not set diff --git a/redhat/configs/common/generic/CONFIG_EXT4_KUNIT_TESTS b/redhat/configs/common/generic/CONFIG_EXT4_KUNIT_TESTS new file mode 100644 index blahblah..blahblah 100644 --- /dev/null +++ b/redhat/configs/common/generic/CONFIG_EXT4_KUNIT_TESTS @@ -0,0 +1 @@ +CONFIG_EXT4_KUNIT_TESTS=m diff --git a/redhat/configs/common/generic/CONFIG_FAT_KUNIT_TEST b/redhat/configs/common/generic/CONFIG_FAT_KUNIT_TEST new file mode 100644 index blahblah..blahblah 100644 --- /dev/null +++ b/redhat/configs/common/generic/CONFIG_FAT_KUNIT_TEST @@ -0,0 +1 @@ +CONFIG_FAT_KUNIT_TEST=m diff --git a/redhat/configs/common/generic/CONFIG_KFENCE_KUNIT_TEST b/redhat/configs/common/generic/CONFIG_KFENCE_KUNIT_TEST new file mode 100644 index blahblah..blahblah 100644 --- /dev/null +++ b/redhat/configs/common/generic/CONFIG_KFENCE_KUNIT_TEST @@ -0,0 +1 @@ +CONFIG_KFENCE_KUNIT_TEST=m diff --git a/redhat/configs/common/generic/CONFIG_KUNIT b/redhat/configs/common/generic/CONFIG_KUNIT index blahblah..blahblah 100644 --- a/redhat/configs/common/generic/CONFIG_KUNIT +++ b/redhat/configs/common/generic/CONFIG_KUNIT @@ -1 +1 @@ -# CONFIG_KUNIT is not set +CONFIG_KUNIT=m diff --git a/redhat/configs/common/generic/CONFIG_KUNIT_ALL_TESTS b/redhat/configs/common/generic/CONFIG_KUNIT_ALL_TESTS new file mode 100644 index blahblah..blahblah 100644 --- /dev/null +++ b/redhat/configs/common/generic/CONFIG_KUNIT_ALL_TESTS @@ -0,0 +1 @@ +CONFIG_KUNIT_ALL_TESTS=m diff --git a/redhat/configs/common/generic/CONFIG_KUNIT_DEBUGFS b/redhat/configs/common/generic/CONFIG_KUNIT_DEBUGFS new file mode 100644 index blahblah..blahblah 100644 --- /dev/null +++ b/redhat/configs/common/generic/CONFIG_KUNIT_DEBUGFS @@ -0,0 +1 @@ +CONFIG_KUNIT_DEBUGFS=y diff --git a/redhat/configs/common/generic/CONFIG_KUNIT_EXAMPLE_TEST b/redhat/configs/common/generic/CONFIG_KUNIT_EXAMPLE_TEST new file mode 100644 index blahblah..blahblah 100644 --- /dev/null +++ b/redhat/configs/common/generic/CONFIG_KUNIT_EXAMPLE_TEST @@ -0,0 +1 @@ +CONFIG_KUNIT_EXAMPLE_TEST=m diff --git a/redhat/configs/common/generic/CONFIG_KUNIT_TEST b/redhat/configs/common/generic/CONFIG_KUNIT_TEST new file mode 100644 index blahblah..blahblah 100644 --- /dev/null +++ b/redhat/configs/common/generic/CONFIG_KUNIT_TEST @@ -0,0 +1 @@ +CONFIG_KUNIT_TEST=m diff --git a/redhat/configs/common/generic/CONFIG_LINEAR_RANGES_TEST b/redhat/configs/common/generic/CONFIG_LINEAR_RANGES_TEST new file mode 100644 index blahblah..blahblah 100644 --- /dev/null +++ b/redhat/configs/common/generic/CONFIG_LINEAR_RANGES_TEST @@ -0,0 +1 @@ +# CONFIG_LINEAR_RANGES_TEST is not set diff --git a/redhat/configs/common/generic/CONFIG_LIST_KUNIT_TEST b/redhat/configs/common/generic/CONFIG_LIST_KUNIT_TEST new file mode 100644 index blahblah..blahblah 100644 --- /dev/null +++ b/redhat/configs/common/generic/CONFIG_LIST_KUNIT_TEST @@ -0,0 +1 @@ +CONFIG_LIST_KUNIT_TEST=m diff --git a/redhat/configs/common/generic/CONFIG_MPTCP_KUNIT_TEST b/redhat/configs/common/generic/CONFIG_MPTCP_KUNIT_TEST new file mode 100644 index blahblah..blahblah 100644 --- /dev/null +++ b/redhat/configs/common/generic/CONFIG_MPTCP_KUNIT_TEST @@ -0,0 +1 @@ +CONFIG_MPTCP_KUNIT_TEST=m diff --git a/redhat/configs/common/generic/CONFIG_MPTCP_KUNIT_TESTS b/redhat/configs/common/generic/CONFIG_MPTCP_KUNIT_TESTS new file mode 100644 index blahblah..blahblah 100644 --- /dev/null +++ b/redhat/configs/common/generic/CONFIG_MPTCP_KUNIT_TESTS @@ -0,0 +1 @@ +CONFIG_MPTCP_KUNIT_TESTS=m diff --git a/redhat/configs/common/generic/CONFIG_RATIONAL_KUNIT_TEST b/redhat/configs/common/generic/CONFIG_RATIONAL_KUNIT_TEST new file mode 100644 index blahblah..blahblah 100644 --- /dev/null +++ b/redhat/configs/common/generic/CONFIG_RATIONAL_KUNIT_TEST @@ -0,0 +1 @@ +CONFIG_RATIONAL_KUNIT_TEST=m diff --git a/redhat/configs/common/generic/CONFIG_RESOURCE_KUNIT_TEST b/redhat/configs/common/generic/CONFIG_RESOURCE_KUNIT_TEST new file mode 100644 index blahblah..blahblah 100644 --- /dev/null +++ b/redhat/configs/common/generic/CONFIG_RESOURCE_KUNIT_TEST @@ -0,0 +1 @@ +# CONFIG_RESOURCE_KUNIT_TEST is not set diff --git a/redhat/configs/common/generic/CONFIG_RTC_LIB_KUNIT_TEST b/redhat/configs/common/generic/CONFIG_RTC_LIB_KUNIT_TEST new file mode 100644 index blahblah..blahblah 100644 --- /dev/null +++ b/redhat/configs/common/generic/CONFIG_RTC_LIB_KUNIT_TEST @@ -0,0 +1 @@ +CONFIG_RTC_LIB_KUNIT_TEST=m
-- https://gitlab.com/cki-project/kernel-ark/-/merge_requests/1422
From: Nico Pache on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/merge_requests/1422#note_6983133...
Jiri is correct. That file controls what is packaged into the modules-internal rpm. I managed to do some testing on x86. I went through the list in mod- internal.list and did a modprobe of all the available tests. I did not run into any issues and all tests passed without errors.
Cheers, -- Nico
From: Rafael Aquini on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/merge_requests/1422#note_6983389...
Acked-by: Rafael Aquini aquini@redhat.com (via approve button)
From: Jiri Benc on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/merge_requests/1422#note_6985898...
Acked-by: Jiri Benc jbenc@redhat.com (via approve button)
From: Jarod Wilson on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/merge_requests/1422#note_7006592...
Acked-by: Jarod Wilson jarod@redhat.com (via approve button)
From: Justin M. Forbes on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/merge_requests/1422#note_7006755...
Acked-by: Justin M. Forbes jforbes@fedoraproject.org (via approve button)
From: Justin M. Forbes on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/merge_requests/1422#note_1051481...
While this started out as a good idea, it may be coming back to bite us. So far during the 6.0 merge window, 2 new commits have come in which cause major issues with this setup: ``` 635dcd16844b08adcc1aa7a934893e47260619e4 for thunderbolt fe5be808fa6c8df5cf939ec622514f970573bc88 for nitro_enclave ``` In both cases, the modules have moved to the new implementation of kunit_test_suite(), and I expect more modules to follow. This gives them dependencies on kunit symbols, and depmod will fail because those symbols do not exist when partitioned off to mod-internal. Example from x86:
``` depmod: WARNING: /builddir/build/BUILDROOT/kernel-5.20.0-0.rc0.20220803gite2b5 42100719.2.fc37.x86_64/./lib/modules/5.20.0-0.rc0.20220803gite2b542100719.2.fc 37.x86_64/kernel/drivers/virt/nitro_enclaves/nitro_enclaves.ko needs unknown symbol kunit_do_failed_assertion depmod: WARNING: /builddir/build/BUILDROOT/kernel-5.20.0-0.rc0.20220803gite2b5 42100719.2.fc37.x86_64/./lib/modules/5.20.0-0.rc0.20220803gite2b542100719.2.fc 37.x86_64/kernel/drivers/virt/nitro_enclaves/nitro_enclaves.ko needs unknown symbol kunit_kmalloc_array depmod: WARNING: /builddir/build/BUILDROOT/kernel-5.20.0-0.rc0.20220803gite2b5 42100719.2.fc37.x86_64/./lib/modules/5.20.0-0.rc0.20220803gite2b542100719.2.fc 37.x86_64/kernel/drivers/virt/nitro_enclaves/nitro_enclaves.ko needs unknown symbol kunit_binary_assert_format depmod: WARNING: /builddir/build/BUILDROOT/kernel-5.20.0-0.rc0.20220803gite2b5 42100719.2.fc37.x86_64/./lib/modules/5.20.0-0.rc0.20220803gite2b542100719.2.fc 37.x86_64/kernel/drivers/virt/nitro_enclaves/nitro_enclaves.ko needs unknown symbol kunit_unary_assert_format depmod: WARNING: /builddir/build/BUILDROOT/kernel-5.20.0-0.rc0.20220803gite2b5 42100719.2.fc37.x86_64/./lib/modules/5.20.0-0.rc0.20220803gite2b542100719.2.fc 37.x86_64/kernel/drivers/virt/nitro_enclaves/nitro_enclaves.ko needs unknown symbol kunit_kfree depmod: WARNING: /builddir/build/BUILDROOT/kernel-5.20.0-0.rc0.20220803gite2b5 42100719.2.fc37.x86_64/./lib/modules/5.20.0-0.rc0.20220803gite2b542100719.2.fc 37.x86_64/kernel/drivers/thunderbolt/thunderbolt.ko needs unknown symbol kunit_binary_ptr_assert_format depmod: WARNING: /builddir/build/BUILDROOT/kernel-5.20.0-0.rc0.20220803gite2b5 42100719.2.fc37.x86_64/./lib/modules/5.20.0-0.rc0.20220803gite2b542100719.2.fc 37.x86_64/kernel/drivers/thunderbolt/thunderbolt.ko needs unknown symbol kunit_do_failed_assertion depmod: WARNING: /builddir/build/BUILDROOT/kernel-5.20.0-0.rc0.20220803gite2b5 42100719.2.fc37.x86_64/./lib/modules/5.20.0-0.rc0.20220803gite2b542100719.2.fc 37.x86_64/kernel/drivers/thunderbolt/thunderbolt.ko needs unknown symbol kunit_fail_assert_format depmod: WARNING: /builddir/build/BUILDROOT/kernel-5.20.0-0.rc0.20220803gite2b5 42100719.2.fc37.x86_64/./lib/modules/5.20.0-0.rc0.20220803gite2b542100719.2.fc 37.x86_64/kernel/drivers/thunderbolt/thunderbolt.ko needs unknown symbol kunit_binary_str_assert_format depmod: WARNING: /builddir/build/BUILDROOT/kernel-5.20.0-0.rc0.20220803gite2b5 42100719.2.fc37.x86_64/./lib/modules/5.20.0-0.rc0.20220803gite2b542100719.2.fc 37.x86_64/kernel/drivers/thunderbolt/thunderbolt.ko needs unknown symbol __kunit_add_resource depmod: WARNING: /builddir/build/BUILDROOT/kernel-5.20.0-0.rc0.20220803gite2b5 42100719.2.fc37.x86_64/./lib/modules/5.20.0-0.rc0.20220803gite2b542100719.2.fc 37.x86_64/kernel/drivers/thunderbolt/thunderbolt.ko needs unknown symbol kunit_kmalloc_array depmod: WARNING: /builddir/build/BUILDROOT/kernel-5.20.0-0.rc0.20220803gite2b5 42100719.2.fc37.x86_64/./lib/modules/5.20.0-0.rc0.20220803gite2b542100719.2.fc 37.x86_64/kernel/drivers/thunderbolt/thunderbolt.ko needs unknown symbol kunit_binary_assert_format depmod: WARNING: /builddir/build/BUILDROOT/kernel-5.20.0-0.rc0.20220803gite2b5 42100719.2.fc37.x86_64/./lib/modules/5.20.0-0.rc0.20220803gite2b542100719.2.fc 37.x86_64/kernel/drivers/thunderbolt/thunderbolt.ko needs unknown symbol kunit_unary_assert_format ```
From: Nico Pache on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/merge_requests/1422#note_1051740...
Seems like a easy fix, Ill produce a test build and an commit with the following changes. Ill follow up tomorrow!
``` diff --git a/include/kunit/test.h b/include/kunit/test.h index 00b9ff7783ab..a635862228b3 100644 --- a/include/kunit/test.h +++ b/include/kunit/test.h @@ -373,13 +373,17 @@ static inline int kunit_run_all_tests(void) * module. * */ +#ifdef CONFIG_KUNIT #define kunit_test_suites(__suites...) \ __kunit_test_suites(__UNIQUE_ID(array), \ __UNIQUE_ID(suites), \ ##__suites)
#define kunit_test_suite(suite) kunit_test_suites(&suite) - +#else +#define kunit_test_suites(__suites...) +#define kunit_test_suite(suite) +#endif #define kunit_suite_for_each_test_case(suite, test_case) \ for (test_case = suite->test_cases; test_case->run_case; test_case++) ```
kernel@lists.fedoraproject.org