linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alan Maguire <alan.maguire@oracle.com>
To: linux-kselftest@vger.kernel.org, brendanhiggins@google.com,
	skhan@linuxfoundation.org
Cc: mcgrof@kernel.org, keescook@chromium.org, yzaikin@google.com,
	akpm@linux-foundation.org, yamada.masahiro@socionext.com,
	catalin.marinas@arm.com, joe.lawrence@redhat.com,
	penguin-kernel@i-love.sakura.ne.jp, schowdary@nvidia.com,
	urezki@gmail.com, andriy.shevchenko@linux.intel.com,
	changbin.du@intel.com, kunit-dev@googlegroups.com,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	Alan Maguire <alan.maguire@oracle.com>,
	Knut Omang <knut.omang@oracle.com>
Subject: [PATCH linux-kselftest-test 2/3] kunit: allow kunit to be loaded as a module
Date: Tue,  8 Oct 2019 15:43:51 +0100	[thread overview]
Message-ID: <1570545832-32326-3-git-send-email-alan.maguire@oracle.com> (raw)
In-Reply-To: <1570545832-32326-1-git-send-email-alan.maguire@oracle.com>

Making kunit itself buildable as a module allows for "always-on"
kunit configuration; specifying CONFIG_KUNIT=m means the module
is built but only used when loaded.  Kunit test modules will load
kunit.ko as an implicit dependency, so simply running
"modprobe my-kunit-tests" will load the tests along with the kunit
module and run them.

Signed-off-by: Knut Omang <knut.omang@oracle.com>
Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
---
 kunit/Kconfig  | 2 +-
 kunit/Makefile | 9 +++++++++
 kunit/test.c   | 4 ++++
 3 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/kunit/Kconfig b/kunit/Kconfig
index f28bf086..d84f480 100644
--- a/kunit/Kconfig
+++ b/kunit/Kconfig
@@ -5,7 +5,7 @@
 menu "KUnit support"
 
 config KUNIT
-	bool "Enable support for unit tests (KUnit)"
+	tristate "Enable support for unit tests (KUnit)"
 	help
 	  Enables support for kernel unit tests (KUnit), a lightweight unit
 	  testing and mocking framework for the Linux kernel. These tests are
diff --git a/kunit/Makefile b/kunit/Makefile
index 769d940..932a3f2 100644
--- a/kunit/Makefile
+++ b/kunit/Makefile
@@ -1,7 +1,16 @@
+ifeq ($(CONFIG_KUNIT),m)
+obj-$(CONFIG_KUNIT) +=			kunit.o
+
+kunit-objs +=				test.o \
+					string-stream.o \
+					assert.o \
+					try-catch.o
+else
 obj-$(CONFIG_KUNIT) +=			test.o \
 					string-stream.o \
 					assert.o \
 					try-catch.o
+endif
 
 obj-$(CONFIG_KUNIT_TEST) +=		test-test.o \
 					string-stream-test.o
diff --git a/kunit/test.c b/kunit/test.c
index e7896f1..6024627 100644
--- a/kunit/test.c
+++ b/kunit/test.c
@@ -484,3 +484,7 @@ void kunit_cleanup(struct kunit *test)
 	}
 }
 EXPORT_SYMBOL_GPL(kunit_cleanup);
+
+#ifdef MODULE
+MODULE_LICENSE("GPL");
+#endif /* MODULE */
-- 
1.8.3.1


  parent reply	other threads:[~2019-10-08 14:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-08 14:43 [PATCH linux-kselftest-test 0/3] kunit: support module-based build Alan Maguire
2019-10-08 14:43 ` [PATCH linux-kselftest-test 1/3] kunit: allow kunit tests to be loaded as a module Alan Maguire
2019-10-08 14:43 ` Alan Maguire [this message]
2019-10-08 14:55   ` [PATCH linux-kselftest-test 2/3] kunit: allow kunit " Andy Shevchenko
2019-10-08 15:15     ` Alan Maguire
2019-10-08 14:43 ` [PATCH linux-kselftest-test 3/3] kunit: update documentation to describe module-based build Alan Maguire

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=1570545832-32326-3-git-send-email-alan.maguire@oracle.com \
    --to=alan.maguire@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=brendanhiggins@google.com \
    --cc=catalin.marinas@arm.com \
    --cc=changbin.du@intel.com \
    --cc=joe.lawrence@redhat.com \
    --cc=keescook@chromium.org \
    --cc=knut.omang@oracle.com \
    --cc=kunit-dev@googlegroups.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    --cc=schowdary@nvidia.com \
    --cc=skhan@linuxfoundation.org \
    --cc=urezki@gmail.com \
    --cc=yamada.masahiro@socionext.com \
    --cc=yzaikin@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;
as well as URLs for NNTP newsgroup(s).