1 #ifndef _XEBATCHRESULT_HPP 2 #define _XEBATCHRESULT_HPP 3 /*------------------------------------------------------------------------- 4 * drawElements Quality Program Test Executor 5 * ------------------------------------------ 6 * 7 * Copyright 2014 The Android Open Source Project 8 * 9 * Licensed under the Apache License, Version 2.0 (the "License"); 10 * you may not use this file except in compliance with the License. 11 * You may obtain a copy of the License at 12 * 13 * http://www.apache.org/licenses/LICENSE-2.0 14 * 15 * Unless required by applicable law or agreed to in writing, software 16 * distributed under the License is distributed on an "AS IS" BASIS, 17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 * See the License for the specific language governing permissions and 19 * limitations under the License. 20 * 21 *//*! 22 * \file 23 * \brief Test batch result. 24 *//*--------------------------------------------------------------------*/ 25 26 #include "xeDefs.hpp" 27 #include "xeTestCase.hpp" 28 #include "xeTestCaseResult.hpp" 29 #include "deSharedPtr.hpp" 30 31 #include <string> 32 #include <vector> 33 #include <map> 34 35 namespace xe 36 { 37 38 class SessionInfo 39 { 40 public: 41 // Produced by test binary. 42 std::string releaseName; 43 std::string releaseId; 44 std::string targetName; 45 std::string qpaCommandLineParameters; 46 47 // Produced by Candy. 48 std::string candyTargetName; 49 std::string configName; 50 std::string resultName; 51 std::string timestamp; 52 }; 53 54 class InfoLog 55 { 56 public: 57 InfoLog(void); 58 getSize(void) const59 size_t getSize(void) const 60 { 61 return m_data.size(); 62 } getBytes(void) const63 const uint8_t *getBytes(void) const 64 { 65 return !m_data.empty() ? &m_data[0] : DE_NULL; 66 } 67 68 void append(const uint8_t *bytes, size_t numBytes); 69 70 private: 71 InfoLog(const InfoLog &other); 72 InfoLog &operator=(const InfoLog &other); 73 74 std::vector<uint8_t> m_data; 75 }; 76 77 class TestCaseResultData 78 { 79 public: 80 TestCaseResultData(const char *casePath); 81 ~TestCaseResultData(void); 82 getTestCasePath(void) const83 const char *getTestCasePath(void) const 84 { 85 return m_casePath.c_str(); 86 } 87 88 void setTestResult(TestStatusCode code, const char *details); 89 getStatusCode(void) const90 TestStatusCode getStatusCode(void) const 91 { 92 return m_statusCode; 93 } getStatusDetails(void) const94 const char *getStatusDetails(void) const 95 { 96 return m_statusDetails.c_str(); 97 } 98 getDataSize(void) const99 int getDataSize(void) const 100 { 101 return (int)m_data.size(); 102 } setDataSize(int size)103 void setDataSize(int size) 104 { 105 m_data.resize(size); 106 } 107 getData(void) const108 const uint8_t *getData(void) const 109 { 110 return !m_data.empty() ? &m_data[0] : DE_NULL; 111 } getData(void)112 uint8_t *getData(void) 113 { 114 return !m_data.empty() ? &m_data[0] : DE_NULL; 115 } 116 117 void clear(void); 118 119 private: 120 // \note statusCode and statusDetails are either set by BatchExecutor or later parsed from data. 121 std::string m_casePath; 122 TestStatusCode m_statusCode; 123 std::string m_statusDetails; 124 std::vector<uint8_t> m_data; 125 }; 126 127 typedef de::SharedPtr<TestCaseResultData> TestCaseResultPtr; 128 typedef de::SharedPtr<const TestCaseResultData> ConstTestCaseResultPtr; 129 130 class BatchResult 131 { 132 public: 133 BatchResult(void); 134 ~BatchResult(void); 135 getSessionInfo(void) const136 const SessionInfo &getSessionInfo(void) const 137 { 138 return m_sessionInfo; 139 } getSessionInfo(void)140 SessionInfo &getSessionInfo(void) 141 { 142 return m_sessionInfo; 143 } 144 getNumTestCaseResults(void) const145 int getNumTestCaseResults(void) const 146 { 147 return (int)m_testCaseResults.size(); 148 } getTestCaseResult(int ndx) const149 ConstTestCaseResultPtr getTestCaseResult(int ndx) const 150 { 151 return ConstTestCaseResultPtr(m_testCaseResults[ndx]); 152 } getTestCaseResult(int ndx)153 TestCaseResultPtr getTestCaseResult(int ndx) 154 { 155 return m_testCaseResults[ndx]; 156 } 157 158 bool hasTestCaseResult(const char *casePath) const; 159 ConstTestCaseResultPtr getTestCaseResult(const char *casePath) const; 160 TestCaseResultPtr getTestCaseResult(const char *casePath); 161 162 TestCaseResultPtr createTestCaseResult(const char *casePath); 163 164 private: 165 BatchResult(const BatchResult &other); 166 BatchResult &operator=(const BatchResult &other); 167 168 SessionInfo m_sessionInfo; 169 std::vector<TestCaseResultPtr> m_testCaseResults; 170 std::map<std::string, int> m_resultMap; 171 }; 172 173 } // namespace xe 174 175 #endif // _XEBATCHRESULT_HPP 176