xref: /minix3/external/bsd/atf/dist/atf-c++/check.hpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
111be35a1SLionel Sambuc //
211be35a1SLionel Sambuc // Automated Testing Framework (atf)
311be35a1SLionel Sambuc //
411be35a1SLionel Sambuc // Copyright (c) 2007 The NetBSD Foundation, Inc.
511be35a1SLionel Sambuc // All rights reserved.
611be35a1SLionel Sambuc //
711be35a1SLionel Sambuc // Redistribution and use in source and binary forms, with or without
811be35a1SLionel Sambuc // modification, are permitted provided that the following conditions
911be35a1SLionel Sambuc // are met:
1011be35a1SLionel Sambuc // 1. Redistributions of source code must retain the above copyright
1111be35a1SLionel Sambuc //    notice, this list of conditions and the following disclaimer.
1211be35a1SLionel Sambuc // 2. Redistributions in binary form must reproduce the above copyright
1311be35a1SLionel Sambuc //    notice, this list of conditions and the following disclaimer in the
1411be35a1SLionel Sambuc //    documentation and/or other materials provided with the distribution.
1511be35a1SLionel Sambuc //
1611be35a1SLionel Sambuc // THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
1711be35a1SLionel Sambuc // CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
1811be35a1SLionel Sambuc // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
1911be35a1SLionel Sambuc // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
2011be35a1SLionel Sambuc // IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
2111be35a1SLionel Sambuc // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2211be35a1SLionel Sambuc // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
2311be35a1SLionel Sambuc // GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2411be35a1SLionel Sambuc // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
2511be35a1SLionel Sambuc // IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
2611be35a1SLionel Sambuc // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
2711be35a1SLionel Sambuc // IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2811be35a1SLionel Sambuc //
2911be35a1SLionel Sambuc 
3011be35a1SLionel Sambuc #if !defined(_ATF_CXX_CHECK_HPP_)
3111be35a1SLionel Sambuc #define _ATF_CXX_CHECK_HPP_
3211be35a1SLionel Sambuc 
3311be35a1SLionel Sambuc extern "C" {
3411be35a1SLionel Sambuc #include <atf-c/check.h>
3511be35a1SLionel Sambuc }
3611be35a1SLionel Sambuc 
3711be35a1SLionel Sambuc #include <cstddef>
3811be35a1SLionel Sambuc #include <memory>
3911be35a1SLionel Sambuc #include <string>
4011be35a1SLionel Sambuc #include <vector>
4111be35a1SLionel Sambuc 
4211be35a1SLionel Sambuc namespace atf {
4311be35a1SLionel Sambuc 
4411be35a1SLionel Sambuc namespace process {
4511be35a1SLionel Sambuc class argv_array;
4611be35a1SLionel Sambuc } // namespace process
4711be35a1SLionel Sambuc 
4811be35a1SLionel Sambuc namespace check {
4911be35a1SLionel Sambuc 
5011be35a1SLionel Sambuc // ------------------------------------------------------------------------
5111be35a1SLionel Sambuc // The "check_result" class.
5211be35a1SLionel Sambuc // ------------------------------------------------------------------------
5311be35a1SLionel Sambuc 
5411be35a1SLionel Sambuc //!
5511be35a1SLionel Sambuc //! \brief A class that contains results of executed command.
5611be35a1SLionel Sambuc //!
5711be35a1SLionel Sambuc //! The check_result class holds information about results
5811be35a1SLionel Sambuc //! of executing arbitrary command and manages files containing
5911be35a1SLionel Sambuc //! its output.
6011be35a1SLionel Sambuc //!
61*0a6a1f1dSLionel Sambuc class check_result {
62*0a6a1f1dSLionel Sambuc     // Non-copyable.
63*0a6a1f1dSLionel Sambuc     check_result(const check_result&);
64*0a6a1f1dSLionel Sambuc     check_result& operator=(const check_result&);
65*0a6a1f1dSLionel Sambuc 
6611be35a1SLionel Sambuc     //!
6711be35a1SLionel Sambuc     //! \brief Internal representation of a result.
6811be35a1SLionel Sambuc     //!
6911be35a1SLionel Sambuc     atf_check_result_t m_result;
7011be35a1SLionel Sambuc 
7111be35a1SLionel Sambuc     //!
7211be35a1SLionel Sambuc     //! \brief Constructs a results object and grabs ownership of the
7311be35a1SLionel Sambuc     //! parameter passed in.
7411be35a1SLionel Sambuc     //!
7511be35a1SLionel Sambuc     check_result(const atf_check_result_t* result);
7611be35a1SLionel Sambuc 
7711be35a1SLionel Sambuc     friend check_result test_constructor(const char* const*);
7811be35a1SLionel Sambuc     friend std::auto_ptr< check_result > exec(const atf::process::argv_array&);
7911be35a1SLionel Sambuc 
8011be35a1SLionel Sambuc public:
8111be35a1SLionel Sambuc     //!
8211be35a1SLionel Sambuc     //! \brief Destroys object and removes all managed files.
8311be35a1SLionel Sambuc     //!
8411be35a1SLionel Sambuc     ~check_result(void);
8511be35a1SLionel Sambuc 
8611be35a1SLionel Sambuc     //!
8711be35a1SLionel Sambuc     //! \brief Returns whether the command exited correctly or not.
8811be35a1SLionel Sambuc     //!
8911be35a1SLionel Sambuc     bool exited(void) const;
9011be35a1SLionel Sambuc 
9111be35a1SLionel Sambuc     //!
9211be35a1SLionel Sambuc     //! \brief Returns command's exit status.
9311be35a1SLionel Sambuc     //!
9411be35a1SLionel Sambuc     int exitcode(void) const;
9511be35a1SLionel Sambuc 
9611be35a1SLionel Sambuc     //!
9711be35a1SLionel Sambuc     //! \brief Returns whether the command received a signal or not.
9811be35a1SLionel Sambuc     //!
9911be35a1SLionel Sambuc     bool signaled(void) const;
10011be35a1SLionel Sambuc 
10111be35a1SLionel Sambuc     //!
10211be35a1SLionel Sambuc     //! \brief Returns the signal that terminated the command.
10311be35a1SLionel Sambuc     //!
10411be35a1SLionel Sambuc     int termsig(void) const;
10511be35a1SLionel Sambuc 
10611be35a1SLionel Sambuc     //!
10711be35a1SLionel Sambuc     //! \brief Returns the path to file contaning command's stdout.
10811be35a1SLionel Sambuc     //!
10911be35a1SLionel Sambuc     const std::string stdout_path(void) const;
11011be35a1SLionel Sambuc 
11111be35a1SLionel Sambuc     //!
11211be35a1SLionel Sambuc     //! \brief Returns the path to file contaning command's stderr.
11311be35a1SLionel Sambuc     //!
11411be35a1SLionel Sambuc     const std::string stderr_path(void) const;
11511be35a1SLionel Sambuc };
11611be35a1SLionel Sambuc 
11711be35a1SLionel Sambuc // ------------------------------------------------------------------------
11811be35a1SLionel Sambuc // Free functions.
11911be35a1SLionel Sambuc // ------------------------------------------------------------------------
12011be35a1SLionel Sambuc 
12111be35a1SLionel Sambuc bool build_c_o(const std::string&, const std::string&,
12211be35a1SLionel Sambuc                const atf::process::argv_array&);
12311be35a1SLionel Sambuc bool build_cpp(const std::string&, const std::string&,
12411be35a1SLionel Sambuc                const atf::process::argv_array&);
12511be35a1SLionel Sambuc bool build_cxx_o(const std::string&, const std::string&,
12611be35a1SLionel Sambuc                  const atf::process::argv_array&);
12711be35a1SLionel Sambuc std::auto_ptr< check_result > exec(const atf::process::argv_array&);
12811be35a1SLionel Sambuc 
12911be35a1SLionel Sambuc // Useful for testing only.
13011be35a1SLionel Sambuc check_result test_constructor(void);
13111be35a1SLionel Sambuc 
13211be35a1SLionel Sambuc } // namespace check
13311be35a1SLionel Sambuc } // namespace atf
13411be35a1SLionel Sambuc 
13511be35a1SLionel Sambuc #endif // !defined(_ATF_CXX_CHECK_HPP_)
136