blob: 3961eaa91b3740a82475a82608cffc54b154440d [file] [log] [blame]
Jarkko Poyry3c827362014-09-02 11:48:52 +03001/*-------------------------------------------------------------------------
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 <memory>
28
29using tcu::TestLog;
30
31namespace deqp
32{
33namespace egl
34{
35
Pyry Haulos3c67e4f2014-12-19 15:45:39 -080036using namespace eglw;
37
38template <deUint32 Type>
39static bool renderable (const eglu::CandidateConfig& c)
40{
41 return (c.renderableType() & Type) == Type;
42}
43
44template <deUint32 Type>
45static bool notRenderable (const eglu::CandidateConfig& c)
46{
47 return (c.renderableType() & Type) == 0;
48}
49
50template <deUint32 Bits>
51static bool surfaceBits (const eglu::CandidateConfig& c)
52{
53 return (c.surfaceType() & Bits) == Bits;
54}
55
56template <deUint32 Bits>
57static bool notSurfaceBits (const eglu::CandidateConfig& c)
58{
59 return (c.surfaceType() & Bits) == 0;
60}
61
Jarkko Poyry3c827362014-09-02 11:48:52 +030062NegativeApiTests::NegativeApiTests (EglTestContext& eglTestCtx)
63 : TestCaseGroup(eglTestCtx, "negative_api", "Negative API Tests")
64{
65}
66
67NegativeApiTests::~NegativeApiTests (void)
68{
69}
70
71void NegativeApiTests::init (void)
72{
73 // \todo [2012-10-02 pyry] Add tests for EGL_NOT_INITIALIZED to all functions taking in EGLDisplay
74 // \todo [2012-10-02 pyry] Implement negative cases for following non-trivial cases:
75 // * eglBindTexImage()
76 // - EGL_BAD_ACCESS is generated if buffer is already bound to a texture
77 // - EGL_BAD_MATCH is generated if the surface attribute EGL_TEXTURE_FORMAT is set to EGL_NO_TEXTURE
78 // - EGL_BAD_MATCH is generated if buffer is not a valid buffer (currently only EGL_BACK_BUFFER may be specified)
79 // - EGL_BAD_SURFACE is generated if surface is not a pbuffer surface supporting texture binding
80 // * eglCopyBuffers()
81 // - EGL_BAD_NATIVE_PIXMAP is generated if the implementation does not support native pixmaps
82 // - EGL_BAD_NATIVE_PIXMAP may be generated if native_pixmap is not a valid native pixmap
83 // - EGL_BAD_MATCH is generated if the format of native_pixmap is not compatible with the color buffer of surface
84 // * eglCreateContext()
85 // - EGL_BAD_MATCH is generated if the current rendering API is EGL_NONE
86 // - 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
87 // - 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
88 // * eglCreatePbufferFromClientBuffer()
89 // - various BAD_MATCH, BAD_ACCESS etc. conditions
90 // * eglCreatePbufferSurface()
91 // - 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
92 // * eglCreatePixmapSurface()
93 // - EGL_BAD_ATTRIBUTE is generated if attrib_list contains an invalid pixmap attribute
94 // - 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
95 // - EGL_BAD_MATCH is generated if config does not support the specified OpenVG alpha format attribute or colorspace attribute
96 // * eglCreateWindowSurface()
97 // - EGL_BAD_ATTRIBUTE is generated if attrib_list contains an invalid window attribute
98 // - 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
99 // - EGL_BAD_MATCH is generated if config does not support the specified OpenVG alpha format attribute or colorspace attribute
100 // * eglMakeCurrent()
101 // - EGL_BAD_MATCH is generated if draw or read are not compatible with context
102 // - EGL_BAD_MATCH is generated if context is set to EGL_NO_CONTEXT and draw or read are not set to EGL_NO_SURFACE
103 // - EGL_BAD_MATCH is generated if draw or read are set to EGL_NO_SURFACE and context is not set to EGL_NO_CONTEXT
104 // - EGL_BAD_ACCESS is generated if context is current to some other thread
105 // - EGL_BAD_NATIVE_PIXMAP may be generated if a native pixmap underlying either draw or read is no longer valid
106 // - EGL_BAD_NATIVE_WINDOW may be generated if a native window underlying either draw or read is no longer valid
107 // * eglReleaseTexImage()
108 // - EGL_BAD_MATCH is generated if buffer is not a valid buffer (currently only EGL_BACK_BUFFER may be specified)
109 // * eglSwapInterval()
110 // - EGL_BAD_SURFACE is generated if there is no surface bound to the current context
111 // * eglWaitNative()
112 // - 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
113
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800114 using namespace eglw;
Jarkko Poyry3c827362014-09-02 11:48:52 +0300115 using namespace eglu;
116
117 static const EGLint s_emptyAttribList[] = { EGL_NONE };
118 static const EGLint s_es1ContextAttribList[] = { EGL_CONTEXT_CLIENT_VERSION, 1, EGL_NONE };
119 static const EGLint s_es2ContextAttribList[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
120
121 static const EGLenum s_renderAPIs[] = { EGL_OPENGL_API, EGL_OPENGL_ES_API, EGL_OPENVG_API };
122
123 TEGL_ADD_API_CASE(bind_api, "eglBindAPI() negative tests",
124 {
125 TestLog& log = m_testCtx.getLog();
126 log << TestLog::Section("Test1", "EGL_BAD_PARAMETER is generated if api is not one of the accepted tokens");
127
128 expectFalse(eglBindAPI(0));
129 expectError(EGL_BAD_PARAMETER);
130
131 expectFalse(eglBindAPI(0xfdfdfdfd));
132 expectError(EGL_BAD_PARAMETER);
133
134 expectFalse(eglBindAPI((EGLenum)0xffffffff));
135 expectError(EGL_BAD_PARAMETER);
136
137 log << TestLog::EndSection;
138
139 log << TestLog::Section("Test2", "EGL_BAD_PARAMETER is generated if the specified client API is not supported by the EGL implementation");
140
141 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_renderAPIs); ndx++)
142 {
143 if (!isAPISupported(s_renderAPIs[ndx]))
144 {
145 expectFalse(eglBindAPI(s_renderAPIs[ndx]));
146 expectError(EGL_BAD_PARAMETER);
147 }
148 }
149
150 log << TestLog::EndSection;
151 });
152
153 TEGL_ADD_API_CASE(bind_tex_image, "eglBindTexImage() negative tests",
154 {
155 TestLog& log = m_testCtx.getLog();
156 EGLDisplay display = getDisplay();
157
158 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
159
160 expectFalse(eglBindTexImage(EGL_NO_DISPLAY, EGL_NO_SURFACE, EGL_BACK_BUFFER));
161 expectError(EGL_BAD_DISPLAY);
162
163 expectFalse(eglBindTexImage((EGLDisplay)-1, EGL_NO_SURFACE, EGL_BACK_BUFFER));
164 expectError(EGL_BAD_DISPLAY);
165
166 log << TestLog::EndSection;
167
168 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
169
170 expectFalse(eglBindTexImage(display, EGL_NO_SURFACE, EGL_BACK_BUFFER));
171 expectError(EGL_BAD_SURFACE);
172
173 expectFalse(eglBindTexImage(display, (EGLSurface)-1, EGL_BACK_BUFFER));
174 expectError(EGL_BAD_SURFACE);
175
176 log << TestLog::EndSection;
177 });
178
179 TEGL_ADD_API_CASE(copy_buffers, "eglCopyBuffers() negative tests",
180 {
181 TestLog& log = m_testCtx.getLog();
182 EGLDisplay display = getDisplay();
183
184 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
185
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800186 expectFalse(eglCopyBuffers(EGL_NO_DISPLAY, EGL_NO_SURFACE, (EGLNativePixmapType)0));
Jarkko Poyry3c827362014-09-02 11:48:52 +0300187 expectError(EGL_BAD_DISPLAY);
188
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800189 expectFalse(eglCopyBuffers((EGLDisplay)-1, EGL_NO_SURFACE, (EGLNativePixmapType)0));
Jarkko Poyry3c827362014-09-02 11:48:52 +0300190 expectError(EGL_BAD_DISPLAY);
191
192 log << TestLog::EndSection;
193
194 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
195
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800196 expectFalse(eglCopyBuffers(display, EGL_NO_SURFACE, (EGLNativePixmapType)0));
Jarkko Poyry3c827362014-09-02 11:48:52 +0300197 expectError(EGL_BAD_SURFACE);
198
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800199 expectFalse(eglCopyBuffers(display, (EGLSurface)-1, (EGLNativePixmapType)0));
Jarkko Poyry3c827362014-09-02 11:48:52 +0300200 expectError(EGL_BAD_SURFACE);
201
202 log << TestLog::EndSection;
203 });
204
205 static const EGLint s_invalidChooseConfigAttribList0[] = { 0, EGL_NONE };
206 static const EGLint s_invalidChooseConfigAttribList1[] = { (EGLint)0xffffffff };
207 static const EGLint s_invalidChooseConfigAttribList2[] = { EGL_BIND_TO_TEXTURE_RGB, 4, EGL_NONE };
208 static const EGLint s_invalidChooseConfigAttribList3[] = { EGL_BIND_TO_TEXTURE_RGBA, 5, EGL_NONE };
209 static const EGLint s_invalidChooseConfigAttribList4[] = { EGL_COLOR_BUFFER_TYPE, 0, EGL_NONE };
210 static const EGLint s_invalidChooseConfigAttribList5[] = { EGL_MATCH_NATIVE_PIXMAP, -1, EGL_NONE };
211 static const EGLint s_invalidChooseConfigAttribList6[] = { EGL_NATIVE_RENDERABLE, 6, EGL_NONE };
212 static const EGLint s_invalidChooseConfigAttribList7[] = { EGL_TRANSPARENT_TYPE, 6, EGL_NONE };
213 static const EGLint* s_invalidChooseConfigAttribLists[] =
214 {
215 &s_invalidChooseConfigAttribList0[0],
216 &s_invalidChooseConfigAttribList1[0],
217 &s_invalidChooseConfigAttribList2[0],
218 &s_invalidChooseConfigAttribList3[0],
219 &s_invalidChooseConfigAttribList4[0],
220 &s_invalidChooseConfigAttribList5[0],
221 &s_invalidChooseConfigAttribList6[0],
222 &s_invalidChooseConfigAttribList7[0]
223 };
224
225 TEGL_ADD_API_CASE(choose_config, "eglChooseConfig() negative tests",
226 {
227 TestLog& log = m_testCtx.getLog();
228 EGLDisplay display = getDisplay();
229 EGLConfig configs[1];
230 EGLint numConfigs;
231
232 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
233
234 expectFalse(eglChooseConfig(EGL_NO_DISPLAY, s_emptyAttribList, &configs[0], DE_LENGTH_OF_ARRAY(configs), &numConfigs));
235 expectError(EGL_BAD_DISPLAY);
236
237 expectFalse(eglChooseConfig((EGLDisplay)-1, s_emptyAttribList, &configs[0], DE_LENGTH_OF_ARRAY(configs), &numConfigs));
238 expectError(EGL_BAD_DISPLAY);
239
240 log << TestLog::EndSection;
241
242 log << TestLog::Section("Test2", "EGL_BAD_ATTRIBUTE is generated if attribute_list contains an invalid frame buffer configuration attribute");
243
244 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_invalidChooseConfigAttribLists); ndx++)
245 {
246 expectFalse(eglChooseConfig(display, s_invalidChooseConfigAttribLists[ndx], &configs[0], DE_LENGTH_OF_ARRAY(configs), &numConfigs));
247 expectError(EGL_BAD_ATTRIBUTE);
248 }
249
250 log << TestLog::EndSection;
251
252 log << TestLog::Section("Test3", "EGL_BAD_PARAMETER is generated if num_config is NULL");
253
254 expectFalse(eglChooseConfig(display, s_emptyAttribList, &configs[0], DE_LENGTH_OF_ARRAY(configs), DE_NULL));
255 expectError(EGL_BAD_PARAMETER);
256
257 log << TestLog::EndSection;
258 });
259
260 static const EGLint s_invalidCreateContextAttribList0[] = { 0, EGL_NONE };
261 static const EGLint s_invalidCreateContextAttribList1[] = { (EGLint)0xffffffff };
262
263 TEGL_ADD_API_CASE(create_context, "eglCreateContext() negative tests",
264 {
265 TestLog& log = m_testCtx.getLog();
266 EGLDisplay display = getDisplay();
267
268 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
269
270 expectNoContext(eglCreateContext(EGL_NO_DISPLAY, DE_NULL, EGL_NO_CONTEXT, s_emptyAttribList));
271 expectError(EGL_BAD_DISPLAY);
272
273 expectNoContext(eglCreateContext((EGLDisplay)-1, DE_NULL, EGL_NO_CONTEXT, s_emptyAttribList));
274 expectError(EGL_BAD_DISPLAY);
275
276 log << TestLog::EndSection;
277
278 log << TestLog::Section("Test2", "EGL_BAD_CONFIG is generated if config is not an EGL frame buffer configuration");
279
280 expectNoContext(eglCreateContext(display, (EGLConfig)-1, EGL_NO_CONTEXT, s_emptyAttribList));
281 expectError(EGL_BAD_CONFIG);
282
283 log << TestLog::EndSection;
284
285 log << TestLog::Section("Test3", "EGL_BAD_CONFIG is generated if config does not support the current rendering API");
286
287 if (isAPISupported(EGL_OPENGL_API))
288 {
289 EGLConfig es1OnlyConfig;
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800290 if (getConfig(&es1OnlyConfig, FilterList() << renderable<EGL_OPENGL_ES_BIT> << notRenderable<EGL_OPENGL_BIT>))
Jarkko Poyry3c827362014-09-02 11:48:52 +0300291 {
292 expectTrue(eglBindAPI(EGL_OPENGL_API));
293 expectNoContext(eglCreateContext(display, es1OnlyConfig, EGL_NO_CONTEXT, s_es1ContextAttribList));
294 expectError(EGL_BAD_CONFIG);
295 }
296
297 EGLConfig es2OnlyConfig;
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800298 if (getConfig(&es2OnlyConfig, FilterList() << renderable<EGL_OPENGL_ES2_BIT> << notRenderable<EGL_OPENGL_BIT>))
Jarkko Poyry3c827362014-09-02 11:48:52 +0300299 {
300 expectTrue(eglBindAPI(EGL_OPENGL_API));
301 expectNoContext(eglCreateContext(display, es2OnlyConfig, EGL_NO_CONTEXT, s_es2ContextAttribList));
302 expectError(EGL_BAD_CONFIG);
303 }
304
305 EGLConfig vgOnlyConfig;
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800306 if (getConfig(&vgOnlyConfig, FilterList() << renderable<EGL_OPENVG_BIT> << notRenderable<EGL_OPENGL_BIT>))
Jarkko Poyry3c827362014-09-02 11:48:52 +0300307 {
308 expectTrue(eglBindAPI(EGL_OPENGL_API));
309 expectNoContext(eglCreateContext(display, vgOnlyConfig, EGL_NO_CONTEXT, s_emptyAttribList));
310 expectError(EGL_BAD_CONFIG);
311 }
312 }
313
314 if (isAPISupported(EGL_OPENGL_ES_API))
315 {
316 EGLConfig glOnlyConfig;
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800317 if (getConfig(&glOnlyConfig, FilterList() << renderable<EGL_OPENGL_BIT> << notRenderable<EGL_OPENGL_ES_BIT|EGL_OPENGL_ES2_BIT>))
Jarkko Poyry3c827362014-09-02 11:48:52 +0300318 {
319 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
320 expectNoContext(eglCreateContext(display, glOnlyConfig, EGL_NO_CONTEXT, s_emptyAttribList));
321 expectError(EGL_BAD_CONFIG);
322 }
323
324 EGLConfig vgOnlyConfig;
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800325 if (getConfig(&vgOnlyConfig, FilterList() << renderable<EGL_OPENVG_BIT> << notRenderable<EGL_OPENGL_ES_BIT|EGL_OPENGL_ES2_BIT>))
Jarkko Poyry3c827362014-09-02 11:48:52 +0300326 {
327 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
328 expectNoContext(eglCreateContext(display, vgOnlyConfig, EGL_NO_CONTEXT, s_emptyAttribList));
329 expectError(EGL_BAD_CONFIG);
330 }
331 }
332
333 if (isAPISupported(EGL_OPENVG_API))
334 {
335 EGLConfig glOnlyConfig;
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800336 if (getConfig(&glOnlyConfig, FilterList() << renderable<EGL_OPENGL_BIT> << notRenderable<EGL_OPENVG_BIT>))
Jarkko Poyry3c827362014-09-02 11:48:52 +0300337 {
Mika Isojärvic3dc61b2014-10-24 11:42:52 +0300338 expectTrue(eglBindAPI(EGL_OPENVG_API));
Jarkko Poyry3c827362014-09-02 11:48:52 +0300339 expectNoContext(eglCreateContext(display, glOnlyConfig, EGL_NO_CONTEXT, s_emptyAttribList));
340 expectError(EGL_BAD_CONFIG);
341 }
342
343 EGLConfig es1OnlyConfig;
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800344 if (getConfig(&es1OnlyConfig, FilterList() << renderable<EGL_OPENGL_ES_BIT> << notRenderable<EGL_OPENVG_BIT>))
Jarkko Poyry3c827362014-09-02 11:48:52 +0300345 {
Mika Isojärvic3dc61b2014-10-24 11:42:52 +0300346 expectTrue(eglBindAPI(EGL_OPENVG_API));
Jarkko Poyry3c827362014-09-02 11:48:52 +0300347 expectNoContext(eglCreateContext(display, es1OnlyConfig, EGL_NO_CONTEXT, s_es1ContextAttribList));
348 expectError(EGL_BAD_CONFIG);
349 }
350
351 EGLConfig es2OnlyConfig;
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800352 if (getConfig(&es2OnlyConfig, FilterList() << renderable<EGL_OPENGL_ES2_BIT> << notRenderable<EGL_OPENVG_BIT>))
Jarkko Poyry3c827362014-09-02 11:48:52 +0300353 {
Mika Isojärvic3dc61b2014-10-24 11:42:52 +0300354 expectTrue(eglBindAPI(EGL_OPENVG_API));
Jarkko Poyry3c827362014-09-02 11:48:52 +0300355 expectNoContext(eglCreateContext(display, es2OnlyConfig, EGL_NO_CONTEXT, s_es2ContextAttribList));
356 expectError(EGL_BAD_CONFIG);
357 }
358 }
359
360 log << TestLog::EndSection;
361
362 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");
363
364 if (isAPISupported(EGL_OPENGL_ES_API))
365 {
366 EGLConfig notES1Config;
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800367 if (getConfig(&notES1Config, FilterList() << notRenderable<EGL_OPENGL_ES_BIT>))
Jarkko Poyry3c827362014-09-02 11:48:52 +0300368 {
369 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
370 expectNoContext(eglCreateContext(display, notES1Config, EGL_NO_CONTEXT, s_es1ContextAttribList));
371 expectError(EGL_BAD_CONFIG);
372 }
373 }
374
375 log << TestLog::EndSection;
376
377 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");
378
379 if (isAPISupported(EGL_OPENGL_ES_API))
380 {
381 EGLConfig notES2Config;
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800382 if (getConfig(&notES2Config, FilterList() << notRenderable<EGL_OPENGL_ES2_BIT>))
Jarkko Poyry3c827362014-09-02 11:48:52 +0300383 {
384 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
385 expectNoContext(eglCreateContext(display, notES2Config, EGL_NO_CONTEXT, s_es2ContextAttribList));
386 expectError(EGL_BAD_CONFIG);
387 }
388 }
389
390 log << TestLog::EndSection;
391
392 log << TestLog::Section("Test6", "EGL_BAD_ATTRIBUTE is generated if attrib_list contains an invalid context attribute");
393
394 if (isAPISupported(EGL_OPENGL_API))
395 {
396 EGLConfig glConfig;
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800397 if (getConfig(&glConfig, FilterList() << renderable<EGL_OPENGL_BIT>))
Jarkko Poyry3c827362014-09-02 11:48:52 +0300398 {
399 expectTrue(eglBindAPI(EGL_OPENGL_API));
400 expectNoContext(eglCreateContext(display, glConfig, EGL_NO_CONTEXT, s_es1ContextAttribList));
401 expectError(EGL_BAD_ATTRIBUTE);
402 }
403 }
404
405 if (isAPISupported(EGL_OPENVG_API))
406 {
407 EGLConfig vgConfig;
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800408 if (getConfig(&vgConfig, FilterList() << renderable<EGL_OPENVG_BIT>))
Jarkko Poyry3c827362014-09-02 11:48:52 +0300409 {
410 expectTrue(eglBindAPI(EGL_OPENVG_API));
411 expectNoContext(eglCreateContext(display, vgConfig, EGL_NO_CONTEXT, s_es1ContextAttribList));
412 expectError(EGL_BAD_ATTRIBUTE);
413 }
414 }
415
416 if (isAPISupported(EGL_OPENGL_ES_API))
417 {
418 bool gotConfig = false;
419 EGLConfig esConfig;
420
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800421 gotConfig = getConfig(&esConfig, FilterList() << renderable<EGL_OPENGL_ES_BIT>) ||
422 getConfig(&esConfig, FilterList() << renderable<EGL_OPENGL_ES2_BIT>);
Jarkko Poyry3c827362014-09-02 11:48:52 +0300423
424 if (gotConfig)
425 {
426 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
427 expectNoContext(eglCreateContext(display, esConfig, EGL_NO_CONTEXT, s_invalidCreateContextAttribList0));
428 expectError(EGL_BAD_ATTRIBUTE);
429 expectNoContext(eglCreateContext(display, esConfig, EGL_NO_CONTEXT, s_invalidCreateContextAttribList1));
430 expectError(EGL_BAD_ATTRIBUTE);
431 }
432 }
433
434 log << TestLog::EndSection;
435 });
436
437 TEGL_ADD_API_CASE(create_pbuffer_from_client_buffer, "eglCreatePbufferFromClientBuffer() negative tests",
438 {
439 TestLog& log = m_testCtx.getLog();
440 EGLDisplay display = getDisplay();
441 EGLConfig anyConfig;
442 EGLint unused = 0;
443
444 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
445
446 expectNoSurface(eglCreatePbufferFromClientBuffer(EGL_NO_DISPLAY, EGL_OPENVG_IMAGE, 0, (EGLConfig)0, DE_NULL));
447 expectError(EGL_BAD_DISPLAY);
448
449 expectNoSurface(eglCreatePbufferFromClientBuffer((EGLDisplay)-1, EGL_OPENVG_IMAGE, 0, (EGLConfig)0, DE_NULL));
450 expectError(EGL_BAD_DISPLAY);
451
452 log << TestLog::EndSection;
453
454 log << TestLog::Section("Test2", "EGL_BAD_CONFIG is generated if config is not an EGL frame buffer configuration");
455
456 expectNoSurface(eglCreatePbufferFromClientBuffer(display, EGL_OPENVG_IMAGE, 0, (EGLConfig)-1, DE_NULL));
457 expectError(EGL_BAD_CONFIG);
458
459 log << TestLog::EndSection;
460
461 log << TestLog::Section("Test3", "EGL_BAD_PARAMETER is generated if buftype is not EGL_OPENVG_IMAGE");
462
Mika Isojärvic3dc61b2014-10-24 11:42:52 +0300463 log << TestLog::EndSection;
464
Jarkko Poyry3c827362014-09-02 11:48:52 +0300465 expectTrue(eglGetConfigs(display, &anyConfig, 1, &unused));
466
Mika Isojärvic3dc61b2014-10-24 11:42:52 +0300467 log << TestLog::Section("Test4", "EGL_BAD_PARAMETER is generated if buffer is not valid OpenVG image");
Jarkko Poyry3c827362014-09-02 11:48:52 +0300468 expectNoSurface(eglCreatePbufferFromClientBuffer(display, EGL_OPENVG_IMAGE, (EGLClientBuffer)-1, anyConfig, DE_NULL));
Mika Isojärvic3dc61b2014-10-24 11:42:52 +0300469 expectError(EGL_BAD_PARAMETER);
Jarkko Poyry3c827362014-09-02 11:48:52 +0300470
471 log << TestLog::EndSection;
472 });
473
474 static const EGLint s_validGenericPbufferAttrib[] = { EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
475
476 static const EGLint s_invalidGenericPbufferAttrib0[] = { 0, EGL_NONE };
477 static const EGLint s_invalidGenericPbufferAttrib1[] = { (EGLint)0xffffffff };
478 static const EGLint s_invalidGenericPbufferAttrib2[] = { EGL_WIDTH, 64, EGL_HEIGHT, -1, EGL_NONE };
479 static const EGLint s_invalidGenericPbufferAttrib3[] = { EGL_WIDTH, -1, EGL_HEIGHT, 64, EGL_NONE };
480 static const EGLint* s_invalidGenericPbufferAttribs[] =
481 {
482 s_invalidGenericPbufferAttrib0,
483 s_invalidGenericPbufferAttrib1,
484 s_invalidGenericPbufferAttrib2,
485 s_invalidGenericPbufferAttrib3
486 };
487
488 static const EGLint s_invalidNoEsPbufferAttrib0[] = { EGL_MIPMAP_TEXTURE, EGL_TRUE, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
489 static const EGLint s_invalidNoEsPbufferAttrib1[] = { EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGBA, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
490 static const EGLint s_invalidNoEsPbufferAttrib2[] = { EGL_TEXTURE_TARGET, EGL_TEXTURE_2D, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
491 static const EGLint* s_invalidNoEsPbufferAttribs[] =
492 {
493 s_invalidNoEsPbufferAttrib0,
494 s_invalidNoEsPbufferAttrib1,
495 s_invalidNoEsPbufferAttrib2
496 };
497
498 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 };
499 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 };
500 static const EGLint* s_invalidEsPbufferAttribs[] =
501 {
502 s_invalidEsPbufferAttrib0,
503 s_invalidEsPbufferAttrib1
504 };
505
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800506 static const EGLint s_vgPreMultAlphaPbufferAttrib[] = { EGL_ALPHA_FORMAT, EGL_ALPHA_FORMAT_PRE, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
507 static const EGLint s_vgLinearColorspacePbufferAttrib[] = { EGL_COLORSPACE, EGL_VG_COLORSPACE_LINEAR, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
Jarkko Poyry3c827362014-09-02 11:48:52 +0300508
509 TEGL_ADD_API_CASE(create_pbuffer_surface, "eglCreatePbufferSurface() negative tests",
510 {
511 TestLog& log = m_testCtx.getLog();
512 EGLDisplay display = getDisplay();
513
514 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
515
516 expectNoSurface(eglCreatePbufferSurface(EGL_NO_DISPLAY, DE_NULL, s_emptyAttribList));
517 expectError(EGL_BAD_DISPLAY);
518
519 expectNoSurface(eglCreatePbufferSurface((EGLDisplay)-1, DE_NULL, s_emptyAttribList));
520 expectError(EGL_BAD_DISPLAY);
521
522 log << TestLog::EndSection;
523
524 log << TestLog::Section("Test2", "EGL_BAD_CONFIG is generated if config is not an EGL frame buffer configuration");
525
526 expectNoSurface(eglCreatePbufferSurface(display, (EGLConfig)-1, s_emptyAttribList));
527 expectError(EGL_BAD_CONFIG);
528
529 log << TestLog::EndSection;
530
531 log << TestLog::Section("Test3", "EGL_BAD_ATTRIBUTE is generated if attrib_list contains an invalid pixel buffer attribute");
532
533 // Generic pbuffer-capable config
534 EGLConfig genericConfig;
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800535 if (getConfig(&genericConfig, FilterList() << surfaceBits<EGL_PBUFFER_BIT>))
Jarkko Poyry3c827362014-09-02 11:48:52 +0300536 {
537 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_invalidGenericPbufferAttribs); ndx++)
538 {
539 expectNoSurface(eglCreatePbufferSurface(display, genericConfig, s_invalidGenericPbufferAttribs[ndx]));
540 expectError(EGL_BAD_ATTRIBUTE);
541 }
542 }
543
544 log << TestLog::EndSection;
545
546 log << TestLog::Section("Test4", "EGL_BAD_MATCH is generated if config does not support rendering to pixel buffers");
547
548 EGLConfig noPbufferConfig;
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800549 if (getConfig(&noPbufferConfig, FilterList() << notSurfaceBits<EGL_PBUFFER_BIT>))
Jarkko Poyry3c827362014-09-02 11:48:52 +0300550 {
551 expectNoSurface(eglCreatePbufferSurface(display, noPbufferConfig, s_validGenericPbufferAttrib));
552 expectError(EGL_BAD_MATCH);
553 }
554
555 log << TestLog::EndSection;
556
557 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");
558
559 EGLConfig noEsConfig;
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800560 if (getConfig(&noEsConfig, FilterList() << notRenderable<EGL_OPENGL_ES_BIT|EGL_OPENGL_ES2_BIT>))
Jarkko Poyry3c827362014-09-02 11:48:52 +0300561 {
562 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_invalidNoEsPbufferAttribs); ndx++)
563 {
564 expectNoSurface(eglCreatePbufferSurface(display, noEsConfig, s_invalidNoEsPbufferAttribs[ndx]));
565 expectError(EGL_BAD_MATCH);
566 }
567 }
568
569 log << TestLog::EndSection;
570
571 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");
572
573 // ES1 or ES2 config.
574 EGLConfig esConfig;
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800575 bool gotEsConfig = getConfig(&esConfig, FilterList() << renderable<EGL_OPENGL_ES_BIT>) ||
576 getConfig(&esConfig, FilterList() << renderable<EGL_OPENGL_ES2_BIT>);
Jarkko Poyry3c827362014-09-02 11:48:52 +0300577 if (gotEsConfig)
578 {
579 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_invalidEsPbufferAttribs); ndx++)
580 {
581 expectNoSurface(eglCreatePbufferSurface(display, esConfig, s_invalidEsPbufferAttribs[ndx]));
582 expectError(EGL_BAD_MATCH);
583 }
584 }
585
586 log << TestLog::EndSection;
587
588 log << TestLog::Section("Test7", "EGL_BAD_MATCH is generated if config does not support the specified OpenVG alpha format attribute or colorspace attribute");
589
590 EGLConfig vgNoPreConfig;
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800591 if (getConfig(&vgNoPreConfig, FilterList() << renderable<EGL_OPENVG_BIT> << notSurfaceBits<EGL_VG_ALPHA_FORMAT_PRE_BIT>))
Jarkko Poyry3c827362014-09-02 11:48:52 +0300592 {
593 expectNoSurface(eglCreatePbufferSurface(display, vgNoPreConfig, s_vgPreMultAlphaPbufferAttrib));
594 expectError(EGL_BAD_MATCH);
595 }
596
597 EGLConfig vgNoLinearConfig;
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800598 if (getConfig(&vgNoLinearConfig, FilterList() << renderable<EGL_OPENVG_BIT> << notSurfaceBits<EGL_VG_COLORSPACE_LINEAR_BIT>))
Jarkko Poyry3c827362014-09-02 11:48:52 +0300599 {
600 expectNoSurface(eglCreatePbufferSurface(display, vgNoLinearConfig, s_vgLinearColorspacePbufferAttrib));
601 expectError(EGL_BAD_MATCH);
602 }
603
604 log << TestLog::EndSection;
605 });
606
607 TEGL_ADD_API_CASE(create_pixmap_surface, "eglCreatePixmapSurface() negative tests",
608 {
609 TestLog& log = m_testCtx.getLog();
610 EGLDisplay display = getDisplay();
611
612 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
613
614 expectNoSurface(eglCreatePixmapSurface(EGL_NO_DISPLAY, DE_NULL, DE_NULL, s_emptyAttribList));
615 expectError(EGL_BAD_DISPLAY);
616
617 expectNoSurface(eglCreatePixmapSurface((EGLDisplay)-1, DE_NULL, DE_NULL, s_emptyAttribList));
618 expectError(EGL_BAD_DISPLAY);
619
620 log << TestLog::EndSection;
621
622 log << TestLog::Section("Test2", "EGL_BAD_CONFIG is generated if config is not an EGL frame buffer configuration");
623
624 expectNoSurface(eglCreatePixmapSurface(display, (EGLConfig)-1, DE_NULL, s_emptyAttribList));
625 expectError(EGL_BAD_CONFIG);
626
627 log << TestLog::EndSection;
628
629 log << TestLog::Section("Test3", "EGL_BAD_NATIVE_PIXMAP may be generated if native_pixmap is not a valid native pixmap");
630
631 // Any pixmap-capable config.
632 EGLConfig pixmapConfig;
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800633 if (getConfig(&pixmapConfig, FilterList() << surfaceBits<EGL_PIXMAP_BIT>))
Jarkko Poyry3c827362014-09-02 11:48:52 +0300634 {
635 expectNoSurface(eglCreatePixmapSurface(display, pixmapConfig, DE_NULL, s_emptyAttribList));
636 expectError(EGL_BAD_NATIVE_PIXMAP);
637
638 expectNoSurface(eglCreatePixmapSurface(display, pixmapConfig, (EGLNativePixmapType)-1, s_emptyAttribList));
639 expectError(EGL_BAD_NATIVE_PIXMAP);
640 }
641
642 log << TestLog::EndSection;
643 });
644
645 TEGL_ADD_API_CASE(create_window_surface, "eglCreateWindowSurface() negative tests",
646 {
647 TestLog& log = m_testCtx.getLog();
648 EGLDisplay display = getDisplay();
649
650 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
651
652 expectNoSurface(eglCreateWindowSurface(EGL_NO_DISPLAY, DE_NULL, DE_NULL, s_emptyAttribList));
653 expectError(EGL_BAD_DISPLAY);
654
655 expectNoSurface(eglCreateWindowSurface((EGLDisplay)-1, DE_NULL, DE_NULL, s_emptyAttribList));
656 expectError(EGL_BAD_DISPLAY);
657
658 log << TestLog::EndSection;
659
660 log << TestLog::Section("Test2", "EGL_BAD_CONFIG is generated if config is not an EGL frame buffer configuration");
661
662 expectNoSurface(eglCreateWindowSurface(display, (EGLConfig)-1, DE_NULL, s_emptyAttribList));
663 expectError(EGL_BAD_CONFIG);
664
665 log << TestLog::EndSection;
666
667 log << TestLog::Section("Test3", "EGL_BAD_NATIVE_WINDOW may be generated if native_window is not a valid native window");
668
669 // Any window-capable config.
670 EGLConfig windowConfig;
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800671 if (getConfig(&windowConfig, FilterList() << surfaceBits<EGL_WINDOW_BIT>))
Jarkko Poyry3c827362014-09-02 11:48:52 +0300672 {
673 expectNoSurface(eglCreateWindowSurface(display, windowConfig, DE_NULL, s_emptyAttribList));
Mika Isojärvic3dc61b2014-10-24 11:42:52 +0300674 expectError(EGL_BAD_NATIVE_WINDOW);
Jarkko Poyry3c827362014-09-02 11:48:52 +0300675
676 expectNoSurface(eglCreateWindowSurface(display, windowConfig, (EGLNativeWindowType)-1, s_emptyAttribList));
Mika Isojärvic3dc61b2014-10-24 11:42:52 +0300677 expectError(EGL_BAD_NATIVE_WINDOW);
Jarkko Poyry3c827362014-09-02 11:48:52 +0300678 }
679
680 log << TestLog::EndSection;
681 });
682
683 TEGL_ADD_API_CASE(destroy_context, "eglDestroyContext() negative tests",
684 {
685 TestLog& log = m_testCtx.getLog();
686 EGLDisplay display = getDisplay();
687
688 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
689
690 expectFalse(eglDestroyContext(EGL_NO_DISPLAY, DE_NULL));
691 expectError(EGL_BAD_DISPLAY);
692
693 expectFalse(eglDestroyContext((EGLDisplay)-1, DE_NULL));
694 expectError(EGL_BAD_DISPLAY);
695
696 log << TestLog::EndSection;
697
698 log << TestLog::Section("Test2", "EGL_BAD_CONTEXT is generated if context is not an EGL rendering context");
699
700 expectFalse(eglDestroyContext(display, DE_NULL));
701 expectError(EGL_BAD_CONTEXT);
702
703 expectFalse(eglDestroyContext(display, (EGLContext)-1));
704 expectError(EGL_BAD_CONTEXT);
705
706 log << TestLog::EndSection;
707 });
708
709 TEGL_ADD_API_CASE(destroy_surface, "eglDestroySurface() negative tests",
710 {
711 TestLog& log = m_testCtx.getLog();
712 EGLDisplay display = getDisplay();
713
714 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
715
716 expectFalse(eglDestroySurface(EGL_NO_DISPLAY, DE_NULL));
717 expectError(EGL_BAD_DISPLAY);
718
719 expectFalse(eglDestroySurface((EGLDisplay)-1, DE_NULL));
720 expectError(EGL_BAD_DISPLAY);
721
722 log << TestLog::EndSection;
723
724 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
725
726 expectFalse(eglDestroySurface(display, DE_NULL));
727 expectError(EGL_BAD_SURFACE);
728
729 expectFalse(eglDestroySurface(display, (EGLSurface)-1));
730 expectError(EGL_BAD_SURFACE);
731
732 log << TestLog::EndSection;
733 });
734
735 TEGL_ADD_API_CASE(get_config_attrib, "eglGetConfigAttrib() negative tests",
736 {
737 TestLog& log = m_testCtx.getLog();
738 EGLDisplay display = getDisplay();
739 EGLint value = 0;
740
741 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
742
743 expectFalse(eglGetConfigAttrib(EGL_NO_DISPLAY, DE_NULL, EGL_RED_SIZE, &value));
744 expectError(EGL_BAD_DISPLAY);
745
746 expectFalse(eglGetConfigAttrib((EGLDisplay)-1, DE_NULL, EGL_RED_SIZE, &value));
747 expectError(EGL_BAD_DISPLAY);
748
749 log << TestLog::EndSection;
750
751 log << TestLog::Section("Test2", "EGL_BAD_CONFIG is generated if config is not an EGL frame buffer configuration");
752
753 expectFalse(eglGetConfigAttrib(display, (EGLConfig)-1, EGL_RED_SIZE, &value));
754 expectError(EGL_BAD_CONFIG);
755
756 log << TestLog::EndSection;
757
758 // Any config.
759 EGLConfig config = DE_NULL;
760 bool hasConfig = getConfig(&config, FilterList());
761
762 log << TestLog::Section("Test3", "EGL_BAD_ATTRIBUTE is generated if attribute is not a valid frame buffer configuration attribute");
763
764 if (hasConfig)
765 {
766 expectFalse(eglGetConfigAttrib(display, config, 0, &value));
767 expectError(EGL_BAD_ATTRIBUTE);
768
769 expectFalse(eglGetConfigAttrib(display, config, -1, &value));
770 expectError(EGL_BAD_ATTRIBUTE);
771 }
772
773 log << TestLog::EndSection;
774 });
775
776 TEGL_ADD_API_CASE(get_configs, "eglGetConfigs() negative tests",
777 {
778 TestLog& log = m_testCtx.getLog();
779 EGLDisplay display = getDisplay();
780 EGLConfig cfgs[1];
781 EGLint numCfgs = 0;
782
783 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
784
785 expectFalse(eglGetConfigs(EGL_NO_DISPLAY, &cfgs[0], DE_LENGTH_OF_ARRAY(cfgs), &numCfgs));
786 expectError(EGL_BAD_DISPLAY);
787
788 expectFalse(eglGetConfigs((EGLDisplay)-1, &cfgs[0], DE_LENGTH_OF_ARRAY(cfgs), &numCfgs));
789 expectError(EGL_BAD_DISPLAY);
790
791 log << TestLog::EndSection;
792
793 log << TestLog::Section("Test2", "EGL_BAD_PARAMETER is generated if num_config is NULL");
794
795 expectFalse(eglGetConfigs(display, &cfgs[0], DE_LENGTH_OF_ARRAY(cfgs), DE_NULL));
796 expectError(EGL_BAD_PARAMETER);
797
798 log << TestLog::EndSection;
799 });
800
801 TEGL_ADD_API_CASE(get_display, "eglGetDisplay() negative tests",
802 {
803 expectNoDisplay(eglGetDisplay((EGLNativeDisplayType)-1));
804 expectError(EGL_SUCCESS);
805 });
806
807 TEGL_ADD_API_CASE(initialize, "eglInitialize() negative tests",
808 {
809 TestLog& log = m_testCtx.getLog();
810 EGLint major = 0;
811 EGLint minor = 0;
812
813 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
814
815 expectFalse(eglInitialize(EGL_NO_DISPLAY, &major, &minor));
816 expectError(EGL_BAD_DISPLAY);
817
818 expectFalse(eglInitialize((EGLDisplay)-1, &major, &minor));
819 expectError(EGL_BAD_DISPLAY);
820
821 log << TestLog::EndSection;
822 });
823
824 TEGL_ADD_API_CASE(make_current, "eglMakeCurrent() negative tests",
825 {
826 TestLog& log = m_testCtx.getLog();
827 EGLDisplay display = getDisplay();
828
829 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
830
831 expectFalse(eglMakeCurrent(EGL_NO_DISPLAY, DE_NULL, DE_NULL, DE_NULL));
832 expectError(EGL_BAD_DISPLAY);
833
834 expectFalse(eglMakeCurrent((EGLDisplay)-1, DE_NULL, DE_NULL, DE_NULL));
835 expectError(EGL_BAD_DISPLAY);
836
837 log << TestLog::EndSection;
838
839 // Create simple pbuffer surface.
840 EGLSurface surface = EGL_NO_SURFACE;
841 {
842 EGLConfig config;
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800843 if (getConfig(&config, FilterList() << surfaceBits<EGL_PBUFFER_BIT>))
Jarkko Poyry3c827362014-09-02 11:48:52 +0300844 {
845 surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
846 expectError(EGL_SUCCESS);
847 }
848 }
849
850 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
851
852 expectFalse(eglMakeCurrent(display, (EGLSurface)-1, (EGLSurface)-1, DE_NULL));
853 expectError(EGL_BAD_SURFACE);
854
855 if (surface)
856 {
857 expectFalse(eglMakeCurrent(display, surface, (EGLSurface)-1, DE_NULL));
858 expectError(EGL_BAD_SURFACE);
859
860 expectFalse(eglMakeCurrent(display, (EGLSurface)-1, surface, DE_NULL));
861 expectError(EGL_BAD_SURFACE);
862 }
863
864 log << TestLog::EndSection;
865
866 log << TestLog::Section("Test3", "EGL_BAD_CONTEXT is generated if context is not an EGL rendering context");
867
868 if (surface)
869 {
Jarkko Poyry3c827362014-09-02 11:48:52 +0300870 expectFalse(eglMakeCurrent(display, surface, surface, (EGLContext)-1));
871 expectError(EGL_BAD_CONTEXT);
872 }
873
874 log << TestLog::EndSection;
875
876 if (surface)
877 {
878 eglDestroySurface(display, surface);
879 expectError(EGL_SUCCESS);
880 }
881 });
882
883 TEGL_ADD_API_CASE(get_current_context, "eglGetCurrentContext() negative tests",
884 {
885 expectNoContext(eglGetCurrentContext());
886
887 if (isAPISupported(EGL_OPENGL_ES_API))
888 {
889 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
890 expectError(EGL_SUCCESS);
891
892 expectNoContext(eglGetCurrentContext());
893 expectError(EGL_SUCCESS);
894 }
895 });
896
897 TEGL_ADD_API_CASE(get_current_surface, "eglGetCurrentSurface() negative tests",
898 {
899 TestLog& log = m_testCtx.getLog();
900
901 log << TestLog::Section("Test1", "EGL_BAD_PARAMETER is generated if readdraw is neither EGL_READ nor EGL_DRAW");
902
903 expectNoSurface(eglGetCurrentSurface(EGL_NONE));
904 expectError(EGL_BAD_PARAMETER);
905
906 log << TestLog::EndSection;
907
908 expectNoSurface(eglGetCurrentSurface(EGL_READ));
909 expectError(EGL_SUCCESS);
910
911 expectNoSurface(eglGetCurrentSurface(EGL_DRAW));
912 expectError(EGL_SUCCESS);
913 });
914
915 TEGL_ADD_API_CASE(query_context, "eglQueryContext() negative tests",
916 {
917 TestLog& log = m_testCtx.getLog();
918 EGLDisplay display = getDisplay();
919 EGLint value = 0;
920
921 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
922
923 expectFalse(eglQueryContext(EGL_NO_DISPLAY, DE_NULL, EGL_CONFIG_ID, &value));
924 expectError(EGL_BAD_DISPLAY);
925
926 expectFalse(eglQueryContext((EGLDisplay)-1, DE_NULL, EGL_CONFIG_ID, &value));
927 expectError(EGL_BAD_DISPLAY);
928
929 log << TestLog::EndSection;
930
931 log << TestLog::Section("Test2", "EGL_BAD_CONTEXT is generated if context is not an EGL rendering context");
932
933 expectFalse(eglQueryContext(display, DE_NULL, EGL_CONFIG_ID, &value));
934 expectError(EGL_BAD_CONTEXT);
935
936 expectFalse(eglQueryContext(display, DE_NULL, EGL_CONFIG_ID, &value));
937 expectError(EGL_BAD_CONTEXT);
938
939 log << TestLog::EndSection;
940
941 // Create ES2 context.
942 EGLConfig config = DE_NULL;
943 EGLContext context = DE_NULL;
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800944 bool gotConfig = getConfig(&config, FilterList() << renderable<EGL_OPENGL_ES2_BIT>);
Jarkko Poyry3c827362014-09-02 11:48:52 +0300945
946 if (gotConfig)
947 {
948 expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
949 expectError(EGL_SUCCESS);
950
951 context = eglCreateContext(display, config, EGL_NO_CONTEXT, s_es2ContextAttribList);
952 expectError(EGL_SUCCESS);
953 }
954
955 log << TestLog::Section("Test3", "EGL_BAD_ATTRIBUTE is generated if attribute is not a valid context attribute");
956
957 if (context)
958 {
959 expectFalse(eglQueryContext(display, context, 0, &value));
960 expectError(EGL_BAD_ATTRIBUTE);
961 expectFalse(eglQueryContext(display, context, -1, &value));
962 expectError(EGL_BAD_ATTRIBUTE);
963 expectFalse(eglQueryContext(display, context, EGL_RED_SIZE, &value));
964 expectError(EGL_BAD_ATTRIBUTE);
965 }
966
967 log << TestLog::EndSection;
968
969 if (context)
970 {
971 expectTrue(eglDestroyContext(display, context));
972 expectError(EGL_SUCCESS);
973 }
974 });
975
976 TEGL_ADD_API_CASE(query_string, "eglQueryString() negative tests",
977 {
978 TestLog& log = m_testCtx.getLog();
979 EGLDisplay display = getDisplay();
980
981 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
982
983 expectNull(eglQueryString(EGL_NO_DISPLAY, EGL_VENDOR));
984 expectError(EGL_BAD_DISPLAY);
985
986 expectNull(eglQueryString((EGLDisplay)-1, EGL_VENDOR));
987 expectError(EGL_BAD_DISPLAY);
988
989 log << TestLog::EndSection;
990
991 log << TestLog::Section("Test2", "EGL_BAD_PARAMETER is generated if name is not an accepted value");
992
993 expectNull(eglQueryString(display, 0));
994 expectError(EGL_BAD_PARAMETER);
995 expectNull(eglQueryString(display, -1));
996 expectError(EGL_BAD_PARAMETER);
997
998 log << TestLog::EndSection;
999 });
1000
1001 TEGL_ADD_API_CASE(query_surface, "eglQuerySurface() negative tests",
1002 {
1003 TestLog& log = m_testCtx.getLog();
1004 EGLDisplay display = getDisplay();
1005 EGLint value = 0;
1006
1007 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1008
1009 expectFalse(eglQuerySurface(EGL_NO_DISPLAY, DE_NULL, EGL_CONFIG_ID, &value));
1010 expectError(EGL_BAD_DISPLAY);
1011
1012 expectFalse(eglQuerySurface((EGLDisplay)-1, DE_NULL, EGL_CONFIG_ID, &value));
1013 expectError(EGL_BAD_DISPLAY);
1014
1015 log << TestLog::EndSection;
1016
1017 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
1018
1019 expectFalse(eglQuerySurface(display, DE_NULL, EGL_CONFIG_ID, &value));
1020 expectError(EGL_BAD_SURFACE);
1021
1022 expectFalse(eglQuerySurface(display, (EGLSurface)-1, EGL_CONFIG_ID, &value));
1023 expectError(EGL_BAD_SURFACE);
1024
1025 log << TestLog::EndSection;
1026
1027 // Create pbuffer surface.
1028 EGLSurface surface = EGL_NO_SURFACE;
1029 {
1030 EGLConfig config;
Pyry Haulos3c67e4f2014-12-19 15:45:39 -08001031 if (getConfig(&config, FilterList() << surfaceBits<EGL_PBUFFER_BIT>))
Jarkko Poyry3c827362014-09-02 11:48:52 +03001032 {
1033 surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
1034 expectError(EGL_SUCCESS);
1035 }
1036 else
1037 log << TestLog::Message << "// WARNING: No suitable config found, testing will be incomplete" << TestLog::EndMessage;
1038 }
1039
1040 log << TestLog::Section("Test3", "EGL_BAD_ATTRIBUTE is generated if attribute is not a valid surface attribute");
1041
1042 if (surface)
1043 {
1044 expectFalse(eglQuerySurface(display, surface, 0, &value));
1045 expectError(EGL_BAD_ATTRIBUTE);
1046
1047 expectFalse(eglQuerySurface(display, surface, -1, &value));
1048 expectError(EGL_BAD_ATTRIBUTE);
1049 }
1050
1051 log << TestLog::EndSection;
1052
1053 if (surface)
1054 {
1055 eglDestroySurface(display, surface);
1056 expectError(EGL_SUCCESS);
1057 }
1058 });
1059
1060 TEGL_ADD_API_CASE(release_tex_image, "eglReleaseTexImage() negative tests",
1061 {
1062 TestLog& log = m_testCtx.getLog();
1063 EGLDisplay display = getDisplay();
1064
1065 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1066
1067 expectFalse(eglReleaseTexImage(EGL_NO_DISPLAY, EGL_NO_SURFACE, EGL_BACK_BUFFER));
1068 expectError(EGL_BAD_DISPLAY);
1069
1070 expectFalse(eglReleaseTexImage((EGLDisplay)-1, EGL_NO_SURFACE, EGL_BACK_BUFFER));
1071 expectError(EGL_BAD_DISPLAY);
1072
1073 log << TestLog::EndSection;
1074
1075 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
1076
1077 expectFalse(eglReleaseTexImage(display, EGL_NO_SURFACE, EGL_BACK_BUFFER));
1078 expectError(EGL_BAD_SURFACE);
1079
1080 expectFalse(eglReleaseTexImage(display, (EGLSurface)-1, EGL_BACK_BUFFER));
1081 expectError(EGL_BAD_SURFACE);
1082
1083 log << TestLog::EndSection;
1084 });
1085
1086 TEGL_ADD_API_CASE(surface_attrib, "eglSurfaceAttrib() negative tests",
1087 {
1088 TestLog& log = m_testCtx.getLog();
1089 EGLDisplay display = getDisplay();
1090
1091 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1092
1093 expectFalse(eglSurfaceAttrib(EGL_NO_DISPLAY, DE_NULL, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED));
1094 expectError(EGL_BAD_DISPLAY);
1095
1096 expectFalse(eglSurfaceAttrib((EGLDisplay)-1, DE_NULL, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED));
1097 expectError(EGL_BAD_DISPLAY);
1098
1099 log << TestLog::EndSection;
1100
1101 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
1102
1103 expectFalse(eglSurfaceAttrib(display, DE_NULL, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED));
1104 expectError(EGL_BAD_SURFACE);
1105
1106 expectFalse(eglSurfaceAttrib(display, (EGLSurface)-1, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED));
1107 expectError(EGL_BAD_SURFACE);
1108
1109 log << TestLog::EndSection;
1110
1111 {
1112 // Create pbuffer surface.
1113 EGLSurface surface = EGL_NO_SURFACE;
1114 {
1115 EGLConfig config;
Pyry Haulos3c67e4f2014-12-19 15:45:39 -08001116 if (getConfig(&config, FilterList() << surfaceBits<EGL_PBUFFER_BIT>))
Jarkko Poyry3c827362014-09-02 11:48:52 +03001117 {
1118 surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
1119 expectError(EGL_SUCCESS);
1120 }
1121 else
1122 log << TestLog::Message << "// WARNING: No suitable config found, testing will be incomplete" << TestLog::EndMessage;
1123 }
1124
1125 log << TestLog::Section("Test3", "EGL_BAD_ATTRIBUTE is generated if attribute is not a valid surface attribute");
1126
1127 if (surface)
1128 {
1129 expectFalse(eglSurfaceAttrib(display, surface, 0, 0));
1130 expectError(EGL_BAD_ATTRIBUTE);
1131
1132 expectFalse(eglSurfaceAttrib(display, surface, -1, 0));
1133 expectError(EGL_BAD_ATTRIBUTE);
1134 }
1135
1136 log << TestLog::EndSection;
1137
1138 if (surface)
1139 {
1140 eglDestroySurface(display, surface);
1141 expectError(EGL_SUCCESS);
1142 }
1143 }
1144
1145 {
1146 // Create pbuffer surface without EGL_MULTISAMPLE_RESOLVE_BOX_BIT.
1147 EGLSurface surface = EGL_NO_SURFACE;
1148 {
1149 EGLConfig config;
Pyry Haulos3c67e4f2014-12-19 15:45:39 -08001150 if (getConfig(&config, FilterList() << surfaceBits<EGL_PBUFFER_BIT> << notSurfaceBits<EGL_MULTISAMPLE_RESOLVE_BOX_BIT>))
Jarkko Poyry3c827362014-09-02 11:48:52 +03001151 {
1152 surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
1153 expectError(EGL_SUCCESS);
1154 }
1155 else
1156 log << TestLog::Message << "// WARNING: No suitable config found, testing will be incomplete" << TestLog::EndMessage;
1157 }
1158
1159 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");
1160
1161 if (surface)
1162 {
1163 expectFalse(eglSurfaceAttrib(display, surface, EGL_MULTISAMPLE_RESOLVE, EGL_MULTISAMPLE_RESOLVE_BOX));
1164 expectError(EGL_BAD_MATCH);
1165 }
1166
1167 log << TestLog::EndSection;
1168
1169 if (surface)
1170 {
1171 eglDestroySurface(display, surface);
1172 expectError(EGL_SUCCESS);
1173 }
1174 }
1175
1176 {
1177 // Create pbuffer surface without EGL_SWAP_BEHAVIOR_PRESERVED_BIT.
1178 EGLSurface surface = EGL_NO_SURFACE;
1179 {
1180 EGLConfig config;
Pyry Haulos3c67e4f2014-12-19 15:45:39 -08001181 if (getConfig(&config, FilterList() << surfaceBits<EGL_PBUFFER_BIT> << notSurfaceBits<EGL_SWAP_BEHAVIOR_PRESERVED_BIT>))
Jarkko Poyry3c827362014-09-02 11:48:52 +03001182 {
1183 surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
1184 expectError(EGL_SUCCESS);
1185 }
1186 else
1187 log << TestLog::Message << "// WARNING: No suitable config found, testing will be incomplete" << TestLog::EndMessage;
1188 }
1189
1190 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");
1191
1192 if (surface)
1193 {
1194 expectFalse(eglSurfaceAttrib(display, surface, EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED));
1195 expectError(EGL_BAD_MATCH);
1196 }
1197
1198 log << TestLog::EndSection;
1199
1200 if (surface)
1201 {
1202 eglDestroySurface(display, surface);
1203 expectError(EGL_SUCCESS);
1204 }
1205 }
1206 });
1207
1208 TEGL_ADD_API_CASE(swap_buffers, "eglSwapBuffers() negative tests",
1209 {
1210 TestLog& log = m_testCtx.getLog();
1211 EGLDisplay display = getDisplay();
1212
1213 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1214
1215 expectFalse(eglSwapBuffers(EGL_NO_DISPLAY, DE_NULL));
1216 expectError(EGL_BAD_DISPLAY);
1217
1218 expectFalse(eglSwapBuffers((EGLDisplay)-1, DE_NULL));
1219 expectError(EGL_BAD_DISPLAY);
1220
1221 log << TestLog::EndSection;
1222
1223 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
1224
1225 expectFalse(eglSwapBuffers(display, DE_NULL));
1226 expectError(EGL_BAD_SURFACE);
1227
1228 expectFalse(eglSwapBuffers(display, (EGLSurface)-1));
1229 expectError(EGL_BAD_SURFACE);
1230
1231 log << TestLog::EndSection;
1232 });
1233
1234 TEGL_ADD_API_CASE(swap_interval, "eglSwapInterval() negative tests",
1235 {
1236 TestLog& log = m_testCtx.getLog();
1237 EGLDisplay display = getDisplay();
1238
1239 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1240
1241 expectFalse(eglSwapInterval(EGL_NO_DISPLAY, 0));
1242 expectError(EGL_BAD_DISPLAY);
1243
1244 expectFalse(eglSwapInterval((EGLDisplay)-1, 0));
1245 expectError(EGL_BAD_DISPLAY);
1246
1247 log << TestLog::EndSection;
1248
1249 log << TestLog::Section("Test2", "EGL_BAD_CONTEXT is generated if there is no current context on the calling thread");
1250
1251 expectFalse(eglSwapInterval(display, 0));
1252 expectError(EGL_BAD_CONTEXT);
1253
1254 log << TestLog::EndSection;
1255 });
1256
1257 TEGL_ADD_API_CASE(terminate, "eglTerminate() negative tests",
1258 {
1259 TestLog& log = m_testCtx.getLog();
1260
1261 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
1262
1263 expectFalse(eglTerminate(EGL_NO_DISPLAY));
1264 expectError(EGL_BAD_DISPLAY);
1265
1266 expectFalse(eglTerminate((EGLDisplay)-1));
1267 expectError(EGL_BAD_DISPLAY);
1268
1269 log << TestLog::EndSection;
1270 });
1271
1272 TEGL_ADD_API_CASE(wait_native, "eglWaitNative() negative tests",
1273 {
1274 TestLog& log = m_testCtx.getLog();
1275
1276 log << TestLog::Section("Test1", "EGL_BAD_PARAMETER is generated if engine is not a recognized marking engine");
1277
1278 expectFalse(eglWaitNative(-1));
1279 expectError(EGL_BAD_PARAMETER);
1280
1281 log << TestLog::EndSection;
1282 });
1283}
1284
1285} // egl
1286} // deqp