]> git.saurik.com Git - apple/xnu.git/blame - bsd/kern/kern_tests.c
xnu-2422.110.17.tar.gz
[apple/xnu.git] / bsd / kern / kern_tests.c
CommitLineData
39236c6e
A
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 ***************************************************************/
12typedef int (*xnu_test_func_t)(void);
13
14typedef 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
21xnu_test_t xnu_tests[] = {
22};
23
24#define NUM_XNU_TESTS (sizeof(xnu_tests) / sizeof(xnu_test_t))
25
26static int
27run_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
45SYSCTL_PROC(_kern, OID_AUTO, kern_tests,
46 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
47 0, 0, run_xnu_tests, "I", "");
48