kunit: move string-stream.h to lib/kunit
authorAlan Maguire <alan.maguire@oracle.com>
Mon, 6 Jan 2020 22:28:18 +0000 (22:28 +0000)
committerShuah Khan <skhan@linuxfoundation.org>
Thu, 9 Jan 2020 23:41:05 +0000 (16:41 -0700)
string-stream interfaces are not intended for external use;
move them from include/kunit to lib/kunit accordingly.

Co-developed-by: Knut Omang <knut.omang@oracle.com>
Signed-off-by: Knut Omang <knut.omang@oracle.com>
Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
Reviewed-by: Brendan Higgins <brendanhiggins@google.com>
Tested-by: Brendan Higgins <brendanhiggins@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
include/kunit/assert.h
include/kunit/string-stream.h [deleted file]
lib/kunit/assert.c
lib/kunit/string-stream-test.c
lib/kunit/string-stream.c
lib/kunit/string-stream.h [new file with mode: 0644]
lib/kunit/test.c

index db6a0fca09b491ed00636aa583c3bfe73d25e31c..ad889b539ab3916976d2e8169cfe70a33d048990 100644 (file)
@@ -9,10 +9,11 @@
 #ifndef _KUNIT_ASSERT_H
 #define _KUNIT_ASSERT_H
 
-#include <kunit/string-stream.h>
 #include <linux/err.h>
+#include <linux/kernel.h>
 
 struct kunit;
+struct string_stream;
 
 /**
  * enum kunit_assert_type - Type of expectation/assertion.
diff --git a/include/kunit/string-stream.h b/include/kunit/string-stream.h
deleted file mode 100644 (file)
index fe98a00..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * C++ stream style string builder used in KUnit for building messages.
- *
- * Copyright (C) 2019, Google LLC.
- * Author: Brendan Higgins <brendanhiggins@google.com>
- */
-
-#ifndef _KUNIT_STRING_STREAM_H
-#define _KUNIT_STRING_STREAM_H
-
-#include <linux/spinlock.h>
-#include <linux/types.h>
-#include <stdarg.h>
-
-struct string_stream_fragment {
-       struct kunit *test;
-       struct list_head node;
-       char *fragment;
-};
-
-struct string_stream {
-       size_t length;
-       struct list_head fragments;
-       /* length and fragments are protected by this lock */
-       spinlock_t lock;
-       struct kunit *test;
-       gfp_t gfp;
-};
-
-struct kunit;
-
-struct string_stream *alloc_string_stream(struct kunit *test, gfp_t gfp);
-
-int __printf(2, 3) string_stream_add(struct string_stream *stream,
-                                    const char *fmt, ...);
-
-int string_stream_vadd(struct string_stream *stream,
-                      const char *fmt,
-                      va_list args);
-
-char *string_stream_get_string(struct string_stream *stream);
-
-int string_stream_append(struct string_stream *stream,
-                        struct string_stream *other);
-
-bool string_stream_is_empty(struct string_stream *stream);
-
-int string_stream_destroy(struct string_stream *stream);
-
-#endif /* _KUNIT_STRING_STREAM_H */
index 86013d4cf891c1dd3cdc132194ce8fc36a686bdf..9aca71cee3df821ee56a1bbe2568a26e08cb3fe6 100644 (file)
@@ -7,6 +7,8 @@
  */
 #include <kunit/assert.h>
 
+#include "string-stream.h"
+
 void kunit_base_assert_format(const struct kunit_assert *assert,
                              struct string_stream *stream)
 {
index 76cc05eb00edd4a4a6ed2b1249871b6edf204161..6c70dc87f67627aedf2ff5847673da1e18aaf53b 100644 (file)
@@ -6,10 +6,11 @@
  * Author: Brendan Higgins <brendanhiggins@google.com>
  */
 
-#include <kunit/string-stream.h>
 #include <kunit/test.h>
 #include <linux/slab.h>
 
+#include "string-stream.h"
+
 static void string_stream_test_empty_on_creation(struct kunit *test)
 {
        struct string_stream *stream = alloc_string_stream(test, GFP_KERNEL);
index e6d17aacca30da4e05d77e8407342b8392ac45c7..350392013c143e8fc358f5dcce00c1733c691419 100644 (file)
@@ -6,11 +6,12 @@
  * Author: Brendan Higgins <brendanhiggins@google.com>
  */
 
-#include <kunit/string-stream.h>
 #include <kunit/test.h>
 #include <linux/list.h>
 #include <linux/slab.h>
 
+#include "string-stream.h"
+
 struct string_stream_fragment_alloc_context {
        struct kunit *test;
        int len;
diff --git a/lib/kunit/string-stream.h b/lib/kunit/string-stream.h
new file mode 100644 (file)
index 0000000..fe98a00
--- /dev/null
@@ -0,0 +1,51 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * C++ stream style string builder used in KUnit for building messages.
+ *
+ * Copyright (C) 2019, Google LLC.
+ * Author: Brendan Higgins <brendanhiggins@google.com>
+ */
+
+#ifndef _KUNIT_STRING_STREAM_H
+#define _KUNIT_STRING_STREAM_H
+
+#include <linux/spinlock.h>
+#include <linux/types.h>
+#include <stdarg.h>
+
+struct string_stream_fragment {
+       struct kunit *test;
+       struct list_head node;
+       char *fragment;
+};
+
+struct string_stream {
+       size_t length;
+       struct list_head fragments;
+       /* length and fragments are protected by this lock */
+       spinlock_t lock;
+       struct kunit *test;
+       gfp_t gfp;
+};
+
+struct kunit;
+
+struct string_stream *alloc_string_stream(struct kunit *test, gfp_t gfp);
+
+int __printf(2, 3) string_stream_add(struct string_stream *stream,
+                                    const char *fmt, ...);
+
+int string_stream_vadd(struct string_stream *stream,
+                      const char *fmt,
+                      va_list args);
+
+char *string_stream_get_string(struct string_stream *stream);
+
+int string_stream_append(struct string_stream *stream,
+                        struct string_stream *other);
+
+bool string_stream_is_empty(struct string_stream *stream);
+
+int string_stream_destroy(struct string_stream *stream);
+
+#endif /* _KUNIT_STRING_STREAM_H */
index c83c0fa59cbd7fdb351aeb167523060eea9e988e..36ebf47240f87b85a297f7b25f2f59320cbaeb45 100644 (file)
@@ -11,6 +11,8 @@
 #include <linux/kernel.h>
 #include <linux/sched/debug.h>
 
+#include "string-stream.h"
+
 static void kunit_set_failure(struct kunit *test)
 {
        WRITE_ONCE(test->success, false);