1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL ES 3.0 Module
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 OpenGL ES 3.0 Test Package
22 *//*--------------------------------------------------------------------*/
23
24 #include "tes3TestPackage.hpp"
25 #include "tes3InfoTests.hpp"
26 #include "es3fFunctionalTests.hpp"
27 #include "es3aAccuracyTests.hpp"
28 #include "es3sStressTests.hpp"
29 #include "es3pPerformanceTests.hpp"
30 #include "tcuTestLog.hpp"
31 #include "tcuWaiverUtil.hpp"
32 #include "tcuCommandLine.hpp"
33 #include "gluContextInfo.hpp"
34 #include "gluRenderContext.hpp"
35 #include "gluStateReset.hpp"
36 #include "glwFunctions.hpp"
37 #include "glwEnums.hpp"
38
39 namespace deqp
40 {
41 namespace gles3
42 {
43
44 class TestCaseWrapper : public tcu::TestCaseExecutor
45 {
46 public:
47 TestCaseWrapper (TestPackage& package, de::SharedPtr<tcu::WaiverUtil> waiverMechanism);
48 ~TestCaseWrapper (void);
49
50 void init (tcu::TestCase* testCase, const std::string& path);
51 void deinit (tcu::TestCase* testCase);
52 tcu::TestNode::IterateResult iterate (tcu::TestCase* testCase);
53
54 private:
55 TestPackage& m_testPackage;
56 de::SharedPtr<tcu::WaiverUtil> m_waiverMechanism;
57 };
58
TestCaseWrapper(TestPackage & package,de::SharedPtr<tcu::WaiverUtil> waiverMechanism)59 TestCaseWrapper::TestCaseWrapper (TestPackage& package, de::SharedPtr<tcu::WaiverUtil> waiverMechanism)
60 : m_testPackage(package)
61 , m_waiverMechanism(waiverMechanism)
62 {
63 }
64
~TestCaseWrapper(void)65 TestCaseWrapper::~TestCaseWrapper (void)
66 {
67 }
68
init(tcu::TestCase * testCase,const std::string & path)69 void TestCaseWrapper::init (tcu::TestCase* testCase, const std::string& path)
70 {
71 if (m_waiverMechanism->isOnWaiverList(path))
72 throw tcu::TestException("Waived test", QP_TEST_RESULT_WAIVER);
73
74 testCase->init();
75 }
76
deinit(tcu::TestCase * testCase)77 void TestCaseWrapper::deinit (tcu::TestCase* testCase)
78 {
79 testCase->deinit();
80
81 DE_ASSERT(m_testPackage.getContext());
82 glu::resetState(m_testPackage.getContext()->getRenderContext(), m_testPackage.getContext()->getContextInfo());
83 }
84
iterate(tcu::TestCase * testCase)85 tcu::TestNode::IterateResult TestCaseWrapper::iterate (tcu::TestCase* testCase)
86 {
87 tcu::TestContext& testCtx = m_testPackage.getContext()->getTestContext();
88 glu::RenderContext& renderCtx = m_testPackage.getContext()->getRenderContext();
89 tcu::TestCase::IterateResult result;
90
91 // Clear to surrender-blue
92 {
93 const glw::Functions& gl = renderCtx.getFunctions();
94 gl.clearColor(0.125f, 0.25f, 0.5f, 1.f);
95 gl.clear(GL_COLOR_BUFFER_BIT);
96 }
97
98 result = testCase->iterate();
99
100 // Call implementation specific post-iterate routine (usually handles native events and swaps buffers)
101 try
102 {
103 renderCtx.postIterate();
104 return result;
105 }
106 catch (const tcu::ResourceError& e)
107 {
108 testCtx.getLog() << e;
109 testCtx.setTestResult(QP_TEST_RESULT_RESOURCE_ERROR, "Resource error in context post-iteration routine");
110 testCtx.setTerminateAfter(true);
111 return tcu::TestNode::STOP;
112 }
113 catch (const std::exception& e)
114 {
115 testCtx.getLog() << e;
116 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Error in context post-iteration routine");
117 return tcu::TestNode::STOP;
118 }
119 }
120
TestPackage(tcu::TestContext & testCtx)121 TestPackage::TestPackage (tcu::TestContext& testCtx)
122 : tcu::TestPackage (testCtx, "dEQP-GLES3", "dEQP OpenGL ES 3.0 Tests")
123 , m_archive (testCtx.getRootArchive(), "gles3/")
124 , m_context (DE_NULL)
125 , m_waiverMechanism (new tcu::WaiverUtil)
126 {
127 }
128
~TestPackage(void)129 TestPackage::~TestPackage (void)
130 {
131 // Destroy children first since destructors may access context.
132 TestNode::deinit();
133 delete m_context;
134 }
135
init(void)136 void TestPackage::init (void)
137 {
138 try
139 {
140 // Create context
141 m_context = new Context(m_testCtx);
142
143 // Setup waiver mechanism
144 if (m_testCtx.getCommandLine().getRunMode() == tcu::RUNMODE_EXECUTE)
145 {
146 const glu::ContextInfo& contextInfo = m_context->getContextInfo();
147 std::string vendor = contextInfo.getString(GL_VENDOR);
148 std::string renderer = contextInfo.getString(GL_RENDERER);
149 const tcu::CommandLine& commandLine = m_context->getTestContext().getCommandLine();
150 tcu::SessionInfo sessionInfo (vendor, renderer, commandLine.getInitialCmdLine());
151 m_waiverMechanism->setup(commandLine.getWaiverFileName(), m_name, vendor, renderer, sessionInfo);
152 m_context->getTestContext().getLog().writeSessionInfo(sessionInfo.get());
153 }
154
155 // Add main test groups
156 addChild(new InfoTests (*m_context));
157 addChild(new Functional::FunctionalTests (*m_context));
158 addChild(new Accuracy::AccuracyTests (*m_context));
159 addChild(new Performance::PerformanceTests (*m_context));
160 addChild(new Stress::StressTests (*m_context));
161 }
162 catch (...)
163 {
164 delete m_context;
165 m_context = DE_NULL;
166
167 throw;
168 }
169 }
170
deinit(void)171 void TestPackage::deinit (void)
172 {
173 TestNode::deinit();
174 delete m_context;
175 m_context = DE_NULL;
176 }
177
createExecutor(void) const178 tcu::TestCaseExecutor* TestPackage::createExecutor (void) const
179 {
180 return new TestCaseWrapper(const_cast<TestPackage&>(*this), m_waiverMechanism);
181 }
182
183 } // gles3
184 } // deqp
185