Skip to contentSkip to conversation

tests: improve pipe enumeration

PATCH In review Thomas Wood 2 participants 7 messages Feb 18, 2015 – Feb 24, 2015 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 tests: improve pipe enumeration

---
 tests/kms_flip_event_leak.c | 2 +-
 tests/kms_plane.c           | 2 +-
 tests/kms_universal_plane.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
tests/kms_flip_event_leak.c +1 -1
index 8a5e6db..ea4ce4c 100644
@@ -119,7 +119,7 @@ igt_simple_main
 
 	igt_display_init(&data.display, data.drm_fd);
 
-	for (pipe = 0; pipe < 3; pipe++) {
+	for_each_pipe(&data.display, pipe) {
 		for_each_connected_output(&data.display, output) {
 			if (test(&data, pipe, output))
 				valid_tests++;
tests/kms_plane.c +1 -1
index c94eac0..8a08f20 100644
@@ -399,7 +399,7 @@ igt_main
 		igt_display_init(&data.display, data.drm_fd);
 	}
 
-	for (int pipe = 0; pipe < 3; pipe++)
+	for (int pipe = 0; pipe < I915_MAX_PIPES; pipe++)
 		run_tests_for_pipe(&data, pipe);
 
 	igt_fixture {
tests/kms_universal_plane.c +1 -1
index 04ff840..6a05584 100644
@@ -569,7 +569,7 @@ igt_main
 		igt_require(data.display.has_universal_planes);
 	}
 
-	for (int pipe = 0; pipe < 3; pipe++)
+	for (int pipe = 0; pipe < I915_MAX_PIPES; pipe++)
 		run_tests_for_pipe(&data, pipe);
 
 	igt_fixture {
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

PATCH 2/4 lib: use defines for igt_simple_init and igt_subtest_init

---
 lib/igt_core.c | 34 ----------------------------------
 lib/igt_core.h | 36 ++++++++++++++++++++++++++++++++----
 2 files changed, 32 insertions(+), 38 deletions(-)
lib/igt_core.c +0 -34
index eef338b..afecdf1 100644
@@ -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()
lib/igt_core.h +32 -4
index 0086945..88b47bf 100644
@@ -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(); \
 	} \
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

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

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

Quoted 138 lines · Thomas Wood
---
 lib/igt_core.c | 34 ----------------------------------
 lib/igt_core.h | 36 ++++++++++++++++++++++++++++++++----
 2 files changed, 32 insertions(+), 38 deletions(-)
lib/igt_core.c +0 -34
index eef338b..afecdf1 100644
@@ -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()
lib/igt_core.h +32 -4
index 0086945..88b47bf 100644
@@ -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(); \
 	} \
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw

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

Quoted 2 lines · Daniel Vetter

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.

Quoted 137 lines

-Daniel

Quoted 134 lines · Thomas Wood
---
 lib/igt_core.c | 34 ----------------------------------
 lib/igt_core.h | 36 ++++++++++++++++++++++++++++++++----
 2 files changed, 32 insertions(+), 38 deletions(-)
lib/igt_core.c +0 -34
index eef338b..afecdf1 100644
@@ -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()
lib/igt_core.h +32 -5
index 0086945..88b47bf 100644
@@ -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

Quoted 9 lines
Quoted 4 lines

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#4 lore raw

PATCH 3/4 lib: remove handled option arguments from argv

In reply to Thomas Wood

Remove options from argv that have been handled by getopt to allow additional non-option parameters to be processed in the test application.

This fixes issues when using options such as --debug with tests that accept additional non-option parameters.

---
 lib/igt_core.c                    | 13 +++++++++----
 lib/igt_core.h                    | 12 ++++++------
 lib/tests/igt_list_only.c         |  3 ++-
 lib/tests/igt_no_exit.c           |  3 ++-
 lib/tests/igt_no_exit_list_only.c |  3 ++-
 lib/tests/igt_no_subtest.c        |  3 ++-
 lib/tests/igt_simulation.c        | 15 ++++++++++-----
 tests/gem_ctx_basic.c             |  2 +-
 tests/gem_render_copy.c           |  2 +-
 tests/gem_seqno_wrap.c            |  2 +-
 tests/gem_stress.c                |  2 +-
 tests/kms_psr_sink_crc.c          |  2 +-
 tests/kms_setmode.c               |  2 +-
 tests/pm_rpm.c                    |  2 +-
 14 files changed, 40 insertions(+), 26 deletions(-)
lib/igt_core.c +9 -4
index afecdf1..75b98f6 100644
@@ -487,7 +487,7 @@ static void oom_adjust_for_doom(void)
 	low_mem_killer_disable(true);
 }
 
-static int common_init(int argc, char **argv,
+static int common_init(int *argc, char **argv,
 		       const char *extra_short_opts,
 		       struct option *extra_long_opts,
 		       const char *help_str,
@@ -582,7 +582,7 @@ static int common_init(int argc, char **argv,
 		       std_short_opts);
 	assert(ret >= 0);
 
-	while ((c = getopt_long(argc, argv, short_opts, combined_opts,
+	while ((c = getopt_long(*argc, argv, short_opts, combined_opts,
 			       &option_index)) != -1) {
 		switch(c) {
 		case OPT_INTERACTIVE_DEBUG:
@@ -655,6 +655,11 @@ out:
 	if (!test_with_subtests)
 		gettime(&subtest_time);
 
+	for (i = 0; (optind + i) < *argc; i++)
+		argv[i + 1] = argv[optind + i];
+
+	*argc = *argc - optind + 1;
+
 	return ret;
 }
 
@@ -678,7 +683,7 @@ out:
  *
  * Returns: Forwards any option parsing errors from getopt_long.
  */
-int igt_subtest_init_parse_opts(int argc, char **argv,
+int igt_subtest_init_parse_opts(int *argc, char **argv,
 				const char *extra_short_opts,
 				struct option *extra_long_opts,
 				const char *help_str,
@@ -707,7 +712,7 @@ enum igt_log_level igt_log_level = IGT_LOG_INFO;
  * This initializes a simple test without any support for subtests and allows
  * an arbitrary set of additional options.
  */
-void igt_simple_init_parse_opts(int argc, char **argv,
+void igt_simple_init_parse_opts(int *argc, char **argv,
 				const char *extra_short_opts,
 				struct option *extra_long_opts,
 				const char *help_str,
lib/igt_core.h +6 -6
index 88b47bf..e1833cf 100644
@@ -110,7 +110,7 @@ typedef int (*igt_opt_handler_t)(int opt, int opt_index);
 #ifndef __GTK_DOC_IGNORE__ /* gtkdoc wants to document this forward decl */
 struct option;
 #endif
-int igt_subtest_init_parse_opts(int argc, char **argv,
+int igt_subtest_init_parse_opts(int *argc, char **argv,
 				const char *extra_short_opts,
 				struct option *extra_long_opts,
 				const char *help_str,
@@ -130,7 +130,7 @@ int igt_subtest_init_parse_opts(int argc, char **argv,
  * #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);
+#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
@@ -195,14 +195,14 @@ 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_parse_opts(argc, argv, NULL, NULL, NULL, NULL); \
+		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_parse_opts(int argc, char **argv,
+void igt_simple_init_parse_opts(int *argc, char **argv,
 				const char *extra_short_opts,
 				struct option *extra_long_opts,
 				const char *help_str,
@@ -219,7 +219,7 @@ void igt_simple_init_parse_opts(int argc, char **argv,
  * #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);
+#define igt_simple_init(argc, argv) igt_simple_init_parse_opts(&argc, argv, NULL, NULL, NULL, NULL);
 
 /**
  * igt_simple_main:
@@ -231,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_parse_opts(argc, argv, NULL, NULL, NULL, NULL); \
+		igt_simple_init_parse_opts(&argc, argv, NULL, NULL, NULL, NULL); \
 		igt_tokencat(__real_main, __LINE__)(); \
 		igt_exit(); \
 	} \
lib/tests/igt_list_only.c +2 -1
index d3ea8c2..65fa9da 100644
@@ -32,8 +32,9 @@ int main(int argc, char **argv)
 	char prog[] = "igt_list_only";
 	char arg[] = "--list-subtests";
 	char *fake_argv[] = {prog, arg};
+	int fake_argc = 2;
 
-	igt_subtest_init(2, fake_argv);
+	igt_subtest_init(fake_argc, fake_argv);
 
 	igt_subtest("A")
 		;
lib/tests/igt_no_exit.c +2 -1
index ba3fae0..dc89b83 100644
@@ -31,8 +31,9 @@ int main(int argc, char **argv)
 {
 	char prog[] = "igt_no_exit";
 	char *fake_argv[] = {prog};
+	int fake_argc = 1;
 
-	igt_subtest_init(1, fake_argv);
+	igt_subtest_init(fake_argc, fake_argv);
 
 	igt_subtest("A")
 		;
lib/tests/igt_no_exit_list_only.c +2 -1
index 3b232be..add3fc2 100644
@@ -32,8 +32,9 @@ int main(int argc, char **argv)
 	char prog[] = "igt_list_only";
 	char arg[] = "--list-subtests";
 	char *fake_argv[] = {prog, arg};
+	int fake_argc = 2;
 
-	igt_subtest_init(2, fake_argv);
+	igt_subtest_init(fake_argc, fake_argv);
 
 	igt_subtest("A")
 		;
lib/tests/igt_no_subtest.c +2 -1
index 47f15fc..1ae62cf 100644
@@ -31,8 +31,9 @@ int main(int argc, char **argv)
 {
 	char prog[] = "igt_no_exit";
 	char *fake_argv[] = {prog};
+	int fake_argc = 1;
 
-	igt_subtest_init(1, fake_argv);
+	igt_subtest_init(fake_argc, fake_argv);
 
 	igt_exit();
 }
lib/tests/igt_simulation.c +10 -5
index e588959..32830ba 100644
@@ -55,22 +55,27 @@ char *argv_run[] = { test };
 static int do_fork(void)
 {
 	int pid, status;
+	int argc;
 
 	switch (pid = fork()) {
 	case -1:
 		internal_assert(0);
 	case 0:
 		if (simple) {
-			igt_simple_init(1, argv_run);
+			argc = 1;
+			igt_simple_init(argc, argv_run);
 
 			igt_skip_on_simulation();
 
 			igt_exit();
 		} else {
-			if (list_subtests)
-				igt_subtest_init(2, argv_list);
-			else
-				igt_subtest_init(1, argv_run);
+			if (list_subtests) {
+				argc = 2;
+				igt_subtest_init(argc, argv_list);
+			} else {
+				argc = 1;
+				igt_subtest_init(argc, argv_run);
+			}
 
 			if (in_fixture) {
 				igt_fixture
tests/gem_ctx_basic.c +1 -1
index 2d866b3..4301b34 100644
@@ -144,7 +144,7 @@ int main(int argc, char *argv[])
 {
 	int i;
 
-	igt_simple_init_parse_opts(argc, argv, "i:c:n:mu", NULL, NULL,
+	igt_simple_init_parse_opts(&argc, argv, "i:c:n:mu", NULL, NULL,
 				   opt_handler);
 
 	fd = drm_open_any_render();
tests/gem_render_copy.c +1 -1
index 6348eee..df1ac88 100644
@@ -141,7 +141,7 @@ int main(int argc, char **argv)
 	igt_render_copyfunc_t render_copy = NULL;
 	int opt_dump_aub = igt_aub_dump_enabled();
 
-	igt_simple_init_parse_opts(argc, argv, "da", NULL, NULL, opt_handler);
+	igt_simple_init_parse_opts(&argc, argv, "da", NULL, NULL, opt_handler);
 
 	igt_fixture {
 		data.drm_fd = drm_open_any_render();
tests/gem_seqno_wrap.c +1 -1
index d07ec96..ba58ebd 100644
@@ -503,7 +503,7 @@ int main(int argc, char **argv)
 	options.prewrap_space = 21;
 	options.buffers = 10;
 
-	igt_simple_init_parse_opts(argc, argv, "n:bvt:dp:ri:", long_options,
+	igt_simple_init_parse_opts(&argc, argv, "n:bvt:dp:ri:", long_options,
 				   help, parse_options);
 
 	card_index = drm_get_card();
tests/gem_stress.c +1 -1
index f687b2d..cb951af 100644
@@ -854,7 +854,7 @@ int main(int argc, char **argv)
 	options.tiles_per_buf = options.scratch_buf_size / TILE_BYTES(options.tile_size);
 	options.check_render_cpyfn = 0;
 
-	igt_simple_init_parse_opts(argc, argv,"ds:g:c:t:rbuxmo:fp:",
+	igt_simple_init_parse_opts(&argc, argv,"ds:g:c:t:rbuxmo:fp:",
 				   long_options, NULL, parse_options);
 
 	drm_fd = drm_open_any();
tests/kms_psr_sink_crc.c +1 -1
index 98b60cf..9256640 100644
@@ -489,7 +489,7 @@ int main(int argc, char *argv[])
 	data_t data = {};
 	enum operations op;
 
-	igt_subtest_init_parse_opts(argc, argv, "", long_options,
+	igt_subtest_init_parse_opts(&argc, argv, "", long_options,
 				    help_str, opt_handler);
 	igt_skip_on_simulation();
 
tests/kms_setmode.c +1 -1
index f13871e..8e6afbf 100644
@@ -699,7 +699,7 @@ int main(int argc, char **argv)
 	int i;
 	int ret;
 
-	ret = igt_subtest_init_parse_opts(argc, argv, "dt:", NULL, help_str,
+	ret = igt_subtest_init_parse_opts(&argc, argv, "dt:", NULL, help_str,
 					  opt_handler);
 	if (ret < 0)
 		return ret == -1 ? 0 : ret;
tests/pm_rpm.c +1 -1
index 84254b7..c2847d0 100644
@@ -1811,7 +1811,7 @@ int main(int argc, char *argv[])
 		{ 0, 0, 0, 0 }
 	};
 
-	igt_subtest_init_parse_opts(argc, argv, "", long_options,
+	igt_subtest_init_parse_opts(&argc, argv, "", long_options,
 				    help_str, opt_handler);
 
 	/* Skip instead of failing in case the machine is not prepared to reach
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#5 lore raw

PATCH 4/4 tests: remove extra file

In reply to Thomas Wood

Remove a file accidentally added in commit 6f582f7 (tests: Add gem_ctx_param_basic).

---
 tests/gem_ctx_param_basic. | 172 ---------------------------------------------
 1 file changed, 172 deletions(-)
 delete mode 100644 tests/gem_ctx_param_basic.
tests/gem_ctx_param_basic. deleted +0 -172
deleted file mode 100644
index 2d866b3..0000000
@@ -1,172 +0,0 @@
-/*
- * Copyright © 2011 Intel Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- * IN THE SOFTWARE.
- *
- * Authors:
- *    Ben Widawsky <[email protected]>
- *
- */
-
-/*
- * This test is useful for finding memory and refcount leaks.
- */
-
-#include <pthread.h>
-#include <stdlib.h>
-#include <sys/ioctl.h>
-#include <stdio.h>
-#include <string.h>
-#include <fcntl.h>
-#include <inttypes.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include "drm.h"
-#include "ioctl_wrappers.h"
-#include "drmtest.h"
-#include "intel_bufmgr.h"
-#include "intel_batchbuffer.h"
-#include "intel_io.h"
-#include "intel_chipset.h"
-
-IGT_TEST_DESCRIPTION("Basic test for memory and refcount leaks.");
-
-/* options */
-int num_contexts = 10;
-int uncontexted = 0; /* test only context create/destroy */
-int multiple_fds = 1;
-int iter = 10000;
-
-/* globals */
-pthread_t *threads;
-int devid;
-int fd;
-
-static void init_buffer(drm_intel_bufmgr *bufmgr,
-			struct igt_buf *buf,
-			uint32_t size)
-{
-	buf->bo = drm_intel_bo_alloc(bufmgr, "", size, 4096);
-	buf->size = size;
-	igt_assert(buf->bo);
-	buf->tiling = I915_TILING_NONE;
-	buf->stride = 4096;
-}
-
-static void *work(void *arg)
-{
-	struct intel_batchbuffer *batch;
-	igt_render_copyfunc_t rendercopy = igt_get_render_copyfunc(devid);
-	drm_intel_context *context;
-	drm_intel_bufmgr *bufmgr;
-	int td_fd;
-	int i;
-
-	if (multiple_fds)
-		td_fd = fd = drm_open_any_render();
-	else
-		td_fd = fd;
-
-	igt_assert(td_fd >= 0);
-
-	bufmgr = drm_intel_bufmgr_gem_init(td_fd, 4096);
-	batch = intel_batchbuffer_alloc(bufmgr, devid);
-	context = drm_intel_gem_context_create(bufmgr);
-	igt_require(context);
-
-	for (i = 0; i < iter; i++) {
-		struct igt_buf src, dst;
-
-		init_buffer(bufmgr, &src, 4096);
-		init_buffer(bufmgr, &dst, 4096);
-
-
-		if (uncontexted) {
-			igt_assert(rendercopy);
-			rendercopy(batch, NULL, &src, 0, 0, 0, 0, &dst, 0, 0);
-		} else {
-			int ret;
-			ret = drm_intel_bo_subdata(batch->bo, 0, 4096, batch->buffer);
-			igt_assert(ret == 0);
-			intel_batchbuffer_flush_with_context(batch, context);
-		}
-	}
-
-	drm_intel_gem_context_destroy(context);
-	intel_batchbuffer_free(batch);
-	drm_intel_bufmgr_destroy(bufmgr);
-
-	if (multiple_fds)
-		close(td_fd);
-
-	pthread_exit(NULL);
-}
-
-static int opt_handler(int opt, int opt_index)
-{
-	switch (opt) {
-		case 'i':
-			iter = atoi(optarg);
-			break;
-		case 'c':
-			num_contexts = atoi(optarg);
-			break;
-		case 'm':
-			multiple_fds = 1;
-			break;
-		case 'u':
-			uncontexted = 1;
-			break;
-	}
-
-	return 0;
-}
-
-int main(int argc, char *argv[])
-{
-	int i;
-
-	igt_simple_init_parse_opts(argc, argv, "i:c:n:mu", NULL, NULL,
-				   opt_handler);
-
-	fd = drm_open_any_render();
-	devid = intel_get_drm_devid(fd);
-
-	if (igt_run_in_simulation()) {
-		num_contexts = 2;
-		iter = 4;
-	}
-
-	threads = calloc(num_contexts, sizeof(*threads));
-
-	for (i = 0; i < num_contexts; i++)
-		pthread_create(&threads[i], NULL, work, &i);
-
-	for (i = 0; i < num_contexts; i++) {
-		void *retval;
-		igt_assert(pthread_join(threads[i], &retval) == 0);
-	}
-
-	free(threads);
-	close(fd);
-
-	igt_exit();
-}
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#6 lore raw
In reply to Thomas Wood
Quoted 25 lines · Thomas Wood
---
 tests/kms_flip_event_leak.c | 2 +-
 tests/kms_plane.c           | 2 +-
 tests/kms_universal_plane.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
tests/kms_flip_event_leak.c +1 -1
index 8a5e6db..ea4ce4c 100644
@@ -119,7 +119,7 @@ igt_simple_main
 
 	igt_display_init(&data.display, data.drm_fd);
 
-	for (pipe = 0; pipe < 3; pipe++) {
+	for_each_pipe(&data.display, pipe) {
 		for_each_connected_output(&data.display, output) {
 			if (test(&data, pipe, output))
 				valid_tests++;
tests/kms_plane.c +0 -0
index c94eac0..8a08f20 100644

tests/kms_plane.c igt_main · line 402

Quoted 5 lines
tests/kms_plane.c +1 -1
@@ -399,7 +399,7 @@ igt_main
 		igt_display_init(&data.display, data.drm_fd);
 	}
 
-	for (int pipe = 0; pipe < 3; pipe++)
+	for (int pipe = 0; pipe < I915_MAX_PIPES; pipe++)

Should we maybe add a for_each_possible_pipe for this kind of stuff? Just an idea, but should be quick to implement if we also add a new semantic patch to lib/igt.cocci to match it.
-Daniel

Quoted 23 lines
tests/kms_plane.c +0 -0
 		run_tests_for_pipe(&data, pipe);
 
 	igt_fixture {
tests/kms_universal_plane.c +1 -1
index 04ff840..6a05584 100644
@@ -569,7 +569,7 @@ igt_main
 		igt_require(data.display.has_universal_planes);
 	}
 
-	for (int pipe = 0; pipe < 3; pipe++)
+	for (int pipe = 0; pipe < I915_MAX_PIPES; pipe++)
 		run_tests_for_pipe(&data, pipe);
 
 	igt_fixture {
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx