xref: /openbmc/linux/arch/s390/lib/test_modules.c (revision 90c53187)
1 // SPDX-License-Identifier: GPL-2.0+
2 
3 #include <kunit/test.h>
4 #include <linux/module.h>
5 
6 #include "test_modules.h"
7 
8 #define DECLARE_RETURN(i) int test_modules_return_ ## i(void)
9 REPEAT_10000(DECLARE_RETURN);
10 
11 /*
12  * Test that modules with many relocations are loaded properly.
13  */
14 static void test_modules_many_vmlinux_relocs(struct kunit *test)
15 {
16 	int result = 0;
17 
18 #define CALL_RETURN(i) result += test_modules_return_ ## i()
19 	REPEAT_10000(CALL_RETURN);
20 	KUNIT_ASSERT_EQ(test, result, 49995000);
21 }
22 
23 static struct kunit_case modules_testcases[] = {
24 	KUNIT_CASE(test_modules_many_vmlinux_relocs),
25 	{}
26 };
27 
28 static struct kunit_suite modules_test_suite = {
29 	.name = "modules_test_s390",
30 	.test_cases = modules_testcases,
31 };
32 
33 kunit_test_suites(&modules_test_suite);
34 
35 MODULE_LICENSE("GPL");
36