tools/llvm: Do not build with symbols
[minix3.git] / external / bsd / atf / dist / atf-c++ / tests.hpp
blob22a2a8706a9ac5a7073074eed40c52fa922ca0eb
1 //
2 // Automated Testing Framework (atf)
3 //
4 // Copyright (c) 2007 The NetBSD Foundation, Inc.
5 // All rights reserved.
6 //
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions
9 // are met:
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_
33 #include <map>
34 #include <memory>
35 #include <string>
37 extern "C" {
38 #include <atf-c/defs.h>
41 #include <atf-c++/noncopyable.hpp>
43 namespace atf {
44 namespace tests {
46 namespace detail {
48 class atf_tp_writer {
49 std::ostream& m_os;
51 bool m_is_first;
53 public:
54 atf_tp_writer(std::ostream&);
56 void start_tc(const std::string&);
57 void end_tc(void);
58 void tc_meta_data(const std::string&, const std::string&);
61 bool match(const std::string&, const std::string&);
63 } // namespace
65 // ------------------------------------------------------------------------
66 // The "vars_map" class.
67 // ------------------------------------------------------------------------
69 typedef std::map< std::string, std::string > vars_map;
71 // ------------------------------------------------------------------------
72 // The "tc" class.
73 // ------------------------------------------------------------------------
75 struct tc_impl;
77 class tc : noncopyable {
78 std::auto_ptr< tc_impl > pimpl;
80 protected:
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;
89 public:
90 tc(const std::string&, const bool);
91 virtual ~tc(void);
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&)
97 const;
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*,
113 const bool);
114 static void require_errno(const char*, const int, const int, const char*,
115 const bool);
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&);
124 } // namespace tests
125 } // namespace atf
127 #endif // !defined(_ATF_CXX_TESTS_HPP_)