xref: /aosp_15_r20/external/deqp/modules/gles2/tes2TestPackage.cpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1 /*-------------------------------------------------------------------------
2  * drawElements Quality Program OpenGL ES 2.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 2.0 Test Package
22  *//*--------------------------------------------------------------------*/
23 
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"
40 
41 namespace deqp
42 {
43 namespace gles2
44 {
45 
46 class TestCaseWrapper : public tcu::TestCaseExecutor
47 {
48 public:
49     TestCaseWrapper(TestPackage &package, de::SharedPtr<tcu::WaiverUtil> waiverMechanism);
50     ~TestCaseWrapper(void);
51 
52     void init(tcu::TestCase *testCase, const std::string &path);
53     void deinit(tcu::TestCase *testCase);
54     tcu::TestNode::IterateResult iterate(tcu::TestCase *testCase);
55 
56 private:
57     TestPackage &m_testPackage;
58     de::SharedPtr<tcu::WaiverUtil> m_waiverMechanism;
59 };
60 
TestCaseWrapper(TestPackage & package,de::SharedPtr<tcu::WaiverUtil> waiverMechanism)61 TestCaseWrapper::TestCaseWrapper(TestPackage &package, de::SharedPtr<tcu::WaiverUtil> waiverMechanism)
62     : m_testPackage(package)
63     , m_waiverMechanism(waiverMechanism)
64 {
65 }
66 
~TestCaseWrapper(void)67 TestCaseWrapper::~TestCaseWrapper(void)
68 {
69 }
70 
init(tcu::TestCase * testCase,const std::string & path)71 void TestCaseWrapper::init(tcu::TestCase *testCase, const std::string &path)
72 {
73     if (m_waiverMechanism->isOnWaiverList(path))
74         throw tcu::TestException("Waived test", QP_TEST_RESULT_WAIVER);
75 
76     testCase->init();
77 }
78 
deinit(tcu::TestCase * testCase)79 void TestCaseWrapper::deinit(tcu::TestCase *testCase)
80 {
81     testCase->deinit();
82 
83     DE_ASSERT(m_testPackage.getContext());
84     glu::resetState(m_testPackage.getContext()->getRenderContext(), m_testPackage.getContext()->getContextInfo());
85 }
86 
iterate(tcu::TestCase * testCase)87 tcu::TestNode::IterateResult TestCaseWrapper::iterate(tcu::TestCase *testCase)
88 {
89     tcu::TestContext &testCtx     = m_testPackage.getContext()->getTestContext();
90     glu::RenderContext &renderCtx = m_testPackage.getContext()->getRenderContext();
91     tcu::TestCase::IterateResult result;
92 
93     // Clear to surrender-blue
94     {
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);
98     }
99 
100     result = testCase->iterate();
101 
102     // Call implementation specific post-iterate routine (usually handles native events and swaps buffers)
103     try
104     {
105         renderCtx.postIterate();
106         return result;
107     }
108     catch (const tcu::ResourceError &e)
109     {
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;
114     }
115     catch (const std::exception &e)
116     {
117         testCtx.getLog() << e;
118         testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Error in context post-iteration routine");
119         return tcu::TestNode::STOP;
120     }
121 }
122 
TestPackage(tcu::TestContext & testCtx)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)
128 {
129 }
130 
~TestPackage(void)131 TestPackage::~TestPackage(void)
132 {
133     // Destroy children first since destructors may access context.
134     TestNode::deinit();
135     delete m_context;
136 }
137 
init(void)138 void TestPackage::init(void)
139 {
140     try
141     {
142         // Create context
143         m_context = new Context(m_testCtx);
144 
145         // Setup waiver mechanism
146         if (m_testCtx.getCommandLine().getRunMode() == tcu::RUNMODE_EXECUTE)
147         {
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());
155         }
156 
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));
164     }
165     catch (...)
166     {
167         delete m_context;
168         m_context = DE_NULL;
169 
170         throw;
171     }
172 }
173 
deinit(void)174 void TestPackage::deinit(void)
175 {
176     TestNode::deinit();
177     delete m_context;
178     m_context = DE_NULL;
179 }
180 
createExecutor(void) const181 tcu::TestCaseExecutor *TestPackage::createExecutor(void) const
182 {
183     return new TestCaseWrapper(const_cast<TestPackage &>(*this), m_waiverMechanism);
184 }
185 
186 } // namespace gles2
187 } // namespace deqp
188