Fix for the string query tests on desktop GL
authorTapani Pälli <tapani.palli@intel.com>
Fri, 28 Oct 2022 11:22:16 +0000 (14:22 +0300)
committerMatthew Netsch <quic_mnetsch@quicinc.com>
Fri, 18 Nov 2022 00:07:04 +0000 (00:07 +0000)
Affects:
dEQP*functional.state_query.string.*

Components: OpenGL
VK-GL-CTS issue: 3761

Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Change-Id: I1b2a81a54f048bea057a32f3426dc4af02bd54d7

modules/gles3/functional/es3fStringQueryTests.cpp

index ea3a5ea..9fd21a9 100644 (file)
@@ -68,8 +68,10 @@ void StringQueryTests::init (void)
        });
        ES3F_ADD_API_CASE(version, "VERSION",
        {
-               const char* string                              = (const char*)glGetString(GL_VERSION);
-               const char      referenceString[]       = "OpenGL ES 3.";
+               bool isES = glu::isContextTypeES(m_context.getRenderContext().getType());
+
+               const char* string              = (const char*)glGetString(GL_VERSION);
+               const char *referenceString     = isES ? "OpenGL ES 3." : "4.";
 
                if (string == NULL)
                        TCU_FAIL("Got invalid string");
@@ -85,8 +87,12 @@ void StringQueryTests::init (void)
                        GLint           stateVersionMinor       = 0;
 
                        std::istringstream versionStream(string);
-                       versionStream >> tmpString;                     // OpenGL
-                       versionStream >> tmpString;                     // ES
+
+                       if (isES) {
+                               versionStream >> tmpString;                     // OpenGL
+                               versionStream >> tmpString;                     // ES
+                       }
+
                        versionStream >> glMajor;                       // 3
                        versionStream >> std::noskipws;
                        versionStream >> versionDelimiter;      // .
@@ -106,8 +112,10 @@ void StringQueryTests::init (void)
        });
        ES3F_ADD_API_CASE(shading_language_version, "SHADING_LANGUAGE_VERSION",
        {
-               const char* string                              = (const char*)glGetString(GL_SHADING_LANGUAGE_VERSION);
-               const char      referenceString[]       = "OpenGL ES GLSL ES ";
+               bool isES = glu::isContextTypeES(m_context.getRenderContext().getType());
+
+               const char* string              = (const char*)glGetString(GL_SHADING_LANGUAGE_VERSION);
+               const char *referenceString     = isES ? "OpenGL ES GLSL ES " : "4.";
 
                if (string == NULL)
                        TCU_FAIL("Got invalid string");
@@ -124,10 +132,14 @@ void StringQueryTests::init (void)
                        bool            digitsAreValid;
 
                        std::istringstream versionStream(string);
-                       versionStream >> tmpString;                     // OpenGL
-                       versionStream >> tmpString;                     // ES
-                       versionStream >> tmpString;                     // GLSL
-                       versionStream >> tmpString;                     // ES
+
+                       if (isES) {
+                               versionStream >> tmpString;                     // OpenGL
+                               versionStream >> tmpString;                     // ES
+                               versionStream >> tmpString;                     // GLSL
+                               versionStream >> tmpString;                     // ES
+                       }
+
                        versionStream >> glslMajor;                     // x
                        versionStream >> std::noskipws;
                        versionStream >> versionDelimiter;      // .
@@ -144,8 +156,19 @@ void StringQueryTests::init (void)
        ES3F_ADD_API_CASE(extensions, "EXTENSIONS",
        {
                const char* extensions_cstring = (const char*)glGetString(GL_EXTENSIONS);
-               if (extensions_cstring == NULL)
+               if (extensions_cstring == NULL) {
+                       bool isES = glu::isContextTypeES(m_context.getRenderContext().getType());
+
+                       // GL_EXTENSIONS has been deprecated on desktop GL
+                       if (!isES) {
+                               m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Got NULL string for deprecated enum");
+                               expectError(GL_INVALID_ENUM);
+                               return;
+                       }
+
                        m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid string");
+                       return;
+                }
 
                // split extensions_string at ' '