1 2 /* 3 * Module under test: linux/block/genhd.c 4 * 5 * Only those functions are tested here which are declared in <linux/genhd.h> 6 * 7 * Usage: 8 * 1. make 9 * 2. su 10 * 3. insmod ./test_genhd.ko 11 * 4. Check the test results in "dmesg" 12 * 5. rmmod test_genhd 13 */ 14 15 #include <linux/module.h> 16 #include <linux/genhd.h> 17 18 MODULE_AUTHOR("Márton Németh <nm127@freemail.hu>"); 19 MODULE_DESCRIPTION("Test block drivers"); 20 MODULE_LICENSE("GPL"); 21 22 #define BLK_DEV_NAME "test_block" 23 #define MAX_MAJOR 255 24 tc20(void)25static void tc20(void) 26 { 27 struct gendisk *gd_ptr; 28 29 gd_ptr = alloc_disk(1); 30 if (!gd_ptr) { 31 return; 32 } 33 printk(KERN_DEBUG "gd_ptr after alloc=%p\n", gd_ptr); 34 35 del_gendisk(gd_ptr); 36 } 37 test_init_module(void)38static int test_init_module(void) 39 { 40 printk(KERN_INFO "Starting test_genhd module\n"); 41 42 tc20(); 43 44 return 0; 45 } 46 test_exit_module(void)47static void test_exit_module(void) 48 { 49 printk(KERN_DEBUG "Unloading test_genhd module\n"); 50 } 51 52 module_init(test_init_module); 53 module_exit(test_exit_module); 54