All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alan Maguire <alan.maguire@oracle.com>
To: brendanhiggins@google.com, linux-kselftest@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, kunit-dev@googlegroups.com,
	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, urezki@gmail.com,
	andriy.shevchenko@linux.intel.com, corbet@lwn.net,
	davidgow@google.com, adilger.kernel@dilger.ca, tytso@mit.edu,
	mcgrof@kernel.org, linux-doc@vger.kernel.org,
	Alan Maguire <alan.maguire@oracle.com>,
	Knut Omang <knut.omang@oracle.com>
Subject: [PATCH v6 linux-kselftest-test 5/6] kunit: allow kunit to be loaded as a module
Date: Wed,  4 Dec 2019 15:27:13 +0000	[thread overview]
Message-ID: <1575473234-5443-6-git-send-email-alan.maguire@oracle.com> (raw)
In-Reply-To: <1575473234-5443-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.

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>
---
 lib/kunit/Kconfig  |  2 +-
 lib/kunit/Makefile |  4 +++-
 lib/kunit/test.c   | 13 +++++++++++++
 3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/lib/kunit/Kconfig b/lib/kunit/Kconfig
index 9ebd5e6..065aa16 100644
--- a/lib/kunit/Kconfig
+++ b/lib/kunit/Kconfig
@@ -3,7 +3,7 @@
 #
 
 menuconfig KUNIT
-	bool "KUnit - Enable support for unit tests"
+	tristate "KUnit - Enable support for unit tests"
 	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/lib/kunit/Makefile b/lib/kunit/Makefile
index bc6e5e54..fab5564 100644
--- a/lib/kunit/Makefile
+++ b/lib/kunit/Makefile
@@ -1,4 +1,6 @@
-obj-$(CONFIG_KUNIT) +=			test.o \
+obj-$(CONFIG_KUNIT) +=			kunit.o
+
+kunit-objs +=				test.o \
 					string-stream.o \
 					assert.o \
 					try-catch.o
diff --git a/lib/kunit/test.c b/lib/kunit/test.c
index 87b5cf1..9242f93 100644
--- a/lib/kunit/test.c
+++ b/lib/kunit/test.c
@@ -486,3 +486,16 @@ void kunit_cleanup(struct kunit *test)
 	}
 }
 EXPORT_SYMBOL_GPL(kunit_cleanup);
+
+static int __init kunit_init(void)
+{
+	return 0;
+}
+late_initcall(kunit_init);
+
+static void __exit kunit_exit(void)
+{
+}
+module_exit(kunit_exit);
+
+MODULE_LICENSE("GPL v2");
-- 
1.8.3.1


  parent reply	other threads:[~2019-12-04 15:29 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-04 15:27 [PATCH v6 linux-kselftest-test 0/6] kunit: support building core/tests as modules Alan Maguire
2019-12-04 15:27 ` [PATCH v6 linux-kselftest-test 1/6] kunit: move string-stream.h to lib/kunit Alan Maguire
2019-12-04 15:27 ` [PATCH v6 linux-kselftest-test 2/6] kunit: hide unexported try-catch interface in try-catch-impl.h Alan Maguire
2019-12-04 15:27 ` [PATCH v6 linux-kselftest-test 3/6] kunit: allow kunit tests to be loaded as a module Alan Maguire
2019-12-04 21:47   ` Iurii Zaikin
2019-12-18 22:52   ` kbuild test robot
2019-12-18 22:52     ` kbuild test robot
2019-12-19 14:28     ` Alan Maguire
2019-12-19 14:28       ` Alan Maguire
2020-01-06 18:56       ` shuah
2020-01-06 18:56         ` shuah
2019-12-04 15:27 ` [PATCH v6 linux-kselftest-test 4/6] kunit: remove timeout dependence on sysctl_hung_task_timeout_seconds Alan Maguire
2019-12-04 15:27 ` Alan Maguire [this message]
2019-12-04 15:27 ` [PATCH v6 linux-kselftest-test 6/6] kunit: update documentation to describe module-based build Alan Maguire
2019-12-13  1:11 ` [PATCH v6 linux-kselftest-test 0/6] kunit: support building core/tests as modules Brendan Higgins
2020-01-06 18:54 ` shuah

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=1575473234-5443-6-git-send-email-alan.maguire@oracle.com \
    --to=alan.maguire@oracle.com \
    --cc=adilger.kernel@dilger.ca \
    --cc=akpm@linux-foundation.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=brendanhiggins@google.com \
    --cc=catalin.marinas@arm.com \
    --cc=corbet@lwn.net \
    --cc=davidgow@google.com \
    --cc=joe.lawrence@redhat.com \
    --cc=keescook@chromium.org \
    --cc=knut.omang@oracle.com \
    --cc=kunit-dev@googlegroups.com \
    --cc=linux-doc@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=tytso@mit.edu \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.