1 // Copyright (c) 2007 The NetBSD Foundation, Inc.
2 // All rights reserved.
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_CXX_TESTS_HPP)
27 #define ATF_CXX_TESTS_HPP
34 #include <atf-c/defs.h>
48 atf_tp_writer(std::ostream&);
50 void start_tc(const std::string&);
52 void tc_meta_data(const std::string&, const std::string&);
55 bool match(const std::string&, const std::string&);
59 // ------------------------------------------------------------------------
60 // The "vars_map" class.
61 // ------------------------------------------------------------------------
63 typedef std::map< std::string, std::string > vars_map;
65 // ------------------------------------------------------------------------
67 // ------------------------------------------------------------------------
74 tc& operator=(const tc&);
76 std::unique_ptr< tc_impl > pimpl;
79 virtual void head(void);
80 virtual void body(void) const = 0;
81 virtual void cleanup(void) const;
83 void require_prog(const std::string&) const;
85 friend struct tc_impl;
88 tc(const std::string&, const bool);
91 void init(const vars_map&);
93 const std::string get_config_var(const std::string&) const;
94 const std::string get_config_var(const std::string&, const std::string&)
96 const std::string get_md_var(const std::string&) const;
97 const vars_map get_md_vars(void) const;
98 bool has_config_var(const std::string&) const;
99 bool has_md_var(const std::string&) const;
100 void set_md_var(const std::string&, const std::string&);
102 void run(const std::string&) const;
103 void run_cleanup(void) const;
105 // To be called from the child process only.
106 static void pass(void) ATF_DEFS_ATTRIBUTE_NORETURN;
107 static void fail(const std::string&) ATF_DEFS_ATTRIBUTE_NORETURN;
108 static void fail_nonfatal(const std::string&);
109 static void skip(const std::string&) ATF_DEFS_ATTRIBUTE_NORETURN;
110 static void check_errno(const char*, const int, const int, const char*,
112 static void require_errno(const char*, const int, const int, const char*,
114 static void expect_pass(void);
115 static void expect_fail(const std::string&);
116 static void expect_exit(const int, const std::string&);
117 static void expect_signal(const int, const std::string&);
118 static void expect_death(const std::string&);
119 static void expect_timeout(const std::string&);
125 #endif // !defined(ATF_CXX_TESTS_HPP)