[Piglit] [PATCH v2 1/2] Add a piglit_require_GL_version() function.
Brian Paul
brian.e.paul at gmail.com
Sat Oct 8 06:49:02 PDT 2011
On Fri, Oct 7, 2011 at 6:28 PM, Paul Berry <stereotype441 at gmail.com> wrote:
> ---
> tests/util/piglit-util.c | 12 ++++++++++++
> tests/util/piglit-util.h | 1 +
> 2 files changed, 13 insertions(+), 0 deletions(-)
>
> diff --git a/tests/util/piglit-util.c b/tests/util/piglit-util.c
> index 358b0dc..b8a0219 100644
> --- a/tests/util/piglit-util.c
> +++ b/tests/util/piglit-util.c
> @@ -108,6 +108,18 @@ bool piglit_is_extension_supported(const char *name)
> return found;
> }
>
> +void piglit_require_GL_version(double required_version)
> +{
> + double gl_version = strtod((char *) glGetString(GL_VERSION), NULL);
I don't think we can use strtod(). The OpenGL version string always
uses '.' while strtod()'s decimal point character is local-dependent.
I think we could get by with something like
const GLUbyte *verStr = glGetString(GL_VERSION);
int version = verStr[0] * 10 + verStr[2];
BTW, I think a pigilt_get_gl_version() function would be useful too.
> + /* Allow some slop in case of rounding errors */
> + if (gl_version < required_version - 1.0e-5) {
> + printf("Test requires GL version %g\n", required_version);
> + piglit_report_result(PIGLIT_SKIP);
> + exit(1);
> + }
> +}
> +
> void piglit_require_extension(const char *name)
> {
> if (!piglit_is_extension_supported(name)) {
> diff --git a/tests/util/piglit-util.h b/tests/util/piglit-util.h
> index 9c3858b..a61ce91 100644
> --- a/tests/util/piglit-util.h
> +++ b/tests/util/piglit-util.h
> @@ -130,6 +130,7 @@ void piglit_check_gl_error(GLenum expected_error, enum piglit_result result);
>
> int FindLine(const char *program, int position);
> void piglit_report_result(enum piglit_result result);
> +void piglit_require_GL_version(double required_version);
> void piglit_require_extension(const char *name);
> void piglit_require_not_extension(const char *name);
> int piglit_probe_pixel_rgb_silent(int x, int y, const float* expected, float *out_probe);
-Brian
More information about the Piglit
mailing list