Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kcsan: test: use new suite_{init,exit} support

Use the newly added suite_{init,exit} support for suite-wide init and
cleanup. This avoids the unsupported method by which the test used to do
suite-wide init and cleanup (avoiding issues such as missing TAP
headers, and possible future conflicts).

Signed-off-by: Marco Elver <elver@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Marco Elver and committed by
Shuah Khan
2434031c b18d2847

+13 -18
+13 -18
kernel/kcsan/kcsan_test.c
··· 1565 1565 torture_cleanup_end(); 1566 1566 } 1567 1567 1568 - static struct kunit_suite kcsan_test_suite = { 1569 - .name = "kcsan", 1570 - .test_cases = kcsan_test_cases, 1571 - .init = test_init, 1572 - .exit = test_exit, 1573 - }; 1574 - static struct kunit_suite *kcsan_test_suites[] = { &kcsan_test_suite, NULL }; 1575 - 1576 1568 __no_kcsan 1577 1569 static void register_tracepoints(struct tracepoint *tp, void *ignore) 1578 1570 { ··· 1580 1588 tracepoint_probe_unregister(tp, probe_console, NULL); 1581 1589 } 1582 1590 1583 - /* 1584 - * We only want to do tracepoints setup and teardown once, therefore we have to 1585 - * customize the init and exit functions and cannot rely on kunit_test_suite(). 1586 - */ 1587 - static int __init kcsan_test_init(void) 1591 + static int kcsan_suite_init(struct kunit_suite *suite) 1588 1592 { 1589 1593 /* 1590 1594 * Because we want to be able to build the test as a module, we need to ··· 1588 1600 * won't work here. 1589 1601 */ 1590 1602 for_each_kernel_tracepoint(register_tracepoints, NULL); 1591 - return __kunit_test_suites_init(kcsan_test_suites); 1603 + return 0; 1592 1604 } 1593 1605 1594 - static void kcsan_test_exit(void) 1606 + static void kcsan_suite_exit(struct kunit_suite *suite) 1595 1607 { 1596 - __kunit_test_suites_exit(kcsan_test_suites); 1597 1608 for_each_kernel_tracepoint(unregister_tracepoints, NULL); 1598 1609 tracepoint_synchronize_unregister(); 1599 1610 } 1600 1611 1601 - late_initcall_sync(kcsan_test_init); 1602 - module_exit(kcsan_test_exit); 1612 + static struct kunit_suite kcsan_test_suite = { 1613 + .name = "kcsan", 1614 + .test_cases = kcsan_test_cases, 1615 + .init = test_init, 1616 + .exit = test_exit, 1617 + .suite_init = kcsan_suite_init, 1618 + .suite_exit = kcsan_suite_exit, 1619 + }; 1620 + 1621 + kunit_test_suites(&kcsan_test_suite); 1603 1622 1604 1623 MODULE_LICENSE("GPL v2"); 1605 1624 MODULE_AUTHOR("Marco Elver <elver@google.com>");