summaryrefslogtreecommitdiffstats
path: root/lib/test_printf.c
diff options
context:
space:
mode:
authorTobin C. Harding <tobin@kernel.org>2019-04-05 12:58:57 +1100
committerShuah Khan <shuah@kernel.org>2019-04-08 16:44:20 -0600
commit6b1a4d5b1a26ae830d50e08d7b3ca0e8b3e6b453 (patch)
tree81b50e651aced73bf2b80f6a7444b9dd3f921586 /lib/test_printf.c
parenteebf4dd452377921e3a2635f0f5df2042470faef (diff)
downloadlinux-6b1a4d5b1a26ae830d50e08d7b3ca0e8b3e6b453.tar.gz
linux-6b1a4d5b1a26ae830d50e08d7b3ca0e8b3e6b453.tar.bz2
linux-6b1a4d5b1a26ae830d50e08d7b3ca0e8b3e6b453.zip
lib: Use new kselftest header
We just added a new C header file for use with test modules that are intended to be run with kselftest. We can reduce code duplication by using this header. Use new kselftest header to reduce code duplication in test_printf and test_bitmap test modules. Acked-by: Kees Cook <keescook@chromium.org> Signed-off-by: Tobin C. Harding <tobin@kernel.org> Signed-off-by: Shuah Khan <shuah@kernel.org>
Diffstat (limited to 'lib/test_printf.c')
-rw-r--r--lib/test_printf.c23
1 files changed, 5 insertions, 18 deletions
diff --git a/lib/test_printf.c b/lib/test_printf.c
index 601e8519319a..f4fcc1c43739 100644
--- a/lib/test_printf.c
+++ b/lib/test_printf.c
@@ -21,6 +21,8 @@
#include <linux/gfp.h>
#include <linux/mm.h>
+#include "../tools/testing/selftests/kselftest_module.h"
+
#define BUF_SIZE 256
#define PAD_SIZE 16
#define FILL_CHAR '$'
@@ -590,12 +592,11 @@ test_pointer(void)
flags();
}
-static int __init
-test_printf_init(void)
+static void __init selftest(void)
{
alloced_buffer = kmalloc(BUF_SIZE + 2*PAD_SIZE, GFP_KERNEL);
if (!alloced_buffer)
- return -ENOMEM;
+ return;
test_buffer = alloced_buffer + PAD_SIZE;
test_basic();
@@ -604,22 +605,8 @@ test_printf_init(void)
test_pointer();
kfree(alloced_buffer);
-
- if (failed_tests == 0)
- pr_info("all %u tests passed\n", total_tests);
- else
- pr_warn("failed %u out of %u tests\n", failed_tests, total_tests);
-
- return failed_tests ? -EINVAL : 0;
}
-module_init(test_printf_init);
-
-static void __exit test_printf_exit(void)
-{
-}
-
-module_exit(test_printf_exit);
-
+KSTM_MODULE_LOADERS(test_printf);
MODULE_AUTHOR("Rasmus Villemoes <linux@rasmusvillemoes.dk>");
MODULE_LICENSE("GPL");