tc.h revision 1.1.1.7.4.1 1 1.1 jmmv /*
2 1.1 jmmv * Automated Testing Framework (atf)
3 1.1 jmmv *
4 1.1.1.7.4.1 cherry * Copyright (c) 2008, 2009, 2010, 2011 The NetBSD Foundation, Inc.
5 1.1 jmmv * All rights reserved.
6 1.1 jmmv *
7 1.1 jmmv * Redistribution and use in source and binary forms, with or without
8 1.1 jmmv * modification, are permitted provided that the following conditions
9 1.1 jmmv * are met:
10 1.1 jmmv * 1. Redistributions of source code must retain the above copyright
11 1.1 jmmv * notice, this list of conditions and the following disclaimer.
12 1.1 jmmv * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 jmmv * notice, this list of conditions and the following disclaimer in the
14 1.1 jmmv * documentation and/or other materials provided with the distribution.
15 1.1 jmmv *
16 1.1 jmmv * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
17 1.1 jmmv * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
18 1.1 jmmv * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 1.1 jmmv * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 1.1 jmmv * IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
21 1.1 jmmv * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 1.1 jmmv * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23 1.1 jmmv * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 1.1 jmmv * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25 1.1 jmmv * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26 1.1 jmmv * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27 1.1 jmmv * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 1.1 jmmv */
29 1.1 jmmv
30 1.1 jmmv #if !defined(ATF_C_TC_H)
31 1.1 jmmv #define ATF_C_TC_H
32 1.1 jmmv
33 1.1.1.6 jmmv #include <stdbool.h>
34 1.1.1.6 jmmv #include <stddef.h>
35 1.1.1.6 jmmv
36 1.1 jmmv #include <atf-c/defs.h>
37 1.1 jmmv #include <atf-c/error_fwd.h>
38 1.1 jmmv
39 1.1 jmmv struct atf_tc;
40 1.1 jmmv
41 1.1 jmmv typedef void (*atf_tc_head_t)(struct atf_tc *);
42 1.1 jmmv typedef void (*atf_tc_body_t)(const struct atf_tc *);
43 1.1 jmmv typedef void (*atf_tc_cleanup_t)(const struct atf_tc *);
44 1.1 jmmv
45 1.1 jmmv /* ---------------------------------------------------------------------
46 1.1 jmmv * The "atf_tc_pack" type.
47 1.1 jmmv * --------------------------------------------------------------------- */
48 1.1 jmmv
49 1.1 jmmv /* For static initialization only. */
50 1.1 jmmv struct atf_tc_pack {
51 1.1 jmmv const char *m_ident;
52 1.1 jmmv
53 1.1.1.6 jmmv const char *const *m_config;
54 1.1 jmmv
55 1.1 jmmv atf_tc_head_t m_head;
56 1.1 jmmv atf_tc_body_t m_body;
57 1.1 jmmv atf_tc_cleanup_t m_cleanup;
58 1.1 jmmv };
59 1.1 jmmv typedef const struct atf_tc_pack atf_tc_pack_t;
60 1.1 jmmv
61 1.1 jmmv /* ---------------------------------------------------------------------
62 1.1 jmmv * The "atf_tc" type.
63 1.1 jmmv * --------------------------------------------------------------------- */
64 1.1 jmmv
65 1.1.1.6 jmmv struct atf_tc_impl;
66 1.1 jmmv struct atf_tc {
67 1.1.1.6 jmmv struct atf_tc_impl *pimpl;
68 1.1 jmmv };
69 1.1 jmmv typedef struct atf_tc atf_tc_t;
70 1.1 jmmv
71 1.1 jmmv /* Constructors/destructors. */
72 1.1 jmmv atf_error_t atf_tc_init(atf_tc_t *, const char *, atf_tc_head_t,
73 1.1 jmmv atf_tc_body_t, atf_tc_cleanup_t,
74 1.1.1.6 jmmv const char *const *);
75 1.1 jmmv atf_error_t atf_tc_init_pack(atf_tc_t *, atf_tc_pack_t *,
76 1.1.1.6 jmmv const char *const *);
77 1.1 jmmv void atf_tc_fini(atf_tc_t *);
78 1.1 jmmv
79 1.1 jmmv /* Getters. */
80 1.1 jmmv const char *atf_tc_get_ident(const atf_tc_t *);
81 1.1 jmmv const char *atf_tc_get_config_var(const atf_tc_t *, const char *);
82 1.1 jmmv const char *atf_tc_get_config_var_wd(const atf_tc_t *, const char *,
83 1.1 jmmv const char *);
84 1.1.1.7 jmmv bool atf_tc_get_config_var_as_bool(const atf_tc_t *, const char *);
85 1.1.1.7 jmmv bool atf_tc_get_config_var_as_bool_wd(const atf_tc_t *, const char *,
86 1.1.1.7 jmmv const bool);
87 1.1.1.7 jmmv long atf_tc_get_config_var_as_long(const atf_tc_t *, const char *);
88 1.1.1.7 jmmv long atf_tc_get_config_var_as_long_wd(const atf_tc_t *, const char *,
89 1.1.1.7 jmmv const long);
90 1.1 jmmv const char *atf_tc_get_md_var(const atf_tc_t *, const char *);
91 1.1.1.6 jmmv char **atf_tc_get_md_vars(const atf_tc_t *);
92 1.1 jmmv bool atf_tc_has_config_var(const atf_tc_t *, const char *);
93 1.1 jmmv bool atf_tc_has_md_var(const atf_tc_t *, const char *);
94 1.1 jmmv
95 1.1 jmmv /* Modifiers. */
96 1.1 jmmv atf_error_t atf_tc_set_md_var(atf_tc_t *, const char *, const char *, ...);
97 1.1 jmmv
98 1.1 jmmv /* ---------------------------------------------------------------------
99 1.1 jmmv * Free functions.
100 1.1 jmmv * --------------------------------------------------------------------- */
101 1.1 jmmv
102 1.1.1.6 jmmv atf_error_t atf_tc_run(const atf_tc_t *, const char *);
103 1.1.1.3 jmmv atf_error_t atf_tc_cleanup(const atf_tc_t *);
104 1.1 jmmv
105 1.1 jmmv /* To be run from test case bodies only. */
106 1.1.1.7.4.1 cherry void atf_tc_fail(const char *, ...)
107 1.1.1.7.4.1 cherry ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(1, 2)
108 1.1.1.7.4.1 cherry ATF_DEFS_ATTRIBUTE_NORETURN;
109 1.1.1.7.4.1 cherry void atf_tc_fail_nonfatal(const char *, ...)
110 1.1.1.7.4.1 cherry ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(1, 2);
111 1.1.1.7.4.1 cherry void atf_tc_pass(void)
112 1.1.1.7.4.1 cherry ATF_DEFS_ATTRIBUTE_NORETURN;
113 1.1 jmmv void atf_tc_require_prog(const char *);
114 1.1.1.7.4.1 cherry void atf_tc_skip(const char *, ...)
115 1.1.1.7.4.1 cherry ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(1, 2)
116 1.1.1.7.4.1 cherry ATF_DEFS_ATTRIBUTE_NORETURN;
117 1.1.1.5 jmmv void atf_tc_expect_pass(void);
118 1.1.1.7.4.1 cherry void atf_tc_expect_fail(const char *, ...)
119 1.1.1.7.4.1 cherry ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(1, 2);
120 1.1.1.7.4.1 cherry void atf_tc_expect_exit(const int, const char *, ...)
121 1.1.1.7.4.1 cherry ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(2, 3);
122 1.1.1.7.4.1 cherry void atf_tc_expect_signal(const int, const char *, ...)
123 1.1.1.7.4.1 cherry ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(2, 3);
124 1.1.1.7.4.1 cherry void atf_tc_expect_death(const char *, ...)
125 1.1.1.7.4.1 cherry ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(1, 2);
126 1.1.1.7.4.1 cherry void atf_tc_expect_timeout(const char *, ...)
127 1.1.1.7.4.1 cherry ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(1, 2);
128 1.1 jmmv
129 1.1 jmmv /* To be run from test case bodies only; internal to macros.h. */
130 1.1.1.7.4.1 cherry void atf_tc_fail_check(const char *, const size_t, const char *, ...)
131 1.1.1.7.4.1 cherry ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(3, 4);
132 1.1.1.5 jmmv void atf_tc_fail_requirement(const char *, const size_t, const char *, ...)
133 1.1.1.7.4.1 cherry ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(3, 4)
134 1.1.1.7.4.1 cherry ATF_DEFS_ATTRIBUTE_NORETURN;
135 1.1.1.5 jmmv void atf_tc_check_errno(const char *, const size_t, const int,
136 1.1.1.5 jmmv const char *, const bool);
137 1.1.1.5 jmmv void atf_tc_require_errno(const char *, const size_t, const int,
138 1.1.1.5 jmmv const char *, const bool);
139 1.1 jmmv
140 1.1 jmmv #endif /* ATF_C_TC_H */
141