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