2 * Copyright (c) 2011 Alex Hornung <alex@alexhornung.com>.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
19 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
20 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
22 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
24 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
26 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 #include <sys/resource.h>
32 #include <sys/types.h>
33 #include <sys/param.h>
35 #include <sys/linker.h>
37 #include <sys/ioctl.h>
52 #include <libprop/proplib.h>
59 #include <dfregress.h>
60 #include <sys/tbridge.h>
64 run_kernel(const char *kmod, prop_dictionary_t testcase)
67 prop_dictionary_t tkcase = NULL;
69 int fd, r, kmod_id, ret = 0;
71 if ((r = stat("/dev/tbridge", &sb)) != 0) {
72 sprintf(errmsg, "Kernel bridge module probably not loaded: %s",
74 testcase_set_sys_buf(testcase, errmsg);
75 testcase_set_result(testcase, RESULT_PREFAIL);
80 /* First kldload the testcase */
81 kmod_id = kldload(kmod);
83 sprintf(errmsg, "Could not load testcase kmod %s: %s", kmod,
85 testcase_set_sys_buf(testcase, errmsg);
86 testcase_set_result(testcase, RESULT_PREFAIL);
91 /* Open control device */
92 fd = open("/dev/tbridge", O_RDWR);
94 sprintf(errmsg, "Could not open kernel bridge interface: %s",
96 testcase_set_sys_buf(testcase, errmsg);
97 testcase_set_result(testcase, RESULT_PREFAIL);
103 /* Then load the testcase description into the kernel */
104 r = prop_dictionary_send_ioctl(testcase, fd, TBRIDGE_LOADTEST);
106 sprintf(errmsg, "sending testcase to kernel failed: %s",
108 testcase_set_sys_buf(testcase, errmsg);
109 testcase_set_result(testcase, RESULT_PREFAIL);
115 /* Then wait for the result */
116 r = prop_dictionary_recv_ioctl(fd, TBRIDGE_GETRESULT, &tkcase);
118 sprintf(errmsg, "receiving test results from kernel failed: %s",
120 testcase_set_sys_buf(testcase, errmsg);
121 testcase_set_result(testcase, RESULT_PREFAIL);
127 /* Copy over the values of interest */
128 testcase_set_result(testcase, testcase_get_result(tkcase));
129 testcase_set_stdout_buf(testcase, testcase_get_stdout_buf(tkcase));
131 /* Release copy received from kernel */
132 prop_object_release(tkcase);
135 r = kldunload(kmod_id);
137 sprintf(errmsg, "kldunload for %s failed: %s", kmod,
139 testcase_set_sys_buf(testcase, errmsg);