1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program Test Executor
3 * ------------------------------------------
4 *
5 * Copyright 2014 The Android Open Source Project
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 *//*!
20 * \file
21 * \brief Test batch result.
22 *//*--------------------------------------------------------------------*/
23
24 #include "xeBatchResult.hpp"
25 #include "deMemory.h"
26
27 using std::map;
28 using std::string;
29 using std::vector;
30
31 namespace xe
32 {
33
34 // InfoLog
35
InfoLog(void)36 InfoLog::InfoLog(void)
37 {
38 }
39
append(const uint8_t * bytes,size_t numBytes)40 void InfoLog::append(const uint8_t *bytes, size_t numBytes)
41 {
42 DE_ASSERT(numBytes > 0);
43 const size_t oldSize = m_data.size();
44 m_data.resize(oldSize + numBytes);
45 deMemcpy(&m_data[oldSize], bytes, numBytes);
46 }
47
48 // TestCaseResultData
49
TestCaseResultData(const char * casePath)50 TestCaseResultData::TestCaseResultData(const char *casePath) : m_casePath(casePath), m_statusCode(TESTSTATUSCODE_LAST)
51 {
52 }
53
~TestCaseResultData(void)54 TestCaseResultData::~TestCaseResultData(void)
55 {
56 }
57
setTestResult(TestStatusCode statusCode,const char * statusDetails)58 void TestCaseResultData::setTestResult(TestStatusCode statusCode, const char *statusDetails)
59 {
60 m_statusCode = statusCode;
61 m_statusDetails = statusDetails;
62 }
63
clear(void)64 void TestCaseResultData::clear(void)
65 {
66 m_statusCode = TESTSTATUSCODE_LAST;
67 m_statusDetails.clear();
68 m_casePath.clear();
69 m_data.clear();
70 }
71
72 // BatchResult
73
BatchResult(void)74 BatchResult::BatchResult(void)
75 {
76 }
77
~BatchResult(void)78 BatchResult::~BatchResult(void)
79 {
80 }
81
hasTestCaseResult(const char * casePath) const82 bool BatchResult::hasTestCaseResult(const char *casePath) const
83 {
84 return m_resultMap.find(casePath) != m_resultMap.end();
85 }
86
getTestCaseResult(const char * casePath) const87 ConstTestCaseResultPtr BatchResult::getTestCaseResult(const char *casePath) const
88 {
89 map<string, int>::const_iterator pos = m_resultMap.find(casePath);
90 DE_ASSERT(pos != m_resultMap.end());
91 return getTestCaseResult(pos->second);
92 }
93
getTestCaseResult(const char * casePath)94 TestCaseResultPtr BatchResult::getTestCaseResult(const char *casePath)
95 {
96 map<string, int>::const_iterator pos = m_resultMap.find(casePath);
97 DE_ASSERT(pos != m_resultMap.end());
98 return getTestCaseResult(pos->second);
99 }
100
createTestCaseResult(const char * casePath)101 TestCaseResultPtr BatchResult::createTestCaseResult(const char *casePath)
102 {
103 DE_ASSERT(!hasTestCaseResult(casePath));
104
105 m_testCaseResults.reserve(m_testCaseResults.size() + 1);
106 m_resultMap[casePath] = (int)m_testCaseResults.size();
107
108 TestCaseResultPtr caseResult(new TestCaseResultData(casePath));
109 m_testCaseResults.push_back(caseResult);
110
111 return caseResult;
112 }
113
114 } // namespace xe
115