public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ivan Orlov <ivan.orlov0322@gmail.com>
To: brendan.higgins@linux.dev, davidgow@google.com, rmoar@google.com
Cc: Ivan Orlov <ivan.orlov0322@gmail.com>,
	linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com,
	linux-kernel@vger.kernel.org
Subject: [PATCH 3/5] kunit: string-stream-test: Make it a separate module
Date: Tue,  4 Jun 2024 13:32:02 +0100	[thread overview]
Message-ID: <20240604123204.10412-4-ivan.orlov0322@gmail.com> (raw)
In-Reply-To: <20240604123204.10412-1-ivan.orlov0322@gmail.com>

Currently, the only way to build string-stream-test is by setting
CONFIG_KUNIT_TEST=y. However, CONFIG_KUNIT_TEST is a config option for
a different test (`kunit-test.c`).

Introduce a new Kconfig entry in order to be able to build the
string-stream-test test as a separate module. Import the KUnit namespace
in the test so we could have string-stream functions accessible.

Signed-off-by: Ivan Orlov <ivan.orlov0322@gmail.com>
---
 lib/kunit/Kconfig              | 8 ++++++++
 lib/kunit/Makefile             | 2 +-
 lib/kunit/string-stream-test.c | 2 ++
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/lib/kunit/Kconfig b/lib/kunit/Kconfig
index 34d7242d526d..b0713c0f9265 100644
--- a/lib/kunit/Kconfig
+++ b/lib/kunit/Kconfig
@@ -45,6 +45,14 @@ config KUNIT_TEST
 	  purposes by developers interested in testing that KUnit works as
 	  expected.
 
+config KUNIT_STRING_STREAM_TEST
+	tristate "KUnit test for string-stream" if !KUNIT_ALL_TESTS
+	default KUNIT_ALL_TESTS
+	help
+	  Enables the KUnit test for the string-stream (C++ stream style string
+	  builder used in KUnit for building messages). For the string-stream
+	  implementation, see lib/kunit/string-stream.c.
+
 config KUNIT_EXAMPLE_TEST
 	tristate "Example test for KUnit" if !KUNIT_ALL_TESTS
 	default KUNIT_ALL_TESTS
diff --git a/lib/kunit/Makefile b/lib/kunit/Makefile
index 900e6447c8e8..4793a3960f07 100644
--- a/lib/kunit/Makefile
+++ b/lib/kunit/Makefile
@@ -18,10 +18,10 @@ endif
 obj-y +=				hooks.o
 
 obj-$(CONFIG_KUNIT_TEST) +=		kunit-test.o
+obj-$(CONFIG_KUNIT_STRING_STREAM_TEST) += string-stream-test.o
 
 # string-stream-test compiles built-in only.
 ifeq ($(CONFIG_KUNIT_TEST),y)
-obj-$(CONFIG_KUNIT_TEST) +=		string-stream-test.o
 obj-$(CONFIG_KUNIT_TEST) +=		assert_test.o
 endif
 
diff --git a/lib/kunit/string-stream-test.c b/lib/kunit/string-stream-test.c
index 7511442ea98f..d03cac934e04 100644
--- a/lib/kunit/string-stream-test.c
+++ b/lib/kunit/string-stream-test.c
@@ -534,3 +534,5 @@ static struct kunit_suite string_stream_test_suite = {
 	.init = string_stream_test_init,
 };
 kunit_test_suites(&string_stream_test_suite);
+MODULE_IMPORT_NS(EXPORTED_FOR_KUNIT_TESTING);
+MODULE_LICENSE("GPL");
-- 
2.34.1


  parent reply	other threads:[~2024-06-04 12:32 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-04 12:31 [PATCH 0/5] Reorganize string-stream and assert tests Ivan Orlov
2024-06-04 12:32 ` [PATCH 1/5] kunit: string-stream: export non-static functions Ivan Orlov
2024-06-08  9:20   ` David Gow
2024-06-09 19:01     ` Ivan Orlov
2024-06-04 12:32 ` [PATCH 2/5] kunit: kunit-test: Remove stub for log tests Ivan Orlov
2024-06-08  9:20   ` David Gow
2024-06-04 12:32 ` Ivan Orlov [this message]
2024-06-08  9:20   ` [PATCH 3/5] kunit: string-stream-test: Make it a separate module David Gow
2024-06-04 12:32 ` [PATCH 4/5] kunit: assert: export non-static functions Ivan Orlov
2024-06-08  9:20   ` David Gow
2024-06-09 19:05     ` Ivan Orlov
2024-06-04 12:32 ` [PATCH 5/5] kunit: Merge assertion test into kunit-test.c Ivan Orlov
2024-06-08  9:20   ` David Gow
2024-06-11 13:10     ` Ivan Orlov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240604123204.10412-4-ivan.orlov0322@gmail.com \
    --to=ivan.orlov0322@gmail.com \
    --cc=brendan.higgins@linux.dev \
    --cc=davidgow@google.com \
    --cc=kunit-dev@googlegroups.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=rmoar@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox