1240116Smarcel// 2240116Smarcel// Automated Testing Framework (atf) 3240116Smarcel// 4240116Smarcel// Copyright (c) 2007 The NetBSD Foundation, Inc. 5240116Smarcel// All rights reserved. 6240116Smarcel// 7240116Smarcel// Redistribution and use in source and binary forms, with or without 8240116Smarcel// modification, are permitted provided that the following conditions 9240116Smarcel// are met: 10240116Smarcel// 1. Redistributions of source code must retain the above copyright 11240116Smarcel// notice, this list of conditions and the following disclaimer. 12240116Smarcel// 2. Redistributions in binary form must reproduce the above copyright 13240116Smarcel// notice, this list of conditions and the following disclaimer in the 14240116Smarcel// documentation and/or other materials provided with the distribution. 15240116Smarcel// 16240116Smarcel// THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND 17240116Smarcel// CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 18240116Smarcel// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19240116Smarcel// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20240116Smarcel// IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY 21240116Smarcel// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22240116Smarcel// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 23240116Smarcel// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24240116Smarcel// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 25240116Smarcel// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 26240116Smarcel// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 27240116Smarcel// IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28240116Smarcel// 29240116Smarcel 30240116Smarcel#if !defined(_ATF_CXX_CHECK_HPP_) 31240116Smarcel#define _ATF_CXX_CHECK_HPP_ 32240116Smarcel 33240116Smarcelextern "C" { 34240116Smarcel#include <atf-c/check.h> 35240116Smarcel} 36240116Smarcel 37240116Smarcel#include <cstddef> 38240116Smarcel#include <memory> 39240116Smarcel#include <string> 40240116Smarcel#include <vector> 41240116Smarcel 42240116Smarcel#include <atf-c++/utils.hpp> 43240116Smarcel 44240116Smarcelnamespace atf { 45240116Smarcel 46240116Smarcelnamespace process { 47240116Smarcelclass argv_array; 48240116Smarcel} // namespace process 49240116Smarcel 50240116Smarcelnamespace check { 51240116Smarcel 52240116Smarcel// ------------------------------------------------------------------------ 53240116Smarcel// The "check_result" class. 54240116Smarcel// ------------------------------------------------------------------------ 55240116Smarcel 56240116Smarcel//! 57240116Smarcel//! \brief A class that contains results of executed command. 58240116Smarcel//! 59240116Smarcel//! The check_result class holds information about results 60240116Smarcel//! of executing arbitrary command and manages files containing 61240116Smarcel//! its output. 62240116Smarcel//! 63240116Smarcelclass check_result : utils::noncopyable { 64240116Smarcel //! 65240116Smarcel //! \brief Internal representation of a result. 66240116Smarcel //! 67240116Smarcel atf_check_result_t m_result; 68240116Smarcel 69240116Smarcel //! 70240116Smarcel //! \brief Constructs a results object and grabs ownership of the 71240116Smarcel //! parameter passed in. 72240116Smarcel //! 73240116Smarcel check_result(const atf_check_result_t* result); 74240116Smarcel 75240116Smarcel friend check_result test_constructor(const char* const*); 76240116Smarcel friend std::auto_ptr< check_result > exec(const atf::process::argv_array&); 77240116Smarcel 78240116Smarcelpublic: 79240116Smarcel //! 80240116Smarcel //! \brief Destroys object and removes all managed files. 81240116Smarcel //! 82240116Smarcel ~check_result(void); 83240116Smarcel 84240116Smarcel //! 85240116Smarcel //! \brief Returns whether the command exited correctly or not. 86240116Smarcel //! 87240116Smarcel bool exited(void) const; 88240116Smarcel 89240116Smarcel //! 90240116Smarcel //! \brief Returns command's exit status. 91240116Smarcel //! 92240116Smarcel int exitcode(void) const; 93240116Smarcel 94240116Smarcel //! 95240116Smarcel //! \brief Returns whether the command received a signal or not. 96240116Smarcel //! 97240116Smarcel bool signaled(void) const; 98240116Smarcel 99240116Smarcel //! 100240116Smarcel //! \brief Returns the signal that terminated the command. 101240116Smarcel //! 102240116Smarcel int termsig(void) const; 103240116Smarcel 104240116Smarcel //! 105240116Smarcel //! \brief Returns the path to file contaning command's stdout. 106240116Smarcel //! 107240116Smarcel const std::string stdout_path(void) const; 108240116Smarcel 109240116Smarcel //! 110240116Smarcel //! \brief Returns the path to file contaning command's stderr. 111240116Smarcel //! 112240116Smarcel const std::string stderr_path(void) const; 113240116Smarcel}; 114240116Smarcel 115240116Smarcel// ------------------------------------------------------------------------ 116240116Smarcel// Free functions. 117240116Smarcel// ------------------------------------------------------------------------ 118240116Smarcel 119240116Smarcelbool build_c_o(const std::string&, const std::string&, 120240116Smarcel const atf::process::argv_array&); 121240116Smarcelbool build_cpp(const std::string&, const std::string&, 122240116Smarcel const atf::process::argv_array&); 123240116Smarcelbool build_cxx_o(const std::string&, const std::string&, 124240116Smarcel const atf::process::argv_array&); 125240116Smarcelstd::auto_ptr< check_result > exec(const atf::process::argv_array&); 126240116Smarcel 127240116Smarcel// Useful for testing only. 128240116Smarcelcheck_result test_constructor(void); 129240116Smarcel 130240116Smarcel} // namespace check 131240116Smarcel} // namespace atf 132240116Smarcel 133240116Smarcel#endif // !defined(_ATF_CXX_CHECK_HPP_) 134