Skip to contentSkip to conversation

lib/tests: string_helpers: Slight improvements

PATCH Applied Andy Shevchenko 1 participant 4 messages Apr 6 – Apr 9 Generic string library

lore
Share & tools
lore
#1 lore raw

PATCH 1/2 lib/tests: string_helpers: Decouple unescape and escape cases

In reply to Andy Shevchenko

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
index c853046183d2..cd08e79a857d 100644
@@ -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
#2 lore raw

PATCH 2/2 lib/tests: string_helpers: Don't use "proxy" headers

In reply to Andy Shevchenko

Update 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
index cd08e79a857d..9fbe91079c7e 100644
@@ -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
#0 lore raw

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
#3 lore raw
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