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 46 // Produced by Candy. 47 std::string candyTargetName; 48 std::string configName; 49 std::string resultName; 50 std::string timestamp; 51 }; 52 53 class InfoLog 54 { 55 public: 56 InfoLog (void); 57 getSize(void) const58 size_t getSize (void) const { return m_data.size(); } getBytes(void) const59 const deUint8* getBytes (void) const { return !m_data.empty() ? &m_data[0] : DE_NULL; } 60 61 void append (const deUint8* bytes, size_t numBytes); 62 63 private: 64 InfoLog (const InfoLog& other); 65 InfoLog& operator= (const InfoLog& other); 66 67 std::vector<deUint8> m_data; 68 }; 69 70 class TestCaseResultData 71 { 72 public: 73 TestCaseResultData (const char* casePath); 74 ~TestCaseResultData (void); 75 getTestCasePath(void) const76 const char* getTestCasePath (void) const { return m_casePath.c_str(); } 77 78 void setTestResult (TestStatusCode code, const char* details); 79 getStatusCode(void) const80 TestStatusCode getStatusCode (void) const { return m_statusCode; } getStatusDetails(void) const81 const char* getStatusDetails (void) const { return m_statusDetails.c_str(); } 82 getDataSize(void) const83 int getDataSize (void) const { return (int)m_data.size(); } setDataSize(int size)84 void setDataSize (int size) { m_data.resize(size); } 85 getData(void) const86 const deUint8* getData (void) const { return !m_data.empty() ? &m_data[0] : DE_NULL; } getData(void)87 deUint8* getData (void) { return !m_data.empty() ? &m_data[0] : DE_NULL; } 88 89 void clear (void); 90 91 private: 92 // \note statusCode and statusDetails are either set by BatchExecutor or later parsed from data. 93 std::string m_casePath; 94 TestStatusCode m_statusCode; 95 std::string m_statusDetails; 96 std::vector<deUint8> m_data; 97 }; 98 99 typedef de::SharedPtr<TestCaseResultData> TestCaseResultPtr; 100 typedef de::SharedPtr<const TestCaseResultData> ConstTestCaseResultPtr; 101 102 class BatchResult 103 { 104 public: 105 BatchResult (void); 106 ~BatchResult (void); 107 getSessionInfo(void) const108 const SessionInfo& getSessionInfo (void) const { return m_sessionInfo; } getSessionInfo(void)109 SessionInfo& getSessionInfo (void) { return m_sessionInfo; } 110 getNumTestCaseResults(void) const111 int getNumTestCaseResults (void) const { return (int)m_testCaseResults.size(); } getTestCaseResult(int ndx) const112 ConstTestCaseResultPtr getTestCaseResult (int ndx) const { return ConstTestCaseResultPtr(m_testCaseResults[ndx]); } getTestCaseResult(int ndx)113 TestCaseResultPtr getTestCaseResult (int ndx) { return m_testCaseResults[ndx]; } 114 115 bool hasTestCaseResult (const char* casePath) const; 116 ConstTestCaseResultPtr getTestCaseResult (const char* casePath) const; 117 TestCaseResultPtr getTestCaseResult (const char* casePath); 118 119 TestCaseResultPtr createTestCaseResult (const char* casePath); 120 121 private: 122 BatchResult (const BatchResult& other); 123 BatchResult& operator= (const BatchResult& other); 124 125 SessionInfo m_sessionInfo; 126 std::vector<TestCaseResultPtr> m_testCaseResults; 127 std::map<std::string, int> m_resultMap; 128 }; 129 130 } // xe 131 132 #endif // _XEBATCHRESULT_HPP 133