lib: Convert test_uuid.c to KUnit
Subsystems (2)
PATCH 1/1 lib: Convert test_uuid.c to KUnit
Converts test lib/test_uuid.c to KUnit
---
lib/Kconfig.debug | 7 +--
lib/Makefile | 2 +-
lib/{test_uuid.c => uuid_kunit.c} | 84 +++++++++----------------------
3 files changed, 28 insertions(+), 65 deletions(-)
rename lib/{test_uuid.c => uuid_kunit.c} (48%)lib/Kconfig.debug +4 -3
@@ -2070,9 +2070,6 @@ config TEST_BITFIELD If unsure, say N. -config TEST_UUID - tristate "Test functions located in the uuid module at runtime" - config TEST_XARRAY tristate "Test the XArray code at runtime"
@@ -2273,6 +2270,10 @@ config BITS_TEST If unsure, say N. +config UUID_KUNIT_TEST + tristate "KUnit test for functions located in the uuid module at runtime" + depends on KUNIT + config TEST_UDELAY tristate "udelay test driver" help
lib/Makefile +1 -1
@@ -81,7 +81,6 @@ 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 obj-$(CONFIG_TEST_KMOD) += test_kmod.o
@@ -342,5 +341,6 @@ obj-$(CONFIG_PLDMFW) += pldmfw/ obj-$(CONFIG_LIST_KUNIT_TEST) += list-test.o obj-$(CONFIG_LINEAR_RANGES_TEST) += test_linear_ranges.o obj-$(CONFIG_BITS_TEST) += test_bits.o +obj-$(CONFIG_UUID_KUNIT_TEST) += uuid_kunit.o obj-$(CONFIG_GENERIC_LIB_DEVMEM_IS_ALLOWED) += devmem_is_allowed.o
lib/uuid_kunit.c renamed from lib/test_uuid.c +23 -61
124 lines not on this page · raw message
Signature · 1 line
2.25.1
Quoted 2 lines · Arpitha Raghunandan
Converts test
lib/test_uuid.cto KUnit
Can you add some more detail to the commit message? Maybe link to KUnit and say something about why this change is beneficial.
Quoted 1 line
Signed-off-by Arpitha Raghunandan <[email protected]>
Change mostly looks good to me.
Quoted 7 lines · Brendan Higgins
Quoted 2 lines · Arpitha Raghunandan
Converts test
lib/test_uuid.cto KUnitCan you add some more detail to the commit message? Maybe link to KUnit and say something about why this change is beneficial.
Sure, I will make this change.
Quoted 4 lines
Quoted 1 line
Signed-off-by Arpitha Raghunandan <[email protected]>Change mostly looks good to me.
Thank you for the review.
On failure, the original test calls another function which prints a detailed error. I removed it when converting to KUnit. Is this required?
Quoted 9 lines · Arpitha Raghunandan
Quoted 7 lines · Brendan Higgins
Quoted 2 lines · Arpitha Raghunandan
Converts test
lib/test_uuid.cto KUnitCan you add some more detail to the commit message? Maybe link to KUnit and say something about why this change is beneficial.
Quoted 7 lines
Sure, I will make this change.
Quoted 4 lines
Quoted 1 line
Signed-off-by Arpitha Raghunandan <[email protected]>Change mostly looks good to me.
Thank you for the review.On failure, the original test calls another function which prints a detailed error. I removed it when converting to KUnit. Is this required?
I think that's probably Andy's call. Do you mind calling out the segment of code in question?
Quoted 83 lines · Arpitha Raghunandan
Converts test
lib/test_uuid.cto KUnitSigned-off-by Arpitha Raghunandan <[email protected]>--- lib/Kconfig.debug | 7 +-- lib/Makefile | 2 +- lib/{test_uuid.c => uuid_kunit.c} | 84 +++++++++---------------------- 3 files changed, 28 insertions(+), 65 deletions(-) rename lib/{test_uuid.c => uuid_kunit.c} (48%)lib/Kconfig.debug +4
-3@@ -2070,9 +2070,6 @@ config TEST_BITFIELD If unsure, say N. -config TEST_UUID - tristate "Test functions located in the uuid module at runtime" - config TEST_XARRAY tristate "Test the XArray code at runtime"@@ -2273,6 +2270,10 @@ config BITS_TEST If unsure, say N. +config UUID_KUNIT_TEST + tristate "KUnit test for functions located in the uuid module at runtime" + depends on KUNIT + config TEST_UDELAY tristate "udelay test driver" helplib/Makefile +1
-1@@ -81,7 +81,6 @@ 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 obj-$(CONFIG_TEST_KMOD) += test_kmod.o@@ -342,5 +341,6 @@ obj-$(CONFIG_PLDMFW) += pldmfw/ obj-$(CONFIG_LIST_KUNIT_TEST) += list-test.o obj-$(CONFIG_LINEAR_RANGES_TEST) += test_linear_ranges.o obj-$(CONFIG_BITS_TEST) += test_bits.o +obj-$(CONFIG_UUID_KUNIT_TEST) += uuid_kunit.o obj-$(CONFIG_GENERIC_LIB_DEVMEM_IS_ALLOWED) += devmem_is_allowed.olib/uuid_kunit.c renamed from lib/test_uuid.c +1
-10@@ -3,6 +3,7 @@*/ #define pr_fmt (fmt) KBUILD_MODNAME ": " fmt +#include <kunit/test.h> #include <linux/init.h> #include <linux/kernel.h> #include <linux/module.h> @@ -39,95 +40,56 @@ static const char * const test_uuid_wrong_data[] = { "0cb4ddff-a545-4401-9d06-688af53e", /* not enough data */ }; -static unsigned total_tests__initdata ; -static unsigned failed_tests__initdata ; - -static void __init test_uuid_failed (const char *prefix,bool wrong,bool be, -const char *data,const char *actual) -{ - pr_err("%s test #%u %s %s data: '%s'\n", - prefix, - total_tests, - wrong ? "passed on wrong" : "failed on",
lib/uuid_kunit.c static const char * const test_uuid_wrong_data[] = { · line 61
Quoted 10 lines
lib/uuid_kunit.c renamed from lib/test_uuid.c +0
-10- be ?"BE" :"LE" , - data); -if (actual && *actual) -pr_err ("%s test #%u actual data: '%s'\n" , - prefix, - total_tests, - actual); - failed_tests++; -} -
I have removed the above test_uuid_failed function while converting to KUnit, as mentioned earlier. Is this required?