[PATCH 1/5] lib/tests: string_helpers: check null terminator too
From: Jonas Rebmann
Date: Wed Sep 16 2026 - 13:45:40 EST
string_unescape() returns the number of character written to dst, not
counting the null terminator which is always written.
Ensure string_unescape has included the null terminator by adding a
separate check.
While at it, improve output for failed tests by showing the memory dump
even if the length differs.
Signed-off-by: Jonas Rebmann <jre@xxxxxxxxxxxxxx>
---
lib/tests/string_helpers_kunit.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/tests/string_helpers_kunit.c b/lib/tests/string_helpers_kunit.c
index 9fbe91079c7e..9bc3acffaf2f 100644
--- a/lib/tests/string_helpers_kunit.c
+++ b/lib/tests/string_helpers_kunit.c
@@ -22,7 +22,7 @@ static void test_string_check_buf(struct kunit *test,
char *out_real, size_t q_real,
char *out_test, size_t q_test)
{
- KUNIT_ASSERT_EQ_MSG(test, q_real, q_test, "name:%s", name);
+ KUNIT_EXPECT_EQ_MSG(test, q_real, q_test, "name:%s", name);
KUNIT_EXPECT_MEMEQ_MSG(test, out_test, out_real, q_test,
"name:%s", name);
}
@@ -103,6 +103,7 @@ static void test_string_unescape(struct kunit *test,
test_string_check_buf(test, name, flags, in, p - 1, out_real, q_real,
out_test, q_test);
+ KUNIT_EXPECT_EQ_MSG(test, out_real[q_real], '\0', "name:%s", name);
}
struct test_string_1 {
--
2.56.0.rc0.108.gf0ef1b96a0