blob: 225cf94fcaf41afa8ffecdc3daeb54fcf775eed8 [file] [log] [blame]
Jarkko Poyry3c827362014-09-02 11:48:52 +03001/*-------------------------------------------------------------------------
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"
Pyry Haulos4e3ea872015-03-20 11:06:41 -070028#include "gluStateReset.hpp"
29#include "gluRenderContext.hpp"
30#include "tcuTestLog.hpp"
Jarkko Poyry3c827362014-09-02 11:48:52 +030031
32namespace deqp
33{
34namespace gles31
35{
36
Pyry Haulos4e3ea872015-03-20 11:06:41 -070037class TestCaseWrapper : public tcu::TestCaseExecutor
Jarkko Poyry3c827362014-09-02 11:48:52 +030038{
Pyry Haulos4e3ea872015-03-20 11:06:41 -070039public:
40 TestCaseWrapper (TestPackage& package);
41 ~TestCaseWrapper (void);
Jarkko Poyry3c827362014-09-02 11:48:52 +030042
Pyry Haulos4e3ea872015-03-20 11:06:41 -070043 void init (tcu::TestCase* testCase, const std::string& path);
44 void deinit (tcu::TestCase* testCase);
45 tcu::TestNode::IterateResult iterate (tcu::TestCase* testCase);
46
47private:
48 TestPackage& m_testPackage;
49};
50
51TestCaseWrapper::TestCaseWrapper (TestPackage& package)
52 : m_testPackage(package)
53{
Jarkko Poyry3c827362014-09-02 11:48:52 +030054}
55
Pyry Haulos4e3ea872015-03-20 11:06:41 -070056TestCaseWrapper::~TestCaseWrapper (void)
Jarkko Poyry3c827362014-09-02 11:48:52 +030057{
Pyry Haulos4e3ea872015-03-20 11:06:41 -070058}
59
60void TestCaseWrapper::init (tcu::TestCase* testCase, const std::string&)
61{
62 testCase->init();
63}
64
65void TestCaseWrapper::deinit (tcu::TestCase* testCase)
66{
67 testCase->deinit();
68
69 DE_ASSERT(m_testPackage.getContext());
Mika Isojärvi344563b2016-03-10 13:56:54 -080070 glu::resetState(m_testPackage.getContext()->getRenderContext(), m_testPackage.getContext()->getContextInfo());
Pyry Haulos4e3ea872015-03-20 11:06:41 -070071}
72
73tcu::TestNode::IterateResult TestCaseWrapper::iterate (tcu::TestCase* testCase)
74{
75 tcu::TestContext& testCtx = m_testPackage.getContext()->getTestContext();
76 const tcu::TestCase::IterateResult result = testCase->iterate();
77
78 // Call implementation specific post-iterate routine (usually handles native events and swaps buffers)
79 try
80 {
81 m_testPackage.getContext()->getRenderContext().postIterate();
82 return result;
83 }
84 catch (const tcu::ResourceError& e)
85 {
86 testCtx.getLog() << e;
87 testCtx.setTestResult(QP_TEST_RESULT_RESOURCE_ERROR, "Resource error in context post-iteration routine");
88 testCtx.setTerminateAfter(true);
89 return tcu::TestNode::STOP;
90 }
91 catch (const std::exception& e)
92 {
93 testCtx.getLog() << e;
94 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Error in context post-iteration routine");
95 return tcu::TestNode::STOP;
96 }
Jarkko Poyry3c827362014-09-02 11:48:52 +030097}
98
99TestPackage::TestPackage (tcu::TestContext& testCtx)
100 : tcu::TestPackage (testCtx, "dEQP-GLES31", "dEQP OpenGL ES 3.1 Tests")
Jarkko Poyry3c827362014-09-02 11:48:52 +0300101 , m_archive (testCtx.getRootArchive(), "gles31/")
Pyry Haulos4e3ea872015-03-20 11:06:41 -0700102 , m_context (DE_NULL)
Jarkko Poyry3c827362014-09-02 11:48:52 +0300103{
104}
105
106TestPackage::~TestPackage (void)
107{
108 // Destroy children first since destructors may access context.
109 TestNode::deinit();
Pyry Haulos4e3ea872015-03-20 11:06:41 -0700110 delete m_context;
Jarkko Poyry3c827362014-09-02 11:48:52 +0300111}
112
113void TestPackage::init (void)
114{
115 try
116 {
117 // Create context
Pyry Haulos4e3ea872015-03-20 11:06:41 -0700118 m_context = new Context(m_testCtx);
Jarkko Poyry3c827362014-09-02 11:48:52 +0300119
120 // Add main test groups
Pyry Haulos4e3ea872015-03-20 11:06:41 -0700121 addChild(new InfoTests (*m_context));
122 addChild(new Functional::FunctionalTests (*m_context));
123 addChild(new Stress::StressTests (*m_context));
Jarkko Poyry3c827362014-09-02 11:48:52 +0300124 }
125 catch (...)
126 {
Pyry Haulos4e3ea872015-03-20 11:06:41 -0700127 delete m_context;
128 m_context = DE_NULL;
Jarkko Poyry3c827362014-09-02 11:48:52 +0300129
130 throw;
131 }
132}
133
134void TestPackage::deinit (void)
135{
136 TestNode::deinit();
Pyry Haulos4e3ea872015-03-20 11:06:41 -0700137 delete m_context;
138 m_context = DE_NULL;
139}
140
141tcu::TestCaseExecutor* TestPackage::createExecutor (void) const
142{
143 return new TestCaseWrapper(const_cast<TestPackage&>(*this));
Jarkko Poyry3c827362014-09-02 11:48:52 +0300144}
145
146} // gles31
147} // deqp