]> git.saurik.com Git - apple/xnu.git/blob - bsd/kern/kern_tests.c
xnu-2422.90.20.tar.gz
[apple/xnu.git] / bsd / kern / kern_tests.c
1 /***************************************************************
2 * Test Declarations Go Here *
3 ***************************************************************/
4 #include <pexpert/pexpert.h>
5 #include <sys/sysctl.h>
6 #include <kern/debug.h>
7 #include <sys/kern_tests.h>
8
9 /***************************************************************
10 * End Test Declarations *
11 ***************************************************************/
12 typedef int (*xnu_test_func_t)(void);
13
14 typedef struct xnu_test {
15 xnu_test_func_t t_func;
16 const char *t_name;
17 } xnu_test_t;
18
19 #define DEFINE_XNU_TEST(func) { func, #func }
20
21 xnu_test_t xnu_tests[] = {
22 };
23
24 #define NUM_XNU_TESTS (sizeof(xnu_tests) / sizeof(xnu_test_t))
25
26 static int
27 run_xnu_tests
28 (struct sysctl_oid *oidp, __unused void *arg1, __unused int arg2, struct sysctl_req *req)
29 {
30 unsigned i;
31 int result;
32
33 for (i = 0; i < NUM_XNU_TESTS; i++) {
34 result = xnu_tests[i].t_func();
35 if (result == 0) {
36 kprintf("xnu_tests: %s passed.\n", xnu_tests[i].t_name);
37 } else{
38 panic("xnu_tests: %s failed.\n", xnu_tests[i].t_name);
39 }
40 }
41
42 return sysctl_handle_int(oidp, NULL, 0, req);
43 }
44
45 SYSCTL_PROC(_kern, OID_AUTO, kern_tests,
46 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
47 0, 0, run_xnu_tests, "I", "");
48