xref: /freebsd/contrib/kyua/model/test_program.hpp (revision b392a90ba4e5ea07d8a88a834fd102191d1967bf)
1b0d29bc4SBrooks Davis // Copyright 2010 The Kyua Authors.
2b0d29bc4SBrooks Davis // All rights reserved.
3b0d29bc4SBrooks Davis //
4b0d29bc4SBrooks Davis // Redistribution and use in source and binary forms, with or without
5b0d29bc4SBrooks Davis // modification, are permitted provided that the following conditions are
6b0d29bc4SBrooks Davis // met:
7b0d29bc4SBrooks Davis //
8b0d29bc4SBrooks Davis // * Redistributions of source code must retain the above copyright
9b0d29bc4SBrooks Davis //   notice, this list of conditions and the following disclaimer.
10b0d29bc4SBrooks Davis // * Redistributions in binary form must reproduce the above copyright
11b0d29bc4SBrooks Davis //   notice, this list of conditions and the following disclaimer in the
12b0d29bc4SBrooks Davis //   documentation and/or other materials provided with the distribution.
13b0d29bc4SBrooks Davis // * Neither the name of Google Inc. nor the names of its contributors
14b0d29bc4SBrooks Davis //   may be used to endorse or promote products derived from this software
15b0d29bc4SBrooks Davis //   without specific prior written permission.
16b0d29bc4SBrooks Davis //
17b0d29bc4SBrooks Davis // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18b0d29bc4SBrooks Davis // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19b0d29bc4SBrooks Davis // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20b0d29bc4SBrooks Davis // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21b0d29bc4SBrooks Davis // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22b0d29bc4SBrooks Davis // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23b0d29bc4SBrooks Davis // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24b0d29bc4SBrooks Davis // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25b0d29bc4SBrooks Davis // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26b0d29bc4SBrooks Davis // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27b0d29bc4SBrooks Davis // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28b0d29bc4SBrooks Davis 
29b0d29bc4SBrooks Davis /// \file model/test_program.hpp
30b0d29bc4SBrooks Davis /// Definition of the "test program" concept.
31b0d29bc4SBrooks Davis 
32b0d29bc4SBrooks Davis #if !defined(MODEL_TEST_PROGRAM_HPP)
33b0d29bc4SBrooks Davis #define MODEL_TEST_PROGRAM_HPP
34b0d29bc4SBrooks Davis 
35b0d29bc4SBrooks Davis #include "model/test_program_fwd.hpp"
36b0d29bc4SBrooks Davis 
37b0d29bc4SBrooks Davis #include <memory>
38b0d29bc4SBrooks Davis #include <ostream>
39b0d29bc4SBrooks Davis #include <string>
40b0d29bc4SBrooks Davis #include <vector>
41b0d29bc4SBrooks Davis 
42b0d29bc4SBrooks Davis #include "model/metadata_fwd.hpp"
43b0d29bc4SBrooks Davis #include "model/test_case_fwd.hpp"
44b0d29bc4SBrooks Davis #include "utils/fs/path_fwd.hpp"
45b0d29bc4SBrooks Davis #include "utils/noncopyable.hpp"
46b0d29bc4SBrooks Davis 
47b0d29bc4SBrooks Davis namespace model {
48b0d29bc4SBrooks Davis 
49b0d29bc4SBrooks Davis 
50b0d29bc4SBrooks Davis /// Representation of a test program.
51b0d29bc4SBrooks Davis class test_program {
52b0d29bc4SBrooks Davis     struct impl;
53b0d29bc4SBrooks Davis 
54b0d29bc4SBrooks Davis     /// Pointer to the shared internal implementation.
55b0d29bc4SBrooks Davis     std::shared_ptr< impl > _pimpl;
56b0d29bc4SBrooks Davis 
57b0d29bc4SBrooks Davis protected:
58b0d29bc4SBrooks Davis     void set_test_cases(const model::test_cases_map&);
59b0d29bc4SBrooks Davis 
60b0d29bc4SBrooks Davis public:
61b0d29bc4SBrooks Davis     test_program(const std::string&, const utils::fs::path&,
62b0d29bc4SBrooks Davis                  const utils::fs::path&, const std::string&,
63b0d29bc4SBrooks Davis                  const model::metadata&, const model::test_cases_map&);
64b0d29bc4SBrooks Davis     virtual ~test_program(void);
65b0d29bc4SBrooks Davis 
66b0d29bc4SBrooks Davis     const std::string& interface_name(void) const;
67b0d29bc4SBrooks Davis     const utils::fs::path& root(void) const;
68b0d29bc4SBrooks Davis     const utils::fs::path& relative_path(void) const;
69b0d29bc4SBrooks Davis     const utils::fs::path absolute_path(void) const;
70b0d29bc4SBrooks Davis     const std::string& test_suite_name(void) const;
71b0d29bc4SBrooks Davis     const model::metadata& get_metadata(void) const;
72b0d29bc4SBrooks Davis 
73b0d29bc4SBrooks Davis     const model::test_case& find(const std::string&) const;
74b0d29bc4SBrooks Davis     virtual const model::test_cases_map& test_cases(void) const;
75b0d29bc4SBrooks Davis 
76b0d29bc4SBrooks Davis     bool operator==(const test_program&) const;
77b0d29bc4SBrooks Davis     bool operator!=(const test_program&) const;
78b0d29bc4SBrooks Davis     bool operator<(const test_program&) const;
79b0d29bc4SBrooks Davis };
80b0d29bc4SBrooks Davis 
81b0d29bc4SBrooks Davis 
82b0d29bc4SBrooks Davis std::ostream& operator<<(std::ostream&, const test_program&);
83b0d29bc4SBrooks Davis 
84b0d29bc4SBrooks Davis 
85b0d29bc4SBrooks Davis /// Builder for a test_program object.
86b0d29bc4SBrooks Davis class test_program_builder : utils::noncopyable {
87b0d29bc4SBrooks Davis     struct impl;
88b0d29bc4SBrooks Davis 
89b0d29bc4SBrooks Davis     /// Pointer to the shared internal implementation.
90*b392a90bSJohn Baldwin     std::unique_ptr< impl > _pimpl;
91b0d29bc4SBrooks Davis 
92b0d29bc4SBrooks Davis public:
93b0d29bc4SBrooks Davis     test_program_builder(const std::string&, const utils::fs::path&,
94b0d29bc4SBrooks Davis                          const utils::fs::path&, const std::string&);
95b0d29bc4SBrooks Davis     ~test_program_builder(void);
96b0d29bc4SBrooks Davis 
97b0d29bc4SBrooks Davis     test_program_builder& add_test_case(const std::string&);
98b0d29bc4SBrooks Davis     test_program_builder& add_test_case(const std::string&,
99b0d29bc4SBrooks Davis                                         const model::metadata&);
100b0d29bc4SBrooks Davis 
101b0d29bc4SBrooks Davis     test_program_builder& set_metadata(const model::metadata&);
102b0d29bc4SBrooks Davis 
103b0d29bc4SBrooks Davis     test_program build(void) const;
104b0d29bc4SBrooks Davis     test_program_ptr build_ptr(void) const;
105b0d29bc4SBrooks Davis };
106b0d29bc4SBrooks Davis 
107b0d29bc4SBrooks Davis 
108b0d29bc4SBrooks Davis }  // namespace model
109b0d29bc4SBrooks Davis 
110b0d29bc4SBrooks Davis #endif  // !defined(MODEL_TEST_PROGRAM_HPP)
111