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 01/36] lib: Introduce main function macros with custom args
Date: Thu, 23 May 2019 15:26:52 +0300 [thread overview]
Message-ID: <20190523122727.6932-1-petri.latvala@intel.com> (raw)
Instead of using a custom main function and calling
igt_subtest_init_parse_opts / igt_simple_init_parse_opts, the _args
variants of igt_main and igt_simple_main take the relevant parameters
and pass them along to the correct init function.
Open-coding a custom main function is no longer necessary and not
recommended.
Signed-off-by: Petri Latvala <petri.latvala@intel.com>
---
lib/igt_core.h | 64 +++++++++++++++++++++++++++++++++++++-------------
1 file changed, 48 insertions(+), 16 deletions(-)
diff --git a/lib/igt_core.h b/lib/igt_core.h
index 44634e0f..cd89921e 100644
--- a/lib/igt_core.h
+++ b/lib/igt_core.h
@@ -250,23 +250,38 @@ void __igt_subtest_group_restore(int);
__igt_subtest_group_restore(igt_tokencat(__save,__LINE__) ))
/**
- * igt_main:
- *
- * This is a magic control flow block used instead of a main() function for
- * tests with subtests. Open-coding the main() function is only recommended if
- * the test needs to parse additional command line arguments of its own.
- */
-#define igt_main \
+ * igt_main_args:
+ * @extra_short_opts: getopt_long() compliant list with additional short options
+ * @extra_long_opts: getopt_long() compliant list with additional long options
+ * @help_str: help string for the additional options
+ * @extra_opt_handler: handler for the additional options
+ * @handler_data: user data given to @extra_opt_handler when invoked
+ *
+ * This is a magic control flow block used instead of a main()
+ * function for tests with subtests, along with custom command line
+ * arguments. The macro parameters are passed directly to
+ * #igt_subtest_init_parse_opts.
+ */
+#define igt_main_args(short_opts, long_opts, help_str, opt_handler, handler_data) \
static void igt_tokencat(__real_main, __LINE__)(void); \
int main(int argc, char **argv) { \
- igt_subtest_init_parse_opts(&argc, argv, NULL, NULL, NULL, \
- NULL, NULL); \
+ igt_subtest_init_parse_opts(&argc, argv, \
+ short_opts, long_opts, help_str, \
+ opt_handler, handler_data); \
igt_tokencat(__real_main, __LINE__)(); \
igt_exit(); \
} \
static void igt_tokencat(__real_main, __LINE__)(void) \
+/**
+ * igt_main:
+ *
+ * This is a magic control flow block used instead of a main() function for
+ * tests with subtests. Open-coding the main() function is not recommended.
+ */
+#define igt_main igt_main_args(NULL, NULL, NULL, NULL, NULL)
+
const char *igt_test_name(void);
void igt_simple_init_parse_opts(int *argc, char **argv,
const char *extra_short_opts,
@@ -289,23 +304,40 @@ void igt_simple_init_parse_opts(int *argc, char **argv,
#define igt_simple_init(argc, argv) \
igt_simple_init_parse_opts(&argc, argv, NULL, NULL, NULL, NULL, NULL);
+
/**
- * igt_simple_main:
+ * igt_simple_main_args:
+ * @extra_short_opts: getopt_long() compliant list with additional short options
+ * @extra_long_opts: getopt_long() compliant list with additional long options
+ * @help_str: help string for the additional options
+ * @extra_opt_handler: handler for the additional options
+ * @handler_data: user data given to @extra_opt_handler when invoked
*
- * This is a magic control flow block used instead of a main() function for
- * simple tests. Open-coding the main() function is only recommended if
- * the test needs to parse additional command line arguments of its own.
+ * This is a magic control flow block used instead of a main()
+ * function for simple tests with custom command line arguments. The
+ * macro parameters are passed directly to
+ * #igt_simple_init_parse_opts.
*/
-#define igt_simple_main \
+#define igt_simple_main_args(short_opts, long_opts, help_str, opt_handler, handler_data) \
static void igt_tokencat(__real_main, __LINE__)(void); \
int main(int argc, char **argv) { \
- igt_simple_init_parse_opts(&argc, argv, NULL, NULL, NULL, \
- NULL, NULL); \
+ igt_simple_init_parse_opts(&argc, argv, \
+ short_opts, long_opts, help_str, \
+ opt_handler, handler_data); \
igt_tokencat(__real_main, __LINE__)(); \
igt_exit(); \
} \
static void igt_tokencat(__real_main, __LINE__)(void) \
+
+/**
+ * igt_simple_main:
+ *
+ * This is a magic control flow block used instead of a main() function for
+ * simple tests. Open-coding the main() function is not recommended.
+ */
+#define igt_simple_main igt_simple_main_args(NULL, NULL, NULL, NULL, NULL)
+
/**
* igt_constructor:
*
--
2.19.1
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next 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 Petri Latvala [this message]
2019-05-23 12:26 ` [igt-dev] [PATCH i-g-t 02/36] lib: Document igt_opt_handler_t semantics Petri Latvala
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-1-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