xref: /linux/lib/test_module.c (revision 613f21505b25a4f43f33de00f11afc059bedde2b)
1  // SPDX-License-Identifier: GPL-2.0-only
2  /*
3   * This module emits "Hello, world" on printk when loaded.
4   *
5   * It is designed to be used for basic evaluation of the module loading
6   * subsystem (for example when validating module signing/verification). It
7   * lacks any extra dependencies, and will not normally be loaded by the
8   * system unless explicitly requested by name.
9   */
10  
11  #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
12  
13  #include <linux/init.h>
14  #include <linux/module.h>
15  #include <linux/printk.h>
16  
17  static int __init test_module_init(void)
18  {
19  	pr_warn("Hello, world\n");
20  
21  	return 0;
22  }
23  
24  module_init(test_module_init);
25  
26  static void __exit test_module_exit(void)
27  {
28  	pr_warn("Goodbye\n");
29  }
30  
31  module_exit(test_module_exit);
32  
33  MODULE_AUTHOR("Kees Cook <keescook@chromium.org>");
34  MODULE_DESCRIPTION("module loading subsystem test module");
35  MODULE_LICENSE("GPL");
36