diff mbox

[i-g-t,2/4] lib: use defines for igt_simple_init and igt_subtest_init

Message ID 1424279176-5000-2-git-send-email-thomas.wood@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Thomas Wood Feb. 18, 2015, 5:06 p.m. UTC
Signed-off-by: Thomas Wood <thomas.wood@intel.com>
---
 lib/igt_core.c | 34 ----------------------------------
 lib/igt_core.h | 36 ++++++++++++++++++++++++++++++++----
 2 files changed, 32 insertions(+), 38 deletions(-)

Comments

Daniel Vetter Feb. 23, 2015, 11:49 p.m. UTC | #1
What's the benifit here? Would be nice to add that to the commit message
with a short sentence. Series lgtm otherwise, imo you could push it as-is.
-Daniel

On Wed, Feb 18, 2015 at 05:06:14PM +0000, Thomas Wood wrote:
> Signed-off-by: Thomas Wood <thomas.wood@intel.com>
> ---
>  lib/igt_core.c | 34 ----------------------------------
>  lib/igt_core.h | 36 ++++++++++++++++++++++++++++++++----
>  2 files changed, 32 insertions(+), 38 deletions(-)
> 
> diff --git a/lib/igt_core.c b/lib/igt_core.c
> index eef338b..afecdf1 100644
> --- a/lib/igt_core.c
> +++ b/lib/igt_core.c
> @@ -696,40 +696,6 @@ int igt_subtest_init_parse_opts(int argc, char **argv,
>  enum igt_log_level igt_log_level = IGT_LOG_INFO;
>  
>  /**
> - * igt_subtest_init:
> - * @argc: argc from the test's main()
> - * @argv: argv from the test's main()
> - *
> - * This initializes the for tests with subtests without the need for additional
> - * cmdline options. It is just a simplified version of
> - * igt_subtest_init_parse_opts().
> - *
> - * If there's not a reason to the contrary it's less error prone to just use an
> - * #igt_main block instead of stitching the tests's main() function together
> - * manually.
> - */
> -void igt_subtest_init(int argc, char **argv)
> -{
> -	igt_subtest_init_parse_opts(argc, argv, NULL, NULL, NULL, NULL);
> -}
> -
> -/**
> - * igt_simple_init:
> - * @argc: argc from the test's main()
> - * @argv: argv from the test's main()
> - *
> - * This initializes a simple test without any support for subtests.
> - *
> - * If there's not a reason to the contrary it's less error prone to just use an
> - * #igt_simple_main block instead of stitching the tests's main() function together
> - * manually.
> - */
> -void igt_simple_init(int argc, char **argv)
> -{
> -	common_init(argc, argv, NULL, NULL, NULL, NULL);
> -}
> -
> -/**
>   * igt_simple_init_parse_opts:
>   * @argc: argc from the test's main()
>   * @argv: argv from the test's main()
> diff --git a/lib/igt_core.h b/lib/igt_core.h
> index 0086945..88b47bf 100644
> --- a/lib/igt_core.h
> +++ b/lib/igt_core.h
> @@ -106,7 +106,6 @@ void __igt_fixture_end(void) __attribute__((noreturn));
>  
>  /* subtest infrastructure */
>  jmp_buf igt_subtest_jmpbuf;
> -void igt_subtest_init(int argc, char **argv);
>  typedef int (*igt_opt_handler_t)(int opt, int opt_index);
>  #ifndef __GTK_DOC_IGNORE__ /* gtkdoc wants to document this forward decl */
>  struct option;
> @@ -117,6 +116,22 @@ int igt_subtest_init_parse_opts(int argc, char **argv,
>  				const char *help_str,
>  				igt_opt_handler_t extra_opt_handler);
>  
> +
> +/**
> + * igt_subtest_init:
> + * @argc: argc from the test's main()
> + * @argv: argv from the test's main()
> + *
> + * This initializes the for tests with subtests without the need for additional
> + * cmdline options. It is just a simplified version of
> + * igt_subtest_init_parse_opts().
> + *
> + * If there's not a reason to the contrary it's less error prone to just use an
> + * #igt_main block instead of stitching the test's main() function together
> + * manually.
> + */
> +#define igt_subtest_init(argc, argv) igt_subtest_init_parse_opts(argc, argv, NULL, NULL, NULL, NULL);
> +
>  bool __igt_run_subtest(const char *subtest_name);
>  #define __igt_tokencat2(x, y) x ## y
>  
> @@ -180,13 +195,13 @@ bool igt_only_list_subtests(void);
>  #define igt_main \
>  	static void igt_tokencat(__real_main, __LINE__)(void); \
>  	int main(int argc, char **argv) { \
> -		igt_subtest_init(argc, argv); \
> +		igt_subtest_init_parse_opts(argc, argv, NULL, NULL, NULL, NULL); \
>  		igt_tokencat(__real_main, __LINE__)(); \
>  		igt_exit(); \
>  	} \
>  	static void igt_tokencat(__real_main, __LINE__)(void) \
>  
> -void igt_simple_init(int argc, char **argv);
> +
>  void igt_simple_init_parse_opts(int argc, char **argv,
>  				const char *extra_short_opts,
>  				struct option *extra_long_opts,
> @@ -194,6 +209,19 @@ void igt_simple_init_parse_opts(int argc, char **argv,
>  				igt_opt_handler_t extra_opt_handler);
>  
>  /**
> + * igt_simple_init:
> + * @argc: argc from the test's main()
> + * @argv: argv from the test's main()
> + *
> + * This initializes a simple test without any support for subtests.
> + *
> + * If there's not a reason to the contrary it's less error prone to just use an
> + * #igt_simple_main block instead of stitching the test's main() function together
> + * manually.
> + */
> +#define igt_simple_init(argc, argv) igt_simple_init_parse_opts(argc, argv, NULL, NULL, NULL, NULL);
> +
> +/**
>   * igt_simple_main:
>   *
>   * This is a magic control flow block used instead of a main() function for
> @@ -203,7 +231,7 @@ void igt_simple_init_parse_opts(int argc, char **argv,
>  #define igt_simple_main \
>  	static void igt_tokencat(__real_main, __LINE__)(void); \
>  	int main(int argc, char **argv) { \
> -		igt_simple_init(argc, argv); \
> +		igt_simple_init_parse_opts(argc, argv, NULL, NULL, NULL, NULL); \
>  		igt_tokencat(__real_main, __LINE__)(); \
>  		igt_exit(); \
>  	} \
> -- 
> 2.1.0
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Thomas Wood Feb. 24, 2015, 9:45 a.m. UTC | #2
On 23 February 2015 at 23:49, Daniel Vetter <daniel@ffwll.ch> wrote:
> What's the benifit here? Would be nice to add that to the commit message
> with a short sentence. Series lgtm otherwise, imo you could push it as-is.

It is partly as preparation for the next patch and partly just a
simplification to remove an extra function call. I'll add a suitable
comment to the commit message.

> -Daniel
>
> On Wed, Feb 18, 2015 at 05:06:14PM +0000, Thomas Wood wrote:
>> Signed-off-by: Thomas Wood <thomas.wood@intel.com>
>> ---
>>  lib/igt_core.c | 34 ----------------------------------
>>  lib/igt_core.h | 36 ++++++++++++++++++++++++++++++++----
>>  2 files changed, 32 insertions(+), 38 deletions(-)
>>
>> diff --git a/lib/igt_core.c b/lib/igt_core.c
>> index eef338b..afecdf1 100644
>> --- a/lib/igt_core.c
>> +++ b/lib/igt_core.c
>> @@ -696,40 +696,6 @@ int igt_subtest_init_parse_opts(int argc, char **argv,
>>  enum igt_log_level igt_log_level = IGT_LOG_INFO;
>>
>>  /**
>> - * igt_subtest_init:
>> - * @argc: argc from the test's main()
>> - * @argv: argv from the test's main()
>> - *
>> - * This initializes the for tests with subtests without the need for additional
>> - * cmdline options. It is just a simplified version of
>> - * igt_subtest_init_parse_opts().
>> - *
>> - * If there's not a reason to the contrary it's less error prone to just use an
>> - * #igt_main block instead of stitching the tests's main() function together
>> - * manually.
>> - */
>> -void igt_subtest_init(int argc, char **argv)
>> -{
>> -     igt_subtest_init_parse_opts(argc, argv, NULL, NULL, NULL, NULL);
>> -}
>> -
>> -/**
>> - * igt_simple_init:
>> - * @argc: argc from the test's main()
>> - * @argv: argv from the test's main()
>> - *
>> - * This initializes a simple test without any support for subtests.
>> - *
>> - * If there's not a reason to the contrary it's less error prone to just use an
>> - * #igt_simple_main block instead of stitching the tests's main() function together
>> - * manually.
>> - */
>> -void igt_simple_init(int argc, char **argv)
>> -{
>> -     common_init(argc, argv, NULL, NULL, NULL, NULL);
>> -}
>> -
>> -/**
>>   * igt_simple_init_parse_opts:
>>   * @argc: argc from the test's main()
>>   * @argv: argv from the test's main()
>> diff --git a/lib/igt_core.h b/lib/igt_core.h
>> index 0086945..88b47bf 100644
>> --- a/lib/igt_core.h
>> +++ b/lib/igt_core.h
>> @@ -106,7 +106,6 @@ void __igt_fixture_end(void) __attribute__((noreturn));
>>
>>  /* subtest infrastructure */
>>  jmp_buf igt_subtest_jmpbuf;
>> -void igt_subtest_init(int argc, char **argv);
>>  typedef int (*igt_opt_handler_t)(int opt, int opt_index);
>>  #ifndef __GTK_DOC_IGNORE__ /* gtkdoc wants to document this forward decl */
>>  struct option;
>> @@ -117,6 +116,22 @@ int igt_subtest_init_parse_opts(int argc, char **argv,
>>                               const char *help_str,
>>                               igt_opt_handler_t extra_opt_handler);
>>
>> +
>> +/**
>> + * igt_subtest_init:
>> + * @argc: argc from the test's main()
>> + * @argv: argv from the test's main()
>> + *
>> + * This initializes the for tests with subtests without the need for additional
>> + * cmdline options. It is just a simplified version of
>> + * igt_subtest_init_parse_opts().
>> + *
>> + * If there's not a reason to the contrary it's less error prone to just use an
>> + * #igt_main block instead of stitching the test's main() function together
>> + * manually.
>> + */
>> +#define igt_subtest_init(argc, argv) igt_subtest_init_parse_opts(argc, argv, NULL, NULL, NULL, NULL);
>> +
>>  bool __igt_run_subtest(const char *subtest_name);
>>  #define __igt_tokencat2(x, y) x ## y
>>
>> @@ -180,13 +195,13 @@ bool igt_only_list_subtests(void);
>>  #define igt_main \
>>       static void igt_tokencat(__real_main, __LINE__)(void); \
>>       int main(int argc, char **argv) { \
>> -             igt_subtest_init(argc, argv); \
>> +             igt_subtest_init_parse_opts(argc, argv, NULL, NULL, NULL, NULL); \
>>               igt_tokencat(__real_main, __LINE__)(); \
>>               igt_exit(); \
>>       } \
>>       static void igt_tokencat(__real_main, __LINE__)(void) \
>>
>> -void igt_simple_init(int argc, char **argv);
>> +
>>  void igt_simple_init_parse_opts(int argc, char **argv,
>>                               const char *extra_short_opts,
>>                               struct option *extra_long_opts,
>> @@ -194,6 +209,19 @@ void igt_simple_init_parse_opts(int argc, char **argv,
>>                               igt_opt_handler_t extra_opt_handler);
>>
>>  /**
>> + * igt_simple_init:
>> + * @argc: argc from the test's main()
>> + * @argv: argv from the test's main()
>> + *
>> + * This initializes a simple test without any support for subtests.
>> + *
>> + * If there's not a reason to the contrary it's less error prone to just use an
>> + * #igt_simple_main block instead of stitching the test's main() function together
>> + * manually.
>> + */
>> +#define igt_simple_init(argc, argv) igt_simple_init_parse_opts(argc, argv, NULL, NULL, NULL, NULL);
>> +
>> +/**
>>   * igt_simple_main:
>>   *
>>   * This is a magic control flow block used instead of a main() function for
>> @@ -203,7 +231,7 @@ void igt_simple_init_parse_opts(int argc, char **argv,
>>  #define igt_simple_main \
>>       static void igt_tokencat(__real_main, __LINE__)(void); \
>>       int main(int argc, char **argv) { \
>> -             igt_simple_init(argc, argv); \
>> +             igt_simple_init_parse_opts(argc, argv, NULL, NULL, NULL, NULL); \
>>               igt_tokencat(__real_main, __LINE__)(); \
>>               igt_exit(); \
>>       } \
>> --
>> 2.1.0
>>
>> _______________________________________________
>> Intel-gfx mailing list
>> Intel-gfx@lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
>
> --
> Daniel Vetter
> Software Engineer, Intel Corporation
> +41 (0) 79 365 57 48 - http://blog.ffwll.ch
diff mbox

Patch

diff --git a/lib/igt_core.c b/lib/igt_core.c
index eef338b..afecdf1 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -696,40 +696,6 @@  int igt_subtest_init_parse_opts(int argc, char **argv,
 enum igt_log_level igt_log_level = IGT_LOG_INFO;
 
 /**
- * igt_subtest_init:
- * @argc: argc from the test's main()
- * @argv: argv from the test's main()
- *
- * This initializes the for tests with subtests without the need for additional
- * cmdline options. It is just a simplified version of
- * igt_subtest_init_parse_opts().
- *
- * If there's not a reason to the contrary it's less error prone to just use an
- * #igt_main block instead of stitching the tests's main() function together
- * manually.
- */
-void igt_subtest_init(int argc, char **argv)
-{
-	igt_subtest_init_parse_opts(argc, argv, NULL, NULL, NULL, NULL);
-}
-
-/**
- * igt_simple_init:
- * @argc: argc from the test's main()
- * @argv: argv from the test's main()
- *
- * This initializes a simple test without any support for subtests.
- *
- * If there's not a reason to the contrary it's less error prone to just use an
- * #igt_simple_main block instead of stitching the tests's main() function together
- * manually.
- */
-void igt_simple_init(int argc, char **argv)
-{
-	common_init(argc, argv, NULL, NULL, NULL, NULL);
-}
-
-/**
  * igt_simple_init_parse_opts:
  * @argc: argc from the test's main()
  * @argv: argv from the test's main()
diff --git a/lib/igt_core.h b/lib/igt_core.h
index 0086945..88b47bf 100644
--- a/lib/igt_core.h
+++ b/lib/igt_core.h
@@ -106,7 +106,6 @@  void __igt_fixture_end(void) __attribute__((noreturn));
 
 /* subtest infrastructure */
 jmp_buf igt_subtest_jmpbuf;
-void igt_subtest_init(int argc, char **argv);
 typedef int (*igt_opt_handler_t)(int opt, int opt_index);
 #ifndef __GTK_DOC_IGNORE__ /* gtkdoc wants to document this forward decl */
 struct option;
@@ -117,6 +116,22 @@  int igt_subtest_init_parse_opts(int argc, char **argv,
 				const char *help_str,
 				igt_opt_handler_t extra_opt_handler);
 
+
+/**
+ * igt_subtest_init:
+ * @argc: argc from the test's main()
+ * @argv: argv from the test's main()
+ *
+ * This initializes the for tests with subtests without the need for additional
+ * cmdline options. It is just a simplified version of
+ * igt_subtest_init_parse_opts().
+ *
+ * If there's not a reason to the contrary it's less error prone to just use an
+ * #igt_main block instead of stitching the test's main() function together
+ * manually.
+ */
+#define igt_subtest_init(argc, argv) igt_subtest_init_parse_opts(argc, argv, NULL, NULL, NULL, NULL);
+
 bool __igt_run_subtest(const char *subtest_name);
 #define __igt_tokencat2(x, y) x ## y
 
@@ -180,13 +195,13 @@  bool igt_only_list_subtests(void);
 #define igt_main \
 	static void igt_tokencat(__real_main, __LINE__)(void); \
 	int main(int argc, char **argv) { \
-		igt_subtest_init(argc, argv); \
+		igt_subtest_init_parse_opts(argc, argv, NULL, NULL, NULL, NULL); \
 		igt_tokencat(__real_main, __LINE__)(); \
 		igt_exit(); \
 	} \
 	static void igt_tokencat(__real_main, __LINE__)(void) \
 
-void igt_simple_init(int argc, char **argv);
+
 void igt_simple_init_parse_opts(int argc, char **argv,
 				const char *extra_short_opts,
 				struct option *extra_long_opts,
@@ -194,6 +209,19 @@  void igt_simple_init_parse_opts(int argc, char **argv,
 				igt_opt_handler_t extra_opt_handler);
 
 /**
+ * igt_simple_init:
+ * @argc: argc from the test's main()
+ * @argv: argv from the test's main()
+ *
+ * This initializes a simple test without any support for subtests.
+ *
+ * If there's not a reason to the contrary it's less error prone to just use an
+ * #igt_simple_main block instead of stitching the test's main() function together
+ * manually.
+ */
+#define igt_simple_init(argc, argv) igt_simple_init_parse_opts(argc, argv, NULL, NULL, NULL, NULL);
+
+/**
  * igt_simple_main:
  *
  * This is a magic control flow block used instead of a main() function for
@@ -203,7 +231,7 @@  void igt_simple_init_parse_opts(int argc, char **argv,
 #define igt_simple_main \
 	static void igt_tokencat(__real_main, __LINE__)(void); \
 	int main(int argc, char **argv) { \
-		igt_simple_init(argc, argv); \
+		igt_simple_init_parse_opts(argc, argv, NULL, NULL, NULL, NULL); \
 		igt_tokencat(__real_main, __LINE__)(); \
 		igt_exit(); \
 	} \