teglNegativeApiTests.cpp revision cd521810662827147fc3a4c24fa22ac7aadec5b8
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 <memory> 28 29using tcu::TestLog; 30 31namespace deqp 32{ 33namespace egl 34{ 35 36using 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 62NegativeApiTests::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 114 using namespace eglw; 115 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 186 expectFalse(eglCopyBuffers(EGL_NO_DISPLAY, EGL_NO_SURFACE, (EGLNativePixmapType)0)); 187 expectError(EGL_BAD_DISPLAY); 188 189 expectFalse(eglCopyBuffers((EGLDisplay)-1, EGL_NO_SURFACE, (EGLNativePixmapType)0)); 190 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 196 expectFalse(eglCopyBuffers(display, EGL_NO_SURFACE, (EGLNativePixmapType)0)); 197 expectError(EGL_BAD_SURFACE); 198 199 expectFalse(eglCopyBuffers(display, (EGLSurface)-1, (EGLNativePixmapType)0)); 200 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; 290 if (getConfig(&es1OnlyConfig, FilterList() << renderable<EGL_OPENGL_ES_BIT> << notRenderable<EGL_OPENGL_BIT>)) 291 { 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; 298 if (getConfig(&es2OnlyConfig, FilterList() << renderable<EGL_OPENGL_ES2_BIT> << notRenderable<EGL_OPENGL_BIT>)) 299 { 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; 306 if (getConfig(&vgOnlyConfig, FilterList() << renderable<EGL_OPENVG_BIT> << notRenderable<EGL_OPENGL_BIT>)) 307 { 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; 317 if (getConfig(&glOnlyConfig, FilterList() << renderable<EGL_OPENGL_BIT> << notRenderable<EGL_OPENGL_ES_BIT|EGL_OPENGL_ES2_BIT>)) 318 { 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; 325 if (getConfig(&vgOnlyConfig, FilterList() << renderable<EGL_OPENVG_BIT> << notRenderable<EGL_OPENGL_ES_BIT|EGL_OPENGL_ES2_BIT>)) 326 { 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; 336 if (getConfig(&glOnlyConfig, FilterList() << renderable<EGL_OPENGL_BIT> << notRenderable<EGL_OPENVG_BIT>)) 337 { 338 expectTrue(eglBindAPI(EGL_OPENVG_API)); 339 expectNoContext(eglCreateContext(display, glOnlyConfig, EGL_NO_CONTEXT, s_emptyAttribList)); 340 expectError(EGL_BAD_CONFIG); 341 } 342 343 EGLConfig es1OnlyConfig; 344 if (getConfig(&es1OnlyConfig, FilterList() << renderable<EGL_OPENGL_ES_BIT> << notRenderable<EGL_OPENVG_BIT>)) 345 { 346 expectTrue(eglBindAPI(EGL_OPENVG_API)); 347 expectNoContext(eglCreateContext(display, es1OnlyConfig, EGL_NO_CONTEXT, s_es1ContextAttribList)); 348 expectError(EGL_BAD_CONFIG); 349 } 350 351 EGLConfig es2OnlyConfig; 352 if (getConfig(&es2OnlyConfig, FilterList() << renderable<EGL_OPENGL_ES2_BIT> << notRenderable<EGL_OPENVG_BIT>)) 353 { 354 expectTrue(eglBindAPI(EGL_OPENVG_API)); 355 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; 367 if (getConfig(¬ES1Config, FilterList() << notRenderable<EGL_OPENGL_ES_BIT>)) 368 { 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; 382 if (getConfig(¬ES2Config, FilterList() << notRenderable<EGL_OPENGL_ES2_BIT>)) 383 { 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; 397 if (getConfig(&glConfig, FilterList() << renderable<EGL_OPENGL_BIT>)) 398 { 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; 408 if (getConfig(&vgConfig, FilterList() << renderable<EGL_OPENVG_BIT>)) 409 { 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 421 gotConfig = getConfig(&esConfig, FilterList() << renderable<EGL_OPENGL_ES_BIT>) || 422 getConfig(&esConfig, FilterList() << renderable<EGL_OPENGL_ES2_BIT>); 423 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 463 log << TestLog::EndSection; 464 465 expectTrue(eglGetConfigs(display, &anyConfig, 1, &unused)); 466 467 log << TestLog::Section("Test4", "EGL_BAD_PARAMETER is generated if buffer is not valid OpenVG image"); 468 expectNoSurface(eglCreatePbufferFromClientBuffer(display, EGL_OPENVG_IMAGE, (EGLClientBuffer)-1, anyConfig, DE_NULL)); 469 expectError(EGL_BAD_PARAMETER); 470 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 506 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 }; 508 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; 535 if (getConfig(&genericConfig, FilterList() << surfaceBits<EGL_PBUFFER_BIT>)) 536 { 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; 549 if (getConfig(&noPbufferConfig, FilterList() << notSurfaceBits<EGL_PBUFFER_BIT>)) 550 { 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; 560 if (getConfig(&noEsConfig, FilterList() << notRenderable<EGL_OPENGL_ES_BIT|EGL_OPENGL_ES2_BIT>)) 561 { 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; 575 bool gotEsConfig = getConfig(&esConfig, FilterList() << renderable<EGL_OPENGL_ES_BIT>) || 576 getConfig(&esConfig, FilterList() << renderable<EGL_OPENGL_ES2_BIT>); 577 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; 591 if (getConfig(&vgNoPreConfig, FilterList() << renderable<EGL_OPENVG_BIT> << notSurfaceBits<EGL_VG_ALPHA_FORMAT_PRE_BIT>)) 592 { 593 expectNoSurface(eglCreatePbufferSurface(display, vgNoPreConfig, s_vgPreMultAlphaPbufferAttrib)); 594 expectError(EGL_BAD_MATCH); 595 } 596 597 EGLConfig vgNoLinearConfig; 598 if (getConfig(&vgNoLinearConfig, FilterList() << renderable<EGL_OPENVG_BIT> << notSurfaceBits<EGL_VG_COLORSPACE_LINEAR_BIT>)) 599 { 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; 633 if (getConfig(&pixmapConfig, FilterList() << surfaceBits<EGL_PIXMAP_BIT>)) 634 { 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; 671 if (getConfig(&windowConfig, FilterList() << surfaceBits<EGL_WINDOW_BIT>)) 672 { 673 expectNoSurface(eglCreateWindowSurface(display, windowConfig, DE_NULL, s_emptyAttribList)); 674 expectError(EGL_BAD_NATIVE_WINDOW); 675 676 expectNoSurface(eglCreateWindowSurface(display, windowConfig, (EGLNativeWindowType)-1, s_emptyAttribList)); 677 expectError(EGL_BAD_NATIVE_WINDOW); 678 } 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; 843 if (getConfig(&config, FilterList() << surfaceBits<EGL_PBUFFER_BIT>)) 844 { 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 { 870 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 EGLDisplay display = getDisplay(); 901 EGLConfig config = DE_NULL; 902 EGLContext context = EGL_NO_CONTEXT; 903 EGLSurface surface = EGL_NO_SURFACE; 904 bool gotConfig = getConfig(&config, FilterList() << renderable<EGL_OPENGL_ES2_BIT> << surfaceBits<EGL_PBUFFER_BIT>); 905 906 if (gotConfig) 907 { 908 expectTrue(eglBindAPI(EGL_OPENGL_ES_API)); 909 expectError(EGL_SUCCESS); 910 911 context = eglCreateContext(display, config, EGL_NO_CONTEXT, s_es2ContextAttribList); 912 expectError(EGL_SUCCESS); 913 914 // Create simple pbuffer surface. 915 surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib); 916 expectError(EGL_SUCCESS); 917 918 expectTrue(eglMakeCurrent(display, surface, surface, context)); 919 expectError(EGL_SUCCESS); 920 921 log << TestLog::Section("Test1", "EGL_BAD_PARAMETER is generated if readdraw is neither EGL_READ nor EGL_DRAW"); 922 923 expectNoSurface(eglGetCurrentSurface(EGL_NONE)); 924 expectError(EGL_BAD_PARAMETER); 925 926 log << TestLog::EndSection; 927 928 expectTrue(eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)); 929 expectError(EGL_SUCCESS); 930 931 if (surface != EGL_NO_SURFACE) 932 { 933 expectTrue(eglDestroySurface(display, surface)); 934 expectError(EGL_SUCCESS); 935 } 936 937 if (context != EGL_NO_CONTEXT) 938 { 939 expectTrue(eglDestroyContext(display, context)); 940 expectError(EGL_SUCCESS); 941 } 942 } 943 }); 944 945 TEGL_ADD_API_CASE(query_context, "eglQueryContext() negative tests", 946 { 947 TestLog& log = m_testCtx.getLog(); 948 EGLDisplay display = getDisplay(); 949 EGLint value = 0; 950 951 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection"); 952 953 expectFalse(eglQueryContext(EGL_NO_DISPLAY, DE_NULL, EGL_CONFIG_ID, &value)); 954 expectError(EGL_BAD_DISPLAY); 955 956 expectFalse(eglQueryContext((EGLDisplay)-1, DE_NULL, EGL_CONFIG_ID, &value)); 957 expectError(EGL_BAD_DISPLAY); 958 959 log << TestLog::EndSection; 960 961 log << TestLog::Section("Test2", "EGL_BAD_CONTEXT is generated if context is not an EGL rendering context"); 962 963 expectFalse(eglQueryContext(display, DE_NULL, EGL_CONFIG_ID, &value)); 964 expectError(EGL_BAD_CONTEXT); 965 966 expectFalse(eglQueryContext(display, DE_NULL, EGL_CONFIG_ID, &value)); 967 expectError(EGL_BAD_CONTEXT); 968 969 log << TestLog::EndSection; 970 971 // Create ES2 context. 972 EGLConfig config = DE_NULL; 973 EGLContext context = DE_NULL; 974 bool gotConfig = getConfig(&config, FilterList() << renderable<EGL_OPENGL_ES2_BIT>); 975 976 if (gotConfig) 977 { 978 expectTrue(eglBindAPI(EGL_OPENGL_ES_API)); 979 expectError(EGL_SUCCESS); 980 981 context = eglCreateContext(display, config, EGL_NO_CONTEXT, s_es2ContextAttribList); 982 expectError(EGL_SUCCESS); 983 } 984 985 log << TestLog::Section("Test3", "EGL_BAD_ATTRIBUTE is generated if attribute is not a valid context attribute"); 986 987 if (context) 988 { 989 expectFalse(eglQueryContext(display, context, 0, &value)); 990 expectError(EGL_BAD_ATTRIBUTE); 991 expectFalse(eglQueryContext(display, context, -1, &value)); 992 expectError(EGL_BAD_ATTRIBUTE); 993 expectFalse(eglQueryContext(display, context, EGL_RED_SIZE, &value)); 994 expectError(EGL_BAD_ATTRIBUTE); 995 } 996 997 log << TestLog::EndSection; 998 999 if (context) 1000 { 1001 expectTrue(eglDestroyContext(display, context)); 1002 expectError(EGL_SUCCESS); 1003 } 1004 }); 1005 1006 TEGL_ADD_API_CASE(query_string, "eglQueryString() negative tests", 1007 { 1008 TestLog& log = m_testCtx.getLog(); 1009 EGLDisplay display = getDisplay(); 1010 1011 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection"); 1012 1013 expectNull(eglQueryString(EGL_NO_DISPLAY, EGL_VENDOR)); 1014 expectError(EGL_BAD_DISPLAY); 1015 1016 expectNull(eglQueryString((EGLDisplay)-1, EGL_VENDOR)); 1017 expectError(EGL_BAD_DISPLAY); 1018 1019 log << TestLog::EndSection; 1020 1021 log << TestLog::Section("Test2", "EGL_BAD_PARAMETER is generated if name is not an accepted value"); 1022 1023 expectNull(eglQueryString(display, 0)); 1024 expectError(EGL_BAD_PARAMETER); 1025 expectNull(eglQueryString(display, -1)); 1026 expectError(EGL_BAD_PARAMETER); 1027 1028 log << TestLog::EndSection; 1029 }); 1030 1031 TEGL_ADD_API_CASE(query_surface, "eglQuerySurface() negative tests", 1032 { 1033 TestLog& log = m_testCtx.getLog(); 1034 EGLDisplay display = getDisplay(); 1035 EGLint value = 0; 1036 1037 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection"); 1038 1039 expectFalse(eglQuerySurface(EGL_NO_DISPLAY, DE_NULL, EGL_CONFIG_ID, &value)); 1040 expectError(EGL_BAD_DISPLAY); 1041 1042 expectFalse(eglQuerySurface((EGLDisplay)-1, DE_NULL, EGL_CONFIG_ID, &value)); 1043 expectError(EGL_BAD_DISPLAY); 1044 1045 log << TestLog::EndSection; 1046 1047 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface"); 1048 1049 expectFalse(eglQuerySurface(display, DE_NULL, EGL_CONFIG_ID, &value)); 1050 expectError(EGL_BAD_SURFACE); 1051 1052 expectFalse(eglQuerySurface(display, (EGLSurface)-1, EGL_CONFIG_ID, &value)); 1053 expectError(EGL_BAD_SURFACE); 1054 1055 log << TestLog::EndSection; 1056 1057 // Create pbuffer surface. 1058 EGLSurface surface = EGL_NO_SURFACE; 1059 { 1060 EGLConfig config; 1061 if (getConfig(&config, FilterList() << surfaceBits<EGL_PBUFFER_BIT>)) 1062 { 1063 surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib); 1064 expectError(EGL_SUCCESS); 1065 } 1066 else 1067 log << TestLog::Message << "// WARNING: No suitable config found, testing will be incomplete" << TestLog::EndMessage; 1068 } 1069 1070 log << TestLog::Section("Test3", "EGL_BAD_ATTRIBUTE is generated if attribute is not a valid surface attribute"); 1071 1072 if (surface) 1073 { 1074 expectFalse(eglQuerySurface(display, surface, 0, &value)); 1075 expectError(EGL_BAD_ATTRIBUTE); 1076 1077 expectFalse(eglQuerySurface(display, surface, -1, &value)); 1078 expectError(EGL_BAD_ATTRIBUTE); 1079 } 1080 1081 log << TestLog::EndSection; 1082 1083 if (surface) 1084 { 1085 eglDestroySurface(display, surface); 1086 expectError(EGL_SUCCESS); 1087 } 1088 }); 1089 1090 TEGL_ADD_API_CASE(release_tex_image, "eglReleaseTexImage() negative tests", 1091 { 1092 TestLog& log = m_testCtx.getLog(); 1093 EGLDisplay display = getDisplay(); 1094 1095 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection"); 1096 1097 expectFalse(eglReleaseTexImage(EGL_NO_DISPLAY, EGL_NO_SURFACE, EGL_BACK_BUFFER)); 1098 expectError(EGL_BAD_DISPLAY); 1099 1100 expectFalse(eglReleaseTexImage((EGLDisplay)-1, EGL_NO_SURFACE, EGL_BACK_BUFFER)); 1101 expectError(EGL_BAD_DISPLAY); 1102 1103 log << TestLog::EndSection; 1104 1105 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface"); 1106 1107 expectFalse(eglReleaseTexImage(display, EGL_NO_SURFACE, EGL_BACK_BUFFER)); 1108 expectError(EGL_BAD_SURFACE); 1109 1110 expectFalse(eglReleaseTexImage(display, (EGLSurface)-1, EGL_BACK_BUFFER)); 1111 expectError(EGL_BAD_SURFACE); 1112 1113 log << TestLog::EndSection; 1114 }); 1115 1116 TEGL_ADD_API_CASE(surface_attrib, "eglSurfaceAttrib() negative tests", 1117 { 1118 TestLog& log = m_testCtx.getLog(); 1119 EGLDisplay display = getDisplay(); 1120 1121 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection"); 1122 1123 expectFalse(eglSurfaceAttrib(EGL_NO_DISPLAY, DE_NULL, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED)); 1124 expectError(EGL_BAD_DISPLAY); 1125 1126 expectFalse(eglSurfaceAttrib((EGLDisplay)-1, DE_NULL, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED)); 1127 expectError(EGL_BAD_DISPLAY); 1128 1129 log << TestLog::EndSection; 1130 1131 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface"); 1132 1133 expectFalse(eglSurfaceAttrib(display, DE_NULL, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED)); 1134 expectError(EGL_BAD_SURFACE); 1135 1136 expectFalse(eglSurfaceAttrib(display, (EGLSurface)-1, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED)); 1137 expectError(EGL_BAD_SURFACE); 1138 1139 log << TestLog::EndSection; 1140 1141 { 1142 // Create pbuffer surface. 1143 EGLSurface surface = EGL_NO_SURFACE; 1144 { 1145 EGLConfig config; 1146 if (getConfig(&config, FilterList() << surfaceBits<EGL_PBUFFER_BIT>)) 1147 { 1148 surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib); 1149 expectError(EGL_SUCCESS); 1150 } 1151 else 1152 log << TestLog::Message << "// WARNING: No suitable config found, testing will be incomplete" << TestLog::EndMessage; 1153 } 1154 1155 log << TestLog::Section("Test3", "EGL_BAD_ATTRIBUTE is generated if attribute is not a valid surface attribute"); 1156 1157 if (surface) 1158 { 1159 expectFalse(eglSurfaceAttrib(display, surface, 0, 0)); 1160 expectError(EGL_BAD_ATTRIBUTE); 1161 1162 expectFalse(eglSurfaceAttrib(display, surface, -1, 0)); 1163 expectError(EGL_BAD_ATTRIBUTE); 1164 } 1165 1166 log << TestLog::EndSection; 1167 1168 if (surface) 1169 { 1170 eglDestroySurface(display, surface); 1171 expectError(EGL_SUCCESS); 1172 } 1173 } 1174 1175 { 1176 // Create pbuffer surface without EGL_MULTISAMPLE_RESOLVE_BOX_BIT. 1177 EGLSurface surface = EGL_NO_SURFACE; 1178 { 1179 EGLConfig config; 1180 if (getConfig(&config, FilterList() << surfaceBits<EGL_PBUFFER_BIT> << notSurfaceBits<EGL_MULTISAMPLE_RESOLVE_BOX_BIT>)) 1181 { 1182 surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib); 1183 expectError(EGL_SUCCESS); 1184 } 1185 else 1186 log << TestLog::Message << "// WARNING: No suitable config found, testing will be incomplete" << TestLog::EndMessage; 1187 } 1188 1189 log << TestLog::Section("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"); 1190 1191 if (surface) 1192 { 1193 expectFalse(eglSurfaceAttrib(display, surface, EGL_MULTISAMPLE_RESOLVE, EGL_MULTISAMPLE_RESOLVE_BOX)); 1194 expectError(EGL_BAD_MATCH); 1195 } 1196 1197 log << TestLog::EndSection; 1198 1199 if (surface) 1200 { 1201 eglDestroySurface(display, surface); 1202 expectError(EGL_SUCCESS); 1203 } 1204 } 1205 1206 { 1207 // Create pbuffer surface without EGL_SWAP_BEHAVIOR_PRESERVED_BIT. 1208 EGLSurface surface = EGL_NO_SURFACE; 1209 { 1210 EGLConfig config; 1211 if (getConfig(&config, FilterList() << surfaceBits<EGL_PBUFFER_BIT> << notSurfaceBits<EGL_SWAP_BEHAVIOR_PRESERVED_BIT>)) 1212 { 1213 surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib); 1214 expectError(EGL_SUCCESS); 1215 } 1216 else 1217 log << TestLog::Message << "// WARNING: No suitable config found, testing will be incomplete" << TestLog::EndMessage; 1218 } 1219 1220 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"); 1221 1222 if (surface) 1223 { 1224 expectFalse(eglSurfaceAttrib(display, surface, EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED)); 1225 expectError(EGL_BAD_MATCH); 1226 } 1227 1228 log << TestLog::EndSection; 1229 1230 if (surface) 1231 { 1232 eglDestroySurface(display, surface); 1233 expectError(EGL_SUCCESS); 1234 } 1235 } 1236 }); 1237 1238 TEGL_ADD_API_CASE(swap_buffers, "eglSwapBuffers() negative tests", 1239 { 1240 TestLog& log = m_testCtx.getLog(); 1241 EGLDisplay display = getDisplay(); 1242 1243 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection"); 1244 1245 expectFalse(eglSwapBuffers(EGL_NO_DISPLAY, DE_NULL)); 1246 expectError(EGL_BAD_DISPLAY); 1247 1248 expectFalse(eglSwapBuffers((EGLDisplay)-1, DE_NULL)); 1249 expectError(EGL_BAD_DISPLAY); 1250 1251 log << TestLog::EndSection; 1252 1253 log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface"); 1254 1255 expectFalse(eglSwapBuffers(display, DE_NULL)); 1256 expectError(EGL_BAD_SURFACE); 1257 1258 expectFalse(eglSwapBuffers(display, (EGLSurface)-1)); 1259 expectError(EGL_BAD_SURFACE); 1260 1261 log << TestLog::EndSection; 1262 }); 1263 1264 TEGL_ADD_API_CASE(swap_interval, "eglSwapInterval() negative tests", 1265 { 1266 TestLog& log = m_testCtx.getLog(); 1267 EGLDisplay display = getDisplay(); 1268 1269 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection"); 1270 1271 expectFalse(eglSwapInterval(EGL_NO_DISPLAY, 0)); 1272 expectError(EGL_BAD_DISPLAY); 1273 1274 expectFalse(eglSwapInterval((EGLDisplay)-1, 0)); 1275 expectError(EGL_BAD_DISPLAY); 1276 1277 log << TestLog::EndSection; 1278 1279 log << TestLog::Section("Test2", "EGL_BAD_CONTEXT is generated if there is no current context on the calling thread"); 1280 1281 expectFalse(eglSwapInterval(display, 0)); 1282 expectError(EGL_BAD_CONTEXT); 1283 1284 log << TestLog::EndSection; 1285 }); 1286 1287 TEGL_ADD_API_CASE(terminate, "eglTerminate() negative tests", 1288 { 1289 TestLog& log = m_testCtx.getLog(); 1290 1291 log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection"); 1292 1293 expectFalse(eglTerminate(EGL_NO_DISPLAY)); 1294 expectError(EGL_BAD_DISPLAY); 1295 1296 expectFalse(eglTerminate((EGLDisplay)-1)); 1297 expectError(EGL_BAD_DISPLAY); 1298 1299 log << TestLog::EndSection; 1300 }); 1301 1302 TEGL_ADD_API_CASE(wait_native, "eglWaitNative() negative tests", 1303 { 1304 TestLog& log = m_testCtx.getLog(); 1305 1306 log << TestLog::Section("Test1", "EGL_BAD_PARAMETER is generated if engine is not a recognized marking engine"); 1307 1308 expectFalse(eglWaitNative(-1)); 1309 expectError(EGL_BAD_PARAMETER); 1310 1311 log << TestLog::EndSection; 1312 }); 1313} 1314 1315} // egl 1316} // deqp 1317