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