On 10/04/2013 06:11 PM, Ian Romanick wrote:
From: Ian Romanick <[email protected]>
This required some ugly hacking about to get the list of subtests to
process_args. Suggestions?
Let's avoid these ugly hacks. Here's my suggestion, which covers patches 2 and
3.
Patch 2/4 moves `struct piglit_gl_test_config config` out of main() to
file scope. Let's avoid making things global; that leads to a slippery
slope. I fought hard to kill many of Piglit's globals, and I don't welcome
the arrival of new ones. If at all possible, let's leave it in main() where it
is.
To leave 'config' in main(), we need to restructure a few things. First,
piglit_gl_test_config_init() should no longer parse args; instead, it should
only
memset 'config' to 0. That is, let's change its signature from
void piglit_gl_test_config_init(int *argc, char *argv[], struct
piglit_gl_test_config *config)
to
void piglit_gl_test_config_init(struct piglit_gl_test_config *config)
Move the argparsing (that is, the call to process_args()) into
piglit_gl_test_run(). That will ensure
that args are parsed *after* the test author has set all config variables in
the CONFIG block.
The CONFIG block in your patch 4/4 should now look like this:
PIGLIT_GL_TEST_CONFIG_BEGIN
config.subtests = subtests;
config.supports_gl_compat_version = 10;
config.window_visual = PIGLIT_GL_VISUAL_RGB;
PIGLIT_GL_TEST_CONFIG_END
The config is no longer defined with file-scope, so piglit_init() should
execute subtests
like this:
result = piglit_run_subtests(PIGLIT_SKIP);
piglit_run_selected_subtests() should access `config->subtests` through the
global
"test context object", piglit-framework-gl.c:`struct piglit_gl_framework
*gl_fw`,
like this:
enum piglit_result
piglit_run_selected_subtests(enum piglit_result previous_result)
{
enum piglit_result result = previous_result;
const struct piglit_gl_subtest *subtests
gl_fw->config->subtests;
const char **selected_subtests =
gl_fw->config->selected_subtests;
...
}
At this point, it's no longer necessary for the subtests array to be global,
so you could even do the below if you wanted, but that's really up to personal
taste.
PIGLIT_GL_TEST_CONFIG_BEGIN
config.supports_gl_compat_version = 10;
config.window_visual = PIGLIT_GL_VISUAL_RGB;
config.subtests = {
{
"Cannot delete while active",
"delete-inactive-only",
delete_inactive_only
},
...,
};
PIGLIT_GL_TEST_CONFIG_END
_______________________________________________
Piglit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/piglit