Skip to contentSkip to conversation

lib: Add module support to crc32 tests

PATCH Applied Geert Uytterhoeven 2 participants 4 messages Jan 3, 2017 – Jan 4, 2017 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 lib: Add module support to crc32 tests

Extract the crc32 test code into its own source file, to allow to compile it either to a loadable module, or builtin into the kernel.

---
 lib/Kconfig                  |   3 +-
 lib/Makefile                 |   1 +
 lib/crc32.c                  | 824 -------------------------------------------
 lib/{crc32.c => crc32test.c} | 320 +----------------
 4 files changed, 7 insertions(+), 1141 deletions(-)
 copy lib/{crc32.c => crc32test.c} (82%)
lib/Kconfig +1 -2
index 260a80e313b9022a..0095b828f2384691 100644
@@ -103,8 +103,7 @@ config CRC32
 	  functions require M here.
 
 config CRC32_SELFTEST
-	bool "CRC32 perform self test on init"
-	default n
+	tristate "CRC32 perform self test on init"
 	depends on CRC32
 	help
 	  This option enables the CRC32 library functions to perform a
lib/Makefile +1 -0
index bc4073a8cd08da83..ef723f8d3c1dd9d8 100644
@@ -90,6 +90,7 @@ obj-$(CONFIG_CRC16)	+= crc16.o
 obj-$(CONFIG_CRC_T10DIF)+= crc-t10dif.o
 obj-$(CONFIG_CRC_ITU_T)	+= crc-itu-t.o
 obj-$(CONFIG_CRC32)	+= crc32.o
+obj-$(CONFIG_CRC32_SELFTEST)	+= crc32test.o
 obj-$(CONFIG_CRC7)	+= crc7.o
 obj-$(CONFIG_LIBCRC32C)	+= libcrc32c.o
 obj-$(CONFIG_CRC8)	+= crc8.o
lib/crc32.c +0 -824

827 lines not on this page · raw message

lib/crc32test.c renamed from lib/crc32.c +5 -315

333 lines not on this page · raw message

Signature · 1 line
1.9.1
#1 lore raw

PATCH 2/3 lib: Add module support to glob tests

Extract the glob test code into its own source file, to allow to compile it either to a loadable module, or builtin into the kernel.

---
 lib/Kconfig                |   3 +-
 lib/Makefile               |   1 +
 lib/glob.c                 | 164 ---------------------------------------------
 lib/{glob.c => globtest.c} | 132 ++----------------------------------
 4 files changed, 8 insertions(+), 292 deletions(-)
 copy lib/{glob.c => globtest.c} (54%)
lib/Kconfig +1 -2
index 0095b828f2384691..7e19f85a8c5e7db8 100644
@@ -431,8 +431,7 @@ config GLOB
 	  depends on this.
 
 config GLOB_SELFTEST
-	bool "glob self-test on init"
-	default n
+	tristate "glob self-test on init"
 	depends on GLOB
 	help
 	  This option enables a simple self-test of the glob_match
lib/Makefile +1 -0
index ef723f8d3c1dd9d8..35621b9c641432f1 100644
@@ -160,6 +160,7 @@ obj-$(CONFIG_CORDIC) += cordic.o
 obj-$(CONFIG_DQL) += dynamic_queue_limits.o
 
 obj-$(CONFIG_GLOB) += glob.o
+obj-$(CONFIG_GLOB_SELFTEST) += globtest.o
 
 obj-$(CONFIG_MPILIB) += mpi/
 obj-$(CONFIG_SIGNATURE) += digsig.o
lib/glob.c +0 -164

167 lines not on this page · raw message

lib/globtest.c renamed from lib/glob.c +6 -126

142 lines not on this page · raw message

Signature · 1 line
1.9.1
Reviewed-by on v1 2/3
#2 lore raw

Re: [PATCH 2/3] lib: Add module support to glob tests

Quoted 2 lines · Geert Uytterhoeven

Extract the glob test code into its own source file, to allow to compile it either to a loadable module, or builtin into the kernel.

To the whole series

One minor comment below.

Quoted 1 line

+obj-$(CONFIG_GLOB_SELFTEST) += globtest.o

Can we use pattern test_*, or at least *_test.*?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#3 lore raw

PATCH 3/3 lib: Add module support to atomic64 tests

In reply to Geert Uytterhoeven

Allow to compile the atomic64 test code either to a loadable module, or builtin into the kernel.

---
 lib/Kconfig.debug   |  5 +++--
 lib/atomic64_test.c | 10 ++++++++--
 2 files changed, 11 insertions(+), 4 deletions(-)
lib/Kconfig.debug +3 -2
index b06848a104e6940e..42e210544b27fca7 100644
@@ -1765,9 +1765,10 @@ config PERCPU_TEST
 	  If unsure, say N.
 
 config ATOMIC64_SELFTEST
-	bool "Perform an atomic64_t self-test at boot"
+	tristate "Perform an atomic64_t self-test"
 	help
-	  Enable this option to test the atomic64_t functions at boot.
+	  Enable this option to test the atomic64_t functions at boot or
+	  at module load time.
 
 	  If unsure, say N.
 
lib/atomic64_test.c +8 -2
index 46042901130f107b..fd70c0e0e6731499 100644
@@ -15,6 +15,7 @@
 #include <linux/bug.h>
 #include <linux/kernel.h>
 #include <linux/atomic.h>
+#include <linux/module.h>
 
 #ifdef CONFIG_X86
 #include <asm/cpufeature.h>	/* for boot_cpu_has below */
@@ -241,7 +242,7 @@ static __init void test_atomic64(void)
 	BUG_ON(v.counter != r);
 }
 
-static __init int test_atomics(void)
+static __init int test_atomics_init(void)
 {
 	test_atomic();
 	test_atomic64();
@@ -264,4 +265,9 @@ static __init int test_atomics(void)
 	return 0;
 }
 
-core_initcall(test_atomics);
+static __exit void test_atomics_exit(void) {}
+
+module_init(test_atomics_init);
+module_exit(test_atomics_exit);
+
+MODULE_LICENSE("GPL");
Signature · 1 line
1.9.1