From patchwork Wed Jan 23 00:51:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Gall X-Patchwork-Id: 14220 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 2093D23E57 for ; Wed, 23 Jan 2013 01:28:27 +0000 (UTC) Received: from mail-vb0-f42.google.com (mail-vb0-f42.google.com [209.85.212.42]) by fiordland.canonical.com (Postfix) with ESMTP id B2E45A1900A for ; Wed, 23 Jan 2013 01:28:26 +0000 (UTC) Received: by mail-vb0-f42.google.com with SMTP id ff1so4905841vbb.29 for ; Tue, 22 Jan 2013 17:28:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=4x6hPzzRJuN7gBnmdKdLpdhYOoyTDVf/bSWIOe51QfQ=; b=ke4zT/lOLIZHgH3iokJG8SQz94tga7jwaFS8zROwmjUbV0KZ0bKg7+FXs9fZtZizkY OsEgtaGifJzf9+01fIo0+ABvcZFBk/QX1o7hVEpADZIdXrjHFNwWQEYwVUBtIZ0RJe06 xJ8IwOYjdEvaGWuLEBfMXhwR5ZAgPSjb8HAFeU1ffmonMYIAmA10dFCe4n7n+IGv6GKY eRa8hWSgY9zYXQdYRVJsguskkEokyf/Xk0vCC0u9KWeDka3mbEyjRSRoKru1FMP4RdZ2 YL0UWl/7FeNvloBa3DQQuRBRewKXoWUbVbPadACUaWobOzqPwmV2echLoSMmn+s3f9g5 VcpQ== X-Received: by 10.52.88.168 with SMTP id bh8mr22294533vdb.51.1358904506187; Tue, 22 Jan 2013 17:28:26 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.58.145.101 with SMTP id st5csp280491veb; Tue, 22 Jan 2013 17:28:25 -0800 (PST) X-Received: by 10.43.110.132 with SMTP id ek4mr15981845icc.32.1358904504847; Tue, 22 Jan 2013 17:28:24 -0800 (PST) Received: from mail-ia0-x22b.google.com (mail-ia0-x22b.google.com [2607:f8b0:4001:c02::22b]) by mx.google.com with ESMTPS id gr2si16113409igc.49.2013.01.22.17.28.24 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 22 Jan 2013 17:28:24 -0800 (PST) Received-SPF: neutral (google.com: 2607:f8b0:4001:c02::22b is neither permitted nor denied by best guess record for domain of tom.gall@linaro.org) client-ip=2607:f8b0:4001:c02::22b; Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:4001:c02::22b is neither permitted nor denied by best guess record for domain of tom.gall@linaro.org) smtp.mail=tom.gall@linaro.org Received: by mail-ia0-f171.google.com with SMTP id z13so2530362iaz.2 for ; Tue, 22 Jan 2013 17:28:24 -0800 (PST) X-Received: by 10.50.180.200 with SMTP id dq8mr13457532igc.27.1358904504492; Tue, 22 Jan 2013 17:28:24 -0800 (PST) Received: from localhost.localdomain ([70.35.96.184]) by mx.google.com with ESMTPS id c3sm14195684igj.1.2013.01.22.17.28.22 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 22 Jan 2013 17:28:23 -0800 (PST) From: Tom Gall To: piglit@lists.freedesktop.org Cc: patches@linaro.org, Tom Gall Subject: [PATCH 1/1] RFC: add ability to report gl api supported by tests Date: Tue, 22 Jan 2013 18:51:41 -0600 Message-Id: <1358902302-3015-1-git-send-email-tom.gall@linaro.org> X-Mailer: git-send-email 1.7.10.4 X-Gm-Message-State: ALoCoQkG14bm/j4l1+AWXdMdS2rXChQ7sF0zdUFQyDK86jWFsYIVO1S9bfRLpFmINOxqJY6zgLBg This patch adds a new command line parameter -supports to all tests that make use of PIGLIT_GL_TEST_CONFIG_BEGIN/END. If passed when the test is called, config->piglit_report_supported is set to true and a JSON formated structure will be returned. Within the structure is an encoded python dictionary with supports_gl_es_version : version supports_gl_core_version : version supports_gl_compat_version : version The fields only exist in the structure if they are non-zero in the test. When -supports is passed only the JSON structure is returned and the test is not run. Within the piglit_gl_test_config structure a new fn pointer named supported is added. If set and -supports is passed on the command line, this function is called allowing tests that read data files to report results based on the data file passed on the command line. Ex: With shader_runner it can via waffle utilize GL or GL ES based on what is included in the [required] section of that shader_test data file. Signed-off-by: Tom Gall --- tests/util/piglit-framework-gl.c | 54 +++++++++++++++++++++++++++++++++++--- tests/util/piglit-framework-gl.h | 30 ++++++++++++++++++++- 2 files changed, 80 insertions(+), 4 deletions(-) diff --git a/tests/util/piglit-framework-gl.c b/tests/util/piglit-framework-gl.c index 441e271..cf14594 100644 --- a/tests/util/piglit-framework-gl.c +++ b/tests/util/piglit-framework-gl.c @@ -60,7 +60,8 @@ delete_arg(char *argv[], int argc, int arg) * length is returned in @a argc. */ static void -process_args(int *argc, char *argv[]) +process_args(int *argc, char *argv[], + struct piglit_gl_test_config *config) { int j; @@ -104,19 +105,34 @@ process_args(int *argc, char *argv[]) } *argc -= 2; j -= 2; + } else if (!strcmp(argv[j], "-supports")) { + /* request to return json structure with API / version + * support information. + */ + delete_arg(argv, *argc, j--); + *argc -= 1; + config->piglit_report_supported=true; } } } void piglit_gl_test_run(int argc, char *argv[], - const struct piglit_gl_test_config *config) + struct piglit_gl_test_config *config) { - process_args(&argc, argv); + process_args(&argc, argv, config); piglit_width = config->window_width; piglit_height = config->window_height; + if (config->piglit_report_supported) { + if (config->supported) + (config->supported)(argc,argv); + else + piglit_report_supported_apis(config); + exit(0); + } + gl_fw = piglit_gl_framework_factory(config); if (gl_fw == NULL) { printf("piglit: error: failed to create " @@ -162,3 +178,35 @@ piglit_set_reshape_func(void (*func)(int w, int h)) if (!gl_fw->set_reshape_func) gl_fw->set_reshape_func(gl_fw, func); } + +/* return JSON structure describing the capability of the test based + * on its supports_gl_core_version, supports_gl_compat_version and + * supports_gl_es_version as found in config. + */ +void +piglit_report_supported_apis(const struct piglit_gl_test_config *config) +{ + bool print_comma = false; + + printf("api: {"); + if (config->supports_gl_es_version) { + printf("\"supports_gl_es_version\" : %d ", + config->supports_gl_es_version); + print_comma = true; + } + if (config->supports_gl_core_version) { + if (print_comma) + printf(","); + printf("\"supports_gl_core_version\" : %d ", + config->supports_gl_core_version); + print_comma = true; + } + if (config->supports_gl_compat_version) { + if (print_comma) + printf(","); + printf("\"supports_gl_compat_version\" : %d ", + config->supports_gl_compat_version); + } + printf("}\n" ); + fflush(stdout); +} diff --git a/tests/util/piglit-framework-gl.h b/tests/util/piglit-framework-gl.h index 6ab791a..d3b6331 100644 --- a/tests/util/piglit-framework-gl.h +++ b/tests/util/piglit-framework-gl.h @@ -188,6 +188,33 @@ struct piglit_gl_test_config { */ enum piglit_result (*display)(void); + + /** + * If -supports is passed when the test is called, + * piglit_report_supported will be set to true and + * a JSON formated structure will be returned. Within + * structure is an encoded python dictionary with + * supports_gl_es_version : version + * supports_gl_core_version : version + * supports_gl_compat_version : version + * + * With -supports only the JSON structure is returned + * instead of the test being run. + */ + bool piglit_report_supported; + + /** + * If -suppports is passed when the test is called and + * if the supported fn pointer is set, this function is + * called allowing tests that read data files to + * report results based on the data file passed on the + * command line. + * Ex: shader_runner could via waffle utilize a version + * GL or GL ES based on what is included in the + * [required] section of that shader_test data file. + */ + void + (*supported)(int argc, char *argv[]); }; /** @@ -201,7 +228,7 @@ piglit_gl_test_config_init(struct piglit_gl_test_config *config); */ void piglit_gl_test_run(int argc, char *argv[], - const struct piglit_gl_test_config *config); + struct piglit_gl_test_config *config); #ifdef __cplusplus # define PIGLIT_EXTERN_C_BEGIN extern "C" { @@ -261,5 +288,6 @@ void piglit_present_results(); void piglit_post_redisplay(void); void piglit_set_keyboard_func(void (*func)(unsigned char key, int x, int y)); void piglit_set_reshape_func(void (*func)(int w, int h)); +void piglit_report_supported_apis(const struct piglit_gl_test_config *config); #endif /* PIGLIT_FRAMEWORK_H */