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_CHECK_HPP)
27 #define ATF_CXX_CHECK_HPP
30 #include <atf-c/check.h>
42 } // namespace process
46 // ------------------------------------------------------------------------
47 // The "check_result" class.
48 // ------------------------------------------------------------------------
51 //! \brief A class that contains results of executed command.
53 //! The check_result class holds information about results
54 //! of executing arbitrary command and manages files containing
59 check_result(const check_result&);
60 check_result& operator=(const check_result&);
63 //! \brief Internal representation of a result.
65 atf_check_result_t m_result;
68 //! \brief Constructs a results object and grabs ownership of the
69 //! parameter passed in.
71 check_result(const atf_check_result_t* result);
73 friend check_result test_constructor(const char* const*);
74 friend std::auto_ptr< check_result > exec(const atf::process::argv_array&);
78 //! \brief Destroys object and removes all managed files.
83 //! \brief Returns whether the command exited correctly or not.
85 bool exited(void) const;
88 //! \brief Returns command's exit status.
90 int exitcode(void) const;
93 //! \brief Returns whether the command received a signal or not.
95 bool signaled(void) const;
98 //! \brief Returns the signal that terminated the command.
100 int termsig(void) const;
103 //! \brief Returns the path to file contaning command's stdout.
105 const std::string stdout_path(void) const;
108 //! \brief Returns the path to file contaning command's stderr.
110 const std::string stderr_path(void) const;
113 // ------------------------------------------------------------------------
115 // ------------------------------------------------------------------------
117 bool build_c_o(const std::string&, const std::string&,
118 const atf::process::argv_array&);
119 bool build_cpp(const std::string&, const std::string&,
120 const atf::process::argv_array&);
121 bool build_cxx_o(const std::string&, const std::string&,
122 const atf::process::argv_array&);
123 std::auto_ptr< check_result > exec(const atf::process::argv_array&);
125 // Useful for testing only.
126 check_result test_constructor(void);
131 #endif // !defined(ATF_CXX_CHECK_HPP)