2 // Automated Testing Framework (atf)
4 // Copyright (c) 2007 The NetBSD Foundation, Inc.
5 // All rights reserved.
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions
10 // 1. Redistributions of source code must retain the above copyright
11 // notice, this list of conditions and the following disclaimer.
12 // 2. Redistributions in binary form must reproduce the above copyright
13 // notice, this list of conditions and the following disclaimer in the
14 // documentation and/or other materials provided with the distribution.
16 // THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
17 // CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
18 // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 // IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
21 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23 // GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25 // IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27 // IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #if !defined(_ATF_CXX_TESTS_HPP_)
31 #define _ATF_CXX_TESTS_HPP_
38 #include <atf-c/defs.h>
52 atf_tp_writer(std::ostream
&);
54 void start_tc(const std::string
&);
56 void tc_meta_data(const std::string
&, const std::string
&);
59 bool match(const std::string
&, const std::string
&);
63 // ------------------------------------------------------------------------
64 // The "vars_map" class.
65 // ------------------------------------------------------------------------
67 typedef std::map
< std::string
, std::string
> vars_map
;
69 // ------------------------------------------------------------------------
71 // ------------------------------------------------------------------------
78 tc
& operator=(const tc
&);
80 std::auto_ptr
< tc_impl
> pimpl
;
83 virtual void head(void);
84 virtual void body(void) const = 0;
85 virtual void cleanup(void) const;
87 void require_prog(const std::string
&) const;
89 friend struct tc_impl
;
92 tc(const std::string
&, const bool);
95 void init(const vars_map
&);
97 const std::string
get_config_var(const std::string
&) const;
98 const std::string
get_config_var(const std::string
&, const std::string
&)
100 const std::string
get_md_var(const std::string
&) const;
101 const vars_map
get_md_vars(void) const;
102 bool has_config_var(const std::string
&) const;
103 bool has_md_var(const std::string
&) const;
104 void set_md_var(const std::string
&, const std::string
&);
106 void run(const std::string
&) const;
107 void run_cleanup(void) const;
109 // To be called from the child process only.
110 static void pass(void) ATF_DEFS_ATTRIBUTE_NORETURN
;
111 static void fail(const std::string
&) ATF_DEFS_ATTRIBUTE_NORETURN
;
112 static void fail_nonfatal(const std::string
&);
113 static void skip(const std::string
&) ATF_DEFS_ATTRIBUTE_NORETURN
;
114 static void check_errno(const char*, const int, const int, const char*,
116 static void require_errno(const char*, const int, const int, const char*,
118 static void expect_pass(void);
119 static void expect_fail(const std::string
&);
120 static void expect_exit(const int, const std::string
&);
121 static void expect_signal(const int, const std::string
&);
122 static void expect_death(const std::string
&);
123 static void expect_timeout(const std::string
&);
129 #endif // !defined(_ATF_CXX_TESTS_HPP_)