[Piglit] [PATCH 1/4] util: Add piglit_result_to_string() helper
Chad Versace
chad.versace at linux.intel.com
Wed Dec 12 13:16:03 PST 2012
On 12/06/2012 04:14 PM, Tom Stellard wrote:
> From: Tom Stellard <thomas.stellard at amd.com>
>
> ---
> tests/util/piglit-util.c | 21 +++++++++++++++++----
> tests/util/piglit-util.h | 1 +
> 2 files changed, 18 insertions(+), 4 deletions(-)
>
> diff --git a/tests/util/piglit-util.c b/tests/util/piglit-util.c
> index c061def..98e0800 100644
> --- a/tests/util/piglit-util.c
> +++ b/tests/util/piglit-util.c
> @@ -158,25 +158,38 @@ int piglit_find_line(const char *program, int position)
> return line;
> }
>
> void
> piglit_report_result(enum piglit_result result)
> {
> fflush(stderr);
>
> + const char *result_str = piglit_result_to_string(result);
> if (result == PIGLIT_PASS) {
> - printf("PIGLIT: {'result': 'pass' }\n");
> + printf("PIGLIT: {'result': '%s' }\n", result_str);
> fflush(stdout);
> exit(0);
> } else if (result == PIGLIT_SKIP) {
> - printf("PIGLIT: {'result': 'skip' }\n");
> + printf("PIGLIT: {'result': '%s' }\n", result_str);
> fflush(stdout);
> exit(0);
> } else if (result == PIGLIT_WARN) {
> - printf("PIGLIT: {'result': 'warn' }\n");
> + printf("PIGLIT: {'result': '%s' }\n", result_str);
> fflush(stdout);
> exit(0);
> } else {
> - printf("PIGLIT: {'result': 'fail' }\n");
> + printf("PIGLIT: {'result': '%s' }\n", result_str);
> fflush(stdout);
> exit(1);
> }
Each of the branches are identical, except for the exit code in the 'else' branch.
I'd like to see the code duplication removed.
of the if-tree. Also, the cases for SKIP, WARN, and PASS are now identical. They
should just be folded into a single br
More information about the Piglit
mailing list