xref: /aosp_15_r20/external/deqp/external/openglcts/modules/common/glcNoErrorTests.cpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1 /*-------------------------------------------------------------------------
2  * OpenGL Conformance Test Suite
3  * -----------------------------
4  *
5  * Copyright (c) 2017 The Khronos Group Inc.
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
22  */ /*-------------------------------------------------------------------*/
23 
24 /**
25  */ /*!
26  * \file  glcNoErrorTests.cpp
27  * \brief Conformance tests for the GL_KHR_no_error functionality.
28  */ /*--------------------------------------------------------------------*/
29 
30 #include "glcNoErrorTests.hpp"
31 #include "gluContextInfo.hpp"
32 #include "gluDefs.hpp"
33 #include "glwEnums.hpp"
34 #include "glwFunctions.hpp"
35 #include "tcuCommandLine.hpp"
36 #include "tcuTestLog.hpp"
37 
38 using namespace glu;
39 
40 namespace glcts
41 {
42 
43 /** Constructor.
44  *
45  *  @param context     Rendering context
46  *  @param name        Test name
47  *  @param description Test description
48  *  @param apiType     API version
49  */
NoErrorContextTest(tcu::TestContext & testCtx,glu::ApiType apiType)50 NoErrorContextTest::NoErrorContextTest(tcu::TestContext &testCtx, glu::ApiType apiType)
51     : tcu::TestCase(testCtx, "create_context",
52                     "Test verifies if it is possible to create context with "
53                     "CONTEXT_FLAG_NO_ERROR_BIT_KHR flag set in CONTEXT_FLAGS")
54     , m_ApiType(apiType)
55 {
56     /* Left blank intentionally */
57 }
58 
59 /** Tears down any GL objects set up to run the test. */
deinit(void)60 void NoErrorContextTest::deinit(void)
61 {
62 }
63 
64 /** Stub init method */
init(void)65 void NoErrorContextTest::init(void)
66 {
67 }
68 
69 /** Veriffy if no error context can be successfully created.
70  * @return True when no error context was successfully created.
71  */
verifyNoErrorContext(void)72 bool NoErrorContextTest::verifyNoErrorContext(void)
73 {
74     RenderConfig renderCfg(glu::ContextType(m_ApiType, glu::CONTEXT_NO_ERROR));
75 
76     const tcu::CommandLine &commandLine = m_testCtx.getCommandLine();
77     glu::parseRenderConfig(&renderCfg, commandLine);
78 
79     if (commandLine.getSurfaceType() != tcu::SURFACETYPE_WINDOW)
80         throw tcu::NotSupportedError("Test not supported in non-windowed context");
81 
82     RenderContext *noErrorContext = createRenderContext(m_testCtx.getPlatform(), commandLine, renderCfg);
83     bool contextCreated           = (noErrorContext != NULL);
84     delete noErrorContext;
85 
86     return contextCreated;
87 }
88 
89 /** Executes test iteration.
90  *
91  *  @return Returns STOP when test has finished executing, CONTINUE if more iterations are needed.
92  */
iterate(void)93 tcu::TestNode::IterateResult NoErrorContextTest::iterate(void)
94 {
95     {
96         glu::ContextType contextType(m_ApiType);
97         deqp::Context context(m_testCtx, contextType);
98 
99         bool noErrorExtensionExists = glu::contextSupports(contextType, glu::ApiType::core(4, 6));
100         noErrorExtensionExists |= context.getContextInfo().isExtensionSupported("GL_KHR_no_error");
101 
102         if (!noErrorExtensionExists)
103         {
104             m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "GL_KHR_no_error extension not supported");
105             return STOP;
106         }
107     } // at this point intermediate context used to query the GL_KHR_no_error extension should be destroyed
108 
109     if (verifyNoErrorContext())
110     {
111         m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
112         return STOP;
113     }
114 
115     m_testCtx.getLog() << tcu::TestLog::Message << "Failed to create No Error context" << tcu::TestLog::EndMessage;
116     m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
117     return STOP;
118 }
119 
120 /** Constructor.
121  *
122  *  @param context Rendering context.
123  */
NoErrorTests(tcu::TestContext & testCtx,glu::ApiType apiType)124 NoErrorTests::NoErrorTests(tcu::TestContext &testCtx, glu::ApiType apiType)
125     : tcu::TestCaseGroup(testCtx, "no_error", "Verify conformance of GL_KHR_no_error implementation")
126     , m_ApiType(apiType)
127 {
128 }
129 
130 /** Initializes the test group contents. */
init(void)131 void NoErrorTests::init(void)
132 {
133     addChild(new NoErrorContextTest(m_testCtx, m_ApiType));
134 }
135 } // namespace glcts
136