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 #define TESTCASE_TYPE_USERLAND 0x01
31 #define TESTCASE_TYPE_KERNEL 0x02
32 #define TESTCASE_TYPE_BUILDONLY 0x03
34 #define TESTCASE_INT_PRE 0x001
35 #define TESTCASE_INT_POST 0x002
36 #define TESTCASE_CUSTOM_PRE 0x004
37 #define TESTCASE_CUSTOM_POST 0x008
38 #define TESTCASE_NOBUILD 0x010
39 #define TESTCASE_RUN_AS 0x020
42 struct testcase_options
{
43 long int timeout_in_secs
;
52 struct testcase_result
{
71 struct testcase_options opts
;
72 struct testcase_result results
;
75 prop_dictionary_t
testcase_from_struct(struct testcase
*testcase
);
77 struct timeval
*testcase_get_timeout(prop_dictionary_t testcase
);
78 int testcase_get_type(prop_dictionary_t testcase
);
79 const char *testcase_get_type_desc(prop_dictionary_t testcase
);
80 const char *testcase_get_name(prop_dictionary_t testcase
);
81 const char **testcase_get_args(prop_dictionary_t testcase
);
82 uint32_t testcase_get_flags(prop_dictionary_t testcase
);
83 int testcase_get_precmd_type(prop_dictionary_t testcase
);
84 int testcase_get_postcmd_type(prop_dictionary_t testcase
);
85 int testcase_needs_setuid(prop_dictionary_t testcase
);
86 uid_t
testcase_get_runas_uid(prop_dictionary_t testcase
);
87 const char *testcase_get_custom_precmd(prop_dictionary_t testcase
);
88 const char *testcase_get_custom_postcmd(prop_dictionary_t testcase
);
89 const char *testcase_get_make_cmd(prop_dictionary_t testcase
);
90 prop_dictionary_t
testcase_get_result_dict(prop_dictionary_t testcase
);
91 int testcase_set_build_buf(prop_dictionary_t testcase
, const char *buf
);
92 int testcase_set_cleanup_buf(prop_dictionary_t testcase
, const char *buf
);
93 int testcase_set_sys_buf(prop_dictionary_t testcase
, const char *buf
);
94 int testcase_set_precmd_buf(prop_dictionary_t testcase
, const char *buf
);
95 int testcase_set_postcmd_buf(prop_dictionary_t testcase
, const char *buf
);
96 int testcase_set_stdout_buf(prop_dictionary_t testcase
, const char *buf
);
97 int testcase_set_stderr_buf(prop_dictionary_t testcase
, const char *buf
);
98 int testcase_set_stdout_buf_from_file(prop_dictionary_t testcase
, const char *file
);
99 int testcase_set_stderr_buf_from_file(prop_dictionary_t testcase
, const char *file
);
100 int testcase_set_result(prop_dictionary_t testcase
, int result
);
101 int testcase_set_exit_value(prop_dictionary_t testcase
, int exitval
);
102 int testcase_set_signal(prop_dictionary_t testcase
, int sig
);
103 const char *testcase_get_build_buf(prop_dictionary_t testcase
);
104 const char *testcase_get_cleanup_buf(prop_dictionary_t testcase
);
105 const char *testcase_get_sys_buf(prop_dictionary_t testcase
);
106 const char *testcase_get_precmd_buf(prop_dictionary_t testcase
);
107 const char *testcase_get_postcmd_buf(prop_dictionary_t testcase
);
108 const char *testcase_get_stdout_buf(prop_dictionary_t testcase
);
109 const char *testcase_get_stderr_buf(prop_dictionary_t testcase
);
110 int testcase_get_result(prop_dictionary_t testcase
);
111 const char *testcase_get_result_desc(prop_dictionary_t testcase
);
112 int testcase_get_exit_value(prop_dictionary_t testcase
);
113 int testcase_get_signal(prop_dictionary_t testcase
);
115 int parse_testcase_option(struct testcase_options
*opts
, char *option
);
116 void testcase_entry_parser(void *arg
, char **tokens
);