[Piglit] [PATCH 3/3] framework: parse piglit core args during piglit_gl_test_config_init()

Jordan Justen jljusten at gmail.com
Sat Jul 27 11:38:05 PDT 2013


Series
Reviewed-by: Jordan Justen <jordan.l.justen at intel.com>

On Fri, Jul 26, 2013 at 1:11 PM, Paul Berry <stereotype441 at gmail.com> wrote:
> This makes it safe to examine argc and argv between
> PIGLIT_GL_TEST_CONFIG_BEGIN and PIGLIT_GL_TEST_CONFIG_END, since
> piglit fragmework arguments have already been stripped away.
>
> That in turn means that the following tests can use
> PIGLIT_GL_TEST_CONFIG_{BEGIN,END} instead of having to declare their
> own main() functions:
>
> - spec/arb_texture_buffer_object/formats.c
> - spec/gl-3.0/required-renderbuffer-attachment-formats.c
> - spec/gl-3.0/required-sized-texture-formats.c
> - spec/gl-3.0/required-texture-attachment-formats.c
> - spec/gles-3.0/oes_compressed_etc2_texture-miptree.c
> ---
>  tests/spec/arb_texture_buffer_object/formats.c     | 18 ++------------
>  .../required-renderbuffer-attachment-formats.c     | 15 ++----------
>  tests/spec/gl-3.0/required-sized-texture-formats.c | 15 ++----------
>  .../gl-3.0/required-texture-attachment-formats.c   | 15 ++----------
>  .../gles-3.0/oes_compressed_etc2_texture-miptree.c | 16 ++-----------
>  tests/util/piglit-framework-gl.c                   | 28 ++++++++++++----------
>  tests/util/piglit-framework-gl.h                   |  8 ++++---
>  tests/util/sized-internalformats.c                 |  2 --
>  8 files changed, 31 insertions(+), 86 deletions(-)
>
> diff --git a/tests/spec/arb_texture_buffer_object/formats.c b/tests/spec/arb_texture_buffer_object/formats.c
> index 0dfec7c..568951c 100644
> --- a/tests/spec/arb_texture_buffer_object/formats.c
> +++ b/tests/spec/arb_texture_buffer_object/formats.c
> @@ -715,11 +715,7 @@ find_arg(int argc, char *argv[], const char *str)
>         return false;
>  }
>
> -int
> -main(int argc, char *argv[])
> -{
> -       struct piglit_gl_test_config config;
> -
> +PIGLIT_GL_TEST_CONFIG_BEGIN
>         test_vs = find_arg(argc, argv, "vs");
>         if (!test_vs && !find_arg(argc, argv, "fs"))
>                 usage(argv[0]);
> @@ -728,11 +724,6 @@ main(int argc, char *argv[])
>         if (!test_arb && !find_arg(argc, argv, "core"))
>                 usage(argv[0]);
>
> -       piglit_gl_test_config_init(&config);
> -
> -       config.init = piglit_init;
> -       config.display = piglit_display;
> -
>         if (test_arb)
>                 config.supports_gl_compat_version = 10;
>         else
> @@ -741,9 +732,4 @@ main(int argc, char *argv[])
>         config.window_width = 200;
>         config.window_height = 500;
>         config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
> -
> -       piglit_gl_test_run(argc, argv, &config);
> -
> -       assert(false);
> -       return 0;
> -}
> +PIGLIT_GL_TEST_CONFIG_END
> diff --git a/tests/spec/gl-3.0/required-renderbuffer-attachment-formats.c b/tests/spec/gl-3.0/required-renderbuffer-attachment-formats.c
> index 6a867a7..5236a3f 100644
> --- a/tests/spec/gl-3.0/required-renderbuffer-attachment-formats.c
> +++ b/tests/spec/gl-3.0/required-renderbuffer-attachment-formats.c
> @@ -133,19 +133,8 @@ piglit_init(int argc, char **argv)
>         piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
>  }
>
> -int
> -main(int argc, char *argv[])
> -{
> -       struct piglit_gl_test_config config;
> -
> +PIGLIT_GL_TEST_CONFIG_BEGIN
>         setup_required_size_test(argc, argv, &config);
>         target_version = MAX2(config.supports_gl_compat_version,
>                               config.supports_gl_core_version);
> -       config.init = piglit_init;
> -       config.display = piglit_display;
> -
> -       piglit_gl_test_run(argc, argv, &config);
> -
> -       /* UNREACHED */
> -       return 0;
> -}
> +PIGLIT_GL_TEST_CONFIG_END
> diff --git a/tests/spec/gl-3.0/required-sized-texture-formats.c b/tests/spec/gl-3.0/required-sized-texture-formats.c
> index a3524e7..79ea5b1 100644
> --- a/tests/spec/gl-3.0/required-sized-texture-formats.c
> +++ b/tests/spec/gl-3.0/required-sized-texture-formats.c
> @@ -234,19 +234,8 @@ piglit_init(int argc, char **argv)
>         piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
>  }
>
> -int
> -main(int argc, char *argv[])
> -{
> -       struct piglit_gl_test_config config;
> -
> +PIGLIT_GL_TEST_CONFIG_BEGIN
>         setup_required_size_test(argc, argv, &config);
>         target_version = MAX2(config.supports_gl_compat_version,
>                               config.supports_gl_core_version);
> -       config.init = piglit_init;
> -       config.display = piglit_display;
> -
> -       piglit_gl_test_run(argc, argv, &config);
> -
> -       /* UNREACHED */
> -       return 0;
> -}
> +PIGLIT_GL_TEST_CONFIG_END
> diff --git a/tests/spec/gl-3.0/required-texture-attachment-formats.c b/tests/spec/gl-3.0/required-texture-attachment-formats.c
> index 11e20ac..9c9b234 100644
> --- a/tests/spec/gl-3.0/required-texture-attachment-formats.c
> +++ b/tests/spec/gl-3.0/required-texture-attachment-formats.c
> @@ -143,19 +143,8 @@ piglit_init(int argc, char **argv)
>         piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
>  }
>
> -int
> -main(int argc, char *argv[])
> -{
> -       struct piglit_gl_test_config config;
> -
> +PIGLIT_GL_TEST_CONFIG_BEGIN
>         setup_required_size_test(argc, argv, &config);
>         target_version = MAX2(config.supports_gl_compat_version,
>                               config.supports_gl_core_version);
> -       config.init = piglit_init;
> -       config.display = piglit_display;
> -
> -       piglit_gl_test_run(argc, argv, &config);
> -
> -       /* UNREACHED */
> -       return 0;
> -}
> +PIGLIT_GL_TEST_CONFIG_END
> diff --git a/tests/spec/gles-3.0/oes_compressed_etc2_texture-miptree.c b/tests/spec/gles-3.0/oes_compressed_etc2_texture-miptree.c
> index 8881432..79a4c1f 100644
> --- a/tests/spec/gles-3.0/oes_compressed_etc2_texture-miptree.c
> +++ b/tests/spec/gles-3.0/oes_compressed_etc2_texture-miptree.c
> @@ -314,10 +314,7 @@ piglit_display(void)
>         return pass ? PIGLIT_PASS : PIGLIT_FAIL;
>  }
>
> -int
> -main(int argc, char *argv[])
> -{
> -       struct piglit_gl_test_config config;
> +PIGLIT_GL_TEST_CONFIG_BEGIN
>         bool test_compat = true;
>
>  #if defined(PIGLIT_USE_OPENGL)
> @@ -334,10 +331,6 @@ main(int argc, char *argv[])
>                 print_usage_and_exit(argv[0]);
>  #endif
>
> -       piglit_gl_test_config_init(&config);
> -       config.init = piglit_init;
> -       config.display = piglit_display;
> -
>         if (test_compat)
>                 config.supports_gl_compat_version = 10;
>         else
> @@ -348,9 +341,4 @@ main(int argc, char *argv[])
>         config.window_width = 150;
>         config.window_height = 150;
>         config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
> -
> -       piglit_gl_test_run(argc, argv, &config);
> -
> -       assert(false);
> -       return 0;
> -}
> +PIGLIT_GL_TEST_CONFIG_END
> diff --git a/tests/util/piglit-framework-gl.c b/tests/util/piglit-framework-gl.c
> index ece5968..46325eb 100644
> --- a/tests/util/piglit-framework-gl.c
> +++ b/tests/util/piglit-framework-gl.c
> @@ -39,10 +39,22 @@ unsigned piglit_winsys_fbo = 0;
>  int piglit_width;
>  int piglit_height;
>
> +static void
> +process_args(int *argc, char *argv[], unsigned *force_samples);
> +
>  void
> -piglit_gl_test_config_init(struct piglit_gl_test_config *config)
> +piglit_gl_test_config_init(int *argc, char *argv[],
> +                          struct piglit_gl_test_config *config)
>  {
> +       unsigned force_samples = 0;
> +
>         memset(config, 0, sizeof(*config));
> +
> +       process_args(argc, argv, &force_samples);
> +
> +       if (force_samples > 1)
> +               config->window_samples = force_samples;
> +
>  }
>
>  static void
> @@ -116,18 +128,10 @@ void
>  piglit_gl_test_run(int argc, char *argv[],
>                    const struct piglit_gl_test_config *config)
>  {
> -       struct piglit_gl_test_config conf = *config;
> -       unsigned force_samples = 0;
> -
> -       process_args(&argc, argv, &force_samples);
> -
> -       if (force_samples > 1)
> -               conf.window_samples = force_samples;
> -
> -       piglit_width = conf.window_width;
> -       piglit_height = conf.window_height;
> +       piglit_width = config->window_width;
> +       piglit_height = config->window_height;
>
> -       gl_fw = piglit_gl_framework_factory(&conf);
> +       gl_fw = piglit_gl_framework_factory(config);
>         if (gl_fw == NULL) {
>                 printf("piglit: error: failed to create "
>                        "piglit_gl_framework\n");
> diff --git a/tests/util/piglit-framework-gl.h b/tests/util/piglit-framework-gl.h
> index e65c989..f8f73ad 100644
> --- a/tests/util/piglit-framework-gl.h
> +++ b/tests/util/piglit-framework-gl.h
> @@ -171,10 +171,12 @@ struct piglit_gl_test_config {
>  };
>
>  /**
> - * Initialize @a config with default values.
> + * Initialize @a config with default values, some of which may come
> + * from command line arguments.
>   */
>  void
> -piglit_gl_test_config_init(struct piglit_gl_test_config *config);
> +piglit_gl_test_config_init(int *argc, char *argv[],
> +                          struct piglit_gl_test_config *config);
>
>  /**
>   * Run the OpenGL test described by @a config. Does not return.
> @@ -208,7 +210,7 @@ piglit_gl_test_run(int argc, char *argv[],
>          {                                                                    \
>                  struct piglit_gl_test_config config;                         \
>                                                                               \
> -                piglit_gl_test_config_init(&config);                         \
> +                piglit_gl_test_config_init(&argc, argv, &config);            \
>                                                                               \
>                  config.init = piglit_init;                                   \
>                  config.display = piglit_display;                             \
> diff --git a/tests/util/sized-internalformats.c b/tests/util/sized-internalformats.c
> index 626d215..ae949c7 100644
> --- a/tests/util/sized-internalformats.c
> +++ b/tests/util/sized-internalformats.c
> @@ -385,8 +385,6 @@ setup_required_size_test(int argc, char **argv,
>         if (argc < 2)
>                 usage(argv[0]);
>
> -       piglit_gl_test_config_init(config);
> -
>         target_version = strtol(argv[1], NULL, 0);
>
>         switch (target_version) {
> --
> 1.8.3.4
>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit


More information about the Piglit mailing list