xref: /aosp_15_r20/external/deqp/external/openglcts/modules/common/glcTestPackage.cpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1*35238bceSAndroid Build Coastguard Worker /*-------------------------------------------------------------------------
2*35238bceSAndroid Build Coastguard Worker  * OpenGL Conformance Test Suite
3*35238bceSAndroid Build Coastguard Worker  * -----------------------------
4*35238bceSAndroid Build Coastguard Worker  *
5*35238bceSAndroid Build Coastguard Worker  * Copyright (c) 2016 Google Inc.
6*35238bceSAndroid Build Coastguard Worker  * Copyright (c) 2016 The Khronos Group Inc.
7*35238bceSAndroid Build Coastguard Worker  *
8*35238bceSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
9*35238bceSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
10*35238bceSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
11*35238bceSAndroid Build Coastguard Worker  *
12*35238bceSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
13*35238bceSAndroid Build Coastguard Worker  *
14*35238bceSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
15*35238bceSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
16*35238bceSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17*35238bceSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
18*35238bceSAndroid Build Coastguard Worker  * limitations under the License.
19*35238bceSAndroid Build Coastguard Worker  *
20*35238bceSAndroid Build Coastguard Worker  */ /*!
21*35238bceSAndroid Build Coastguard Worker  * \file
22*35238bceSAndroid Build Coastguard Worker  * \brief OpenGL Conformance Test Package Base Class
23*35238bceSAndroid Build Coastguard Worker  */ /*-------------------------------------------------------------------*/
24*35238bceSAndroid Build Coastguard Worker 
25*35238bceSAndroid Build Coastguard Worker #include "glcTestPackage.hpp"
26*35238bceSAndroid Build Coastguard Worker #include "gluContextInfo.hpp"
27*35238bceSAndroid Build Coastguard Worker #include "tcuTestLog.hpp"
28*35238bceSAndroid Build Coastguard Worker #include "tcuCommandLine.hpp"
29*35238bceSAndroid Build Coastguard Worker #include "tcuWaiverUtil.hpp"
30*35238bceSAndroid Build Coastguard Worker #include "glwEnums.hpp"
31*35238bceSAndroid Build Coastguard Worker 
32*35238bceSAndroid Build Coastguard Worker namespace deqp
33*35238bceSAndroid Build Coastguard Worker {
34*35238bceSAndroid Build Coastguard Worker 
PackageContext(tcu::TestContext & testCtx,glu::ContextType renderContextType)35*35238bceSAndroid Build Coastguard Worker PackageContext::PackageContext(tcu::TestContext &testCtx, glu::ContextType renderContextType)
36*35238bceSAndroid Build Coastguard Worker     : m_context(testCtx, renderContextType)
37*35238bceSAndroid Build Coastguard Worker     , m_caseWrapper(m_context)
38*35238bceSAndroid Build Coastguard Worker {
39*35238bceSAndroid Build Coastguard Worker }
40*35238bceSAndroid Build Coastguard Worker 
~PackageContext(void)41*35238bceSAndroid Build Coastguard Worker PackageContext::~PackageContext(void)
42*35238bceSAndroid Build Coastguard Worker {
43*35238bceSAndroid Build Coastguard Worker }
44*35238bceSAndroid Build Coastguard Worker 
TestPackage(tcu::TestContext & testCtx,const char * name,const char * description,glu::ContextType renderContextType,const char * resourcesPath)45*35238bceSAndroid Build Coastguard Worker TestPackage::TestPackage(tcu::TestContext &testCtx, const char *name, const char *description,
46*35238bceSAndroid Build Coastguard Worker                          glu::ContextType renderContextType, const char *resourcesPath)
47*35238bceSAndroid Build Coastguard Worker     : tcu::TestPackage(testCtx, name, description)
48*35238bceSAndroid Build Coastguard Worker     , m_waiverMechanism(new tcu::WaiverUtil)
49*35238bceSAndroid Build Coastguard Worker     , m_renderContextType(renderContextType)
50*35238bceSAndroid Build Coastguard Worker     , m_packageCtx(DE_NULL)
51*35238bceSAndroid Build Coastguard Worker     , m_archive(testCtx.getRootArchive(), resourcesPath)
52*35238bceSAndroid Build Coastguard Worker {
53*35238bceSAndroid Build Coastguard Worker }
54*35238bceSAndroid Build Coastguard Worker 
~TestPackage(void)55*35238bceSAndroid Build Coastguard Worker TestPackage::~TestPackage(void)
56*35238bceSAndroid Build Coastguard Worker {
57*35238bceSAndroid Build Coastguard Worker     // Destroy all children before destroying context since destructors may access context.
58*35238bceSAndroid Build Coastguard Worker     tcu::TestNode::deinit();
59*35238bceSAndroid Build Coastguard Worker     delete m_packageCtx;
60*35238bceSAndroid Build Coastguard Worker }
61*35238bceSAndroid Build Coastguard Worker 
init(void)62*35238bceSAndroid Build Coastguard Worker void TestPackage::init(void)
63*35238bceSAndroid Build Coastguard Worker {
64*35238bceSAndroid Build Coastguard Worker     try
65*35238bceSAndroid Build Coastguard Worker     {
66*35238bceSAndroid Build Coastguard Worker         // Create context
67*35238bceSAndroid Build Coastguard Worker         m_packageCtx = new PackageContext(m_testCtx, m_renderContextType);
68*35238bceSAndroid Build Coastguard Worker 
69*35238bceSAndroid Build Coastguard Worker         // Setup waiver mechanism
70*35238bceSAndroid Build Coastguard Worker         if (m_testCtx.getCommandLine().getRunMode() == tcu::RUNMODE_EXECUTE)
71*35238bceSAndroid Build Coastguard Worker         {
72*35238bceSAndroid Build Coastguard Worker             Context &context                    = m_packageCtx->getContext();
73*35238bceSAndroid Build Coastguard Worker             const glu::ContextInfo &contextInfo = context.getContextInfo();
74*35238bceSAndroid Build Coastguard Worker             std::string vendor                  = contextInfo.getString(GL_VENDOR);
75*35238bceSAndroid Build Coastguard Worker             std::string renderer                = contextInfo.getString(GL_RENDERER);
76*35238bceSAndroid Build Coastguard Worker             const tcu::CommandLine &commandLine = context.getTestContext().getCommandLine();
77*35238bceSAndroid Build Coastguard Worker             tcu::SessionInfo sessionInfo(vendor, renderer, commandLine.getInitialCmdLine());
78*35238bceSAndroid Build Coastguard Worker             m_waiverMechanism->setup(commandLine.getWaiverFileName(), m_name, vendor, renderer, sessionInfo);
79*35238bceSAndroid Build Coastguard Worker             context.getTestContext().getLog().writeSessionInfo(sessionInfo.get());
80*35238bceSAndroid Build Coastguard Worker         }
81*35238bceSAndroid Build Coastguard Worker     }
82*35238bceSAndroid Build Coastguard Worker     catch (...)
83*35238bceSAndroid Build Coastguard Worker     {
84*35238bceSAndroid Build Coastguard Worker         delete m_packageCtx;
85*35238bceSAndroid Build Coastguard Worker         m_packageCtx = DE_NULL;
86*35238bceSAndroid Build Coastguard Worker 
87*35238bceSAndroid Build Coastguard Worker         throw;
88*35238bceSAndroid Build Coastguard Worker     }
89*35238bceSAndroid Build Coastguard Worker }
90*35238bceSAndroid Build Coastguard Worker 
deinit(void)91*35238bceSAndroid Build Coastguard Worker void TestPackage::deinit(void)
92*35238bceSAndroid Build Coastguard Worker {
93*35238bceSAndroid Build Coastguard Worker     tcu::TestNode::deinit();
94*35238bceSAndroid Build Coastguard Worker     delete m_packageCtx;
95*35238bceSAndroid Build Coastguard Worker     m_packageCtx = DE_NULL;
96*35238bceSAndroid Build Coastguard Worker }
97*35238bceSAndroid Build Coastguard Worker 
98*35238bceSAndroid Build Coastguard Worker } // namespace deqp
99