summaryrefslogtreecommitdiff
path: root/lib/kunit/string-stream.h
diff options
context:
space:
mode:
authorRichard Fitzgerald <rf@opensource.cirrus.com>2023-08-28 13:41:04 +0300
committerShuah Khan <skhan@linuxfoundation.org>2023-09-18 19:45:16 +0300
commita5abe7b201779b0000f1e8ab522e5c6fc0c413bf (patch)
tree4d116c7fac6208c19800510bd83f7a3ec64d8389 /lib/kunit/string-stream.h
parent4551caca6ab67fb0b5199ca43580c4f8d27bf28a (diff)
downloadlinux-a5abe7b201779b0000f1e8ab522e5c6fc0c413bf.tar.xz
kunit: string-stream: Add option to make all lines end with newline
Add an optional feature to string_stream that will append a newline to any added string that does not already end with a newline. The purpose of this is so that string_stream can be used to collect log lines. This is enabled/disabled by calling string_stream_set_append_newlines(). Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Reviewed-by: Rae Moar <rmoar@google.com> Reviewed-by: David Gow <davidgow@google.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Diffstat (limited to 'lib/kunit/string-stream.h')
-rw-r--r--lib/kunit/string-stream.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/kunit/string-stream.h b/lib/kunit/string-stream.h
index b669f9a75a94..048930bf97f0 100644
--- a/lib/kunit/string-stream.h
+++ b/lib/kunit/string-stream.h
@@ -25,6 +25,7 @@ struct string_stream {
spinlock_t lock;
struct kunit *test;
gfp_t gfp;
+ bool append_newlines;
};
struct kunit;
@@ -47,4 +48,10 @@ bool string_stream_is_empty(struct string_stream *stream);
void string_stream_destroy(struct string_stream *stream);
+static inline void string_stream_set_append_newlines(struct string_stream *stream,
+ bool append_newlines)
+{
+ stream->append_newlines = append_newlines;
+}
+
#endif /* _KUNIT_STRING_STREAM_H */