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