<div dir="ltr">On 15 October 2013 17:32, Ian Romanick <span dir="ltr"><<a href="mailto:idr@freedesktop.org" target="_blank">idr@freedesktop.org</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: Ian Romanick <<a href="mailto:ian.d.romanick@intel.com">ian.d.romanick@intel.com</a>><br>
<br>
Create a new function, piglit_gl_process_args, that does the<br>
command-line parsing.  This happens after the test code between<br>
PIGLIT_GL_TEST_CONFIG_BEGIN and PIGLIT_GL_TEST_CONFIG_END.  By having an<br>
explicit function that does this, tests can call it inside the BEGIN/END<br>
block.  This may be useful for tests that expect certain arguments to be<br>
in specific positions.<br>
<br>
Signed-off-by: Ian Romanick <<a href="mailto:ian.d.romanick@intel.com">ian.d.romanick@intel.com</a>><br>
Cc: Chad Versace <<a href="mailto:chad.versace@linux.intel.com">chad.versace@linux.intel.com</a>><br></blockquote><div><br></div><div>I spent a while worrying about the fact that this change causes some tests to call piglit_gl_process_args() twice (once explicitly, and once implicitly from PIGLIT_GL_TEST_CONFIG_END).  Would you mind adding a note to the commit message explaining that piglit_gl_process_args() is idempotent (since it removes the args it processes), so that it's safe to call more than once from a single test?<br>
<br></div><div>With that change, this patch is:<br><br></div><div>Reviewed-by: Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>><br></div><div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

---<br>
 tests/texturing/shaders/texelFetch.c  | 10 ++++++----<br>
 tests/texturing/shaders/textureSize.c | 10 ++++++----<br>
 tests/util/piglit-framework-gl.c      | 24 ++++++++++++++----------<br>
 tests/util/piglit-framework-gl.h      | 10 +++++++---<br>
 4 files changed, 33 insertions(+), 21 deletions(-)<br>
<br>
diff --git a/tests/texturing/shaders/texelFetch.c b/tests/texturing/shaders/texelFetch.c<br>
index ebd48cd..bc6cc8f 100644<br>
--- a/tests/texturing/shaders/texelFetch.c<br>
+++ b/tests/texturing/shaders/texelFetch.c<br>
@@ -84,6 +84,12 @@ static enum shader_target test_stage = UNKNOWN;<br>
<br>
 PIGLIT_GL_TEST_CONFIG_BEGIN<br>
<br>
+       config.window_width = 900;<br>
+       config.window_height = 600;<br>
+       config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;<br>
+<br>
+       piglit_gl_process_args(&argc, argv, &config);<br>
+<br>
        parse_args(argc, argv);<br>
        if (test_stage == GS) {<br>
                config.supports_gl_compat_version = 32;<br>
@@ -93,10 +99,6 @@ PIGLIT_GL_TEST_CONFIG_BEGIN<br>
                config.supports_gl_core_version = 31;<br>
        }<br>
<br>
-       config.window_width = 900;<br>
-       config.window_height = 600;<br>
-       config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;<br>
-<br>
 PIGLIT_GL_TEST_CONFIG_END<br>
<br>
 #define MAX_LOD_OR_SAMPLES  10.0<br>
diff --git a/tests/texturing/shaders/textureSize.c b/tests/texturing/shaders/textureSize.c<br>
index f010d9c..ee64b07 100644<br>
--- a/tests/texturing/shaders/textureSize.c<br>
+++ b/tests/texturing/shaders/textureSize.c<br>
@@ -52,6 +52,12 @@ static enum shader_target test_stage = UNKNOWN;<br>
<br>
 PIGLIT_GL_TEST_CONFIG_BEGIN<br>
<br>
+       config.window_width = 150;<br>
+       config.window_height = 30;<br>
+       config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;<br>
+<br>
+       piglit_gl_process_args(&argc, argv, &config);<br>
+<br>
        parse_args(argc, argv);<br>
        if (test_stage == GS) {<br>
                config.supports_gl_compat_version = 32;<br>
@@ -61,10 +67,6 @@ PIGLIT_GL_TEST_CONFIG_BEGIN<br>
                config.supports_gl_core_version = 31;<br>
        }<br>
<br>
-       config.window_width = 150;<br>
-       config.window_height = 30;<br>
-       config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;<br>
-<br>
 PIGLIT_GL_TEST_CONFIG_END<br>
<br>
 static int lod_location;<br>
diff --git a/tests/util/piglit-framework-gl.c b/tests/util/piglit-framework-gl.c<br>
index 2a315be..dd2e6a5 100644<br>
--- a/tests/util/piglit-framework-gl.c<br>
+++ b/tests/util/piglit-framework-gl.c<br>
@@ -43,18 +43,9 @@ static void<br>
 process_args(int *argc, char *argv[], unsigned *force_samples);<br>
<br>
 void<br>
-piglit_gl_test_config_init(int *argc, char *argv[],<br>
-                          struct piglit_gl_test_config *config)<br>
+piglit_gl_test_config_init(struct piglit_gl_test_config *config)<br>
 {<br>
-       unsigned force_samples = 0;<br>
-<br>
        memset(config, 0, sizeof(*config));<br>
-<br>
-       process_args(argc, argv, &force_samples);<br>
-<br>
-       if (force_samples > 1)<br>
-               config->window_samples = force_samples;<br>
-<br>
 }<br>
<br>
 static void<br>
@@ -125,6 +116,19 @@ process_args(int *argc, char *argv[], unsigned *force_samples)<br>
 }<br>
<br>
 void<br>
+piglit_gl_process_args(int *argc, char *argv[],<br>
+                      struct piglit_gl_test_config *config)<br>
+{<br>
+       unsigned force_samples = 0;<br>
+<br>
+       process_args(argc, argv, &force_samples);<br>
+<br>
+       if (force_samples > 1)<br>
+               config->window_samples = force_samples;<br>
+<br>
+}<br>
+<br>
+void<br>
 piglit_gl_test_run(int argc, char *argv[],<br>
                   const struct piglit_gl_test_config *config)<br>
 {<br>
diff --git a/tests/util/piglit-framework-gl.h b/tests/util/piglit-framework-gl.h<br>
index 7520f38..fcc1594 100644<br>
--- a/tests/util/piglit-framework-gl.h<br>
+++ b/tests/util/piglit-framework-gl.h<br>
@@ -175,8 +175,11 @@ struct piglit_gl_test_config {<br>
  * from command line arguments.<br>
  */<br>
 void<br>
-piglit_gl_test_config_init(int *argc, char *argv[],<br>
-                          struct piglit_gl_test_config *config);<br>
+piglit_gl_test_config_init(struct piglit_gl_test_config *config);<br>
+<br>
+void<br>
+piglit_gl_process_args(int *argc, char *argv[],<br>
+                      struct piglit_gl_test_config *config);<br>
<br>
 /**<br>
  * Run the OpenGL test described by @a config. Does not return.<br>
@@ -210,7 +213,7 @@ piglit_gl_test_run(int argc, char *argv[],<br>
         {                                                                    \<br>
                 struct piglit_gl_test_config config;                         \<br>
                                                                              \<br>
-                piglit_gl_test_config_init(&argc, argv, &config);            \<br>
+                piglit_gl_test_config_init(&config);                         \<br>
                                                                              \<br>
                 config.init = piglit_init;                                   \<br>
                 config.display = piglit_display;                             \<br>
@@ -230,6 +233,7 @@ piglit_gl_test_run(int argc, char *argv[],<br>
 #define PIGLIT_GL_TEST_CONFIG_END                                            \<br>
                 }                                                            \<br>
                                                                              \<br>
+                piglit_gl_process_args(&argc, argv, &config);                \<br>
                 piglit_gl_test_run(argc, argv, &config);                     \<br>
                                                                              \<br>
                 assert(false);                                               \<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.8.1.4<br>
<br>
_______________________________________________<br>
Piglit mailing list<br>
<a href="mailto:Piglit@lists.freedesktop.org">Piglit@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/piglit" target="_blank">http://lists.freedesktop.org/mailman/listinfo/piglit</a><br>
</font></span></blockquote></div><br></div></div>