1 /* Copyright (c) 2008 The NetBSD Foundation, Inc.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
14 * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
15 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 * IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
20 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
22 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
24 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
26 #if !defined(ATF_C_TC_H)
32 #include <atf-c/defs.h>
33 #include <atf-c/error_fwd.h>
37 typedef void (*atf_tc_head_t)(struct atf_tc *);
38 typedef void (*atf_tc_body_t)(const struct atf_tc *);
39 typedef void (*atf_tc_cleanup_t)(const struct atf_tc *);
41 /* ---------------------------------------------------------------------
42 * The "atf_tc_pack" type.
43 * --------------------------------------------------------------------- */
45 /* For static initialization only. */
49 const char *const *m_config;
53 atf_tc_cleanup_t m_cleanup;
55 typedef const struct atf_tc_pack atf_tc_pack_t;
57 /* ---------------------------------------------------------------------
59 * --------------------------------------------------------------------- */
63 struct atf_tc_impl *pimpl;
65 typedef struct atf_tc atf_tc_t;
67 /* Constructors/destructors. */
68 atf_error_t atf_tc_init(atf_tc_t *, const char *, atf_tc_head_t,
69 atf_tc_body_t, atf_tc_cleanup_t,
71 atf_error_t atf_tc_init_pack(atf_tc_t *, atf_tc_pack_t *,
73 void atf_tc_fini(atf_tc_t *);
76 const char *atf_tc_get_ident(const atf_tc_t *);
77 const char *atf_tc_get_config_var(const atf_tc_t *, const char *);
78 const char *atf_tc_get_config_var_wd(const atf_tc_t *, const char *,
80 bool atf_tc_get_config_var_as_bool(const atf_tc_t *, const char *);
81 bool atf_tc_get_config_var_as_bool_wd(const atf_tc_t *, const char *,
83 long atf_tc_get_config_var_as_long(const atf_tc_t *, const char *);
84 long atf_tc_get_config_var_as_long_wd(const atf_tc_t *, const char *,
86 const char *atf_tc_get_md_var(const atf_tc_t *, const char *);
87 char **atf_tc_get_md_vars(const atf_tc_t *);
88 bool atf_tc_has_config_var(const atf_tc_t *, const char *);
89 bool atf_tc_has_md_var(const atf_tc_t *, const char *);
92 atf_error_t atf_tc_set_md_var(atf_tc_t *, const char *, const char *, ...);
94 /* ---------------------------------------------------------------------
96 * --------------------------------------------------------------------- */
98 atf_error_t atf_tc_run(const atf_tc_t *, const char *);
99 atf_error_t atf_tc_cleanup(const atf_tc_t *);
101 /* To be run from test case bodies only. */
102 void atf_tc_fail(const char *, ...)
103 ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(1, 2)
104 ATF_DEFS_ATTRIBUTE_NORETURN;
105 void atf_tc_fail_nonfatal(const char *, ...)
106 ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(1, 2);
107 void atf_tc_pass(void)
108 ATF_DEFS_ATTRIBUTE_NORETURN;
109 void atf_tc_require_prog(const char *);
110 void atf_tc_skip(const char *, ...)
111 ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(1, 2)
112 ATF_DEFS_ATTRIBUTE_NORETURN;
113 void atf_tc_expect_pass(void);
114 void atf_tc_expect_fail(const char *, ...)
115 ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(1, 2);
116 void atf_tc_expect_exit(const int, const char *, ...)
117 ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(2, 3);
118 void atf_tc_expect_signal(const int, const char *, ...)
119 ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(2, 3);
120 void atf_tc_expect_death(const char *, ...)
121 ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(1, 2);
122 void atf_tc_expect_timeout(const char *, ...)
123 ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(1, 2);
125 /* To be run from test case bodies only; internal to macros.h. */
126 void atf_tc_fail_check(const char *, const size_t, const char *, ...)
127 ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(3, 4);
128 void atf_tc_fail_requirement(const char *, const size_t, const char *, ...)
129 ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(3, 4)
130 ATF_DEFS_ATTRIBUTE_NORETURN;
131 void atf_tc_check_errno(const char *, const size_t, const int,
132 const char *, const bool);
133 void atf_tc_require_errno(const char *, const size_t, const int,
134 const char *, const bool);
136 #endif /* !defined(ATF_C_TC_H) */