[Piglit] [PATCH v3 4/5] Fix too-specific GL version checks in glean
Paul Berry
stereotype441 at gmail.com
Thu Oct 13 13:45:36 PDT 2011
This patch fixes several version checks in glean that are too specific
(e.g. checking that the GL version is 2.x or 3.x when the intent is to
make sure the GL version is >= 2.0).
We now perform the version check using the piglit-util functions
piglit_is_gles() and piglit_get_gl_version() rather than manually
inspecting the GL_VERSION string, so this makes the glean tests depend
on the piglitutil library.
---
tests/glean/CMakeLists.gl.txt | 2 ++
tests/glean/tapi2.cpp | 4 ++--
tests/glean/tshaderapi.cpp | 8 +++-----
tests/glean/tstencil2.cpp | 12 +++---------
tests/glean/ttexunits.cpp | 9 ++++-----
tests/glean/tvertarraybgra.cpp | 4 ++--
6 files changed, 16 insertions(+), 23 deletions(-)
diff --git a/tests/glean/CMakeLists.gl.txt b/tests/glean/CMakeLists.gl.txt
index 04081a9..9a9fa36 100644
--- a/tests/glean/CMakeLists.gl.txt
+++ b/tests/glean/CMakeLists.gl.txt
@@ -12,6 +12,7 @@ include_directories(
${GLEXT_INCLUDE_DIR}
${OPENGL_INCLUDE_PATH}
${TIFF_INCLUDE_DIR}
+ ${piglit_SOURCE_DIR}/tests/util
)
add_executable (glean
@@ -94,4 +95,5 @@ target_link_libraries (glean
${X11_X11_LIB}
${TIFF_LIBRARY}
${CARBON_LIBRARY}
+ piglitutil
)
diff --git a/tests/glean/tapi2.cpp b/tests/glean/tapi2.cpp
index f180bc3..33eda25 100644
--- a/tests/glean/tapi2.cpp
+++ b/tests/glean/tapi2.cpp
@@ -36,6 +36,7 @@
#include <cassert>
#include <math.h>
#include "tapi2.h"
+#include "piglit-util.h"
namespace GLEAN {
@@ -181,8 +182,7 @@ bool
API2Test::setup(void)
{
// check that we have OpenGL 2.0
- const char *version = (const char *) glGetString(GL_VERSION);
- if (version[0] != '2' || version[1] != '.') {
+ if (piglit_is_gles() || piglit_get_gl_version() < 20) {
//env->log << "OpenGL 2.0 not supported\n";
return false;
}
diff --git a/tests/glean/tshaderapi.cpp b/tests/glean/tshaderapi.cpp
index 59c3efb..31ef9e6 100644
--- a/tests/glean/tshaderapi.cpp
+++ b/tests/glean/tshaderapi.cpp
@@ -36,6 +36,7 @@
#include "rand.h"
#include "timer.h"
#include "image.h"
+#include "piglit-util.h"
namespace GLEAN {
@@ -573,15 +574,12 @@ ShaderAPIResult::getresults(istream &s)
bool
ShaderAPITest::isApplicable() const
{
- const char *version = (const char *) glGetString(GL_VERSION);
- if (strncmp(version, "2.0", 3) == 0 ||
- strncmp(version, "2.1", 3) == 0 ||
- strncmp(version, "3.0", 3) == 0) {
+ if (!piglit_is_gles() && piglit_get_gl_version() >= 20) {
return true;
}
else {
env->log << name
- << ": skipped. Requires GL 2.0, 2.1 or 3.0.\n";
+ << ": skipped. Requires GL >= 2.0.\n";
return false;
}
}
diff --git a/tests/glean/tstencil2.cpp b/tests/glean/tstencil2.cpp
index d0c783a..e0ff0ae 100644
--- a/tests/glean/tstencil2.cpp
+++ b/tests/glean/tstencil2.cpp
@@ -42,6 +42,7 @@
#include <cassert>
#include <cstring>
#include "tstencil2.h"
+#include "piglit-util.h"
namespace GLEAN {
@@ -111,20 +112,13 @@ Stencil2Test::have_EXT_stencil_two_side(void) const
bool
Stencil2Test::have_GL2_stencil_two_side(void) const
{
- const char *version = (const char *) glGetString(GL_VERSION);
- if (strncmp(version, "2.", 2) == 0 ||
- strncmp(version, "3.0", 3) == 0) {
- return true;
- }
- return false;
+ return !piglit_is_gles() && piglit_get_gl_version() >= 20;
}
bool
Stencil2Test::have_stencil_wrap(void) const
{
- const char *version = (const char *) glGetString(GL_VERSION);
- if (strncmp(version, "2.", 2) == 0 ||
- strncmp(version, "3.0", 3) == 0) {
+ if (!piglit_is_gles() && piglit_get_gl_version() >= 20) {
return true;
}
else if (GLUtils::haveExtension("GL_EXT_stencil_wrap")) {
diff --git a/tests/glean/ttexunits.cpp b/tests/glean/ttexunits.cpp
index 309f4be..4a0bf39 100644
--- a/tests/glean/ttexunits.cpp
+++ b/tests/glean/ttexunits.cpp
@@ -36,6 +36,7 @@
#include <cassert>
#include <math.h>
#include "ttexunits.h"
+#include "piglit-util.h"
namespace GLEAN {
@@ -69,11 +70,9 @@ TexUnitsTest::reportFailure(const char *msg, GLint unit) const
bool
TexUnitsTest::setup(void)
{
- // check that we have OpenGL 2.x or 3.x
- const char *verString = (const char *) glGetString(GL_VERSION);
-
- if (verString[0] != '2' && verString[0] != '3') {
- env->log << "OpenGL 2.x or 3.x not supported\n";
+ // check that we have at least OpenGL 2.0
+ if (piglit_is_gles() || piglit_get_gl_version() < 20) {
+ env->log << "OpenGL >= 2.0 not supported\n";
return false;
}
diff --git a/tests/glean/tvertarraybgra.cpp b/tests/glean/tvertarraybgra.cpp
index fede919..a3b6632 100644
--- a/tests/glean/tvertarraybgra.cpp
+++ b/tests/glean/tvertarraybgra.cpp
@@ -42,6 +42,7 @@
#include "rand.h"
#include "timer.h"
#include "image.h"
+#include "piglit-util.h"
namespace GLEAN {
@@ -70,8 +71,7 @@ VertArrayBGRATest::testAPI(void)
// Get glVertexAttrib() function
PFNGLVERTEXATTRIBPOINTERARBPROC VertexAttribPointer = NULL;
- const char *version = (const char *) glGetString(GL_VERSION);
- if (version[0] == '2') {
+ if (!piglit_is_gles() && piglit_get_gl_version() >= 20) {
VertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERARBPROC)
GLUtils::getProcAddress("glVertexAttribPointer");
}
--
1.7.6.4
More information about the Piglit
mailing list