From deac154a024140d8c681dcc182cacb6191f95544 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mika=20Isoj=C3=A4rvi?= Date: Wed, 18 Mar 2015 16:25:07 -0700 Subject: [PATCH] Fix negative EGL tests expecting EGL_BAD_ATTRIBUTE. Fix negative eglCreatePbufferSurface() tests that expected EGL_BAD_ATTRIBUTE when EGL_WIDTH or EGL_HEIGHT was negative to expect EGL_BAD_PARAMETER. Bug: 19822069 Change-Id: Ifc0b624b7225a3d657a547423b9263f354af77a0 --- modules/egl/teglApiCase.cpp | 12 ++++++------ modules/egl/teglNegativeApiTests.cpp | 24 ++++++++++++++++++++---- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/modules/egl/teglApiCase.cpp b/modules/egl/teglApiCase.cpp index 3e34e56..e0710bc 100644 --- a/modules/egl/teglApiCase.cpp +++ b/modules/egl/teglApiCase.cpp @@ -87,7 +87,7 @@ void ApiCase::expectError (EGLenum expected) EGLenum err = m_eglTestCtx.getLibrary().getError(); if (err != expected) { - m_testCtx.getLog() << TestLog::Message << "// ERROR: expected " << eglu::getErrorStr(expected) << TestLog::EndMessage; + m_testCtx.getLog() << TestLog::Message << "// ERROR expected: " << eglu::getErrorStr(expected) << ", Got: " << eglu::getErrorStr(err) << TestLog::EndMessage; if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS) m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid error"); } @@ -97,7 +97,7 @@ void ApiCase::expectBoolean (EGLBoolean expected, EGLBoolean got) { if (expected != got) { - m_testCtx.getLog() << TestLog::Message << "// ERROR: expected " << (expected ? "EGL_TRUE" : "EGL_FALSE") << TestLog::EndMessage; + m_testCtx.getLog() << TestLog::Message << "// ERROR expected: " << eglu::getBooleanStr(expected) << ", Got: " << eglu::getBooleanStr(got) << TestLog::EndMessage; if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS) m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid value"); } @@ -107,7 +107,7 @@ void ApiCase::expectNoContext (EGLContext got) { if (got != EGL_NO_CONTEXT) { - m_testCtx.getLog() << TestLog::Message << "// ERROR: expected EGL_NO_CONTEXT" << TestLog::EndMessage; + m_testCtx.getLog() << TestLog::Message << "// ERROR expected: EGL_NO_CONTEXT" << TestLog::EndMessage; if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS) m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid value"); eglDestroyContext(getDisplay(), got); @@ -118,7 +118,7 @@ void ApiCase::expectNoSurface (EGLSurface got) { if (got != EGL_NO_CONTEXT) { - m_testCtx.getLog() << TestLog::Message << "// ERROR: expected EGL_NO_SURFACE" << TestLog::EndMessage; + m_testCtx.getLog() << TestLog::Message << "// ERROR expected: EGL_NO_SURFACE" << TestLog::EndMessage; if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS) m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid value"); eglDestroySurface(getDisplay(), got); @@ -129,7 +129,7 @@ void ApiCase::expectNoDisplay (EGLDisplay got) { if (got != EGL_NO_CONTEXT) { - m_testCtx.getLog() << TestLog::Message << "// ERROR: expected EGL_NO_DISPLAY" << TestLog::EndMessage; + m_testCtx.getLog() << TestLog::Message << "// ERROR expected: EGL_NO_DISPLAY" << TestLog::EndMessage; if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS) m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid value"); } @@ -139,7 +139,7 @@ void ApiCase::expectNull (const void* got) { if (got != EGL_NO_CONTEXT) { - m_testCtx.getLog() << TestLog::Message << "// ERROR: expected NULL" << TestLog::EndMessage; + m_testCtx.getLog() << TestLog::Message << "// ERROR expected: NULL" << TestLog::EndMessage; if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS) m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid value"); } diff --git a/modules/egl/teglNegativeApiTests.cpp b/modules/egl/teglNegativeApiTests.cpp index 3961eaa..fa8b1f8 100755 --- a/modules/egl/teglNegativeApiTests.cpp +++ b/modules/egl/teglNegativeApiTests.cpp @@ -475,14 +475,13 @@ void NegativeApiTests::init (void) static const EGLint s_invalidGenericPbufferAttrib0[] = { 0, EGL_NONE }; static const EGLint s_invalidGenericPbufferAttrib1[] = { (EGLint)0xffffffff }; - static const EGLint s_invalidGenericPbufferAttrib2[] = { EGL_WIDTH, 64, EGL_HEIGHT, -1, EGL_NONE }; - static const EGLint s_invalidGenericPbufferAttrib3[] = { EGL_WIDTH, -1, EGL_HEIGHT, 64, EGL_NONE }; + static const EGLint s_negativeWidthPbufferAttrib[] = { EGL_WIDTH, -1, EGL_HEIGHT, 64, EGL_NONE }; + static const EGLint s_negativeHeightPbufferAttrib[] = { EGL_WIDTH, 64, EGL_HEIGHT, -1, EGL_NONE }; + static const EGLint s_negativeWidthAndHeightPbufferAttrib[] = { EGL_WIDTH, -1, EGL_HEIGHT, -1, EGL_NONE }; static const EGLint* s_invalidGenericPbufferAttribs[] = { s_invalidGenericPbufferAttrib0, s_invalidGenericPbufferAttrib1, - s_invalidGenericPbufferAttrib2, - s_invalidGenericPbufferAttrib3 }; static const EGLint s_invalidNoEsPbufferAttrib0[] = { EGL_MIPMAP_TEXTURE, EGL_TRUE, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE }; @@ -602,6 +601,23 @@ void NegativeApiTests::init (void) } log << TestLog::EndSection; + + log << TestLog::Section("Test8", "EGL_BAD_PARAMETER is generated if EGL_WIDTH or EGL_HEIGHT is negative"); + + if (getConfig(&genericConfig, FilterList() << surfaceBits)) + { + expectNoSurface(eglCreatePbufferSurface(display, genericConfig, s_negativeWidthPbufferAttrib)); + expectError(EGL_BAD_PARAMETER); + + expectNoSurface(eglCreatePbufferSurface(display, genericConfig, s_negativeHeightPbufferAttrib)); + expectError(EGL_BAD_PARAMETER); + + expectNoSurface(eglCreatePbufferSurface(display, genericConfig, s_negativeWidthAndHeightPbufferAttrib)); + expectError(EGL_BAD_PARAMETER); + } + + log << TestLog::EndSection; + }); TEGL_ADD_API_CASE(create_pixmap_surface, "eglCreatePixmapSurface() negative tests", -- 2.7.4