lkml.org 
[lkml]   [2023]   [Aug]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2 5/6] kunit: kunit-test: Add test of logging only a newline
Date
Add a test that logging a string containing only a newline appends
one newline to the log.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
---
lib/kunit/kunit-test.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/lib/kunit/kunit-test.c b/lib/kunit/kunit-test.c
index 621acdb5385e..ce80fb42128c 100644
--- a/lib/kunit/kunit-test.c
+++ b/lib/kunit/kunit-test.c
@@ -613,6 +613,12 @@ static void kunit_log_newline_test(struct kunit *test)
kunit_init_log_frag(frag);
list_add_tail(&frag->list, suite.log);

+ /* Log only a newline */
+ kunit_log_append(suite.log, "\n");
+ KUNIT_EXPECT_TRUE(test, list_is_singular(suite.log));
+ KUNIT_EXPECT_STREQ(test, frag->buf, "\n");
+ frag->buf[0] = '\0';
+
/* String that exactly fills fragment leaving no room for \n */
memset(frag->buf, 0, sizeof(frag->buf));
memset(frag->buf, 'x', sizeof(frag->buf) - 9);
--
2.30.2
\
 
 \ /
  Last update: 2023-08-08 18:09    [W:0.106 / U:0.392 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site