1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program EGL Module
3 * ---------------------------------------
5 * Copyright 2014 The Android Open Source Project
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.
21 * \brief EGL_EXT_client_extensions tests
22 *//*--------------------------------------------------------------------*/
24 #include "teglClientExtensionTests.hpp"
26 #include "tcuTestLog.hpp"
28 #include "egluUtil.hpp"
30 #include "eglwLibrary.hpp"
31 #include "eglwEnums.hpp"
33 #include "deStringUtil.hpp"
34 #include "deSTLUtil.hpp"
56 static const char* const s_displayExtensionList[] =
58 "EGL_KHR_config_attribs",
59 "EGL_KHR_lock_surface",
61 "EGL_KHR_vg_parent_image",
62 "EGL_KHR_gl_texture_2D_image",
63 "EGL_KHR_gl_texture_cubemap_image",
64 "EGL_KHR_gl_texture_3D_image",
65 "EGL_KHR_gl_renderbuffer_image",
66 "EGL_KHR_reusable_sync",
68 "EGL_KHR_image_pixmap",
69 "EGL_IMG_context_priority",
70 "EGL_KHR_lock_surface2",
71 "EGL_NV_coverage_sample",
72 "EGL_NV_depth_nonlinear",
75 "EGL_HI_clientpixmap",
76 "EGL_HI_colorformats",
78 "EGL_NV_post_sub_buffer",
79 "EGL_ANGLE_query_surface_pointer",
80 "EGL_ANGLE_surface_d3d_texture_2d_share_handle",
81 "EGL_NV_coverage_sample_resolve",
82 // "EGL_NV_system_time", \todo [mika] Unclear which one this is
84 "EGL_KHR_stream_consumer_gltexture",
85 "EGL_KHR_stream_producer_eglsurface",
86 "EGL_KHR_stream_producer_aldatalocator",
87 "EGL_KHR_stream_fifo",
88 "EGL_EXT_create_context_robustness",
89 "EGL_ANGLE_d3d_share_handle_client_buffer",
90 "EGL_KHR_create_context",
91 "EGL_KHR_surfaceless_context",
92 "EGL_KHR_stream_cross_process_fd",
93 "EGL_EXT_multiview_window",
95 "EGL_NV_post_convert_rounding",
96 "EGL_NV_native_query",
97 "EGL_NV_3dvision_surface",
98 "EGL_ANDROID_framebuffer_target",
99 "EGL_ANDROID_blob_cache",
100 "EGL_ANDROID_image_native_buffer",
101 "EGL_ANDROID_native_fence_sync",
102 "EGL_ANDROID_recordable",
103 "EGL_EXT_buffer_age",
104 "EGL_EXT_image_dma_buf_import",
105 "EGL_ARM_pixmap_multisample_discard",
106 "EGL_EXT_swap_buffers_with_damage",
107 "EGL_NV_stream_sync",
109 "EGL_KHR_get_all_proc_addresses"
112 static const char* const s_clientExtensionList[] =
114 "EGL_EXT_platform_base",
115 "EGL_EXT_client_extensions",
116 "EGL_EXT_platform_x11",
117 "EGL_KHR_client_get_all_proc_addresses",
118 "EGL_MESA_platform_gbm",
119 "EGL_EXT_platform_wayland"
122 class BaseTest : public TestCase
125 BaseTest (EglTestContext& eglTestCtx);
126 IterateResult iterate (void);
129 BaseTest::BaseTest (EglTestContext& eglTestCtx)
130 : TestCase(eglTestCtx, "base", "Basic tests for EGL_EXT_client_extensions")
134 TestCase::IterateResult BaseTest::iterate (void)
136 const Library& egl = m_eglTestCtx.getLibrary();
137 const char* const clientExtesionsStr = egl.queryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
138 const EGLint eglError = egl.getError();
140 if (eglError == EGL_BAD_DISPLAY)
141 TCU_THROW(NotSupportedError, "EGL_EXT_client_extensions not supported");
142 else if (eglError != EGL_SUCCESS)
143 throw eglu::Error(eglError, "eglQueryString()", DE_NULL, __FILE__, __LINE__);
145 TCU_CHECK(clientExtesionsStr);
149 std::istringstream stream (clientExtesionsStr);
152 while (std::getline(stream, extension, ' '))
154 if (extension == "EGL_EXT_client_extensions")
162 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
165 m_testCtx.getLog() << TestLog::Message << "eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS) didn't fail, but extension string doesn't contain EGL_EXT_client_extensions" <<TestLog::EndMessage;
166 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
173 class CheckExtensionsTest : public TestCase
176 CheckExtensionsTest (EglTestContext& eglTestCtx);
177 IterateResult iterate (void);
180 CheckExtensionsTest::CheckExtensionsTest (EglTestContext& eglTestCtx)
181 : TestCase(eglTestCtx, "extensions", "Check that returned extensions are client or display extensions")
185 TestCase::IterateResult CheckExtensionsTest::iterate (void)
187 const Library& egl = m_eglTestCtx.getLibrary();
189 const char* const clientExtensionsStr = egl.queryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
190 const EGLint eglQueryError = egl.getError();
192 set<string> knownClientExtensions (s_clientExtensionList, s_clientExtensionList + DE_LENGTH_OF_ARRAY(s_clientExtensionList));
193 set<string> knownDisplayExtensions (s_displayExtensionList, s_displayExtensionList + DE_LENGTH_OF_ARRAY(s_displayExtensionList));
195 vector<string> displayExtensions;
196 vector<string> clientExtensions;
198 if (eglQueryError == EGL_BAD_DISPLAY)
199 TCU_THROW(NotSupportedError, "EGL_EXT_client_extensions not supported");
200 else if (eglQueryError != EGL_SUCCESS)
201 throw eglu::Error(eglQueryError, "eglQueryString()", DE_NULL, __FILE__, __LINE__);
203 TCU_CHECK(clientExtensionsStr);
205 clientExtensions = de::splitString(clientExtensionsStr, ' ');
208 EGLDisplay display = eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay());
210 displayExtensions = de::splitString(egl.queryString(display, EGL_EXTENSIONS), ' ');
212 egl.terminate(display);
215 for (int extNdx = 0; extNdx < (int)clientExtensions.size(); extNdx++)
217 if (knownDisplayExtensions.find(clientExtensions[extNdx]) != knownDisplayExtensions.end())
219 m_testCtx.getLog() << TestLog::Message << "'" << clientExtensions[extNdx] << "' is not client extension" << TestLog::EndMessage;
224 for (int extNdx = 0; extNdx < (int)displayExtensions.size(); extNdx++)
226 if (knownClientExtensions.find(displayExtensions[extNdx]) != knownClientExtensions.end())
228 m_testCtx.getLog() << TestLog::Message << "'" << displayExtensions[extNdx] << "' is not display extension" << TestLog::EndMessage;
234 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
236 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
241 class DisjointTest : public TestCase
244 DisjointTest (EglTestContext& eglTestCtx);
245 IterateResult iterate (void);
248 DisjointTest::DisjointTest (EglTestContext& eglTestCtx)
249 : TestCase(eglTestCtx, "disjoint", "Check that client and display extensions are disjoint")
253 TestCase::IterateResult DisjointTest::iterate (void)
255 const Library& egl = m_eglTestCtx.getLibrary();
256 const char* const clientExtensionsStr = egl.queryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
257 const EGLint eglQueryError = egl.getError();
259 if (eglQueryError == EGL_BAD_DISPLAY)
260 TCU_THROW(NotSupportedError, "EGL_EXT_client_extensions not supported");
261 else if (eglQueryError != EGL_SUCCESS)
262 throw eglu::Error(eglQueryError, "eglQueryString()", DE_NULL, __FILE__, __LINE__);
264 vector<string> displayExtensions;
265 vector<string> clientExtensions;
267 clientExtensions = de::splitString(clientExtensionsStr, ' ');
270 EGLDisplay display = eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay());
272 displayExtensions = de::splitString(egl.queryString(display, EGL_EXTENSIONS), ' ');
274 egl.terminate(display);
277 // Log client extensions
279 const tcu::ScopedLogSection section(m_testCtx.getLog(), "Client extensions", "Client extensions");
281 for (int extNdx = 0; extNdx < (int)clientExtensions.size(); extNdx++)
282 m_testCtx.getLog() << TestLog::Message << clientExtensions[extNdx] << TestLog::EndMessage;
285 // Log display extensions
287 const tcu::ScopedLogSection section(m_testCtx.getLog(), "Display extensions", "Display extensions");
289 for (int extNdx = 0; extNdx < (int)displayExtensions.size(); extNdx++)
290 m_testCtx.getLog() << TestLog::Message << displayExtensions[extNdx] << TestLog::EndMessage;
293 // Check that sets are disjoint
295 set<string> commonExtensionSet;
296 const set<string> clientExtensionSet(clientExtensions.begin(), clientExtensions.end());
297 const set<string> displayExtensionSet(displayExtensions.begin(), displayExtensions.end());
299 for (set<string>::const_iterator iter = clientExtensionSet.begin(); iter != clientExtensionSet.end(); ++iter)
301 if (displayExtensionSet.find(*iter) != displayExtensionSet.end())
302 commonExtensionSet.insert(*iter);
305 for (set<string>::const_iterator iter = commonExtensionSet.begin(); iter != commonExtensionSet.end(); ++iter)
306 m_testCtx.getLog() << TestLog::Message << "Extension '" << *iter << "' exists in client and display extension sets." << TestLog::EndMessage;
308 if (commonExtensionSet.empty())
309 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
312 m_testCtx.getLog() << TestLog::Message << "Extension sets are not disjoint" << TestLog::EndMessage;
313 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
322 ClientExtensionTests::ClientExtensionTests (EglTestContext& eglTestCtx)
323 : TestCaseGroup(eglTestCtx, "client_extensions", "Test for EGL_EXT_client_extensions")
327 void ClientExtensionTests::init (void)
329 addChild(new BaseTest(m_eglTestCtx));
330 addChild(new DisjointTest(m_eglTestCtx));
331 addChild(new CheckExtensionsTest(m_eglTestCtx));