[igt-dev] [PATCH i-g-t 21/36] i915/gen3_render_tiledy_blits: Nuke custom main function

Petri Latvala petri.latvala at intel.com
Thu May 23 12:27:12 UTC 2019


The buffer count parameter, previously gotten from argv[1], is now the
parameter -c.

Signed-off-by: Petri Latvala <petri.latvala at intel.com>
---
 tests/i915/gen3_render_tiledy_blits.c | 28 ++++++++++++++++++---------
 1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/tests/i915/gen3_render_tiledy_blits.c b/tests/i915/gen3_render_tiledy_blits.c
index 6d1d8bca..94127b62 100644
--- a/tests/i915/gen3_render_tiledy_blits.c
+++ b/tests/i915/gen3_render_tiledy_blits.c
@@ -323,21 +323,33 @@ check_bo(int fd, uint32_t handle, uint32_t val)
 	munmap(v, WIDTH*HEIGHT*4);
 }
 
-int main(int argc, char **argv)
+int count;
+
+static int opt_handler(int opt, int opt_index, void *data)
+{
+	switch (opt) {
+	case 'c':
+		count = atoi(optarg);
+		break;
+	default:
+		return IGT_OPT_HANDLER_ERROR;
+	}
+
+	return IGT_OPT_HANDLER_SUCCESS;
+}
+
+const char *help_str = "  -c\tBuffer count\n";
+
+igt_simple_main_args("c:", NULL, help_str, opt_handler, NULL)
 {
 	uint32_t *handle, *start_val;
 	uint32_t start = 0;
-	int i, fd, count;
-
-	igt_simple_init(argc, argv);
+	int i, fd;
 
 	fd = drm_open_driver(DRIVER_INTEL);
 
 	igt_require(IS_GEN3(intel_get_drm_devid(fd)));
 
-	count = 0;
-	if (argc > 1)
-		count = atoi(argv[1]);
 	if (count == 0)
 		count = 3 * gem_aperture_size(fd) / (1024*1024) / 2;
 	igt_info("Using %d 1MiB buffers\n", count);
@@ -398,6 +410,4 @@ int main(int argc, char **argv)
 	for (i = 0; i < count; i++)
 		check_bo(fd, handle[i], start_val[i]);
 	igt_info("done\n");
-
-	igt_exit();
 }
-- 
2.19.1



More information about the igt-dev mailing list