No empty .Rs/.Re
[netbsd-mini2440.git] / external / bsd / atf / dist / atf-c++ / tests.hpp
blob23d5f43602947908ccf6b5433af3faccd7dd4a2d
1 //
2 // Automated Testing Framework (atf)
3 //
4 // Copyright (c) 2007, 2008, 2009 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 <string>
36 extern "C" {
37 #include <atf-c/tc.h>
38 #include <atf-c/tcr.h>
41 #include <atf-c++/fs.hpp>
42 #include <atf-c++/utils.hpp>
44 namespace atf {
45 namespace tests {
47 // ------------------------------------------------------------------------
48 // The "vars_map" class.
49 // ------------------------------------------------------------------------
51 typedef std::map< std::string, std::string > vars_map;
53 // ------------------------------------------------------------------------
54 // The "tcr" class.
55 // ------------------------------------------------------------------------
57 //!
58 //! \brief Holds the results of a test case's execution.
59 //!
60 //! The tcr class holds the information that describes the results of a
61 //! test case's execution. This is composed of an exit code and a reason
62 //! for that exit code.
63 //!
64 //! TODO: Complete documentation for this class. Not done yet because it
65 //! is worth to investigate if this class could be rewritten as several
66 //! different classes, one for each status.
67 //!
68 class tcr {
69 atf_tcr_t m_tcr;
71 public:
72 typedef atf_tcr_state_t state;
74 static const state passed_state;
75 static const state failed_state;
76 static const state skipped_state;
78 tcr(state);
79 tcr(state, const std::string&);
80 tcr(const tcr&);
81 ~tcr(void);
83 state get_state(void) const;
84 const std::string get_reason(void) const;
86 tcr& operator=(const tcr&);
89 // ------------------------------------------------------------------------
90 // The "tc" class.
91 // ------------------------------------------------------------------------
93 class tc : utils::noncopyable {
94 std::string m_ident;
95 atf_map_t m_config;
96 atf_tc_t m_tc;
98 protected:
99 virtual void head(void) = 0;
100 virtual void body(void) const = 0;
101 virtual void cleanup(void) const;
103 void require_prog(const std::string&) const;
105 static void wrap_head(atf_tc_t *);
106 static void wrap_body(const atf_tc_t *);
107 static void wrap_cleanup(const atf_tc_t *);
109 public:
110 tc(const std::string&);
111 virtual ~tc(void);
113 void init(const vars_map&);
115 const std::string get_config_var(const std::string&) const;
116 const std::string get_config_var(const std::string&, const std::string&)
117 const;
118 const std::string get_md_var(const std::string&) const;
119 bool has_config_var(const std::string&) const;
120 bool has_md_var(const std::string&) const;
121 void set_md_var(const std::string&, const std::string&);
123 tcr run(int, int, const fs::path&) const;
125 // To be called from the child process only.
126 static void pass(void);
127 static void fail(const std::string&);
128 static void skip(const std::string&);
131 } // namespace tests
132 } // namespace atf
134 #endif // !defined(_ATF_CXX_TESTS_HPP_)