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. 15 // 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. 28 // 29 30 #if !defined(_ATF_CXX_CHECK_HPP_) 31 #define _ATF_CXX_CHECK_HPP_ 32 33 extern "C" { 34 #include <atf-c/check.h> 35 } 36 37 #include <cstddef> 38 #include <memory> 39 #include <string> 40 #include <vector> 41 42 #include <atf-c++/utils.hpp> 43 44 namespace atf { 45 46 namespace process { 47 class argv_array; 48 } // namespace process 49 50 namespace check { 51 52 // ------------------------------------------------------------------------ 53 // The "check_result" class. 54 // ------------------------------------------------------------------------ 55 56 //! 57 //! \brief A class that contains results of executed command. 58 //! 59 //! The check_result class holds information about results 60 //! of executing arbitrary command and manages files containing 61 //! its output. 62 //! 63 class check_result : utils::noncopyable { 64 //! 65 //! \brief Internal representation of a result. 66 //! 67 atf_check_result_t m_result; 68 69 //! 70 //! \brief Constructs a results object and grabs ownership of the 71 //! parameter passed in. 72 //! 73 check_result(const atf_check_result_t* result); 74 75 friend check_result test_constructor(const char* const*); 76 friend std::auto_ptr< check_result > exec(const atf::process::argv_array&); 77 78 public: 79 //! 80 //! \brief Destroys object and removes all managed files. 81 //! 82 ~check_result(void); 83 84 //! 85 //! \brief Returns whether the command exited correctly or not. 86 //! 87 bool exited(void) const; 88 89 //! 90 //! \brief Returns command's exit status. 91 //! 92 int exitcode(void) const; 93 94 //! 95 //! \brief Returns whether the command received a signal or not. 96 //! 97 bool signaled(void) const; 98 99 //! 100 //! \brief Returns the signal that terminated the command. 101 //! 102 int termsig(void) const; 103 104 //! 105 //! \brief Returns the path to file contaning command's stdout. 106 //! 107 const std::string stdout_path(void) const; 108 109 //! 110 //! \brief Returns the path to file contaning command's stderr. 111 //! 112 const std::string stderr_path(void) const; 113 }; 114 115 // ------------------------------------------------------------------------ 116 // Free functions. 117 // ------------------------------------------------------------------------ 118 119 bool build_c_o(const std::string&, const std::string&, 120 const atf::process::argv_array&); 121 bool build_cpp(const std::string&, const std::string&, 122 const atf::process::argv_array&); 123 bool build_cxx_o(const std::string&, const std::string&, 124 const atf::process::argv_array&); 125 std::auto_ptr< check_result > exec(const atf::process::argv_array&); 126 127 // Useful for testing only. 128 check_result test_constructor(void); 129 130 } // namespace check 131 } // namespace atf 132 133 #endif // !defined(_ATF_CXX_CHECK_HPP_) 134