xref: /aosp_15_r20/external/deqp/modules/gles31/tes31TestCaseWrapper.hpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1*35238bceSAndroid Build Coastguard Worker #ifndef _TES31TESTCASEWRAPPER_HPP
2*35238bceSAndroid Build Coastguard Worker #define _TES31TESTCASEWRAPPER_HPP
3*35238bceSAndroid Build Coastguard Worker /*-------------------------------------------------------------------------
4*35238bceSAndroid Build Coastguard Worker  * OpenGL Conformance Test Suite
5*35238bceSAndroid Build Coastguard Worker  * -----------------------------
6*35238bceSAndroid Build Coastguard Worker  *
7*35238bceSAndroid Build Coastguard Worker  * Copyright (c) 2019 The Khronos Group Inc.
8*35238bceSAndroid Build Coastguard Worker  *
9*35238bceSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
10*35238bceSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
11*35238bceSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
12*35238bceSAndroid Build Coastguard Worker  *
13*35238bceSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
14*35238bceSAndroid Build Coastguard Worker  *
15*35238bceSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
16*35238bceSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
17*35238bceSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18*35238bceSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
19*35238bceSAndroid Build Coastguard Worker  * limitations under the License.
20*35238bceSAndroid Build Coastguard Worker  *
21*35238bceSAndroid Build Coastguard Worker  */ /*!
22*35238bceSAndroid Build Coastguard Worker  * \file
23*35238bceSAndroid Build Coastguard Worker  * \brief OpenGL ES 3.1 Test Package that runs on GL4.5 context
24*35238bceSAndroid Build Coastguard Worker  *//*--------------------------------------------------------------------*/
25*35238bceSAndroid Build Coastguard Worker 
26*35238bceSAndroid Build Coastguard Worker #include "tcuTestLog.hpp"
27*35238bceSAndroid Build Coastguard Worker #include "tes31Context.hpp"
28*35238bceSAndroid Build Coastguard Worker #include "tcuWaiverUtil.hpp"
29*35238bceSAndroid Build Coastguard Worker #include "gluStateReset.hpp"
30*35238bceSAndroid Build Coastguard Worker 
31*35238bceSAndroid Build Coastguard Worker namespace deqp
32*35238bceSAndroid Build Coastguard Worker {
33*35238bceSAndroid Build Coastguard Worker namespace gles31
34*35238bceSAndroid Build Coastguard Worker {
35*35238bceSAndroid Build Coastguard Worker 
36*35238bceSAndroid Build Coastguard Worker template <typename TEST_PACKAGE>
37*35238bceSAndroid Build Coastguard Worker class TestCaseWrapper : public tcu::TestCaseExecutor
38*35238bceSAndroid Build Coastguard Worker {
39*35238bceSAndroid Build Coastguard Worker public:
40*35238bceSAndroid Build Coastguard Worker     TestCaseWrapper(TEST_PACKAGE &package, de::SharedPtr<tcu::WaiverUtil> waiverMechanism);
41*35238bceSAndroid Build Coastguard Worker     ~TestCaseWrapper(void);
42*35238bceSAndroid Build Coastguard Worker 
43*35238bceSAndroid Build Coastguard Worker     void init(tcu::TestCase *testCase, const std::string &path);
44*35238bceSAndroid Build Coastguard Worker     void deinit(tcu::TestCase *testCase);
45*35238bceSAndroid Build Coastguard Worker     tcu::TestNode::IterateResult iterate(tcu::TestCase *testCase);
46*35238bceSAndroid Build Coastguard Worker 
47*35238bceSAndroid Build Coastguard Worker private:
48*35238bceSAndroid Build Coastguard Worker     TEST_PACKAGE &m_testPackage;
49*35238bceSAndroid Build Coastguard Worker     de::SharedPtr<tcu::WaiverUtil> m_waiverMechanism;
50*35238bceSAndroid Build Coastguard Worker };
51*35238bceSAndroid Build Coastguard Worker 
52*35238bceSAndroid Build Coastguard Worker template <typename TEST_PACKAGE>
TestCaseWrapper(TEST_PACKAGE & package,de::SharedPtr<tcu::WaiverUtil> waiverMechanism)53*35238bceSAndroid Build Coastguard Worker TestCaseWrapper<TEST_PACKAGE>::TestCaseWrapper(TEST_PACKAGE &package, de::SharedPtr<tcu::WaiverUtil> waiverMechanism)
54*35238bceSAndroid Build Coastguard Worker     : m_testPackage(package)
55*35238bceSAndroid Build Coastguard Worker     , m_waiverMechanism(waiverMechanism)
56*35238bceSAndroid Build Coastguard Worker {
57*35238bceSAndroid Build Coastguard Worker }
58*35238bceSAndroid Build Coastguard Worker 
59*35238bceSAndroid Build Coastguard Worker template <typename TEST_PACKAGE>
~TestCaseWrapper(void)60*35238bceSAndroid Build Coastguard Worker TestCaseWrapper<TEST_PACKAGE>::~TestCaseWrapper(void)
61*35238bceSAndroid Build Coastguard Worker {
62*35238bceSAndroid Build Coastguard Worker }
63*35238bceSAndroid Build Coastguard Worker 
64*35238bceSAndroid Build Coastguard Worker template <typename TEST_PACKAGE>
init(tcu::TestCase * testCase,const std::string & path)65*35238bceSAndroid Build Coastguard Worker void TestCaseWrapper<TEST_PACKAGE>::init(tcu::TestCase *testCase, const std::string &path)
66*35238bceSAndroid Build Coastguard Worker {
67*35238bceSAndroid Build Coastguard Worker     if (m_waiverMechanism->isOnWaiverList(path))
68*35238bceSAndroid Build Coastguard Worker         throw tcu::TestException("Waived test", QP_TEST_RESULT_WAIVER);
69*35238bceSAndroid Build Coastguard Worker 
70*35238bceSAndroid Build Coastguard Worker     testCase->init();
71*35238bceSAndroid Build Coastguard Worker }
72*35238bceSAndroid Build Coastguard Worker 
73*35238bceSAndroid Build Coastguard Worker template <typename TEST_PACKAGE>
deinit(tcu::TestCase * testCase)74*35238bceSAndroid Build Coastguard Worker void TestCaseWrapper<TEST_PACKAGE>::deinit(tcu::TestCase *testCase)
75*35238bceSAndroid Build Coastguard Worker {
76*35238bceSAndroid Build Coastguard Worker     testCase->deinit();
77*35238bceSAndroid Build Coastguard Worker 
78*35238bceSAndroid Build Coastguard Worker     DE_ASSERT(m_testPackage.getContext());
79*35238bceSAndroid Build Coastguard Worker     glu::resetState(m_testPackage.getContext()->getRenderContext(), m_testPackage.getContext()->getContextInfo());
80*35238bceSAndroid Build Coastguard Worker }
81*35238bceSAndroid Build Coastguard Worker 
82*35238bceSAndroid Build Coastguard Worker template <typename TEST_PACKAGE>
iterate(tcu::TestCase * testCase)83*35238bceSAndroid Build Coastguard Worker tcu::TestNode::IterateResult TestCaseWrapper<TEST_PACKAGE>::iterate(tcu::TestCase *testCase)
84*35238bceSAndroid Build Coastguard Worker {
85*35238bceSAndroid Build Coastguard Worker     tcu::TestContext &testCtx                 = m_testPackage.getContext()->getTestContext();
86*35238bceSAndroid Build Coastguard Worker     const tcu::TestCase::IterateResult result = testCase->iterate();
87*35238bceSAndroid Build Coastguard Worker 
88*35238bceSAndroid Build Coastguard Worker     // Call implementation specific post-iterate routine (usually handles native events and swaps buffers)
89*35238bceSAndroid Build Coastguard Worker     try
90*35238bceSAndroid Build Coastguard Worker     {
91*35238bceSAndroid Build Coastguard Worker         m_testPackage.getContext()->getRenderContext().postIterate();
92*35238bceSAndroid Build Coastguard Worker         return result;
93*35238bceSAndroid Build Coastguard Worker     }
94*35238bceSAndroid Build Coastguard Worker     catch (const tcu::ResourceError &e)
95*35238bceSAndroid Build Coastguard Worker     {
96*35238bceSAndroid Build Coastguard Worker         testCtx.getLog() << e;
97*35238bceSAndroid Build Coastguard Worker         testCtx.setTestResult(QP_TEST_RESULT_RESOURCE_ERROR, "Resource error in context post-iteration routine");
98*35238bceSAndroid Build Coastguard Worker         testCtx.setTerminateAfter(true);
99*35238bceSAndroid Build Coastguard Worker         return tcu::TestNode::STOP;
100*35238bceSAndroid Build Coastguard Worker     }
101*35238bceSAndroid Build Coastguard Worker     catch (const std::exception &e)
102*35238bceSAndroid Build Coastguard Worker     {
103*35238bceSAndroid Build Coastguard Worker         testCtx.getLog() << e;
104*35238bceSAndroid Build Coastguard Worker         testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Error in context post-iteration routine");
105*35238bceSAndroid Build Coastguard Worker         return tcu::TestNode::STOP;
106*35238bceSAndroid Build Coastguard Worker     }
107*35238bceSAndroid Build Coastguard Worker }
108*35238bceSAndroid Build Coastguard Worker 
109*35238bceSAndroid Build Coastguard Worker } // namespace gles31
110*35238bceSAndroid Build Coastguard Worker } // namespace deqp
111*35238bceSAndroid Build Coastguard Worker 
112*35238bceSAndroid Build Coastguard Worker #endif // _TES31TESTCASEWRAPPER_HPP
113