1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL ES 2.0 Module
3 * -------------------------------------------------
5 * Copyright 2014 The Android Open Source Project
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 * \brief OpenGL ES 2.0 Test Package
22 *//*--------------------------------------------------------------------*/
24 #include "tes2TestPackage.hpp"
25 #include "es2fFunctionalTests.hpp"
26 #include "es2pPerformanceTests.hpp"
27 #include "tes2InfoTests.hpp"
28 #include "tes2CapabilityTests.hpp"
29 #include "es2aAccuracyTests.hpp"
30 #include "es2sStressTests.hpp"
31 #include "tcuTestLog.hpp"
32 #include "tcuTestContext.hpp"
33 #include "tcuWaiverUtil.hpp"
34 #include "tcuCommandLine.hpp"
35 #include "gluContextInfo.hpp"
36 #include "gluRenderContext.hpp"
37 #include "gluStateReset.hpp"
38 #include "glwFunctions.hpp"
39 #include "glwEnums.hpp"
46 class TestCaseWrapper : public tcu::TestCaseExecutor
49 TestCaseWrapper (TestPackage& package, de::SharedPtr<tcu::WaiverUtil> waiverMechanism);
50 ~TestCaseWrapper (void);
52 void init (tcu::TestCase* testCase, const std::string& path);
53 void deinit (tcu::TestCase* testCase);
54 tcu::TestNode::IterateResult iterate (tcu::TestCase* testCase);
57 TestPackage& m_testPackage;
58 de::SharedPtr<tcu::WaiverUtil> m_waiverMechanism;
61 TestCaseWrapper::TestCaseWrapper (TestPackage& package, de::SharedPtr<tcu::WaiverUtil> waiverMechanism)
62 : m_testPackage(package)
63 , m_waiverMechanism(waiverMechanism)
67 TestCaseWrapper::~TestCaseWrapper (void)
71 void TestCaseWrapper::init (tcu::TestCase* testCase, const std::string& path)
73 if (m_waiverMechanism->isOnWaiverList(path))
74 throw tcu::TestException("Waived test", QP_TEST_RESULT_WAIVER);
79 void TestCaseWrapper::deinit (tcu::TestCase* testCase)
83 DE_ASSERT(m_testPackage.getContext());
84 glu::resetState(m_testPackage.getContext()->getRenderContext(), m_testPackage.getContext()->getContextInfo());
87 tcu::TestNode::IterateResult TestCaseWrapper::iterate (tcu::TestCase* testCase)
89 tcu::TestContext& testCtx = m_testPackage.getContext()->getTestContext();
90 glu::RenderContext& renderCtx = m_testPackage.getContext()->getRenderContext();
91 tcu::TestCase::IterateResult result;
93 // Clear to surrender-blue
95 const glw::Functions& gl = renderCtx.getFunctions();
96 gl.clearColor(0.125f, 0.25f, 0.5f, 1.f);
97 gl.clear(GL_COLOR_BUFFER_BIT);
100 result = testCase->iterate();
102 // Call implementation specific post-iterate routine (usually handles native events and swaps buffers)
105 renderCtx.postIterate();
108 catch (const tcu::ResourceError& e)
110 testCtx.getLog() << e;
111 testCtx.setTestResult(QP_TEST_RESULT_RESOURCE_ERROR, "Resource error in context post-iteration routine");
112 testCtx.setTerminateAfter(true);
113 return tcu::TestNode::STOP;
115 catch (const std::exception& e)
117 testCtx.getLog() << e;
118 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Error in context post-iteration routine");
119 return tcu::TestNode::STOP;
123 TestPackage::TestPackage (tcu::TestContext& testCtx)
124 : tcu::TestPackage (testCtx, "dEQP-GLES2", "dEQP OpenGL ES 2.0 Tests")
125 , m_archive (testCtx.getRootArchive(), "gles2/")
126 , m_context (DE_NULL)
127 , m_waiverMechanism(new tcu::WaiverUtil)
131 TestPackage::~TestPackage (void)
133 // Destroy children first since destructors may access context.
138 void TestPackage::init (void)
143 m_context = new Context(m_testCtx);
145 // Setup waiver mechanism
146 if (m_testCtx.getCommandLine().getRunMode() == tcu::RUNMODE_EXECUTE)
148 const glu::ContextInfo& contextInfo = m_context->getContextInfo();
149 std::string vendor = contextInfo.getString(GL_VENDOR);
150 std::string renderer = contextInfo.getString(GL_RENDERER);
151 const tcu::CommandLine& commandLine = m_context->getTestContext().getCommandLine();
152 tcu::SessionInfo sessionInfo (vendor, renderer, commandLine.getInitialCmdLine());
153 m_waiverMechanism->setup(commandLine.getWaiverFileName(), m_name, vendor, renderer, sessionInfo);
154 m_context->getTestContext().getLog().writeSessionInfo(sessionInfo.get());
157 // Add main test groups
158 addChild(new InfoTests (*m_context));
159 addChild(new CapabilityTests (*m_context));
160 addChild(new Functional::FunctionalTests (*m_context));
161 addChild(new Accuracy::AccuracyTests (*m_context));
162 addChild(new Performance::PerformanceTests (*m_context));
163 addChild(new Stress::StressTests (*m_context));
174 void TestPackage::deinit (void)
181 tcu::TestCaseExecutor* TestPackage::createExecutor (void) const
183 return new TestCaseWrapper(const_cast<TestPackage&>(*this), m_waiverMechanism);