xref: /freebsd/contrib/kyua/engine/googletest.hpp (revision eb8f69902f7de8012a31a85db2f88a54584f81af)
1*eb8f6990SEnji Cooper // Copyright 2024 The Kyua Authors.
2*eb8f6990SEnji Cooper // All rights reserved.
3*eb8f6990SEnji Cooper //
4*eb8f6990SEnji Cooper // Redistribution and use in source and binary forms, with or without
5*eb8f6990SEnji Cooper // modification, are permitted provided that the following conditions are
6*eb8f6990SEnji Cooper // met:
7*eb8f6990SEnji Cooper //
8*eb8f6990SEnji Cooper // * Redistributions of source code must retain the above copyright
9*eb8f6990SEnji Cooper //   notice, this list of conditions and the following disclaimer.
10*eb8f6990SEnji Cooper // * Redistributions in binary form must reproduce the above copyright
11*eb8f6990SEnji Cooper //   notice, this list of conditions and the following disclaimer in the
12*eb8f6990SEnji Cooper //   documentation and/or other materials provided with the distribution.
13*eb8f6990SEnji Cooper // * Neither the name of Google Inc. nor the names of its contributors
14*eb8f6990SEnji Cooper //   may be used to endorse or promote products derived from this software
15*eb8f6990SEnji Cooper //   without specific prior written permission.
16*eb8f6990SEnji Cooper //
17*eb8f6990SEnji Cooper // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18*eb8f6990SEnji Cooper // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19*eb8f6990SEnji Cooper // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20*eb8f6990SEnji Cooper // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21*eb8f6990SEnji Cooper // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22*eb8f6990SEnji Cooper // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23*eb8f6990SEnji Cooper // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24*eb8f6990SEnji Cooper // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25*eb8f6990SEnji Cooper // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26*eb8f6990SEnji Cooper // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27*eb8f6990SEnji Cooper // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28*eb8f6990SEnji Cooper 
29*eb8f6990SEnji Cooper /// \file engine/googletest.hpp
30*eb8f6990SEnji Cooper /// Execution engine for test programs that implement the googletest interface.
31*eb8f6990SEnji Cooper 
32*eb8f6990SEnji Cooper #if !defined(ENGINE_GOOGLETEST_HPP)
33*eb8f6990SEnji Cooper #define ENGINE_GOOGLETEST_HPP
34*eb8f6990SEnji Cooper 
35*eb8f6990SEnji Cooper #include "engine/scheduler.hpp"
36*eb8f6990SEnji Cooper 
37*eb8f6990SEnji Cooper namespace engine {
38*eb8f6990SEnji Cooper 
39*eb8f6990SEnji Cooper 
40*eb8f6990SEnji Cooper /// Implementation of the scheduler interface for googletest test programs.
41*eb8f6990SEnji Cooper class googletest_interface : public engine::scheduler::interface {
42*eb8f6990SEnji Cooper public:
43*eb8f6990SEnji Cooper     void exec_list [[noreturn]] (
44*eb8f6990SEnji Cooper     const model::test_program&,
45*eb8f6990SEnji Cooper         const utils::config::properties_map&) const;
46*eb8f6990SEnji Cooper 
47*eb8f6990SEnji Cooper     model::test_cases_map parse_list(
48*eb8f6990SEnji Cooper         const utils::optional< utils::process::status >&,
49*eb8f6990SEnji Cooper         const utils::fs::path&,
50*eb8f6990SEnji Cooper         const utils::fs::path&) const;
51*eb8f6990SEnji Cooper 
52*eb8f6990SEnji Cooper     void exec_test [[noreturn]] (
53*eb8f6990SEnji Cooper         const model::test_program&, const std::string&,
54*eb8f6990SEnji Cooper         const utils::config::properties_map&,
55*eb8f6990SEnji Cooper         const utils::fs::path&) const;
56*eb8f6990SEnji Cooper 
57*eb8f6990SEnji Cooper     model::test_result compute_result(
58*eb8f6990SEnji Cooper         const utils::optional< utils::process::status >&,
59*eb8f6990SEnji Cooper         const utils::fs::path&,
60*eb8f6990SEnji Cooper         const utils::fs::path&,
61*eb8f6990SEnji Cooper         const utils::fs::path&) const;
62*eb8f6990SEnji Cooper };
63*eb8f6990SEnji Cooper 
64*eb8f6990SEnji Cooper 
65*eb8f6990SEnji Cooper }  // namespace engine
66*eb8f6990SEnji Cooper 
67*eb8f6990SEnji Cooper 
68*eb8f6990SEnji Cooper #endif  // !defined(ENGINE_GOOGLETEST_HPP)
69