2 // Automated Testing Framework (atf)
4 // Copyright (c) 2007, 2008, 2009 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/tcr.h>
41 #include <atf-c++/fs.hpp>
42 #include <atf-c++/utils.hpp>
47 // ------------------------------------------------------------------------
48 // The "vars_map" class.
49 // ------------------------------------------------------------------------
51 typedef std::map
< std::string
, std::string
> vars_map
;
53 // ------------------------------------------------------------------------
55 // ------------------------------------------------------------------------
58 //! \brief Holds the results of a test case's execution.
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.
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.
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
;
79 tcr(state
, const std::string
&);
83 state
get_state(void) const;
84 const std::string
get_reason(void) const;
86 tcr
& operator=(const tcr
&);
89 // ------------------------------------------------------------------------
91 // ------------------------------------------------------------------------
93 class tc
: utils::noncopyable
{
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
*);
110 tc(const std::string
&);
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
&)
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
&);
134 #endif // !defined(_ATF_CXX_TESTS_HPP_)