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::vector;
28 using std::string;
29 using std::map;
30 
31 namespace xe
32 {
33 
34 // InfoLog
35 
InfoLog(void)36 InfoLog::InfoLog (void)
37 {
38 }
39 
append(const deUint8 * bytes,size_t numBytes)40 void InfoLog::append (const deUint8* 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)
51 	: m_casePath	(casePath)
52 	, m_statusCode	(TESTSTATUSCODE_LAST)
53 {
54 }
55 
~TestCaseResultData(void)56 TestCaseResultData::~TestCaseResultData (void)
57 {
58 }
59 
setTestResult(TestStatusCode statusCode,const char * statusDetails)60 void TestCaseResultData::setTestResult (TestStatusCode statusCode, const char* statusDetails)
61 {
62 	m_statusCode	= statusCode;
63 	m_statusDetails	= statusDetails;
64 }
65 
clear(void)66 void TestCaseResultData::clear (void)
67 {
68 	m_statusCode = TESTSTATUSCODE_LAST;
69 	m_statusDetails.clear();
70 	m_casePath.clear();
71 	m_data.clear();
72 }
73 
74 // BatchResult
75 
BatchResult(void)76 BatchResult::BatchResult (void)
77 {
78 }
79 
~BatchResult(void)80 BatchResult::~BatchResult (void)
81 {
82 }
83 
hasTestCaseResult(const char * casePath) const84 bool BatchResult::hasTestCaseResult (const char* casePath) const
85 {
86 	return m_resultMap.find(casePath) != m_resultMap.end();
87 }
88 
getTestCaseResult(const char * casePath) const89 ConstTestCaseResultPtr BatchResult::getTestCaseResult (const char* casePath) const
90 {
91 	map<string, int>::const_iterator pos = m_resultMap.find(casePath);
92 	DE_ASSERT(pos != m_resultMap.end());
93 	return getTestCaseResult(pos->second);
94 }
95 
getTestCaseResult(const char * casePath)96 TestCaseResultPtr BatchResult::getTestCaseResult (const char* casePath)
97 {
98 	map<string, int>::const_iterator pos = m_resultMap.find(casePath);
99 	DE_ASSERT(pos != m_resultMap.end());
100 	return getTestCaseResult(pos->second);
101 }
102 
createTestCaseResult(const char * casePath)103 TestCaseResultPtr BatchResult::createTestCaseResult (const char* casePath)
104 {
105 	DE_ASSERT(!hasTestCaseResult(casePath));
106 
107 	m_testCaseResults.reserve(m_testCaseResults.size()+1);
108 	m_resultMap[casePath] = (int)m_testCaseResults.size();
109 
110 	TestCaseResultPtr caseResult(new TestCaseResultData(casePath));
111 	m_testCaseResults.push_back(caseResult);
112 
113 	return caseResult;
114 }
115 
116 } // xe
117