lib: kunit: add list_sort test conversion to KUnit
Subsystems (2)
PATCH v2 1/1 lib: kunit: add list_sort test conversion to KUnit
This adds the conversion of the runtime tests of test_list_sort, from lib/test_list_sort.c to KUnit tests.
---
v2:
* fix KUNIT_TEST sufix;
* make kconfig help more concise;
* remove obsolete commit comments;
* change Kconfig entries to be more adherent to KUnit documentation;
---
lib/Kconfig.debug | 24 ++++---
lib/Makefile | 2 +-
lib/{test_list_sort.c => list_sort_kunit.c} | 73 +++++++++++----------
3 files changed, 53 insertions(+), 46 deletions(-)
rename lib/{test_list_sort.c => list_sort_kunit.c} (62%)lib/Kconfig.debug +14 -10
@@ -1905,16 +1905,6 @@ config LKDTM Documentation on how to use the module can be found in Documentation/fault-injection/provoke-crashes.rst -config TEST_LIST_SORT - tristate "Linked list sorting test" - depends on DEBUG_KERNEL || m - help - Enable this to turn on 'list_sort()' function test. This test is - executed only once during system boot (so affects only boot time), - or at module load time. - - If unsure, say N. - config TEST_MIN_HEAP tristate "Min heap test" depends on DEBUG_KERNEL || m
@@ -2233,6 +2223,20 @@ config LIST_KUNIT_TEST If unsure, say N. +config LIST_SORT_KUNIT_TEST + tristate "KUnit Linked list sorting test" if !KUNIT_ALL_TESTS + depends on KUNIT + default KUNIT_ALL_TESTS + help + Enable this to turn on 'list_sort()' function test. This test is + executed only once during system boot (so affects only boot time), + or at module load time. + + 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 LINEAR_RANGES_TEST tristate "KUnit test for linear_ranges" depends on KUNIT
lib/Makefile +1 -1
@@ -67,7 +67,6 @@ obj-$(CONFIG_TEST_UBSAN) += test_ubsan.o CFLAGS_test_ubsan.o += $(call cc-disable-warning, vla) UBSAN_SANITIZE_test_ubsan.o := y obj-$(CONFIG_TEST_KSTRTOX) += test-kstrtox.o -obj-$(CONFIG_TEST_LIST_SORT) += test_list_sort.o obj-$(CONFIG_TEST_MIN_HEAP) += test_min_heap.o obj-$(CONFIG_TEST_LKM) += test_module.o obj-$(CONFIG_TEST_VMALLOC) += test_vmalloc.o
@@ -341,5 +340,6 @@ obj-$(CONFIG_PLDMFW) += pldmfw/ # KUnit tests obj-$(CONFIG_BITFIELD_KUNIT) += bitfield_kunit.o obj-$(CONFIG_LIST_KUNIT_TEST) += list-test.o +obj-$(CONFIG_LIST_SORT_KUNIT_TEST) += list_sort_kunit.o obj-$(CONFIG_LINEAR_RANGES_TEST) += test_linear_ranges.o obj-$(CONFIG_BITS_TEST) += test_bits.o
lib/list_sort_kunit.c renamed from lib/test_list_sort.c +38 -35
161 lines not on this page · raw message
base-commit: d2585f5164c298aaaed14c2c8d313cbe7bd5b253
Signature · 1 line
2.26.2
Quoted 2 lines · Vitor Massaru Iha
This adds the conversion of the runtime tests of
test_list_sort, fromlib/test_list_sort.cto KUnit tests.
Please, provide better commit message. For example, add the output of _succeeded_ *and* _failed_ test cases (yes, you have to break code manually to reproduce failed test cases) _before_ *and* _after_ the change.
W/o above information I'm going to NAK this as I promised before.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 8 lines · Andy Shevchenko
Quoted 2 lines · Vitor Massaru Iha
This adds the conversion of the runtime tests of
test_list_sort, fromlib/test_list_sort.cto KUnit tests.Please, provide better commit message. For example, add the output of _succeeded_ *and* _failed_ test cases (yes, you have to break code manually to reproduce failed test cases) _before_ *and* _after_ the change.
Sure, I'll do it. Thanks!
Quoted 7 lines
W/o above information I'm going to NAK this as I promised before.
--
With Best Regards,
Andy Shevchenko
Quoted 4 lines · Vitor Massaru Iha
This adds the conversion of the runtime tests of
test_list_sort, fromlib/test_list_sort.cto KUnit tests.rename lib/{test_list_sort.c => list_sort_kunit.c} (62%)
One more thing. The documentation [1] doesn't specify any name conventions. So, please leave file name untouched.
[1]: https://www.kernel.org/doc/html/latest/dev-tools/kunit/index.html
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 11 lines · Andy Shevchenko
Quoted 4 lines · Vitor Massaru Iha
This adds the conversion of the runtime tests of
test_list_sort, fromlib/test_list_sort.cto KUnit tests.rename lib/{test_list_sort.c => list_sort_kunit.c} (62%)One more thing. The documentation [1] doesn't specify any name conventions. So, please leave file name untouched.
[1]: https://www.kernel.org/doc/html/latest/dev-tools/kunit/index.html
This convention hasn't yet entered the Torvaldos tree, but it is in the Shuah tree: [1]
+Test File and Module Names
+==========================
+
+KUnit tests can often be compiled as a module. These modules should be named +after the test suite, followed by ``_test``. If this is likely to conflict with +non-KUnit tests, the suffix ``_kunit`` can also be used.
+
+The easiest way of achieving this is to name the file containing the test suite +``<suite>_test.c`` (or, as above, ``<suite>_kunit.c``). This file should be +placed next to the code under test.
+
+If the suite name contains some or all of the name of the test's parent +directory, it may make sense to modify the source filename to reduce redundancy.
+For example, a ``foo_firmware`` suite could be in the ``foo/firmware_test.c`` +file.
Quoted 10 lines
--
With Best Regards,
Andy Shevchenko--
You received this message because you are subscribed to the Google Groups "KUnit Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/kunit-dev/20201015174823.GY4077%40smile.fi.intel.com.
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Quoted 34 lines · Vitor Massaru Iha
Quoted 11 lines · Andy Shevchenko
Quoted 4 lines · Vitor Massaru Iha
This adds the conversion of the runtime tests of
test_list_sort, fromlib/test_list_sort.cto KUnit tests.rename lib/{test_list_sort.c => list_sort_kunit.c} (62%)One more thing. The documentation [1] doesn't specify any name conventions. So, please leave file name untouched.
[1]: https://www.kernel.org/doc/html/latest/dev-tools/kunit/index.html
This convention hasn't yet entered the Torvaldos tree, but it is in the Shuah tree: [1]
(quoted diff) +13
-0+Test File and Module Names +========================== + +KUnit tests can often be compiled as a module. These modules should be named +after the test suite, followed by ``_test``. If this is likely to conflict with +non-KUnit tests, the suffix ``_kunit`` can also be used. + +The easiest way of achieving this is to name the file containing the test suite +``<suite>_test.c`` (or, as above, ``<suite>_kunit.c``). This file should be +placed next to the code under test. + +If the suite name contains some or all of the name of the test's parent +directory, it may make sense to modify the source filename to reduceredundancy.
(quoted diff) +2
-0+For example, a ``foo_firmware`` suite could be in the ``foo/firmware_test.c`` +file.
Quoted 1 line
I see.
Can the rest of documentation be consistent with this? It seems half-baked, since examples show something different.
(Entire documentation if full of example-test.c)
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 35 lines · Andy Shevchenko
Quoted 34 lines · Vitor Massaru Iha
Quoted 11 lines · Andy Shevchenko
Quoted 4 lines · Vitor Massaru Iha
This adds the conversion of the runtime tests of
test_list_sort, fromlib/test_list_sort.cto KUnit tests.rename lib/{test_list_sort.c => list_sort_kunit.c} (62%)One more thing. The documentation [1] doesn't specify any name conventions. So, please leave file name untouched.
[1]: https://www.kernel.org/doc/html/latest/dev-tools/kunit/index.html
This convention hasn't yet entered the Torvaldos tree, but it is in the Shuah tree: [1]
(quoted diff) +13
-0+Test File and Module Names +========================== + +KUnit tests can often be compiled as a module. These modules should be named +after the test suite, followed by ``_test``. If this is likely to conflict with +non-KUnit tests, the suffix ``_kunit`` can also be used. + +The easiest way of achieving this is to name the file containing the test suite +``<suite>_test.c`` (or, as above, ``<suite>_kunit.c``). This file should be +placed next to the code under test. + +If the suite name contains some or all of the name of the test's parent +directory, it may make sense to modify the source filename to reduceredundancy.
(quoted diff) +2
-0+For example, a ``foo_firmware`` suite could be in the ``foo/firmware_test.c`` +file.
Quoted 8 lines
Quoted 1 line
I see.
Can the rest of documentation be consistent with this? It seems half-baked, since examples show something different.
(Entire documentation if full of
example-test.c)
Also it doesn't really clear about the test cases against header files, like for list.h or bits.h. (There is no c-file and I'm not sure one desires to have include/linux/*_kunit.c)
Signature · 2 lines
With Best Regards, Andy Shevchenko