[Piglit] [PATCH 3/4] util: Add a -list-subtests option that will list all the subtests
Ian Romanick
idr at freedesktop.org
Fri Oct 4 18:11:00 PDT 2013
From: Ian Romanick <ian.d.romanick at intel.com>
This required some ugly hacking about to get the list of subtests to
process_args. Suggestions?
The utility is that all.tests can do 'sometest -list-subtests' to
automatically get the list of subtests to run. Since the syntax for
selecting subtests is regularized, this works quite well.
Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
Cc: Chad Versace <chad.versace at linux.intel.com>
---
tests/util/piglit-framework-gl.c | 14 +++++++++++++-
tests/util/piglit-framework-gl.h | 18 ++++++++++++++++--
2 files changed, 29 insertions(+), 3 deletions(-)
diff --git a/tests/util/piglit-framework-gl.c b/tests/util/piglit-framework-gl.c
index 975c1a9..ea109da 100644
--- a/tests/util/piglit-framework-gl.c
+++ b/tests/util/piglit-framework-gl.c
@@ -45,12 +45,14 @@ process_args(int *argc, char *argv[], unsigned *force_samples,
void
piglit_gl_test_config_init(int *argc, char *argv[],
- struct piglit_gl_test_config *config)
+ struct piglit_gl_test_config *config,
+ const struct piglit_gl_subtest *subtests)
{
unsigned force_samples = 0;
memset(config, 0, sizeof(*config));
+ config->subtests = subtests;
process_args(argc, argv, &force_samples, config);
if (force_samples > 1)
@@ -149,6 +151,16 @@ process_args(int *argc, char *argv[], unsigned *force_samples,
}
*argc -= 2;
j -= 2;
+ } else if (!strcmp(argv[j], "-list-subtests")) {
+ unsigned i;
+
+ for (i = 0; config->subtests[i].name != NULL; i++) {
+ printf("%s: %s\n",
+ config->subtests[i].option,
+ config->subtests[i].name);
+ }
+
+ exit(0);
}
}
}
diff --git a/tests/util/piglit-framework-gl.h b/tests/util/piglit-framework-gl.h
index 3357793..d008809 100644
--- a/tests/util/piglit-framework-gl.h
+++ b/tests/util/piglit-framework-gl.h
@@ -184,6 +184,14 @@ struct piglit_gl_test_config {
(*display)(void);
/**
+ * List of subtests supported by this test case
+ *
+ * This is only used during command line argument parsing to implement
+ * the -list-subtests option.
+ */
+ const struct piglit_gl_subtest *subtests;
+
+ /**
* Names of subtests supplied on the command line.
*
* The paramaters passed to each -subtest command line option is
@@ -199,7 +207,8 @@ struct piglit_gl_test_config {
*/
void
piglit_gl_test_config_init(int *argc, char *argv[],
- struct piglit_gl_test_config *config);
+ struct piglit_gl_test_config *config,
+ const struct piglit_gl_subtest *subtests);
/**
* Run the OpenGL test described by @a config. Does not return.
@@ -216,6 +225,10 @@ piglit_gl_test_run(int argc, char *argv[],
# define PIGLIT_EXTERN_C_END
#endif
+#ifndef PIGLIT_SUBTEST_LIST
+#define PIGLIT_SUBTEST_LIST NULL
+#endif
+
#define PIGLIT_GL_TEST_CONFIG_BEGIN \
\
PIGLIT_EXTERN_C_BEGIN \
@@ -233,7 +246,8 @@ piglit_gl_test_run(int argc, char *argv[],
int \
main(int argc, char *argv[]) \
{ \
- piglit_gl_test_config_init(&argc, argv, &config); \
+ piglit_gl_test_config_init(&argc, argv, &config, \
+ PIGLIT_SUBTEST_LIST); \
\
config.init = piglit_init; \
config.display = piglit_display; \
--
1.8.1.4
More information about the Piglit
mailing list