[Piglit] [PATCH 6/7] cl-program-tester: Defer parsing of input/output values until test execution
Aaron Watry
awatry at gmail.com
Mon Sep 30 10:30:11 PDT 2013
On Mon, Sep 30, 2013 at 9:47 AM, Tom Stellard <tom at stellard.net> wrote:
> From: Tom Stellard <thomas.stellard at amd.com>
>
> This will make it possible to write tests using generic types.
> ---
> tests/cl/program/program-tester.c | 61 +++++++++++++++++++++++++--------------
> 1 file changed, 40 insertions(+), 21 deletions(-)
>
> diff --git a/tests/cl/program/program-tester.c b/tests/cl/program/program-tester.c
> index 557dc4b..fbfeb7b 100644
> --- a/tests/cl/program/program-tester.c
> +++ b/tests/cl/program/program-tester.c
> @@ -211,6 +211,7 @@ struct test_arg {
> /* kernel arg data */
> cl_uint index;
> size_t size_in_mem;
> + char *raw_value;
> void* value;
>
> /* tolerance */
> @@ -231,6 +232,7 @@ struct test_arg create_test_arg()
>
> .index = 0,
> .size_in_mem = 0,
> + .raw_value = NULL,
> .value = NULL,
>
> .toli = 0,
> @@ -1007,11 +1009,10 @@ get_test_arg(const char* src, struct test* test, bool arg_in)
> /* Get value */
> regex_get_match_str(&value, src, pmatch, 3);
> if(regex_match(value, REGEX_FULL_MATCH(REGEX_NULL))) {
> - test_arg.value = NULL;
> + test_arg.raw_value = NULL;
> } else {
> - get_test_arg_value(&test_arg, value, test_arg.vec_elements);
> + test_arg.raw_value = value;
> }
> - free(value);
> } else if(regex_match(src, REGEX_FULL_MATCH(REGEX_ARG_BUFFER))) { // buffer
> char* array_length_str = NULL;
> const char* tolerance_str = NULL;
> @@ -1059,24 +1060,11 @@ get_test_arg(const char* src, struct test* test, bool arg_in)
> exit_report_result(PIGLIT_WARN);
> }
> } else if(regex_match(value, REGEX_FULL_MATCH(REGEX_REPEAT))) {
> - regmatch_t rmatch[3];
> - char* repeat_value_str;
> -
> - regex_get_matches(value, REGEX_REPEAT, rmatch, 3, 0);
> - regex_get_match_str(&repeat_value_str, value, rmatch, 2);
> -
> - get_test_arg_value(&test_arg,
> - repeat_value_str,
> - get_array_length(repeat_value_str));
> -
> - free(repeat_value_str);
> + test_arg.raw_value = value;
> } else if(regex_match(value, REGEX_ARRAY)) {
> - get_test_arg_value(&test_arg,
> - value,
> - test_arg.length * test_arg.vec_elements);
> + test_arg.raw_value = value;
> }
> }
> - free(value);
> }
>
> if(arg_in) {
> @@ -1729,6 +1717,7 @@ test_kernel(const struct piglit_cl_program_test_config* config,
>
> switch(test_arg.type) {
> case TEST_ARG_VALUE:
> + get_test_arg_value(&test_arg, test_arg.raw_value, test_arg.vec_elements);
> arg_set = piglit_cl_set_kernel_arg(kernel,
> test_arg.index,
> test_arg.vec_elements * piglit_cl_type_get_size(test_arg.cl_type),
> @@ -1738,7 +1727,22 @@ test_kernel(const struct piglit_cl_program_test_config* config,
> struct buffer_arg buffer_arg;
> buffer_arg.index = test_arg.index;
>
> - if(test_arg.value != NULL) {
> + if(test_arg.raw_value != NULL) {
> + if(regex_match(test_arg.raw_value, REGEX_FULL_MATCH(REGEX_REPEAT))) {
> + regmatch_t rmatch[3];
> + char* repeat_value_str;
> +
> + regex_get_matches(test_arg.raw_value, REGEX_REPEAT, rmatch, 3, 0);
> + regex_get_match_str(&repeat_value_str, test_arg.raw_value, rmatch, 2);
> +
> + get_test_arg_value(&test_arg,
> + repeat_value_str,
> + get_array_length(repeat_value_str));
> + } else {
> + get_test_arg_value(&test_arg,
> + test_arg.raw_value,
> + test_arg.length * test_arg.vec_elements);
> + }
> buffer_arg.buffer = piglit_cl_create_buffer(env->context,
> CL_MEM_READ_WRITE,
> test_arg.size_in_mem);
> @@ -1802,7 +1806,7 @@ test_kernel(const struct piglit_cl_program_test_config* config,
> break;
> }
>
> - if(test_arg.value != NULL) {
> + if(test_arg.raw_value != NULL) {
> buffer_arg.buffer = piglit_cl_create_buffer(env->context,
> CL_MEM_READ_WRITE,
> test_arg.size_in_mem);
> @@ -1875,7 +1879,22 @@ test_kernel(const struct piglit_cl_program_test_config* config,
> }
> }
>
> - if(test_arg.value != NULL) {
> + if(test_arg.raw_value != NULL) {
> + if(regex_match(test_arg.raw_value, REGEX_FULL_MATCH(REGEX_REPEAT))) {
> + regmatch_t rmatch[3];
> + char* repeat_value_str;
> +
> + regex_get_matches(test_arg.raw_value, REGEX_REPEAT, rmatch, 3, 0);
> + regex_get_match_str(&repeat_value_str, test_arg.raw_value, rmatch, 2);
> +
> + get_test_arg_value(&test_arg,
> + repeat_value_str,
> + get_array_length(repeat_value_str));
> + } else {
> + get_test_arg_value(&test_arg,
> + test_arg.raw_value,
> + test_arg.length * test_arg.vec_elements);
> + }
This if/else block is identical to the one above (unless I missed
something)... can this be consolidated?
--Aaron
> void* read_value = malloc(test_arg.size_in_mem);
>
> if(piglit_cl_read_buffer(env->context->command_queues[0],
> --
> 1.7.11.4
>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit
More information about the Piglit
mailing list