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
42240116Smarcelnamespace atf {
43240116Smarcel
44240116Smarcelnamespace process {
45240116Smarcelclass argv_array;
46240116Smarcel} // namespace process
47240116Smarcel
48240116Smarcelnamespace check {
49240116Smarcel
50240116Smarcel// ------------------------------------------------------------------------
51240116Smarcel// The "check_result" class.
52240116Smarcel// ------------------------------------------------------------------------
53240116Smarcel
54240116Smarcel//!
55240116Smarcel//! \brief A class that contains results of executed command.
56240116Smarcel//!
57240116Smarcel//! The check_result class holds information about results
58240116Smarcel//! of executing arbitrary command and manages files containing
59240116Smarcel//! its output.
60240116Smarcel//!
61262855Sjmmvclass check_result {
62262855Sjmmv    // Non-copyable.
63262855Sjmmv    check_result(const check_result&);
64262855Sjmmv    check_result& operator=(const check_result&);
65262855Sjmmv
66240116Smarcel    //!
67240116Smarcel    //! \brief Internal representation of a result.
68240116Smarcel    //!
69240116Smarcel    atf_check_result_t m_result;
70240116Smarcel
71240116Smarcel    //!
72240116Smarcel    //! \brief Constructs a results object and grabs ownership of the
73240116Smarcel    //! parameter passed in.
74240116Smarcel    //!
75240116Smarcel    check_result(const atf_check_result_t* result);
76240116Smarcel
77240116Smarcel    friend check_result test_constructor(const char* const*);
78240116Smarcel    friend std::auto_ptr< check_result > exec(const atf::process::argv_array&);
79240116Smarcel
80240116Smarcelpublic:
81240116Smarcel    //!
82240116Smarcel    //! \brief Destroys object and removes all managed files.
83240116Smarcel    //!
84240116Smarcel    ~check_result(void);
85240116Smarcel
86240116Smarcel    //!
87240116Smarcel    //! \brief Returns whether the command exited correctly or not.
88240116Smarcel    //!
89240116Smarcel    bool exited(void) const;
90240116Smarcel
91240116Smarcel    //!
92240116Smarcel    //! \brief Returns command's exit status.
93240116Smarcel    //!
94240116Smarcel    int exitcode(void) const;
95240116Smarcel
96240116Smarcel    //!
97240116Smarcel    //! \brief Returns whether the command received a signal or not.
98240116Smarcel    //!
99240116Smarcel    bool signaled(void) const;
100240116Smarcel
101240116Smarcel    //!
102240116Smarcel    //! \brief Returns the signal that terminated the command.
103240116Smarcel    //!
104240116Smarcel    int termsig(void) const;
105240116Smarcel
106240116Smarcel    //!
107240116Smarcel    //! \brief Returns the path to file contaning command's stdout.
108240116Smarcel    //!
109240116Smarcel    const std::string stdout_path(void) const;
110240116Smarcel
111240116Smarcel    //!
112240116Smarcel    //! \brief Returns the path to file contaning command's stderr.
113240116Smarcel    //!
114240116Smarcel    const std::string stderr_path(void) const;
115240116Smarcel};
116240116Smarcel
117240116Smarcel// ------------------------------------------------------------------------
118240116Smarcel// Free functions.
119240116Smarcel// ------------------------------------------------------------------------
120240116Smarcel
121240116Smarcelbool build_c_o(const std::string&, const std::string&,
122240116Smarcel               const atf::process::argv_array&);
123240116Smarcelbool build_cpp(const std::string&, const std::string&,
124240116Smarcel               const atf::process::argv_array&);
125240116Smarcelbool build_cxx_o(const std::string&, const std::string&,
126240116Smarcel                 const atf::process::argv_array&);
127240116Smarcelstd::auto_ptr< check_result > exec(const atf::process::argv_array&);
128240116Smarcel
129240116Smarcel// Useful for testing only.
130240116Smarcelcheck_result test_constructor(void);
131240116Smarcel
132240116Smarcel} // namespace check
133240116Smarcel} // namespace atf
134240116Smarcel
135240116Smarcel#endif // !defined(_ATF_CXX_CHECK_HPP_)
136