// Copyright (c) 2007 The NetBSD Foundation, Inc.1// All rights reserved.2//3// Redistribution and use in source and binary forms, with or without4// modification, are permitted provided that the following conditions5// are met:6// 1. Redistributions of source code must retain the above copyright7// notice, this list of conditions and the following disclaimer.8// 2. Redistributions in binary form must reproduce the above copyright9// notice, this list of conditions and the following disclaimer in the10// documentation and/or other materials provided with the distribution.11//12// THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND13// CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,14// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF15// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.16// IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY17// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL18// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE19// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS20// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER21// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR22// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN23// IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.2425#if !defined(ATF_CXX_CHECK_HPP)26#define ATF_CXX_CHECK_HPP2728extern "C" {29#include <atf-c/check.h>30}3132#include <cstddef>33#include <memory>34#include <string>35#include <vector>3637namespace atf {3839namespace process {40class argv_array;41} // namespace process4243namespace check {4445// ------------------------------------------------------------------------46// The "check_result" class.47// ------------------------------------------------------------------------4849//!50//! \brief A class that contains results of executed command.51//!52//! The check_result class holds information about results53//! of executing arbitrary command and manages files containing54//! its output.55//!56class check_result {57// Non-copyable.58check_result(const check_result&);59check_result& operator=(const check_result&);6061//!62//! \brief Internal representation of a result.63//!64atf_check_result_t m_result;6566//!67//! \brief Constructs a results object and grabs ownership of the68//! parameter passed in.69//!70check_result(const atf_check_result_t* result);7172friend check_result test_constructor(const char* const*);73friend std::unique_ptr< check_result > exec(const atf::process::argv_array&);7475public:76//!77//! \brief Destroys object and removes all managed files.78//!79~check_result(void);8081//!82//! \brief Returns whether the command exited correctly or not.83//!84bool exited(void) const;8586//!87//! \brief Returns command's exit status.88//!89int exitcode(void) const;9091//!92//! \brief Returns whether the command received a signal or not.93//!94bool signaled(void) const;9596//!97//! \brief Returns the signal that terminated the command.98//!99int termsig(void) const;100101//!102//! \brief Returns the path to file contaning command's stdout.103//!104const std::string stdout_path(void) const;105106//!107//! \brief Returns the path to file contaning command's stderr.108//!109const std::string stderr_path(void) const;110};111112// ------------------------------------------------------------------------113// Free functions.114// ------------------------------------------------------------------------115116bool build_c_o(const std::string&, const std::string&,117const atf::process::argv_array&);118bool build_cpp(const std::string&, const std::string&,119const atf::process::argv_array&);120bool build_cxx_o(const std::string&, const std::string&,121const atf::process::argv_array&);122std::unique_ptr< check_result > exec(const atf::process::argv_array&);123124// Useful for testing only.125check_result test_constructor(void);126127} // namespace check128} // namespace atf129130#endif // !defined(ATF_CXX_CHECK_HPP)131132133