xref: /linux/lib/test_module.c (revision 09c434b8)
1*09c434b8SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
293e9ef83SKees Cook /*
393e9ef83SKees Cook  * This module emits "Hello, world" on printk when loaded.
493e9ef83SKees Cook  *
593e9ef83SKees Cook  * It is designed to be used for basic evaluation of the module loading
693e9ef83SKees Cook  * subsystem (for example when validating module signing/verification). It
793e9ef83SKees Cook  * lacks any extra dependencies, and will not normally be loaded by the
893e9ef83SKees Cook  * system unless explicitly requested by name.
993e9ef83SKees Cook  */
1093e9ef83SKees Cook 
1193e9ef83SKees Cook #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
1293e9ef83SKees Cook 
1393e9ef83SKees Cook #include <linux/init.h>
1493e9ef83SKees Cook #include <linux/module.h>
1593e9ef83SKees Cook #include <linux/printk.h>
1693e9ef83SKees Cook 
test_module_init(void)1793e9ef83SKees Cook static int __init test_module_init(void)
1893e9ef83SKees Cook {
1993e9ef83SKees Cook 	pr_warn("Hello, world\n");
2093e9ef83SKees Cook 
2193e9ef83SKees Cook 	return 0;
2293e9ef83SKees Cook }
2393e9ef83SKees Cook 
2493e9ef83SKees Cook module_init(test_module_init);
2593e9ef83SKees Cook 
test_module_exit(void)2693e9ef83SKees Cook static void __exit test_module_exit(void)
2793e9ef83SKees Cook {
2893e9ef83SKees Cook 	pr_warn("Goodbye\n");
2993e9ef83SKees Cook }
3093e9ef83SKees Cook 
3193e9ef83SKees Cook module_exit(test_module_exit);
3293e9ef83SKees Cook 
3393e9ef83SKees Cook MODULE_AUTHOR("Kees Cook <keescook@chromium.org>");
3493e9ef83SKees Cook MODULE_LICENSE("GPL");
35