[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1575374868-32601-6-git-send-email-alan.maguire@oracle.com>
Date: Tue, 3 Dec 2019 12:07:47 +0000
From: Alan Maguire <alan.maguire@...cle.com>
To: brendanhiggins@...gle.com, linux-kselftest@...r.kernel.org
Cc: linux-kernel@...r.kernel.org, kunit-dev@...glegroups.com,
keescook@...omium.org, yzaikin@...gle.com,
akpm@...ux-foundation.org, yamada.masahiro@...ionext.com,
catalin.marinas@....com, joe.lawrence@...hat.com,
penguin-kernel@...ove.sakura.ne.jp, urezki@...il.com,
andriy.shevchenko@...ux.intel.com, corbet@....net,
davidgow@...gle.com, adilger.kernel@...ger.ca, tytso@....edu,
mcgrof@...nel.org, linux-doc@...r.kernel.org,
Alan Maguire <alan.maguire@...cle.com>,
Knut Omang <knut.omang@...cle.com>
Subject: [PATCH v5 linux-kselftest-test 5/6] kunit: allow kunit to be loaded as a module
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@...cle.com>
Signed-off-by: Knut Omang <knut.omang@...cle.com>
Signed-off-by: Alan Maguire <alan.maguire@...cle.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
Powered by blists - more mailing lists