xref: /aosp_15_r20/external/deqp/modules/gles2/tes2TestPackage.cpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1*35238bceSAndroid Build Coastguard Worker /*-------------------------------------------------------------------------
2*35238bceSAndroid Build Coastguard Worker  * drawElements Quality Program OpenGL ES 2.0 Module
3*35238bceSAndroid Build Coastguard Worker  * -------------------------------------------------
4*35238bceSAndroid Build Coastguard Worker  *
5*35238bceSAndroid Build Coastguard Worker  * Copyright 2014 The Android Open Source Project
6*35238bceSAndroid Build Coastguard Worker  *
7*35238bceSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
8*35238bceSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
9*35238bceSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
10*35238bceSAndroid Build Coastguard Worker  *
11*35238bceSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
12*35238bceSAndroid Build Coastguard Worker  *
13*35238bceSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
14*35238bceSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
15*35238bceSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16*35238bceSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
17*35238bceSAndroid Build Coastguard Worker  * limitations under the License.
18*35238bceSAndroid Build Coastguard Worker  *
19*35238bceSAndroid Build Coastguard Worker  *//*!
20*35238bceSAndroid Build Coastguard Worker  * \file
21*35238bceSAndroid Build Coastguard Worker  * \brief OpenGL ES 2.0 Test Package
22*35238bceSAndroid Build Coastguard Worker  *//*--------------------------------------------------------------------*/
23*35238bceSAndroid Build Coastguard Worker 
24*35238bceSAndroid Build Coastguard Worker #include "tes2TestPackage.hpp"
25*35238bceSAndroid Build Coastguard Worker #include "es2fFunctionalTests.hpp"
26*35238bceSAndroid Build Coastguard Worker #include "es2pPerformanceTests.hpp"
27*35238bceSAndroid Build Coastguard Worker #include "tes2InfoTests.hpp"
28*35238bceSAndroid Build Coastguard Worker #include "tes2CapabilityTests.hpp"
29*35238bceSAndroid Build Coastguard Worker #include "es2aAccuracyTests.hpp"
30*35238bceSAndroid Build Coastguard Worker #include "es2sStressTests.hpp"
31*35238bceSAndroid Build Coastguard Worker #include "tcuTestLog.hpp"
32*35238bceSAndroid Build Coastguard Worker #include "tcuTestContext.hpp"
33*35238bceSAndroid Build Coastguard Worker #include "tcuWaiverUtil.hpp"
34*35238bceSAndroid Build Coastguard Worker #include "tcuCommandLine.hpp"
35*35238bceSAndroid Build Coastguard Worker #include "gluContextInfo.hpp"
36*35238bceSAndroid Build Coastguard Worker #include "gluRenderContext.hpp"
37*35238bceSAndroid Build Coastguard Worker #include "gluStateReset.hpp"
38*35238bceSAndroid Build Coastguard Worker #include "glwFunctions.hpp"
39*35238bceSAndroid Build Coastguard Worker #include "glwEnums.hpp"
40*35238bceSAndroid Build Coastguard Worker 
41*35238bceSAndroid Build Coastguard Worker namespace deqp
42*35238bceSAndroid Build Coastguard Worker {
43*35238bceSAndroid Build Coastguard Worker namespace gles2
44*35238bceSAndroid Build Coastguard Worker {
45*35238bceSAndroid Build Coastguard Worker 
46*35238bceSAndroid Build Coastguard Worker class TestCaseWrapper : public tcu::TestCaseExecutor
47*35238bceSAndroid Build Coastguard Worker {
48*35238bceSAndroid Build Coastguard Worker public:
49*35238bceSAndroid Build Coastguard Worker     TestCaseWrapper(TestPackage &package, de::SharedPtr<tcu::WaiverUtil> waiverMechanism);
50*35238bceSAndroid Build Coastguard Worker     ~TestCaseWrapper(void);
51*35238bceSAndroid Build Coastguard Worker 
52*35238bceSAndroid Build Coastguard Worker     void init(tcu::TestCase *testCase, const std::string &path);
53*35238bceSAndroid Build Coastguard Worker     void deinit(tcu::TestCase *testCase);
54*35238bceSAndroid Build Coastguard Worker     tcu::TestNode::IterateResult iterate(tcu::TestCase *testCase);
55*35238bceSAndroid Build Coastguard Worker 
56*35238bceSAndroid Build Coastguard Worker private:
57*35238bceSAndroid Build Coastguard Worker     TestPackage &m_testPackage;
58*35238bceSAndroid Build Coastguard Worker     de::SharedPtr<tcu::WaiverUtil> m_waiverMechanism;
59*35238bceSAndroid Build Coastguard Worker };
60*35238bceSAndroid Build Coastguard Worker 
TestCaseWrapper(TestPackage & package,de::SharedPtr<tcu::WaiverUtil> waiverMechanism)61*35238bceSAndroid Build Coastguard Worker TestCaseWrapper::TestCaseWrapper(TestPackage &package, de::SharedPtr<tcu::WaiverUtil> waiverMechanism)
62*35238bceSAndroid Build Coastguard Worker     : m_testPackage(package)
63*35238bceSAndroid Build Coastguard Worker     , m_waiverMechanism(waiverMechanism)
64*35238bceSAndroid Build Coastguard Worker {
65*35238bceSAndroid Build Coastguard Worker }
66*35238bceSAndroid Build Coastguard Worker 
~TestCaseWrapper(void)67*35238bceSAndroid Build Coastguard Worker TestCaseWrapper::~TestCaseWrapper(void)
68*35238bceSAndroid Build Coastguard Worker {
69*35238bceSAndroid Build Coastguard Worker }
70*35238bceSAndroid Build Coastguard Worker 
init(tcu::TestCase * testCase,const std::string & path)71*35238bceSAndroid Build Coastguard Worker void TestCaseWrapper::init(tcu::TestCase *testCase, const std::string &path)
72*35238bceSAndroid Build Coastguard Worker {
73*35238bceSAndroid Build Coastguard Worker     if (m_waiverMechanism->isOnWaiverList(path))
74*35238bceSAndroid Build Coastguard Worker         throw tcu::TestException("Waived test", QP_TEST_RESULT_WAIVER);
75*35238bceSAndroid Build Coastguard Worker 
76*35238bceSAndroid Build Coastguard Worker     testCase->init();
77*35238bceSAndroid Build Coastguard Worker }
78*35238bceSAndroid Build Coastguard Worker 
deinit(tcu::TestCase * testCase)79*35238bceSAndroid Build Coastguard Worker void TestCaseWrapper::deinit(tcu::TestCase *testCase)
80*35238bceSAndroid Build Coastguard Worker {
81*35238bceSAndroid Build Coastguard Worker     testCase->deinit();
82*35238bceSAndroid Build Coastguard Worker 
83*35238bceSAndroid Build Coastguard Worker     DE_ASSERT(m_testPackage.getContext());
84*35238bceSAndroid Build Coastguard Worker     glu::resetState(m_testPackage.getContext()->getRenderContext(), m_testPackage.getContext()->getContextInfo());
85*35238bceSAndroid Build Coastguard Worker }
86*35238bceSAndroid Build Coastguard Worker 
iterate(tcu::TestCase * testCase)87*35238bceSAndroid Build Coastguard Worker tcu::TestNode::IterateResult TestCaseWrapper::iterate(tcu::TestCase *testCase)
88*35238bceSAndroid Build Coastguard Worker {
89*35238bceSAndroid Build Coastguard Worker     tcu::TestContext &testCtx     = m_testPackage.getContext()->getTestContext();
90*35238bceSAndroid Build Coastguard Worker     glu::RenderContext &renderCtx = m_testPackage.getContext()->getRenderContext();
91*35238bceSAndroid Build Coastguard Worker     tcu::TestCase::IterateResult result;
92*35238bceSAndroid Build Coastguard Worker 
93*35238bceSAndroid Build Coastguard Worker     // Clear to surrender-blue
94*35238bceSAndroid Build Coastguard Worker     {
95*35238bceSAndroid Build Coastguard Worker         const glw::Functions &gl = renderCtx.getFunctions();
96*35238bceSAndroid Build Coastguard Worker         gl.clearColor(0.125f, 0.25f, 0.5f, 1.f);
97*35238bceSAndroid Build Coastguard Worker         gl.clear(GL_COLOR_BUFFER_BIT);
98*35238bceSAndroid Build Coastguard Worker     }
99*35238bceSAndroid Build Coastguard Worker 
100*35238bceSAndroid Build Coastguard Worker     result = testCase->iterate();
101*35238bceSAndroid Build Coastguard Worker 
102*35238bceSAndroid Build Coastguard Worker     // Call implementation specific post-iterate routine (usually handles native events and swaps buffers)
103*35238bceSAndroid Build Coastguard Worker     try
104*35238bceSAndroid Build Coastguard Worker     {
105*35238bceSAndroid Build Coastguard Worker         renderCtx.postIterate();
106*35238bceSAndroid Build Coastguard Worker         return result;
107*35238bceSAndroid Build Coastguard Worker     }
108*35238bceSAndroid Build Coastguard Worker     catch (const tcu::ResourceError &e)
109*35238bceSAndroid Build Coastguard Worker     {
110*35238bceSAndroid Build Coastguard Worker         testCtx.getLog() << e;
111*35238bceSAndroid Build Coastguard Worker         testCtx.setTestResult(QP_TEST_RESULT_RESOURCE_ERROR, "Resource error in context post-iteration routine");
112*35238bceSAndroid Build Coastguard Worker         testCtx.setTerminateAfter(true);
113*35238bceSAndroid Build Coastguard Worker         return tcu::TestNode::STOP;
114*35238bceSAndroid Build Coastguard Worker     }
115*35238bceSAndroid Build Coastguard Worker     catch (const std::exception &e)
116*35238bceSAndroid Build Coastguard Worker     {
117*35238bceSAndroid Build Coastguard Worker         testCtx.getLog() << e;
118*35238bceSAndroid Build Coastguard Worker         testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Error in context post-iteration routine");
119*35238bceSAndroid Build Coastguard Worker         return tcu::TestNode::STOP;
120*35238bceSAndroid Build Coastguard Worker     }
121*35238bceSAndroid Build Coastguard Worker }
122*35238bceSAndroid Build Coastguard Worker 
TestPackage(tcu::TestContext & testCtx)123*35238bceSAndroid Build Coastguard Worker TestPackage::TestPackage(tcu::TestContext &testCtx)
124*35238bceSAndroid Build Coastguard Worker     : tcu::TestPackage(testCtx, "dEQP-GLES2", "dEQP OpenGL ES 2.0 Tests")
125*35238bceSAndroid Build Coastguard Worker     , m_archive(testCtx.getRootArchive(), "gles2/")
126*35238bceSAndroid Build Coastguard Worker     , m_context(DE_NULL)
127*35238bceSAndroid Build Coastguard Worker     , m_waiverMechanism(new tcu::WaiverUtil)
128*35238bceSAndroid Build Coastguard Worker {
129*35238bceSAndroid Build Coastguard Worker }
130*35238bceSAndroid Build Coastguard Worker 
~TestPackage(void)131*35238bceSAndroid Build Coastguard Worker TestPackage::~TestPackage(void)
132*35238bceSAndroid Build Coastguard Worker {
133*35238bceSAndroid Build Coastguard Worker     // Destroy children first since destructors may access context.
134*35238bceSAndroid Build Coastguard Worker     TestNode::deinit();
135*35238bceSAndroid Build Coastguard Worker     delete m_context;
136*35238bceSAndroid Build Coastguard Worker }
137*35238bceSAndroid Build Coastguard Worker 
init(void)138*35238bceSAndroid Build Coastguard Worker void TestPackage::init(void)
139*35238bceSAndroid Build Coastguard Worker {
140*35238bceSAndroid Build Coastguard Worker     try
141*35238bceSAndroid Build Coastguard Worker     {
142*35238bceSAndroid Build Coastguard Worker         // Create context
143*35238bceSAndroid Build Coastguard Worker         m_context = new Context(m_testCtx);
144*35238bceSAndroid Build Coastguard Worker 
145*35238bceSAndroid Build Coastguard Worker         // Setup waiver mechanism
146*35238bceSAndroid Build Coastguard Worker         if (m_testCtx.getCommandLine().getRunMode() == tcu::RUNMODE_EXECUTE)
147*35238bceSAndroid Build Coastguard Worker         {
148*35238bceSAndroid Build Coastguard Worker             const glu::ContextInfo &contextInfo = m_context->getContextInfo();
149*35238bceSAndroid Build Coastguard Worker             std::string vendor                  = contextInfo.getString(GL_VENDOR);
150*35238bceSAndroid Build Coastguard Worker             std::string renderer                = contextInfo.getString(GL_RENDERER);
151*35238bceSAndroid Build Coastguard Worker             const tcu::CommandLine &commandLine = m_context->getTestContext().getCommandLine();
152*35238bceSAndroid Build Coastguard Worker             tcu::SessionInfo sessionInfo(vendor, renderer, commandLine.getInitialCmdLine());
153*35238bceSAndroid Build Coastguard Worker             m_waiverMechanism->setup(commandLine.getWaiverFileName(), m_name, vendor, renderer, sessionInfo);
154*35238bceSAndroid Build Coastguard Worker             m_context->getTestContext().getLog().writeSessionInfo(sessionInfo.get());
155*35238bceSAndroid Build Coastguard Worker         }
156*35238bceSAndroid Build Coastguard Worker 
157*35238bceSAndroid Build Coastguard Worker         // Add main test groups
158*35238bceSAndroid Build Coastguard Worker         addChild(new InfoTests(*m_context));
159*35238bceSAndroid Build Coastguard Worker         addChild(new CapabilityTests(*m_context));
160*35238bceSAndroid Build Coastguard Worker         addChild(new Functional::FunctionalTests(*m_context));
161*35238bceSAndroid Build Coastguard Worker         addChild(new Accuracy::AccuracyTests(*m_context));
162*35238bceSAndroid Build Coastguard Worker         addChild(new Performance::PerformanceTests(*m_context));
163*35238bceSAndroid Build Coastguard Worker         addChild(new Stress::StressTests(*m_context));
164*35238bceSAndroid Build Coastguard Worker     }
165*35238bceSAndroid Build Coastguard Worker     catch (...)
166*35238bceSAndroid Build Coastguard Worker     {
167*35238bceSAndroid Build Coastguard Worker         delete m_context;
168*35238bceSAndroid Build Coastguard Worker         m_context = DE_NULL;
169*35238bceSAndroid Build Coastguard Worker 
170*35238bceSAndroid Build Coastguard Worker         throw;
171*35238bceSAndroid Build Coastguard Worker     }
172*35238bceSAndroid Build Coastguard Worker }
173*35238bceSAndroid Build Coastguard Worker 
deinit(void)174*35238bceSAndroid Build Coastguard Worker void TestPackage::deinit(void)
175*35238bceSAndroid Build Coastguard Worker {
176*35238bceSAndroid Build Coastguard Worker     TestNode::deinit();
177*35238bceSAndroid Build Coastguard Worker     delete m_context;
178*35238bceSAndroid Build Coastguard Worker     m_context = DE_NULL;
179*35238bceSAndroid Build Coastguard Worker }
180*35238bceSAndroid Build Coastguard Worker 
createExecutor(void) const181*35238bceSAndroid Build Coastguard Worker tcu::TestCaseExecutor *TestPackage::createExecutor(void) const
182*35238bceSAndroid Build Coastguard Worker {
183*35238bceSAndroid Build Coastguard Worker     return new TestCaseWrapper(const_cast<TestPackage &>(*this), m_waiverMechanism);
184*35238bceSAndroid Build Coastguard Worker }
185*35238bceSAndroid Build Coastguard Worker 
186*35238bceSAndroid Build Coastguard Worker } // namespace gles2
187*35238bceSAndroid Build Coastguard Worker } // namespace deqp
188