18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci 38c2ecf20Sopenharmony_ci#include <kunit/test.h> 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci/* 68c2ecf20Sopenharmony_ci * These symbols point to the .kunit_test_suites section and are defined in 78c2ecf20Sopenharmony_ci * include/asm-generic/vmlinux.lds.h, and consequently must be extern. 88c2ecf20Sopenharmony_ci */ 98c2ecf20Sopenharmony_ciextern struct kunit_suite * const * const __kunit_suites_start[]; 108c2ecf20Sopenharmony_ciextern struct kunit_suite * const * const __kunit_suites_end[]; 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#if IS_BUILTIN(CONFIG_KUNIT) 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_cistatic void kunit_print_tap_header(void) 158c2ecf20Sopenharmony_ci{ 168c2ecf20Sopenharmony_ci struct kunit_suite * const * const *suites, * const *subsuite; 178c2ecf20Sopenharmony_ci int num_of_suites = 0; 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci for (suites = __kunit_suites_start; 208c2ecf20Sopenharmony_ci suites < __kunit_suites_end; 218c2ecf20Sopenharmony_ci suites++) 228c2ecf20Sopenharmony_ci for (subsuite = *suites; *subsuite != NULL; subsuite++) 238c2ecf20Sopenharmony_ci num_of_suites++; 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci pr_info("TAP version 14\n"); 268c2ecf20Sopenharmony_ci pr_info("1..%d\n", num_of_suites); 278c2ecf20Sopenharmony_ci} 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ciint kunit_run_all_tests(void) 308c2ecf20Sopenharmony_ci{ 318c2ecf20Sopenharmony_ci struct kunit_suite * const * const *suites; 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci kunit_print_tap_header(); 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci for (suites = __kunit_suites_start; 368c2ecf20Sopenharmony_ci suites < __kunit_suites_end; 378c2ecf20Sopenharmony_ci suites++) 388c2ecf20Sopenharmony_ci __kunit_test_suites_init(*suites); 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci return 0; 418c2ecf20Sopenharmony_ci} 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci#endif /* IS_BUILTIN(CONFIG_KUNIT) */ 44