1 /*-------------------------------------------------------------------------
2 * OpenGL Conformance Test Suite
3 * -----------------------------
5 * Copyright (c) 2017 The Khronos Group Inc.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 * \file glcExtensionsExposeTests.cpp
21 * \brief Test that check if specified substring is not in extension name.
22 */ /*--------------------------------------------------------------------*/
24 #include "glcExposedExtensionsTests.hpp"
25 #include "gluContextInfo.hpp"
26 #include "gluDefs.hpp"
27 #include "glwEnums.hpp"
28 #include "glwFunctions.hpp"
29 #include "tcuCommandLine.hpp"
30 #include "tcuTestLog.hpp"
39 class ExposedExtensionsTest : public deqp::TestCase
43 ExposedExtensionsTest(deqp::Context& context, std::string notAllowedSubstring,
44 const std::vector<std::string>* allowedExceptions = NULL);
46 virtual ~ExposedExtensionsTest(void);
50 tcu::TestNode::IterateResult iterate(void);
54 std::string m_notAllowedSubstring;
55 std::vector<std::string> m_allowedExceptions;
60 * @param context Rendering context
61 * @param name Test name
62 * @param description Test description
63 * @param notAllowedSubstring Substring that should not be found in extension name.
64 * @param allowedExceptions List of exceptions that are allowed even despite
65 * containing notAllowedFraze.
67 ExposedExtensionsTest::ExposedExtensionsTest(deqp::Context& context, std::string notAllowedSubstring,
68 const std::vector<std::string>* allowedExceptions)
69 : deqp::TestCase(context, "validate_extensions", "Test verifies if extensions with "
70 "specified phrase are not exposed.")
71 , m_notAllowedSubstring(notAllowedSubstring)
73 if (allowedExceptions)
75 m_allowedExceptions = *allowedExceptions;
79 ExposedExtensionsTest::~ExposedExtensionsTest(void)
83 /** Tears down any GL objects set up to run the test. */
84 void ExposedExtensionsTest::deinit(void)
88 /** Stub init method */
89 void ExposedExtensionsTest::init(void)
93 /** Executes test iteration.
95 * @return Returns STOP when test has finished executing, CONTINUE if more iterations are needed.
97 tcu::TestNode::IterateResult ExposedExtensionsTest::iterate(void)
99 typedef std::vector<std::string> string_vector;
100 const string_vector& extensions = m_context.getContextInfo().getExtensions();
101 string_vector::const_iterator currExtension = extensions.begin();
102 bool allExceptionsAreValid = true;
104 while (currExtension != extensions.end())
106 // If the current extension does not contain not allowed substring then continue
107 if (currExtension->find(m_notAllowedSubstring) == std::string::npos)
113 // Check if current extension is one of allowed exceptions
114 bool currExtensionIsNotAnException = true;
115 string_vector::const_iterator exception = m_allowedExceptions.begin();
116 while (exception != m_allowedExceptions.end())
118 if ((*exception).compare(*currExtension) == 0)
120 currExtensionIsNotAnException = false;
126 // Current exception is not on allowed exceptions list, test will fail
127 // but other exceptions will be checked to log all not allowed extensions
128 if (currExtensionIsNotAnException)
130 m_testCtx.getLog() << tcu::TestLog::Message << "Implementations should not expose " << *currExtension
131 << tcu::TestLog::EndMessage;
132 allExceptionsAreValid = false;
138 if (allExceptionsAreValid)
140 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
144 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
148 ExposedExtensionsTests::ExposedExtensionsTests(deqp::Context& context)
149 : TestCaseGroup(context, "exposed_extensions", "Verifies exposed extensions")
153 void ExposedExtensionsTests::init(void)
155 if (isContextTypeES(m_context.getRenderContext().getType()))
157 addChild(new ExposedExtensionsTest(m_context, "ARB"));
161 std::vector<std::string> allowedExtensions(1, "GL_OES_EGL_image");
162 addChild(new glcts::ExposedExtensionsTest(getContext(), "OES", &allowedExtensions));
166 } /* glcts namespace */