1 // Copyright 2010 The Kyua Authors. 2 // All rights reserved. 3 // 4 // Redistribution and use in source and binary forms, with or without 5 // modification, are permitted provided that the following conditions are 6 // met: 7 // 8 // * Redistributions of source code must retain the above copyright 9 // notice, this list of conditions and the following disclaimer. 10 // * Redistributions in binary form must reproduce the above copyright 11 // notice, this list of conditions and the following disclaimer in the 12 // documentation and/or other materials provided with the distribution. 13 // * Neither the name of Google Inc. nor the names of its contributors 14 // may be used to endorse or promote products derived from this software 15 // without specific prior written permission. 16 // 17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 29 /// \file engine/atf_result.hpp 30 /// Functions and types to process the results of ATF-based test cases. 31 32 #if !defined(ENGINE_ATF_RESULT_HPP) 33 #define ENGINE_ATF_RESULT_HPP 34 35 #include "engine/atf_result_fwd.hpp" 36 37 #include <istream> 38 #include <ostream> 39 40 #include "model/test_result_fwd.hpp" 41 #include "utils/optional.hpp" 42 #include "utils/fs/path_fwd.hpp" 43 #include "utils/process/status_fwd.hpp" 44 45 namespace engine { 46 47 48 /// Internal representation of the raw result files of ATF-based tests. 49 /// 50 /// This class is used exclusively to represent the transient result files read 51 /// from test cases before generating the "public" version of the result. This 52 /// class should actually not be exposed in the header files, but it is for 53 /// testing purposes only. 54 class atf_result { 55 public: 56 /// List of possible types for the test case result. 57 enum types { 58 broken, 59 expected_death, 60 expected_exit, 61 expected_failure, 62 expected_signal, 63 expected_timeout, 64 failed, 65 passed, 66 skipped, 67 }; 68 69 private: 70 /// The test case result. 71 types _type; 72 73 /// The optional integral argument that may accompany the result. 74 /// 75 /// Should only be present if the type is expected_exit or expected_signal. 76 utils::optional< int > _argument; 77 78 /// A description of the test case result. 79 /// 80 /// Should always be present except for the passed type. 81 utils::optional< std::string > _reason; 82 83 public: 84 atf_result(const types); 85 atf_result(const types, const std::string&); 86 atf_result(const types, const utils::optional< int >&, const std::string&); 87 88 static atf_result parse(std::istream&); 89 static atf_result load(const utils::fs::path&); 90 91 types type(void) const; 92 const utils::optional< int >& argument(void) const; 93 const utils::optional< std::string >& reason(void) const; 94 95 bool good(void) const; 96 atf_result apply(const utils::optional< utils::process::status >&) const; 97 model::test_result externalize(void) const; 98 99 bool operator==(const atf_result&) const; 100 bool operator!=(const atf_result&) const; 101 }; 102 103 104 std::ostream& operator<<(std::ostream&, const atf_result&); 105 106 107 model::test_result calculate_atf_result( 108 const utils::optional< utils::process::status >&, 109 const utils::fs::path&); 110 111 112 } // namespace engine 113 114 #endif // !defined(ENGINE_ATF_IFACE_RESULTS_HPP) 115