Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/contrib/atf/atf-c/tc.h
39507 views
1
/* Copyright (c) 2008 The NetBSD Foundation, Inc.
2
* All rights reserved.
3
*
4
* Redistribution and use in source and binary forms, with or without
5
* modification, are permitted provided that the following conditions
6
* are met:
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.
12
*
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. */
25
26
#if !defined(ATF_C_TC_H)
27
#define ATF_C_TC_H
28
29
#include <stdbool.h>
30
#include <stddef.h>
31
32
#include <atf-c/defs.h>
33
#include <atf-c/error_fwd.h>
34
35
struct atf_tc;
36
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 *);
40
41
/* ---------------------------------------------------------------------
42
* The "atf_tc_pack" type.
43
* --------------------------------------------------------------------- */
44
45
/* For static initialization only. */
46
struct atf_tc_pack {
47
const char *m_ident;
48
49
const char *const *m_config;
50
51
atf_tc_head_t m_head;
52
atf_tc_body_t m_body;
53
atf_tc_cleanup_t m_cleanup;
54
};
55
typedef const struct atf_tc_pack atf_tc_pack_t;
56
57
/* ---------------------------------------------------------------------
58
* The "atf_tc" type.
59
* --------------------------------------------------------------------- */
60
61
struct atf_tc_impl;
62
struct atf_tc {
63
struct atf_tc_impl *pimpl;
64
};
65
typedef struct atf_tc atf_tc_t;
66
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,
70
const char *const *);
71
atf_error_t atf_tc_init_pack(atf_tc_t *, atf_tc_pack_t *,
72
const char *const *);
73
void atf_tc_fini(atf_tc_t *);
74
75
/* Getters. */
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 *,
79
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 *,
82
const bool);
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 *,
85
const long);
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 *);
90
91
/* Modifiers. */
92
atf_error_t atf_tc_set_md_var(atf_tc_t *, const char *, const char *, ...);
93
94
/* ---------------------------------------------------------------------
95
* Free functions.
96
* --------------------------------------------------------------------- */
97
98
atf_error_t atf_tc_run(const atf_tc_t *, const char *);
99
atf_error_t atf_tc_cleanup(const atf_tc_t *);
100
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
#ifdef __FreeBSD__
110
void atf_tc_require_kmod(const char *);
111
#endif
112
void atf_tc_require_prog(const char *);
113
void atf_tc_skip(const char *, ...)
114
ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(1, 2)
115
ATF_DEFS_ATTRIBUTE_NORETURN;
116
void atf_tc_expect_pass(void);
117
void atf_tc_expect_fail(const char *, ...)
118
ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(1, 2);
119
void atf_tc_expect_exit(const int, const char *, ...)
120
ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(2, 3);
121
void atf_tc_expect_signal(const int, const char *, ...)
122
ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(2, 3);
123
void atf_tc_expect_death(const char *, ...)
124
ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(1, 2);
125
void atf_tc_expect_timeout(const char *, ...)
126
ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(1, 2);
127
128
/* To be run from test case bodies only; internal to macros.h. */
129
void atf_tc_fail_check(const char *, const size_t, const char *, ...)
130
ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(3, 4);
131
void atf_tc_fail_requirement(const char *, const size_t, const char *, ...)
132
ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(3, 4)
133
ATF_DEFS_ATTRIBUTE_NORETURN;
134
void atf_tc_check_errno(const char *, const size_t, const int,
135
const char *, const bool);
136
void atf_tc_require_errno(const char *, const size_t, const int,
137
const char *, const bool);
138
139
#endif /* !defined(ATF_C_TC_H) */
140
141