1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program EGL Module
3 * ---------------------------------------
4 *
5 * Copyright 2014 The Android Open Source Project
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 Negative API Tests.
22 *//*--------------------------------------------------------------------*/
23
24 #include "teglNegativeApiTests.hpp"
25 #include "teglApiCase.hpp"
26
27 #include "egluNativeDisplay.hpp"
28 #include "egluNativeWindow.hpp"
29 #include "egluUtil.hpp"
30 #include "egluUtil.hpp"
31 #include "egluUnique.hpp"
32
33 #include "eglwLibrary.hpp"
34
35 #include <memory>
36
37 using tcu::TestLog;
38
39 namespace deqp
40 {
41 namespace egl
42 {
43
44 using namespace eglw;
45
46 template <deUint32 Type>
renderable(const eglu::CandidateConfig & c)47 static bool renderable (const eglu::CandidateConfig& c)
48 {
49 return (c.renderableType() & Type) == Type;
50 }
51
52 template <deUint32 Type>
notRenderable(const eglu::CandidateConfig & c)53 static bool notRenderable (const eglu::CandidateConfig& c)
54 {
55 return (c.renderableType() & Type) == 0;
56 }
57
58 template <deUint32 Bits>
surfaceBits(const eglu::CandidateConfig & c)59 static bool surfaceBits (const eglu::CandidateConfig& c)
60 {
61 return (c.surfaceType() & Bits) == Bits;
62 }
63
64 template <deUint32 Bits>
notSurfaceBits(const eglu::CandidateConfig & c)65 static bool notSurfaceBits (const eglu::CandidateConfig& c)
66 {
67 return (c.surfaceType() & Bits) == 0;
68 }
69
NegativeApiTests(EglTestContext & eglTestCtx)70 NegativeApiTests::NegativeApiTests (EglTestContext& eglTestCtx)
71 : TestCaseGroup(eglTestCtx, "negative_api", "Negative API Tests")
72 {
73 }
74
~NegativeApiTests(void)75 NegativeApiTests::~NegativeApiTests (void)
76 {
77 }
78
init(void)79 void NegativeApiTests::init (void)
80 {
81 // \todo [2012-10-02 pyry] Add tests for EGL_NOT_INITIALIZED to all functions taking in EGLDisplay
82 // \todo [2012-10-02 pyry] Implement negative cases for following non-trivial cases:
83 // * eglBindTexImage()
84 // - EGL_BAD_ACCESS is generated if buffer is already bound to a texture
85 // - EGL_BAD_MATCH is generated if the surface attribute EGL_TEXTURE_FORMAT is set to EGL_NO_TEXTURE
86 // - EGL_BAD_MATCH is generated if buffer is not a valid buffer (currently only EGL_BACK_BUFFER may be specified)
87 // - EGL_BAD_SURFACE is generated if surface is not a pbuffer surface supporting texture binding
88 // * eglCopyBuffers()
89 // - EGL_BAD_NATIVE_PIXMAP is generated if the implementation does not support native pixmaps
90 // - EGL_BAD_NATIVE_PIXMAP may be generated if native_pixmap is not a valid native pixmap
91 // - EGL_BAD_MATCH is generated if the format of native_pixmap is not compatible with the color buffer of surface
92 // * eglCreateContext()
93 // - EGL_BAD_MATCH is generated if the current rendering API is EGL_NONE
94 // - EGL_BAD_MATCH is generated if the server context state for share_context exists in an address space which cannot be shared with the newly created context
95 // - EGL_BAD_CONTEXT is generated if share_context is not an EGL rendering context of the same client API type as the newly created context and is not EGL_NO_CONTEXT
96 // * eglCreatePbufferFromClientBuffer()
97 // - various BAD_MATCH, BAD_ACCESS etc. conditions
98 // * eglCreatePbufferSurface()
99 // - EGL_BAD_MATCH is generated if the EGL_TEXTURE_FORMAT attribute is not EGL_NO_TEXTURE, and EGL_WIDTH and/or EGL_HEIGHT specify an invalid size
100 // * eglCreatePixmapSurface()
101 // - EGL_BAD_ATTRIBUTE is generated if attrib_list contains an invalid pixmap attribute
102 // - EGL_BAD_MATCH is generated if the attributes of native_pixmap do not correspond to config or if config does not support rendering to pixmaps
103 // - EGL_BAD_MATCH is generated if config does not support the specified OpenVG alpha format attribute or colorspace attribute
104 // * eglCreateWindowSurface()
105 // - EGL_BAD_ATTRIBUTE is generated if attrib_list contains an invalid window attribute
106 // - EGL_BAD_MATCH is generated if the attributes of native_window do not correspond to config or if config does not support rendering to windows
107 // - EGL_BAD_MATCH is generated if config does not support the specified OpenVG alpha format attribute or colorspace attribute
108 // * eglMakeCurrent()
109 // - EGL_BAD_MATCH is generated if draw or read are not compatible with context
110 // - EGL_BAD_MATCH is generated if context is set to EGL_NO_CONTEXT and draw or read are not set to EGL_NO_SURFACE
111 // - EGL_BAD_MATCH is generated if draw or read are set to EGL_NO_SURFACE and context is not set to EGL_NO_CONTEXT
112 // - EGL_BAD_ACCESS is generated if context is current to some other thread
113 // - EGL_BAD_NATIVE_PIXMAP may be generated if a native pixmap underlying either draw or read is no longer valid
114 // - EGL_BAD_NATIVE_WINDOW may be generated if a native window underlying either draw or read is no longer valid
115 // * eglReleaseTexImage()
116 // - EGL_BAD_MATCH is generated if buffer is not a valid buffer (currently only EGL_BACK_BUFFER may be specified)
117 // * eglSwapInterval()
118 // - EGL_BAD_SURFACE is generated if there is no surface bound to the current context
119 // * eglWaitNative()
120 // - EGL_BAD_CURRENT_SURFACE is generated if the surface associated with the current context has a native window or pixmap, and that window or pixmap is no longer valid
121
122 using namespace eglw;
123 using namespace eglu;
124
125 static const EGLint s_emptyAttribList[] = { EGL_NONE };
126 static const EGLint s_es1ContextAttribList[] = { EGL_CONTEXT_CLIENT_VERSION, 1, EGL_NONE };
127 static const EGLint s_es2ContextAttribList[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
128
129 static const EGLenum s_renderAPIs[] = { EGL_OPENGL_API, EGL_OPENGL_ES_API, EGL_OPENVG_API };
130
131 TEGL_ADD_API_CASE(bind_api, "eglBindAPI() negative tests",
132 {
133 TestLog& log = m_testCtx.getLog();
134 log << TestLog::Section("Test1", "EGL_BAD_PARAMETER is generated if api is not one of the accepted tokens");
135
136 expectFalse(eglBindAPI(0));
137 expectError(EGL_BAD_PARAMETER);
138
139 expectFalse(eglBindAPI(0xfdfdfdfd));
140 expectError(EGL_BAD_PARAMETER);
141
142 expectFalse(eglBindAPI((EGLenum)0xffffffff));
143 expectError(EGL_BAD_PARAMETER);
144
145 log << TestLog::EndSection;
146
147 log << TestLog::Section("Test2", "EGL_BAD_PARAMETER is generated if the specified client API is not supported by the EGL implementation");
148
149 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_renderAPIs); ndx++)
150 {
151 if (!isAPISupported(s_renderAPIs[ndx]))
152 {
153 expectFalse(eglBindAPI(s_renderAPIs[ndx]));
154 expectError(EGL_BAD_PARAMETER);
155 }
156 }
157
158 log << TestLog::EndSection;
159 });
160
161 TEGL_ADD_API_CASE(bind_tex_image, "eglBindTexImage() negative tests",
162 {
163 TestLog& log = m_testCtx.getLog();
164 EGLDisplay display = getDisplay();
165
166 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
167
168 expectFalse(eglBindTexImage(EGL_NO_DISPLAY, EGL_NO_SURFACE, EGL_BACK_BUFFER));
169 expectError(EGL_BAD_DISPLAY);
170
171 expectFalse(eglBindTexImage((EGLDisplay)-1, EGL_NO_SURFACE, EGL_BACK_BUFFER));
172 expectError(EGL_BAD_DISPLAY);
173
174 log << TestLog::EndSection;
175
176 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
177
178 expectFalse(eglBindTexImage(display, EGL_NO_SURFACE, EGL_BACK_BUFFER));
179 expectError(EGL_BAD_SURFACE);
180
181 expectFalse(eglBindTexImage(display, (EGLSurface)-1, EGL_BACK_BUFFER));
182 expectError(EGL_BAD_SURFACE);
183
184 log << TestLog::EndSection;
185 });
186
187 static const EGLint s_validGenericPbufferAttrib[] = { EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
188
189 TEGL_ADD_API_CASE(copy_buffers, "eglCopyBuffers() negative tests",
190 {
191 TestLog& log = m_testCtx.getLog();
192 const eglw::Library& egl = m_eglTestCtx.getLibrary();
193 EGLDisplay display = getDisplay();
194 const eglu::NativePixmapFactory& factory = eglu::selectNativePixmapFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
195 de::UniquePtr<eglu::NativePixmap> pixmap (factory.createPixmap(&m_eglTestCtx.getNativeDisplay(), 64, 64));
196 EGLConfig config;
197
198 {
199 if (getConfig(&config, FilterList() << surfaceBits<EGL_PBUFFER_BIT>))
200 {
201 eglu::UniqueSurface surface (egl, display, egl.createPbufferSurface(display, config, s_validGenericPbufferAttrib));
202
203 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
204
205 expectFalse(eglCopyBuffers(EGL_NO_DISPLAY, EGL_NO_SURFACE, pixmap->getLegacyNative()));
206 expectError(EGL_BAD_DISPLAY);
207
208 expectFalse(eglCopyBuffers((EGLDisplay)-1, EGL_NO_SURFACE, pixmap->getLegacyNative()));
209 expectError(EGL_BAD_DISPLAY);
210
211 log << TestLog::EndSection;
212 }
213 }
214
215 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
216
217 expectFalse(eglCopyBuffers(display, EGL_NO_SURFACE, pixmap->getLegacyNative()));
218 expectError(EGL_BAD_SURFACE);
219
220 expectFalse(eglCopyBuffers(display, (EGLSurface)-1, pixmap->getLegacyNative()));
221 expectError(EGL_BAD_SURFACE);
222
223 log << TestLog::EndSection;
224 });
225
226 static const EGLint s_invalidChooseConfigAttribList0[] = { 0, EGL_NONE };
227 static const EGLint s_invalidChooseConfigAttribList1[] = { (EGLint)0xffffffff };
228 static const EGLint s_invalidChooseConfigAttribList2[] = { EGL_BIND_TO_TEXTURE_RGB, 4, EGL_NONE };
229 static const EGLint s_invalidChooseConfigAttribList3[] = { EGL_BIND_TO_TEXTURE_RGBA, 5, EGL_NONE };
230 static const EGLint s_invalidChooseConfigAttribList4[] = { EGL_COLOR_BUFFER_TYPE, 0, EGL_NONE };
231 static const EGLint s_invalidChooseConfigAttribList5[] = { EGL_NATIVE_RENDERABLE, 6, EGL_NONE };
232 static const EGLint s_invalidChooseConfigAttribList6[] = { EGL_TRANSPARENT_TYPE, 6, EGL_NONE };
233 static const EGLint* s_invalidChooseConfigAttribLists[] =
234 {
235 &s_invalidChooseConfigAttribList0[0],
236 &s_invalidChooseConfigAttribList1[0],
237 &s_invalidChooseConfigAttribList2[0],
238 &s_invalidChooseConfigAttribList3[0],
239 &s_invalidChooseConfigAttribList4[0],
240 &s_invalidChooseConfigAttribList5[0],
241 &s_invalidChooseConfigAttribList6[0]
242 };
243
244 TEGL_ADD_API_CASE(choose_config, "eglChooseConfig() negative tests",
245 {
246 TestLog& log = m_testCtx.getLog();
247 EGLDisplay display = getDisplay();
248 EGLConfig configs[1];
249 EGLint numConfigs;
250
251 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
252
253 expectFalse(eglChooseConfig(EGL_NO_DISPLAY, s_emptyAttribList, &configs[0], DE_LENGTH_OF_ARRAY(configs), &numConfigs));
254 expectError(EGL_BAD_DISPLAY);
255
256 expectFalse(eglChooseConfig((EGLDisplay)-1, s_emptyAttribList, &configs[0], DE_LENGTH_OF_ARRAY(configs), &numConfigs));
257 expectError(EGL_BAD_DISPLAY);
258
259 log << TestLog::EndSection;
260
261 log << TestLog::Section("Test2", "EGL_BAD_ATTRIBUTE is generated if attribute_list contains an invalid frame buffer configuration attribute");
262
263 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_invalidChooseConfigAttribLists); ndx++)
264 {
265 expectFalse(eglChooseConfig(display, s_invalidChooseConfigAttribLists[ndx], &configs[0], DE_LENGTH_OF_ARRAY(configs), &numConfigs));
266 expectError(EGL_BAD_ATTRIBUTE);
267 }
268
269 log << TestLog::EndSection;
270
271 log << TestLog::Section("Test3", "EGL_BAD_PARAMETER is generated if num_config is NULL");
272
273 expectFalse(eglChooseConfig(display, s_emptyAttribList, &configs[0], DE_LENGTH_OF_ARRAY(configs), DE_NULL));
274 expectError(EGL_BAD_PARAMETER);
275
276 log << TestLog::EndSection;
277 });
278
279 static const EGLint s_invalidCreateContextAttribList0[] = { 0, EGL_NONE };
280 static const EGLint s_invalidCreateContextAttribList1[] = { (EGLint)0xffffffff };
281
282 TEGL_ADD_API_CASE(create_context, "eglCreateContext() negative tests",
283 {
284 TestLog& log = m_testCtx.getLog();
285 EGLDisplay display = getDisplay();
286
287 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
288
289 expectNoContext(eglCreateContext(EGL_NO_DISPLAY, DE_NULL, EGL_NO_CONTEXT, s_emptyAttribList));
290 expectError(EGL_BAD_DISPLAY);
291
292 expectNoContext(eglCreateContext((EGLDisplay)-1, DE_NULL, EGL_NO_CONTEXT, s_emptyAttribList));
293 expectError(EGL_BAD_DISPLAY);
294
295 log << TestLog::EndSection;
296
297 log << TestLog::Section("Test2", "EGL_BAD_CONFIG is generated if config is not an EGL frame buffer configuration");
298
299 expectNoContext(eglCreateContext(display, (EGLConfig)-1, EGL_NO_CONTEXT, s_emptyAttribList));
300 expectError(EGL_BAD_CONFIG);
301
302 log << TestLog::EndSection;
303
304 log << TestLog::Section("Test3", "EGL_BAD_CONFIG is generated if config does not support the current rendering API");
305
306 if (isAPISupported(EGL_OPENGL_API))
307 {
308 EGLConfig es1OnlyConfig;
309 if (getConfig(&es1OnlyConfig, FilterList() << renderable<EGL_OPENGL_ES_BIT> << notRenderable<EGL_OPENGL_BIT>))
310 {
311 expectTrue(eglBindAPI(EGL_OPENGL_API));
312 expectNoContext(eglCreateContext(display, es1OnlyConfig, EGL_NO_CONTEXT, s_es1ContextAttribList));
313 expectError(EGL_BAD_CONFIG);
314 }
315
316 EGLConfig es2OnlyConfig;
317 if (getConfig(&es2OnlyConfig, FilterList() << renderable<EGL_OPENGL_ES2_BIT> << notRenderable<EGL_OPENGL_BIT>))
318 {
319 expectTrue(eglBindAPI(EGL_OPENGL_API));
320 expectNoContext(eglCreateContext(display, es2OnlyConfig, EGL_NO_CONTEXT, s_es2ContextAttribList));
321 expectError(EGL_BAD_CONFIG);
322 }
323
324 EGLConfig vgOnlyConfig;
325 if (getConfig(&vgOnlyConfig, FilterList() << renderable<EGL_OPENVG_BIT> << notRenderable<EGL_OPENGL_BIT>))
326 {
327 expectTrue(eglBindAPI(EGL_OPENGL_API));
328 expectNoContext(eglCreateContext(display, vgOnlyConfig, EGL_NO_CONTEXT, s_emptyAttribList));
329 expectError(EGL_BAD_CONFIG);
330 }
331 }
332
333 if (isAPISupported(EGL_OPENGL_ES_API))
334 {
335 EGLConfig glOnlyConfig;
336 if (getConfig(&glOnlyConfig, FilterList() << renderable<EGL_OPENGL_BIT> << notRenderable<EGL_OPENGL_ES_BIT|EGL_OPENGL_ES2_BIT>))
337 {
338 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
339 expectNoContext(eglCreateContext(display, glOnlyConfig, EGL_NO_CONTEXT, s_emptyAttribList));
340 expectError(EGL_BAD_CONFIG);
341 }
342
343 EGLConfig vgOnlyConfig;
344 if (getConfig(&vgOnlyConfig, FilterList() << renderable<EGL_OPENVG_BIT> << notRenderable<EGL_OPENGL_ES_BIT|EGL_OPENGL_ES2_BIT>))
345 {
346 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
347 expectNoContext(eglCreateContext(display, vgOnlyConfig, EGL_NO_CONTEXT, s_emptyAttribList));
348 expectError(EGL_BAD_CONFIG);
349 }
350 }
351
352 if (isAPISupported(EGL_OPENVG_API))
353 {
354 EGLConfig glOnlyConfig;
355 if (getConfig(&glOnlyConfig, FilterList() << renderable<EGL_OPENGL_BIT> << notRenderable<EGL_OPENVG_BIT>))
356 {
357 expectTrue(eglBindAPI(EGL_OPENVG_API));
358 expectNoContext(eglCreateContext(display, glOnlyConfig, EGL_NO_CONTEXT, s_emptyAttribList));
359 expectError(EGL_BAD_CONFIG);
360 }
361
362 EGLConfig es1OnlyConfig;
363 if (getConfig(&es1OnlyConfig, FilterList() << renderable<EGL_OPENGL_ES_BIT> << notRenderable<EGL_OPENVG_BIT>))
364 {
365 expectTrue(eglBindAPI(EGL_OPENVG_API));
366 expectNoContext(eglCreateContext(display, es1OnlyConfig, EGL_NO_CONTEXT, s_es1ContextAttribList));
367 expectError(EGL_BAD_CONFIG);
368 }
369
370 EGLConfig es2OnlyConfig;
371 if (getConfig(&es2OnlyConfig, FilterList() << renderable<EGL_OPENGL_ES2_BIT> << notRenderable<EGL_OPENVG_BIT>))
372 {
373 expectTrue(eglBindAPI(EGL_OPENVG_API));
374 expectNoContext(eglCreateContext(display, es2OnlyConfig, EGL_NO_CONTEXT, s_es2ContextAttribList));
375 expectError(EGL_BAD_CONFIG);
376 }
377 }
378
379 log << TestLog::EndSection;
380
381 log << TestLog::Section("Test4", "EGL_BAD_CONFIG is generated if OpenGL ES 1.x context is requested and EGL_RENDERABLE_TYPE attribute of config does not contain EGL_OPENGL_ES_BIT");
382
383 if (isAPISupported(EGL_OPENGL_ES_API))
384 {
385 EGLConfig notES1Config;
386 if (getConfig(¬ES1Config, FilterList() << notRenderable<EGL_OPENGL_ES_BIT>))
387 {
388 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
389 expectNoContext(eglCreateContext(display, notES1Config, EGL_NO_CONTEXT, s_es1ContextAttribList));
390 expectError(EGL_BAD_CONFIG);
391 }
392 }
393
394 log << TestLog::EndSection;
395
396 log << TestLog::Section("Test5", "EGL_BAD_CONFIG is generated if OpenGL ES 2.x context is requested and EGL_RENDERABLE_TYPE attribute of config does not contain EGL_OPENGL_ES2_BIT");
397
398 if (isAPISupported(EGL_OPENGL_ES_API))
399 {
400 EGLConfig notES2Config;
401 if (getConfig(¬ES2Config, FilterList() << notRenderable<EGL_OPENGL_ES2_BIT>))
402 {
403 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
404 expectNoContext(eglCreateContext(display, notES2Config, EGL_NO_CONTEXT, s_es2ContextAttribList));
405 expectError(EGL_BAD_CONFIG);
406 }
407 }
408
409 log << TestLog::EndSection;
410
411 log << TestLog::Section("Test6", "EGL_BAD_ATTRIBUTE is generated if attrib_list contains an invalid context attribute");
412
413 if (isAPISupported(EGL_OPENGL_API) && !eglu::hasExtension(m_eglTestCtx.getLibrary(), display, "EGL_KHR_create_context"))
414 {
415 EGLConfig glConfig;
416 if (getConfig(&glConfig, FilterList() << renderable<EGL_OPENGL_BIT>))
417 {
418 expectTrue(eglBindAPI(EGL_OPENGL_API));
419 expectNoContext(eglCreateContext(display, glConfig, EGL_NO_CONTEXT, s_es1ContextAttribList));
420 expectError(EGL_BAD_ATTRIBUTE);
421 }
422 }
423
424 if (isAPISupported(EGL_OPENVG_API))
425 {
426 EGLConfig vgConfig;
427 if (getConfig(&vgConfig, FilterList() << renderable<EGL_OPENVG_BIT>))
428 {
429 expectTrue(eglBindAPI(EGL_OPENVG_API));
430 expectNoContext(eglCreateContext(display, vgConfig, EGL_NO_CONTEXT, s_es1ContextAttribList));
431 expectError(EGL_BAD_ATTRIBUTE);
432 }
433 }
434
435 if (isAPISupported(EGL_OPENGL_ES_API))
436 {
437 bool gotConfig = false;
438 EGLConfig esConfig;
439
440 gotConfig = getConfig(&esConfig, FilterList() << renderable<EGL_OPENGL_ES_BIT>) ||
441 getConfig(&esConfig, FilterList() << renderable<EGL_OPENGL_ES2_BIT>);
442
443 if (gotConfig)
444 {
445 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
446 expectNoContext(eglCreateContext(display, esConfig, EGL_NO_CONTEXT, s_invalidCreateContextAttribList0));
447 expectError(EGL_BAD_ATTRIBUTE);
448 expectNoContext(eglCreateContext(display, esConfig, EGL_NO_CONTEXT, s_invalidCreateContextAttribList1));
449 expectError(EGL_BAD_ATTRIBUTE);
450 }
451 }
452
453 log << TestLog::EndSection;
454 });
455
456 TEGL_ADD_API_CASE(create_pbuffer_from_client_buffer, "eglCreatePbufferFromClientBuffer() negative tests",
457 {
458 TestLog& log = m_testCtx.getLog();
459 EGLDisplay display = getDisplay();
460 EGLConfig anyConfig;
461 EGLint unused = 0;
462
463 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
464
465 expectNoSurface(eglCreatePbufferFromClientBuffer(EGL_NO_DISPLAY, EGL_OPENVG_IMAGE, 0, (EGLConfig)0, DE_NULL));
466 expectError(EGL_BAD_DISPLAY);
467
468 expectNoSurface(eglCreatePbufferFromClientBuffer((EGLDisplay)-1, EGL_OPENVG_IMAGE, 0, (EGLConfig)0, DE_NULL));
469 expectError(EGL_BAD_DISPLAY);
470
471 log << TestLog::EndSection;
472
473 if (isAPISupported(EGL_OPENVG_API))
474 {
475 log << TestLog::Section("Test2", "EGL_BAD_CONFIG or EGL_BAD_PARAMETER is generated if config is not an EGL frame buffer configuration and if buffer is not valid OpenVG image");
476
477 expectNoSurface(eglCreatePbufferFromClientBuffer(display, EGL_OPENVG_IMAGE, (EGLClientBuffer)-1, (EGLConfig)-1, DE_NULL));
478 expectEitherError(EGL_BAD_CONFIG, EGL_BAD_PARAMETER);
479
480 log << TestLog::EndSection;
481
482 log << TestLog::Section("Test3", "EGL_BAD_PARAMETER is generated if buftype is not EGL_OPENVG_IMAGE");
483
484 expectTrue(eglGetConfigs(display, &anyConfig, 1, &unused));
485
486 log << TestLog::EndSection;
487
488 log << TestLog::Section("Test4", "EGL_BAD_PARAMETER is generated if buffer is not valid OpenVG image");
489 expectNoSurface(eglCreatePbufferFromClientBuffer(display, EGL_OPENVG_IMAGE, (EGLClientBuffer)-1, anyConfig, DE_NULL));
490 expectError(EGL_BAD_PARAMETER);
491
492 log << TestLog::EndSection;
493 }
494 });
495
496 static const EGLint s_invalidGenericPbufferAttrib0[] = { 0, EGL_NONE };
497 static const EGLint s_invalidGenericPbufferAttrib1[] = { (EGLint)0xffffffff };
498 static const EGLint s_negativeWidthPbufferAttrib[] = { EGL_WIDTH, -1, EGL_HEIGHT, 64, EGL_NONE };
499 static const EGLint s_negativeHeightPbufferAttrib[] = { EGL_WIDTH, 64, EGL_HEIGHT, -1, EGL_NONE };
500 static const EGLint s_negativeWidthAndHeightPbufferAttrib[] = { EGL_WIDTH, -1, EGL_HEIGHT, -1, EGL_NONE };
501 static const EGLint* s_invalidGenericPbufferAttribs[] =
502 {
503 s_invalidGenericPbufferAttrib0,
504 s_invalidGenericPbufferAttrib1,
505 };
506
507 static const EGLint s_invalidNoEsPbufferAttrib0[] = { EGL_MIPMAP_TEXTURE, EGL_TRUE, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
508 static const EGLint s_invalidNoEsPbufferAttrib1[] = { EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGBA, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
509 static const EGLint s_invalidNoEsPbufferAttrib2[] = { EGL_TEXTURE_TARGET, EGL_TEXTURE_2D, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
510 static const EGLint* s_invalidNoEsPbufferAttribs[] =
511 {
512 s_invalidNoEsPbufferAttrib0,
513 s_invalidNoEsPbufferAttrib1,
514 s_invalidNoEsPbufferAttrib2
515 };
516
517 static const EGLint s_invalidEsPbufferAttrib0[] = { EGL_TEXTURE_FORMAT, EGL_NO_TEXTURE, EGL_TEXTURE_TARGET, EGL_TEXTURE_2D, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
518 static const EGLint s_invalidEsPbufferAttrib1[] = { EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGBA, EGL_TEXTURE_TARGET, EGL_NO_TEXTURE, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
519 static const EGLint* s_invalidEsPbufferAttribs[] =
520 {
521 s_invalidEsPbufferAttrib0,
522 s_invalidEsPbufferAttrib1
523 };
524
525 static const EGLint s_vgPreMultAlphaPbufferAttrib[] = { EGL_ALPHA_FORMAT, EGL_ALPHA_FORMAT_PRE, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
526 static const EGLint s_vgLinearColorspacePbufferAttrib[] = { EGL_COLORSPACE, EGL_VG_COLORSPACE_LINEAR, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
527
528 TEGL_ADD_API_CASE(create_pbuffer_surface, "eglCreatePbufferSurface() negative tests",
529 {
530 TestLog& log = m_testCtx.getLog();
531 EGLDisplay display = getDisplay();
532
533 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
534
535 expectNoSurface(eglCreatePbufferSurface(EGL_NO_DISPLAY, DE_NULL, s_emptyAttribList));
536 expectError(EGL_BAD_DISPLAY);
537
538 expectNoSurface(eglCreatePbufferSurface((EGLDisplay)-1, DE_NULL, s_emptyAttribList));
539 expectError(EGL_BAD_DISPLAY);
540
541 log << TestLog::EndSection;
542
543 log << TestLog::Section("Test2", "EGL_BAD_CONFIG is generated if config is not an EGL frame buffer configuration");
544
545 expectNoSurface(eglCreatePbufferSurface(display, (EGLConfig)-1, s_emptyAttribList));
546 expectError(EGL_BAD_CONFIG);
547
548 log << TestLog::EndSection;
549
550 log << TestLog::Section("Test3", "EGL_BAD_ATTRIBUTE is generated if attrib_list contains an invalid pixel buffer attribute");
551
552 // Generic pbuffer-capable config
553 EGLConfig genericConfig;
554 if (getConfig(&genericConfig, FilterList() << surfaceBits<EGL_PBUFFER_BIT>))
555 {
556 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_invalidGenericPbufferAttribs); ndx++)
557 {
558 expectNoSurface(eglCreatePbufferSurface(display, genericConfig, s_invalidGenericPbufferAttribs[ndx]));
559 expectError(EGL_BAD_ATTRIBUTE);
560 }
561 }
562
563 log << TestLog::EndSection;
564
565 log << TestLog::Section("Test4", "EGL_BAD_MATCH is generated if config does not support rendering to pixel buffers");
566
567 EGLConfig noPbufferConfig;
568 if (getConfig(&noPbufferConfig, FilterList() << notSurfaceBits<EGL_PBUFFER_BIT>))
569 {
570 expectNoSurface(eglCreatePbufferSurface(display, noPbufferConfig, s_validGenericPbufferAttrib));
571 expectError(EGL_BAD_MATCH);
572 }
573
574 log << TestLog::EndSection;
575
576 log << TestLog::Section("Test5", "EGL_BAD_ATTRIBUTE is generated if attrib_list contains any of the attributes EGL_MIPMAP_TEXTURE, EGL_TEXTURE_FORMAT, or EGL_TEXTURE_TARGET, and config does not support OpenGL ES rendering");
577
578 EGLConfig noEsConfig;
579 if (getConfig(&noEsConfig, FilterList() << notRenderable<EGL_OPENGL_ES_BIT|EGL_OPENGL_ES2_BIT>))
580 {
581 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_invalidNoEsPbufferAttribs); ndx++)
582 {
583 expectNoSurface(eglCreatePbufferSurface(display, noEsConfig, s_invalidNoEsPbufferAttribs[ndx]));
584 expectError(EGL_BAD_MATCH);
585 }
586 }
587
588 log << TestLog::EndSection;
589
590 log << TestLog::Section("Test6", "EGL_BAD_MATCH is generated if the EGL_TEXTURE_FORMAT attribute is EGL_NO_TEXTURE, and EGL_TEXTURE_TARGET is something other than EGL_NO_TEXTURE; or, EGL_TEXTURE_FORMAT is something other than EGL_NO_TEXTURE, and EGL_TEXTURE_TARGET is EGL_NO_TEXTURE");
591
592 // ES1 or ES2 config.
593 EGLConfig esConfig;
594 bool gotEsConfig = getConfig(&esConfig, FilterList() << renderable<EGL_OPENGL_ES_BIT>) ||
595 getConfig(&esConfig, FilterList() << renderable<EGL_OPENGL_ES2_BIT>);
596 if (gotEsConfig)
597 {
598 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_invalidEsPbufferAttribs); ndx++)
599 {
600 expectNoSurface(eglCreatePbufferSurface(display, esConfig, s_invalidEsPbufferAttribs[ndx]));
601 expectError(EGL_BAD_MATCH);
602 }
603 }
604
605 log << TestLog::EndSection;
606
607 log << TestLog::Section("Test7", "EGL_BAD_MATCH is generated if config does not support the specified OpenVG alpha format attribute or colorspace attribute");
608
609 EGLConfig vgNoPreConfig;
610 if (getConfig(&vgNoPreConfig, FilterList() << renderable<EGL_OPENVG_BIT> << notSurfaceBits<EGL_VG_ALPHA_FORMAT_PRE_BIT>))
611 {
612 expectNoSurface(eglCreatePbufferSurface(display, vgNoPreConfig, s_vgPreMultAlphaPbufferAttrib));
613 expectError(EGL_BAD_MATCH);
614 }
615
616 EGLConfig vgNoLinearConfig;
617 if (getConfig(&vgNoLinearConfig, FilterList() << renderable<EGL_OPENVG_BIT> << notSurfaceBits<EGL_VG_COLORSPACE_LINEAR_BIT>))
618 {
619 expectNoSurface(eglCreatePbufferSurface(display, vgNoLinearConfig, s_vgLinearColorspacePbufferAttrib));
620 expectError(EGL_BAD_MATCH);
621 }
622
623 log << TestLog::EndSection;
624
625 log << TestLog::Section("Test8", "EGL_BAD_PARAMETER is generated if EGL_WIDTH or EGL_HEIGHT is negative");
626
627 if (getConfig(&genericConfig, FilterList() << surfaceBits<EGL_PBUFFER_BIT>))
628 {
629 expectNoSurface(eglCreatePbufferSurface(display, genericConfig, s_negativeWidthPbufferAttrib));
630 expectError(EGL_BAD_PARAMETER);
631
632 expectNoSurface(eglCreatePbufferSurface(display, genericConfig, s_negativeHeightPbufferAttrib));
633 expectError(EGL_BAD_PARAMETER);
634
635 expectNoSurface(eglCreatePbufferSurface(display, genericConfig, s_negativeWidthAndHeightPbufferAttrib));
636 expectError(EGL_BAD_PARAMETER);
637 }
638
639 log << TestLog::EndSection;
640
641 });
642
643 TEGL_ADD_API_CASE(create_pixmap_surface, "eglCreatePixmapSurface() negative tests",
644 {
645 TestLog& log = m_testCtx.getLog();
646 EGLDisplay display = getDisplay();
647
648 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
649
650 expectNoSurface(eglCreatePixmapSurface(EGL_NO_DISPLAY, DE_NULL, DE_NULL, s_emptyAttribList));
651 expectError(EGL_BAD_DISPLAY);
652
653 expectNoSurface(eglCreatePixmapSurface((EGLDisplay)-1, DE_NULL, DE_NULL, s_emptyAttribList));
654 expectError(EGL_BAD_DISPLAY);
655
656 log << TestLog::EndSection;
657
658 log << TestLog::Section("Test2", "EGL_BAD_CONFIG is generated if config is not an EGL frame buffer configuration");
659
660 expectNoSurface(eglCreatePixmapSurface(display, (EGLConfig)-1, DE_NULL, s_emptyAttribList));
661 expectError(EGL_BAD_CONFIG);
662
663 log << TestLog::EndSection;
664 });
665
666 TEGL_ADD_API_CASE(create_window_surface, "eglCreateWindowSurface() negative tests",
667 {
668 EGLConfig config = DE_NULL;
669 bool gotConfig = getConfig(&config, FilterList() << renderable<EGL_OPENGL_ES2_BIT> << surfaceBits<EGL_WINDOW_BIT>);
670
671 if (gotConfig)
672 {
673 TestLog& log = m_testCtx.getLog();
674 EGLDisplay display = getDisplay();
675 const eglu::NativeWindowFactory& factory = eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
676 de::UniquePtr<eglu::NativeWindow> window (factory.createWindow(&m_eglTestCtx.getNativeDisplay(), display, config, DE_NULL, eglu::WindowParams(256, 256, eglu::parseWindowVisibility(m_testCtx.getCommandLine()))));
677
678 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
679
680 expectNoSurface(eglCreateWindowSurface(EGL_NO_DISPLAY, config, window->getLegacyNative(), s_emptyAttribList));
681 expectError(EGL_BAD_DISPLAY);
682
683 expectNoSurface(eglCreateWindowSurface((EGLDisplay)-1, config, window->getLegacyNative(), s_emptyAttribList));
684 expectError(EGL_BAD_DISPLAY);
685
686 log << TestLog::EndSection;
687 }
688 });
689
690 TEGL_ADD_API_CASE(destroy_context, "eglDestroyContext() negative tests",
691 {
692 TestLog& log = m_testCtx.getLog();
693 EGLDisplay display = getDisplay();
694
695 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
696
697 expectFalse(eglDestroyContext(EGL_NO_DISPLAY, DE_NULL));
698 expectError(EGL_BAD_DISPLAY);
699
700 expectFalse(eglDestroyContext((EGLDisplay)-1, DE_NULL));
701 expectError(EGL_BAD_DISPLAY);
702
703 log << TestLog::EndSection;
704
705 log << TestLog::Section("Test2", "EGL_BAD_CONTEXT is generated if context is not an EGL rendering context");
706
707 expectFalse(eglDestroyContext(display, DE_NULL));
708 expectError(EGL_BAD_CONTEXT);
709
710 expectFalse(eglDestroyContext(display, (EGLContext)-1));
711 expectError(EGL_BAD_CONTEXT);
712
713 log << TestLog::EndSection;
714 });
715
716 TEGL_ADD_API_CASE(destroy_surface, "eglDestroySurface() negative tests",
717 {
718 TestLog& log = m_testCtx.getLog();
719 EGLDisplay display = getDisplay();
720
721 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
722
723 expectFalse(eglDestroySurface(EGL_NO_DISPLAY, DE_NULL));
724 expectError(EGL_BAD_DISPLAY);
725
726 expectFalse(eglDestroySurface((EGLDisplay)-1, DE_NULL));
727 expectError(EGL_BAD_DISPLAY);
728
729 log << TestLog::EndSection;
730
731 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
732
733 expectFalse(eglDestroySurface(display, DE_NULL));
734 expectError(EGL_BAD_SURFACE);
735
736 expectFalse(eglDestroySurface(display, (EGLSurface)-1));
737 expectError(EGL_BAD_SURFACE);
738
739 log << TestLog::EndSection;
740 });
741
742 TEGL_ADD_API_CASE(get_config_attrib, "eglGetConfigAttrib() negative tests",
743 {
744 TestLog& log = m_testCtx.getLog();
745 EGLDisplay display = getDisplay();
746 EGLint value = 0;
747
748 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
749
750 expectFalse(eglGetConfigAttrib(EGL_NO_DISPLAY, DE_NULL, EGL_RED_SIZE, &value));
751 expectError(EGL_BAD_DISPLAY);
752
753 expectFalse(eglGetConfigAttrib((EGLDisplay)-1, DE_NULL, EGL_RED_SIZE, &value));
754 expectError(EGL_BAD_DISPLAY);
755
756 log << TestLog::EndSection;
757
758 log << TestLog::Section("Test2", "EGL_BAD_CONFIG is generated if config is not an EGL frame buffer configuration");
759
760 expectFalse(eglGetConfigAttrib(display, (EGLConfig)-1, EGL_RED_SIZE, &value));
761 expectError(EGL_BAD_CONFIG);
762
763 log << TestLog::EndSection;
764
765 // Any config.
766 EGLConfig config = DE_NULL;
767 bool hasConfig = getConfig(&config, FilterList());
768
769 log << TestLog::Section("Test3", "EGL_BAD_ATTRIBUTE is generated if attribute is not a valid frame buffer configuration attribute");
770
771 if (hasConfig)
772 {
773 expectFalse(eglGetConfigAttrib(display, config, 0, &value));
774 expectError(EGL_BAD_ATTRIBUTE);
775
776 expectFalse(eglGetConfigAttrib(display, config, -1, &value));
777 expectError(EGL_BAD_ATTRIBUTE);
778 }
779
780 log << TestLog::EndSection;
781 });
782
783 TEGL_ADD_API_CASE(get_configs, "eglGetConfigs() negative tests",
784 {
785 TestLog& log = m_testCtx.getLog();
786 EGLDisplay display = getDisplay();
787 EGLConfig cfgs[1];
788 EGLint numCfgs = 0;
789
790 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
791
792 expectFalse(eglGetConfigs(EGL_NO_DISPLAY, &cfgs[0], DE_LENGTH_OF_ARRAY(cfgs), &numCfgs));
793 expectError(EGL_BAD_DISPLAY);
794
795 expectFalse(eglGetConfigs((EGLDisplay)-1, &cfgs[0], DE_LENGTH_OF_ARRAY(cfgs), &numCfgs));
796 expectError(EGL_BAD_DISPLAY);
797
798 log << TestLog::EndSection;
799
800 log << TestLog::Section("Test2", "EGL_BAD_PARAMETER is generated if num_config is NULL");
801
802 expectFalse(eglGetConfigs(display, &cfgs[0], DE_LENGTH_OF_ARRAY(cfgs), DE_NULL));
803 expectError(EGL_BAD_PARAMETER);
804
805 log << TestLog::EndSection;
806 });
807
808 TEGL_ADD_API_CASE(initialize, "eglInitialize() negative tests",
809 {
810 TestLog& log = m_testCtx.getLog();
811 EGLint major = 0;
812 EGLint minor = 0;
813
814 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
815
816 expectFalse(eglInitialize(EGL_NO_DISPLAY, &major, &minor));
817 expectError(EGL_BAD_DISPLAY);
818
819 expectFalse(eglInitialize((EGLDisplay)-1, &major, &minor));
820 expectError(EGL_BAD_DISPLAY);
821
822 log << TestLog::EndSection;
823 });
824
825 TEGL_ADD_API_CASE(make_current, "eglMakeCurrent() negative tests",
826 {
827 TestLog& log = m_testCtx.getLog();
828 EGLDisplay display = getDisplay();
829
830 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
831
832 expectFalse(eglMakeCurrent(EGL_NO_DISPLAY, DE_NULL, DE_NULL, DE_NULL));
833 expectError(EGL_BAD_DISPLAY);
834
835 expectFalse(eglMakeCurrent((EGLDisplay)-1, DE_NULL, DE_NULL, DE_NULL));
836 expectError(EGL_BAD_DISPLAY);
837
838 log << TestLog::EndSection;
839
840 // Create simple pbuffer surface.
841 EGLSurface surface = EGL_NO_SURFACE;
842 {
843 EGLConfig config;
844 if (getConfig(&config, FilterList() << surfaceBits<EGL_PBUFFER_BIT>))
845 {
846 surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
847 expectError(EGL_SUCCESS);
848 }
849 }
850
851 // Create simple ES2 context
852 EGLContext context = EGL_NO_CONTEXT;
853 {
854 EGLConfig config;
855 if (getConfig(&config, FilterList() << renderable<EGL_OPENGL_ES2_BIT>))
856 {
857 context = eglCreateContext(display, config, EGL_NO_CONTEXT, s_es2ContextAttribList);
858 expectError(EGL_SUCCESS);
859 }
860 }
861
862 if (surface != EGL_NO_SURFACE && context != EGL_NO_CONTEXT)
863 {
864 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
865
866 expectFalse(eglMakeCurrent(display, (EGLSurface)-1, (EGLSurface)-1, context));
867 expectError(EGL_BAD_SURFACE);
868
869 expectFalse(eglMakeCurrent(display, surface, (EGLSurface)-1, context));
870 expectError(EGL_BAD_SURFACE);
871
872 expectFalse(eglMakeCurrent(display, (EGLSurface)-1, surface, context));
873 expectError(EGL_BAD_SURFACE);
874
875 log << TestLog::EndSection;
876 }
877
878 if (surface)
879 {
880 log << TestLog::Section("Test3", "EGL_BAD_CONTEXT is generated if context is not an EGL rendering context");
881
882 expectFalse(eglMakeCurrent(display, surface, surface, (EGLContext)-1));
883 expectError(EGL_BAD_CONTEXT);
884
885 log << TestLog::EndSection;
886 }
887
888 if (surface != EGL_NO_SURFACE)
889 {
890 log << TestLog::Section("Test4", "EGL_BAD_MATCH is generated if read or draw surface is not EGL_NO_SURFACE and context is EGL_NO_CONTEXT");
891
892 expectFalse(eglMakeCurrent(display, surface, EGL_NO_SURFACE, EGL_NO_CONTEXT));
893 expectError(EGL_BAD_MATCH);
894
895 expectFalse(eglMakeCurrent(display, EGL_NO_SURFACE, surface, EGL_NO_CONTEXT));
896 expectError(EGL_BAD_MATCH);
897
898 expectFalse(eglMakeCurrent(display, surface, surface, EGL_NO_CONTEXT));
899 expectError(EGL_BAD_MATCH);
900
901 log << TestLog::EndSection;
902 }
903
904 if (context)
905 {
906 eglDestroyContext(display, context);
907 expectError(EGL_SUCCESS);
908 }
909
910 if (surface)
911 {
912 eglDestroySurface(display, surface);
913 expectError(EGL_SUCCESS);
914 }
915 });
916
917 TEGL_ADD_API_CASE(get_current_context, "eglGetCurrentContext() negative tests",
918 {
919 expectNoContext(eglGetCurrentContext());
920
921 if (isAPISupported(EGL_OPENGL_ES_API))
922 {
923 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
924 expectError(EGL_SUCCESS);
925
926 expectNoContext(eglGetCurrentContext());
927 expectError(EGL_SUCCESS);
928 }
929 });
930
931 TEGL_ADD_API_CASE(get_current_surface, "eglGetCurrentSurface() negative tests",
932 {
933 TestLog& log = m_testCtx.getLog();
934 EGLDisplay display = getDisplay();
935 EGLConfig config = DE_NULL;
936 EGLContext context = EGL_NO_CONTEXT;
937 EGLSurface surface = EGL_NO_SURFACE;
938 bool gotConfig = getConfig(&config, FilterList() << renderable<EGL_OPENGL_ES2_BIT> << surfaceBits<EGL_PBUFFER_BIT>);
939
940 if (gotConfig)
941 {
942 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
943 expectError(EGL_SUCCESS);
944
945 context = eglCreateContext(display, config, EGL_NO_CONTEXT, s_es2ContextAttribList);
946 expectError(EGL_SUCCESS);
947
948 // Create simple pbuffer surface.
949 surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
950 expectError(EGL_SUCCESS);
951
952 expectTrue(eglMakeCurrent(display, surface, surface, context));
953 expectError(EGL_SUCCESS);
954
955 log << TestLog::Section("Test1", "EGL_BAD_PARAMETER is generated if readdraw is neither EGL_READ nor EGL_DRAW");
956
957 expectNoSurface(eglGetCurrentSurface(EGL_NONE));
958 expectError(EGL_BAD_PARAMETER);
959
960 log << TestLog::EndSection;
961
962 expectTrue(eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
963 expectError(EGL_SUCCESS);
964
965 if (surface != EGL_NO_SURFACE)
966 {
967 expectTrue(eglDestroySurface(display, surface));
968 expectError(EGL_SUCCESS);
969 }
970
971 if (context != EGL_NO_CONTEXT)
972 {
973 expectTrue(eglDestroyContext(display, context));
974 expectError(EGL_SUCCESS);
975 }
976 }
977 });
978
979 TEGL_ADD_API_CASE(query_context, "eglQueryContext() negative tests",
980 {
981 TestLog& log = m_testCtx.getLog();
982 EGLDisplay display = getDisplay();
983 EGLint value = 0;
984
985 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
986
987 expectFalse(eglQueryContext(EGL_NO_DISPLAY, DE_NULL, EGL_CONFIG_ID, &value));
988 expectError(EGL_BAD_DISPLAY);
989
990 expectFalse(eglQueryContext((EGLDisplay)-1, DE_NULL, EGL_CONFIG_ID, &value));
991 expectError(EGL_BAD_DISPLAY);
992
993 log << TestLog::EndSection;
994
995 log << TestLog::Section("Test2", "EGL_BAD_CONTEXT is generated if context is not an EGL rendering context");
996
997 expectFalse(eglQueryContext(display, DE_NULL, EGL_CONFIG_ID, &value));
998 expectError(EGL_BAD_CONTEXT);
999
1000 expectFalse(eglQueryContext(display, DE_NULL, EGL_CONFIG_ID, &value));
1001 expectError(EGL_BAD_CONTEXT);
1002
1003 log << TestLog::EndSection;
1004
1005 // Create ES2 context.
1006 EGLConfig config = DE_NULL;
1007 EGLContext context = DE_NULL;
1008 bool gotConfig = getConfig(&config, FilterList() << renderable<EGL_OPENGL_ES2_BIT>);
1009
1010 if (gotConfig)
1011 {
1012 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
1013 expectError(EGL_SUCCESS);
1014
1015 context = eglCreateContext(display, config, EGL_NO_CONTEXT, s_es2ContextAttribList);
1016 expectError(EGL_SUCCESS);
1017 }
1018
1019 log << TestLog::Section("Test3", "EGL_BAD_ATTRIBUTE is generated if attribute is not a valid context attribute");
1020
1021 if (context)
1022 {
1023 expectFalse(eglQueryContext(display, context, 0, &value));
1024 expectError(EGL_BAD_ATTRIBUTE);
1025 expectFalse(eglQueryContext(display, context, -1, &value));
1026 expectError(EGL_BAD_ATTRIBUTE);
1027 expectFalse(eglQueryContext(display, context, EGL_RED_SIZE, &value));
1028 expectError(EGL_BAD_ATTRIBUTE);
1029 }
1030
1031 log << TestLog::EndSection;
1032
1033 if (context)
1034 {
1035 expectTrue(eglDestroyContext(display, context));
1036 expectError(EGL_SUCCESS);
1037 }
1038 });
1039
1040 TEGL_ADD_API_CASE(query_string, "eglQueryString() negative tests",
1041 {
1042 TestLog& log = m_testCtx.getLog();
1043 EGLDisplay display = getDisplay();
1044
1045 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1046
1047 expectNull(eglQueryString(EGL_NO_DISPLAY, EGL_VENDOR));
1048 expectError(EGL_BAD_DISPLAY);
1049
1050 expectNull(eglQueryString((EGLDisplay)-1, EGL_VENDOR));
1051 expectError(EGL_BAD_DISPLAY);
1052
1053 log << TestLog::EndSection;
1054
1055 log << TestLog::Section("Test2", "EGL_BAD_PARAMETER is generated if name is not an accepted value");
1056
1057 expectNull(eglQueryString(display, 0));
1058 expectError(EGL_BAD_PARAMETER);
1059 expectNull(eglQueryString(display, -1));
1060 expectError(EGL_BAD_PARAMETER);
1061
1062 log << TestLog::EndSection;
1063 });
1064
1065 TEGL_ADD_API_CASE(query_surface, "eglQuerySurface() negative tests",
1066 {
1067 TestLog& log = m_testCtx.getLog();
1068 EGLDisplay display = getDisplay();
1069 EGLint value = 0;
1070
1071 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1072
1073 expectFalse(eglQuerySurface(EGL_NO_DISPLAY, DE_NULL, EGL_CONFIG_ID, &value));
1074 expectError(EGL_BAD_DISPLAY);
1075
1076 expectFalse(eglQuerySurface((EGLDisplay)-1, DE_NULL, EGL_CONFIG_ID, &value));
1077 expectError(EGL_BAD_DISPLAY);
1078
1079 log << TestLog::EndSection;
1080
1081 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
1082
1083 expectFalse(eglQuerySurface(display, DE_NULL, EGL_CONFIG_ID, &value));
1084 expectError(EGL_BAD_SURFACE);
1085
1086 expectFalse(eglQuerySurface(display, (EGLSurface)-1, EGL_CONFIG_ID, &value));
1087 expectError(EGL_BAD_SURFACE);
1088
1089 log << TestLog::EndSection;
1090
1091 // Create pbuffer surface.
1092 EGLSurface surface = EGL_NO_SURFACE;
1093 {
1094 EGLConfig config;
1095 if (getConfig(&config, FilterList() << surfaceBits<EGL_PBUFFER_BIT>))
1096 {
1097 surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
1098 expectError(EGL_SUCCESS);
1099 }
1100 else
1101 log << TestLog::Message << "// WARNING: No suitable config found, testing will be incomplete" << TestLog::EndMessage;
1102 }
1103
1104 log << TestLog::Section("Test3", "EGL_BAD_ATTRIBUTE is generated if attribute is not a valid surface attribute");
1105
1106 if (surface)
1107 {
1108 expectFalse(eglQuerySurface(display, surface, 0, &value));
1109 expectError(EGL_BAD_ATTRIBUTE);
1110
1111 expectFalse(eglQuerySurface(display, surface, -1, &value));
1112 expectError(EGL_BAD_ATTRIBUTE);
1113 }
1114
1115 log << TestLog::EndSection;
1116
1117 if (surface)
1118 {
1119 eglDestroySurface(display, surface);
1120 expectError(EGL_SUCCESS);
1121 }
1122 });
1123
1124 TEGL_ADD_API_CASE(release_tex_image, "eglReleaseTexImage() negative tests",
1125 {
1126 TestLog& log = m_testCtx.getLog();
1127 EGLDisplay display = getDisplay();
1128
1129 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1130
1131 expectFalse(eglReleaseTexImage(EGL_NO_DISPLAY, EGL_NO_SURFACE, EGL_BACK_BUFFER));
1132 expectError(EGL_BAD_DISPLAY);
1133
1134 expectFalse(eglReleaseTexImage((EGLDisplay)-1, EGL_NO_SURFACE, EGL_BACK_BUFFER));
1135 expectError(EGL_BAD_DISPLAY);
1136
1137 log << TestLog::EndSection;
1138
1139 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
1140
1141 expectFalse(eglReleaseTexImage(display, EGL_NO_SURFACE, EGL_BACK_BUFFER));
1142 expectError(EGL_BAD_SURFACE);
1143
1144 expectFalse(eglReleaseTexImage(display, (EGLSurface)-1, EGL_BACK_BUFFER));
1145 expectError(EGL_BAD_SURFACE);
1146
1147 log << TestLog::EndSection;
1148 });
1149
1150 TEGL_ADD_API_CASE(surface_attrib, "eglSurfaceAttrib() negative tests",
1151 {
1152 TestLog& log = m_testCtx.getLog();
1153 EGLDisplay display = getDisplay();
1154
1155 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1156
1157 expectFalse(eglSurfaceAttrib(EGL_NO_DISPLAY, DE_NULL, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED));
1158 expectError(EGL_BAD_DISPLAY);
1159
1160 expectFalse(eglSurfaceAttrib((EGLDisplay)-1, DE_NULL, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED));
1161 expectError(EGL_BAD_DISPLAY);
1162
1163 log << TestLog::EndSection;
1164
1165 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
1166
1167 expectFalse(eglSurfaceAttrib(display, DE_NULL, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED));
1168 expectError(EGL_BAD_SURFACE);
1169
1170 expectFalse(eglSurfaceAttrib(display, (EGLSurface)-1, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED));
1171 expectError(EGL_BAD_SURFACE);
1172
1173 log << TestLog::EndSection;
1174
1175 {
1176 // Create pbuffer surface.
1177 EGLSurface surface = EGL_NO_SURFACE;
1178 {
1179 EGLConfig config;
1180 if (getConfig(&config, FilterList() << surfaceBits<EGL_PBUFFER_BIT>))
1181 {
1182 surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
1183 expectError(EGL_SUCCESS);
1184 }
1185 else
1186 log << TestLog::Message << "// WARNING: No suitable config found, testing will be incomplete" << TestLog::EndMessage;
1187 }
1188
1189 log << TestLog::Section("Test3", "EGL_BAD_ATTRIBUTE is generated if attribute is not a valid surface attribute");
1190
1191 if (surface)
1192 {
1193 expectFalse(eglSurfaceAttrib(display, surface, 0, 0));
1194 expectError(EGL_BAD_ATTRIBUTE);
1195
1196 expectFalse(eglSurfaceAttrib(display, surface, -1, 0));
1197 expectError(EGL_BAD_ATTRIBUTE);
1198 }
1199
1200 log << TestLog::EndSection;
1201
1202 if (surface)
1203 {
1204 eglDestroySurface(display, surface);
1205 expectError(EGL_SUCCESS);
1206 }
1207 }
1208
1209 {
1210 // Create pbuffer surface without EGL_MULTISAMPLE_RESOLVE_BOX_BIT.
1211 EGLSurface surface = EGL_NO_SURFACE;
1212 {
1213 EGLConfig config;
1214 if (getConfig(&config, FilterList() << surfaceBits<EGL_PBUFFER_BIT> << notSurfaceBits<EGL_MULTISAMPLE_RESOLVE_BOX_BIT>))
1215 {
1216 surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
1217 expectError(EGL_SUCCESS);
1218 }
1219 else
1220 log << TestLog::Message << "// WARNING: No suitable config found, testing will be incomplete" << TestLog::EndMessage;
1221 }
1222
1223 log << TestLog::Section("Test4", "EGL_BAD_MATCH is generated if attribute is EGL_MULTISAMPLE_RESOLVE, value is EGL_MULTISAMPLE_RESOLVE_BOX, and the EGL_SURFACE_TYPE attribute of the EGLConfig used to create surface does not contain EGL_MULTISAMPLE_RESOLVE_BOX_BIT");
1224
1225 if (surface)
1226 {
1227 expectFalse(eglSurfaceAttrib(display, surface, EGL_MULTISAMPLE_RESOLVE, EGL_MULTISAMPLE_RESOLVE_BOX));
1228 expectError(EGL_BAD_MATCH);
1229 }
1230
1231 log << TestLog::EndSection;
1232
1233 if (surface)
1234 {
1235 eglDestroySurface(display, surface);
1236 expectError(EGL_SUCCESS);
1237 }
1238 }
1239
1240 {
1241 // Create pbuffer surface without EGL_SWAP_BEHAVIOR_PRESERVED_BIT.
1242 EGLSurface surface = EGL_NO_SURFACE;
1243 {
1244 EGLConfig config;
1245 if (getConfig(&config, FilterList() << surfaceBits<EGL_PBUFFER_BIT> << notSurfaceBits<EGL_SWAP_BEHAVIOR_PRESERVED_BIT>))
1246 {
1247 surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
1248 expectError(EGL_SUCCESS);
1249 }
1250 else
1251 log << TestLog::Message << "// WARNING: No suitable config found, testing will be incomplete" << TestLog::EndMessage;
1252 }
1253
1254 log << TestLog::Section("Test5", "EGL_BAD_MATCH is generated if attribute is EGL_SWAP_BEHAVIOR, value is EGL_BUFFER_PRESERVED, and the EGL_SURFACE_TYPE attribute of the EGLConfig used to create surface does not contain EGL_SWAP_BEHAVIOR_PRESERVED_BIT");
1255
1256 if (surface)
1257 {
1258 expectFalse(eglSurfaceAttrib(display, surface, EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED));
1259 expectError(EGL_BAD_MATCH);
1260 }
1261
1262 log << TestLog::EndSection;
1263
1264 if (surface)
1265 {
1266 eglDestroySurface(display, surface);
1267 expectError(EGL_SUCCESS);
1268 }
1269 }
1270 });
1271
1272 TEGL_ADD_API_CASE(swap_buffers, "eglSwapBuffers() negative tests",
1273 {
1274 TestLog& log = m_testCtx.getLog();
1275 EGLDisplay display = getDisplay();
1276
1277 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1278
1279 expectFalse(eglSwapBuffers(EGL_NO_DISPLAY, DE_NULL));
1280 expectError(EGL_BAD_DISPLAY);
1281
1282 expectFalse(eglSwapBuffers((EGLDisplay)-1, DE_NULL));
1283 expectError(EGL_BAD_DISPLAY);
1284
1285 log << TestLog::EndSection;
1286
1287 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
1288
1289 expectFalse(eglSwapBuffers(display, DE_NULL));
1290 expectError(EGL_BAD_SURFACE);
1291
1292 expectFalse(eglSwapBuffers(display, (EGLSurface)-1));
1293 expectError(EGL_BAD_SURFACE);
1294
1295 log << TestLog::EndSection;
1296 });
1297
1298 TEGL_ADD_API_CASE(swap_interval, "eglSwapInterval() negative tests",
1299 {
1300 TestLog& log = m_testCtx.getLog();
1301 EGLDisplay display = getDisplay();
1302
1303 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1304
1305 expectFalse(eglSwapInterval(EGL_NO_DISPLAY, 0));
1306 expectError(EGL_BAD_DISPLAY);
1307
1308 expectFalse(eglSwapInterval((EGLDisplay)-1, 0));
1309 expectError(EGL_BAD_DISPLAY);
1310
1311 log << TestLog::EndSection;
1312
1313 log << TestLog::Section("Test2", "EGL_BAD_CONTEXT is generated if there is no current context on the calling thread");
1314
1315 expectFalse(eglSwapInterval(display, 0));
1316 expectError(EGL_BAD_CONTEXT);
1317
1318 log << TestLog::EndSection;
1319 });
1320
1321 TEGL_ADD_API_CASE(terminate, "eglTerminate() negative tests",
1322 {
1323 TestLog& log = m_testCtx.getLog();
1324
1325 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1326
1327 expectFalse(eglTerminate(EGL_NO_DISPLAY));
1328 expectError(EGL_BAD_DISPLAY);
1329
1330 expectFalse(eglTerminate((EGLDisplay)-1));
1331 expectError(EGL_BAD_DISPLAY);
1332
1333 log << TestLog::EndSection;
1334 });
1335
1336 TEGL_ADD_API_CASE(wait_native, "eglWaitNative() negative tests",
1337 {
1338 EGLConfig config = DE_NULL;
1339 bool gotConfig = getConfig(&config, FilterList() << renderable<EGL_OPENGL_ES2_BIT> << surfaceBits<EGL_WINDOW_BIT>);
1340
1341 if (gotConfig)
1342 {
1343 TestLog& log = m_testCtx.getLog();
1344 const Library& egl = m_eglTestCtx.getLibrary();
1345 EGLDisplay display = getDisplay();
1346 const eglu::NativeWindowFactory& factory = eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
1347 de::UniquePtr<eglu::NativeWindow> window (factory.createWindow(&m_eglTestCtx.getNativeDisplay(), display, config, DE_NULL, eglu::WindowParams(256, 256, eglu::parseWindowVisibility(m_testCtx.getCommandLine()))));
1348 eglu::UniqueSurface surface (egl, display, eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *window, display, config, DE_NULL));
1349 EGLContext context = EGL_NO_CONTEXT;
1350
1351 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
1352 expectError(EGL_SUCCESS);
1353
1354 context = eglCreateContext(display, config, EGL_NO_CONTEXT, s_es2ContextAttribList);
1355 expectError(EGL_SUCCESS);
1356
1357 expectTrue(eglMakeCurrent(display, *surface, *surface, context));
1358 expectError(EGL_SUCCESS);
1359
1360 log << TestLog::Section("Test1", "EGL_BAD_PARAMETER is generated if engine is not a recognized marking engine and native rendering is supported by current surface");
1361
1362 eglWaitNative(-1);
1363 expectEitherError(EGL_BAD_PARAMETER, EGL_SUCCESS);
1364
1365 log << TestLog::EndSection;
1366
1367 expectTrue(eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
1368 expectError(EGL_SUCCESS);
1369
1370 if (context != EGL_NO_CONTEXT)
1371 {
1372 expectTrue(eglDestroyContext(display, context));
1373 expectError(EGL_SUCCESS);
1374 }
1375 }
1376 });
1377 }
1378
1379 } // egl
1380 } // deqp
1381