From: Petri Latvala <petri.latvala@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Petri Latvala <petri.latvala@intel.com>
Subject: [igt-dev] [PATCH i-g-t 02/36] lib: Document igt_opt_handler_t semantics
Date: Thu, 23 May 2019 15:26:53 +0300 [thread overview]
Message-ID: <20190523122727.6932-2-petri.latvala@intel.com> (raw)
In-Reply-To: <20190523122727.6932-1-petri.latvala@intel.com>
Best practices for the help string formatting, along with explicit
symbols for the possible return values for the callback.
Also documented: Do not call the _parse_opts functions yourself, use
igt_main_args or igt_simple_main_args.
Signed-off-by: Petri Latvala <petri.latvala@intel.com>
---
lib/igt_core.c | 31 ++++++++++++++++++++++++++++---
lib/igt_core.h | 2 ++
2 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/lib/igt_core.c b/lib/igt_core.c
index 9ef18eb1..9c86d664 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -857,8 +857,18 @@ out:
* additional knobs to tune when run manually like the number of rounds execute
* or the size of the allocated buffer objects.
*
- * Tests without special needs should just use igt_subtest_init() or use
- * #igt_main directly instead of their own main() function.
+ * Tests should use #igt_main_args instead of their own main()
+ * function and calling this function.
+ *
+ * The @help_str parameter is printed directly after the help text of
+ * standard arguments. The formatting of the string should be:
+ * - One line per option
+ * - Two spaces, option flag, tab character, help text, newline character
+ *
+ * Example: " -s\tBuffer size\n"
+ *
+ * The opt handler function must return #IGT_OPT_HANDLER_SUCCESS on
+ * successful handling, #IGT_OPT_HANDLER_ERROR on errors.
*
* Returns: Forwards any option parsing errors from getopt_long.
*/
@@ -891,7 +901,22 @@ enum igt_log_level igt_log_level = IGT_LOG_INFO;
* @handler_data: user data given to @extra_opt_handler when invoked
*
* This initializes a simple test without any support for subtests and allows
- * an arbitrary set of additional options.
+ * an arbitrary set of additional options. This is useful for tests which have
+ * additional knobs to tune when run manually like the number of rounds execute
+ * or the size of the allocated buffer objects.
+ *
+ * Tests should use #igt_simple_main_args instead of their own main()
+ * function and calling this function.
+ *
+ * The @help_str parameter is printed directly after the help text of
+ * standard arguments. The formatting of the string should be:
+ * - One line per option
+ * - Two spaces, option flag, tab character, help text, newline character
+ *
+ * Example: " -s\tBuffer size\n"
+ *
+ * The opt handler function must return #IGT_OPT_HANDLER_SUCCESS on
+ * successful handling, #IGT_OPT_HANDLER_ERROR on errors.
*/
void igt_simple_init_parse_opts(int *argc, char **argv,
const char *extra_short_opts,
diff --git a/lib/igt_core.h b/lib/igt_core.h
index cd89921e..88a95ec2 100644
--- a/lib/igt_core.h
+++ b/lib/igt_core.h
@@ -145,6 +145,8 @@ void __igt_fixture_end(void) __attribute__((noreturn));
/* subtest infrastructure */
jmp_buf igt_subtest_jmpbuf;
typedef int (*igt_opt_handler_t)(int opt, int opt_index, void *data);
+#define IGT_OPT_HANDLER_SUCCESS 0
+#define IGT_OPT_HANDLER_ERROR -2
#ifndef __GTK_DOC_IGNORE__ /* gtkdoc wants to document this forward decl */
struct option;
#endif
--
2.19.1
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next prev parent reply other threads:[~2019-05-23 12:27 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-23 12:26 [igt-dev] [PATCH i-g-t 01/36] lib: Introduce main function macros with custom args Petri Latvala
2019-05-23 12:26 ` Petri Latvala [this message]
2019-05-23 12:26 ` [igt-dev] [PATCH i-g-t 03/36] i915/gem_exec_blt: Nuke custom main function Petri Latvala
2019-05-23 12:26 ` [igt-dev] [PATCH i-g-t 04/36] i915/gem_gtt_speed: " Petri Latvala
2019-05-23 12:26 ` [igt-dev] [PATCH i-g-t 05/36] i915/gem_hang: " Petri Latvala
2019-05-23 12:26 ` [igt-dev] [PATCH i-g-t 06/36] i915/gem_linear_blits: " Petri Latvala
2019-05-23 12:26 ` [igt-dev] [PATCH i-g-t 07/36] i915/gem_ppgtt: " Petri Latvala
2019-05-23 12:26 ` [igt-dev] [PATCH i-g-t 08/36] i915/gem_pread: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 09/36] i915/gem_pwrite: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 10/36] i915/gem_pwrite_pread: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 11/36] i915/gem_render_copy: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 12/36] i915/gem_render_copy_redux: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 13/36] i915/gem_request_retire: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 14/36] i915/gem_stress: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 15/36] i915/gem_tiled_blits: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 16/36] i915/gem_userptr_blits: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 17/36] i915/gen3_mixed_blits: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 18/36] i915/gen3_render_linear_blits: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 19/36] i915/gen3_render_mixed_blits: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 20/36] i915/gen3_render_tiledx_blits: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 21/36] i915/gen3_render_tiledy_blits: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 22/36] i915/i915_pm_rpm: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 23/36] kms_concurrent: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 24/36] kms_cursor_edge_walk: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 25/36] kms_flip: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 26/36] kms_force_connector_basic: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 27/36] kms_frontbuffer_tracking: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 28/36] kms_mmap_write_crc: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 29/36] kms_plane_multiple: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 30/36] kms_psr2_su: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 31/36] kms_psr: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 32/36] kms_setmode: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 33/36] kms_tv_load_detect: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 34/36] prime_mmap_coherency: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 35/36] testdisplay: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 36/36] tests: Remove redundant igt_exit() calls Petri Latvala
2019-05-23 14:29 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,01/36] lib: Introduce main function macros with custom args Patchwork
2019-05-24 13:50 ` [igt-dev] [PATCH i-g-t 01/36] " Arkadiusz Hiler
2019-05-24 18:14 ` Daniel Vetter
2019-05-24 18:26 ` Hiatt, Don
2019-05-24 19:38 ` [igt-dev] ✓ Fi.CI.IGT: success for series starting with [i-g-t,01/36] " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190523122727.6932-2-petri.latvala@intel.com \
--to=petri.latvala@intel.com \
--cc=igt-dev@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox