1 #include <linux/sort.h>
2 #include <linux/slab.h>
3 #include <linux/module.h>
5 /* a simple boot-time regression test */
9 static int __init cmpint(const void *a, const void *b)
11 return *(int *)a - *(int *)b;
14 static int __init test_sort_init(void)
16 int *a, i, r = 1, err = -ENOMEM;
18 a = kmalloc_array(TEST_LEN, sizeof(*a), GFP_KERNEL);
22 for (i = 0; i < TEST_LEN; i++) {
23 r = (r * 725861) % 6599;
27 sort(a, TEST_LEN, sizeof(*a), cmpint, NULL);
30 for (i = 0; i < TEST_LEN-1; i++)
32 pr_err("test has failed\n");
36 pr_info("test passed\n");
42 static void __exit test_sort_exit(void)
46 module_init(test_sort_init);
47 module_exit(test_sort_exit);
49 MODULE_LICENSE("GPL");