lib/tests: string_helpers: Slight improvements
cover lib/tests: string_helpers: Slight improvements
There are two ad-hoc patches to improve the test module. It was induced by another patch that poorly tried to add (existing) test cases and make me revisit the string_helpers_kunit.c.
Andy Shevchenko (2):
lib/tests: string_helpers: Decouple unescape and escape cases lib/tests: string_helpers: Don't use "proxy" headers
lib/tests/string_helpers_kunit.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
Signature · 1 line
2.50.1
PATCH 1/2 lib/tests: string_helpers: Decouple unescape and escape cases
Currently the escape and unescape test cases go in one step. Decouple them for the better granularity and understanding test coverage in the results.
--- lib/tests/string_helpers_kunit.c | 6 ++++++ 1 file changed, 6 insertions(+)
lib/tests/string_helpers_kunit.c +6 -0
@@ -601,6 +601,11 @@ static void test_unescape(struct kunit *test)test_string_unescape (test,"unescape" , i, false);test_string_unescape (test,"unescape inplace" ,get_random_u32_below (UNESCAPE_ALL_MASK +1 ), true); +} + +static void test_escape (struct kunit *test) +{ +unsigned int i;/* Without dictionary */ for (i =0 ; i <ESCAPE_ALL_MASK +1 ; i++)
@@ -615,6 +620,7 @@ static struct kunit_case string_helpers_test_cases[] = {KUNIT_CASE (test_get_size),KUNIT_CASE (test_upper_lower),KUNIT_CASE (test_unescape), + KUNIT_CASE(test_escape), {} };
Signature · 1 line
2.50.1
PATCH 2/2 lib/tests: string_helpers: Don't use "proxy" headers
In reply to Andy ShevchenkoUpdate header inclusions to follow IWYU (Include What You Use) principle.
--- lib/tests/string_helpers_kunit.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
lib/tests/string_helpers_kunit.c +7 -2
@@ -5,11 +5,16 @@#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt#include <kunit/test.h> +#include <linux/array_size.h> -#include <linux/kernel.h> +#include <linux/bug.h> +#include <linux/limits.h> +#include <linux/module.h> #include <linux/random.h> -#include <linux/string.h> +#include <linux/slab.h> +#include <linux/sprintf.h> #include <linux/string_helpers.h> +#include <linux/types.h> static void test_string_check_buf(struct kunit *test, const char *name, unsigned int flags,
Signature · 1 line
2.50.1
Quoted 3 lines · Andy Shevchenko
There are two ad-hoc patches to improve the test module. It was induced by another patch that poorly tried to add (existing) test cases and make me revisit the
string_helpers_kunit.c.
Kees, I assume you can take it? In any case I'm find with you or Andrew taking them.
Signature · 2 lines
With Best Regards, Andy Shevchenko