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>
41 #include <atf-c++/noncopyable.hpp>
54 atf_tp_writer(std::ostream
&);
56 void start_tc(const std::string
&);
58 void tc_meta_data(const std::string
&, const std::string
&);
61 bool match(const std::string
&, const std::string
&);
65 // ------------------------------------------------------------------------
66 // The "vars_map" class.
67 // ------------------------------------------------------------------------
69 typedef std::map
< std::string
, std::string
> vars_map
;
71 // ------------------------------------------------------------------------
73 // ------------------------------------------------------------------------
77 class tc
: noncopyable
{
78 std::auto_ptr
< tc_impl
> pimpl
;
81 virtual void head(void);
82 virtual void body(void) const = 0;
83 virtual void cleanup(void) const;
85 void require_prog(const std::string
&) const;
87 friend struct tc_impl
;
90 tc(const std::string
&, const bool);
93 void init(const vars_map
&);
95 const std::string
get_config_var(const std::string
&) const;
96 const std::string
get_config_var(const std::string
&, const std::string
&)
98 const std::string
get_md_var(const std::string
&) const;
99 const vars_map
get_md_vars(void) const;
100 bool has_config_var(const std::string
&) const;
101 bool has_md_var(const std::string
&) const;
102 void set_md_var(const std::string
&, const std::string
&);
104 void run(const std::string
&) const;
105 void run_cleanup(void) const;
107 // To be called from the child process only.
108 static void pass(void) ATF_DEFS_ATTRIBUTE_NORETURN
;
109 static void fail(const std::string
&) ATF_DEFS_ATTRIBUTE_NORETURN
;
110 static void fail_nonfatal(const std::string
&);
111 static void skip(const std::string
&) ATF_DEFS_ATTRIBUTE_NORETURN
;
112 static void check_errno(const char*, const int, const int, const char*,
114 static void require_errno(const char*, const int, const int, const char*,
116 static void expect_pass(void);
117 static void expect_fail(const std::string
&);
118 static void expect_exit(const int, const std::string
&);
119 static void expect_signal(const int, const std::string
&);
120 static void expect_death(const std::string
&);
121 static void expect_timeout(const std::string
&);
127 #endif // !defined(_ATF_CXX_TESTS_HPP_)