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