check.hpp revision 262855
1252190Srpaulo// 2252190Srpaulo// Automated Testing Framework (atf) 3252190Srpaulo// 4252190Srpaulo// Copyright (c) 2007 The NetBSD Foundation, Inc. 5252190Srpaulo// All rights reserved. 6252190Srpaulo// 7252190Srpaulo// Redistribution and use in source and binary forms, with or without 8252190Srpaulo// modification, are permitted provided that the following conditions 9252190Srpaulo// are met: 10252190Srpaulo// 1. Redistributions of source code must retain the above copyright 11252190Srpaulo// notice, this list of conditions and the following disclaimer. 12252190Srpaulo// 2. Redistributions in binary form must reproduce the above copyright 13252190Srpaulo// notice, this list of conditions and the following disclaimer in the 14252190Srpaulo// documentation and/or other materials provided with the distribution. 15252190Srpaulo// 16252190Srpaulo// THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND 17252190Srpaulo// CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 18252190Srpaulo// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19252190Srpaulo// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20252190Srpaulo// IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY 21252190Srpaulo// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22252190Srpaulo// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 23252190Srpaulo// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24252190Srpaulo// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 25252190Srpaulo// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 26252190Srpaulo// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 27252190Srpaulo// IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28252190Srpaulo// 29252190Srpaulo 30252190Srpaulo#if !defined(_ATF_CXX_CHECK_HPP_) 31252190Srpaulo#define _ATF_CXX_CHECK_HPP_ 32252190Srpaulo 33252190Srpauloextern "C" { 34252190Srpaulo#include <atf-c/check.h> 35252190Srpaulo} 36252190Srpaulo 37252190Srpaulo#include <cstddef> 38252190Srpaulo#include <memory> 39252190Srpaulo#include <string> 40252190Srpaulo#include <vector> 41252190Srpaulo 42252190Srpaulonamespace atf { 43252190Srpaulo 44252190Srpaulonamespace process { 45252190Srpauloclass argv_array; 46252190Srpaulo} // namespace process 47252190Srpaulo 48252190Srpaulonamespace check { 49252190Srpaulo 50252190Srpaulo// ------------------------------------------------------------------------ 51252190Srpaulo// The "check_result" class. 52252190Srpaulo// ------------------------------------------------------------------------ 53252190Srpaulo 54252190Srpaulo//! 55252190Srpaulo//! \brief A class that contains results of executed command. 56252190Srpaulo//! 57252190Srpaulo//! The check_result class holds information about results 58252190Srpaulo//! of executing arbitrary command and manages files containing 59252190Srpaulo//! its output. 60252190Srpaulo//! 61252190Srpauloclass check_result { 62252190Srpaulo // Non-copyable. 63252190Srpaulo check_result(const check_result&); 64252190Srpaulo check_result& operator=(const check_result&); 65252190Srpaulo 66252190Srpaulo //! 67252190Srpaulo //! \brief Internal representation of a result. 68252190Srpaulo //! 69252190Srpaulo atf_check_result_t m_result; 70252190Srpaulo 71252190Srpaulo //! 72 //! \brief Constructs a results object and grabs ownership of the 73 //! parameter passed in. 74 //! 75 check_result(const atf_check_result_t* result); 76 77 friend check_result test_constructor(const char* const*); 78 friend std::auto_ptr< check_result > exec(const atf::process::argv_array&); 79 80public: 81 //! 82 //! \brief Destroys object and removes all managed files. 83 //! 84 ~check_result(void); 85 86 //! 87 //! \brief Returns whether the command exited correctly or not. 88 //! 89 bool exited(void) const; 90 91 //! 92 //! \brief Returns command's exit status. 93 //! 94 int exitcode(void) const; 95 96 //! 97 //! \brief Returns whether the command received a signal or not. 98 //! 99 bool signaled(void) const; 100 101 //! 102 //! \brief Returns the signal that terminated the command. 103 //! 104 int termsig(void) const; 105 106 //! 107 //! \brief Returns the path to file contaning command's stdout. 108 //! 109 const std::string stdout_path(void) const; 110 111 //! 112 //! \brief Returns the path to file contaning command's stderr. 113 //! 114 const std::string stderr_path(void) const; 115}; 116 117// ------------------------------------------------------------------------ 118// Free functions. 119// ------------------------------------------------------------------------ 120 121bool build_c_o(const std::string&, const std::string&, 122 const atf::process::argv_array&); 123bool build_cpp(const std::string&, const std::string&, 124 const atf::process::argv_array&); 125bool build_cxx_o(const std::string&, const std::string&, 126 const atf::process::argv_array&); 127std::auto_ptr< check_result > exec(const atf::process::argv_array&); 128 129// Useful for testing only. 130check_result test_constructor(void); 131 132} // namespace check 133} // namespace atf 134 135#endif // !defined(_ATF_CXX_CHECK_HPP_) 136