Jarkko Poyry | 3c82736 | 2014-09-02 11:48:52 +0300 | [diff] [blame] | 1 | /*------------------------------------------------------------------------- |
| 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 Haulos | 4e3ea87 | 2015-03-20 11:06:41 -0700 | [diff] [blame] | 28 | #include "gluStateReset.hpp" |
| 29 | #include "gluRenderContext.hpp" |
| 30 | #include "tcuTestLog.hpp" |
Jarkko Poyry | 3c82736 | 2014-09-02 11:48:52 +0300 | [diff] [blame] | 31 | |
| 32 | namespace deqp |
| 33 | { |
| 34 | namespace gles31 |
| 35 | { |
| 36 | |
Pyry Haulos | 4e3ea87 | 2015-03-20 11:06:41 -0700 | [diff] [blame] | 37 | class TestCaseWrapper : public tcu::TestCaseExecutor |
Jarkko Poyry | 3c82736 | 2014-09-02 11:48:52 +0300 | [diff] [blame] | 38 | { |
Pyry Haulos | 4e3ea87 | 2015-03-20 11:06:41 -0700 | [diff] [blame] | 39 | public: |
| 40 | TestCaseWrapper (TestPackage& package); |
| 41 | ~TestCaseWrapper (void); |
Jarkko Poyry | 3c82736 | 2014-09-02 11:48:52 +0300 | [diff] [blame] | 42 | |
Pyry Haulos | 4e3ea87 | 2015-03-20 11:06:41 -0700 | [diff] [blame] | 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 | TestPackage& m_testPackage; |
| 49 | }; |
| 50 | |
| 51 | TestCaseWrapper::TestCaseWrapper (TestPackage& package) |
| 52 | : m_testPackage(package) |
| 53 | { |
Jarkko Poyry | 3c82736 | 2014-09-02 11:48:52 +0300 | [diff] [blame] | 54 | } |
| 55 | |
Pyry Haulos | 4e3ea87 | 2015-03-20 11:06:41 -0700 | [diff] [blame] | 56 | TestCaseWrapper::~TestCaseWrapper (void) |
Jarkko Poyry | 3c82736 | 2014-09-02 11:48:52 +0300 | [diff] [blame] | 57 | { |
Pyry Haulos | 4e3ea87 | 2015-03-20 11:06:41 -0700 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | void TestCaseWrapper::init (tcu::TestCase* testCase, const std::string&) |
| 61 | { |
| 62 | testCase->init(); |
| 63 | } |
| 64 | |
| 65 | void TestCaseWrapper::deinit (tcu::TestCase* testCase) |
| 66 | { |
| 67 | testCase->deinit(); |
| 68 | |
| 69 | DE_ASSERT(m_testPackage.getContext()); |
Mika Isojärvi | 344563b | 2016-03-10 13:56:54 -0800 | [diff] [blame] | 70 | glu::resetState(m_testPackage.getContext()->getRenderContext(), m_testPackage.getContext()->getContextInfo()); |
Pyry Haulos | 4e3ea87 | 2015-03-20 11:06:41 -0700 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | tcu::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 Poyry | 3c82736 | 2014-09-02 11:48:52 +0300 | [diff] [blame] | 97 | } |
| 98 | |
| 99 | TestPackage::TestPackage (tcu::TestContext& testCtx) |
| 100 | : tcu::TestPackage (testCtx, "dEQP-GLES31", "dEQP OpenGL ES 3.1 Tests") |
Jarkko Poyry | 3c82736 | 2014-09-02 11:48:52 +0300 | [diff] [blame] | 101 | , m_archive (testCtx.getRootArchive(), "gles31/") |
Pyry Haulos | 4e3ea87 | 2015-03-20 11:06:41 -0700 | [diff] [blame] | 102 | , m_context (DE_NULL) |
Jarkko Poyry | 3c82736 | 2014-09-02 11:48:52 +0300 | [diff] [blame] | 103 | { |
| 104 | } |
| 105 | |
| 106 | TestPackage::~TestPackage (void) |
| 107 | { |
| 108 | // Destroy children first since destructors may access context. |
| 109 | TestNode::deinit(); |
Pyry Haulos | 4e3ea87 | 2015-03-20 11:06:41 -0700 | [diff] [blame] | 110 | delete m_context; |
Jarkko Poyry | 3c82736 | 2014-09-02 11:48:52 +0300 | [diff] [blame] | 111 | } |
| 112 | |
| 113 | void TestPackage::init (void) |
| 114 | { |
| 115 | try |
| 116 | { |
| 117 | // Create context |
Pyry Haulos | 4e3ea87 | 2015-03-20 11:06:41 -0700 | [diff] [blame] | 118 | m_context = new Context(m_testCtx); |
Jarkko Poyry | 3c82736 | 2014-09-02 11:48:52 +0300 | [diff] [blame] | 119 | |
| 120 | // Add main test groups |
Pyry Haulos | 4e3ea87 | 2015-03-20 11:06:41 -0700 | [diff] [blame] | 121 | addChild(new InfoTests (*m_context)); |
| 122 | addChild(new Functional::FunctionalTests (*m_context)); |
| 123 | addChild(new Stress::StressTests (*m_context)); |
Jarkko Poyry | 3c82736 | 2014-09-02 11:48:52 +0300 | [diff] [blame] | 124 | } |
| 125 | catch (...) |
| 126 | { |
Pyry Haulos | 4e3ea87 | 2015-03-20 11:06:41 -0700 | [diff] [blame] | 127 | delete m_context; |
| 128 | m_context = DE_NULL; |
Jarkko Poyry | 3c82736 | 2014-09-02 11:48:52 +0300 | [diff] [blame] | 129 | |
| 130 | throw; |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | void TestPackage::deinit (void) |
| 135 | { |
| 136 | TestNode::deinit(); |
Pyry Haulos | 4e3ea87 | 2015-03-20 11:06:41 -0700 | [diff] [blame] | 137 | delete m_context; |
| 138 | m_context = DE_NULL; |
| 139 | } |
| 140 | |
| 141 | tcu::TestCaseExecutor* TestPackage::createExecutor (void) const |
| 142 | { |
| 143 | return new TestCaseWrapper(const_cast<TestPackage&>(*this)); |
Jarkko Poyry | 3c82736 | 2014-09-02 11:48:52 +0300 | [diff] [blame] | 144 | } |
| 145 | |
| 146 | } // gles31 |
| 147 | } // deqp |