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

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


The object size parameter, previously gotten from argv[1], is now the
parameter -s.

Signed-off-by: Petri Latvala <petri.latvala at intel.com>
---
 tests/i915/gem_pwrite_pread.c | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/tests/i915/gem_pwrite_pread.c b/tests/i915/gem_pwrite_pread.c
index f91fc7c4..3a58eae6 100644
--- a/tests/i915/gem_pwrite_pread.c
+++ b/tests/i915/gem_pwrite_pread.c
@@ -252,18 +252,30 @@ static const char *bytes_per_sec(char *buf, double v)
 
 uint32_t *tmp, src, dst;
 int fd;
+int object_size = 0;
 
-int main(int argc, char **argv)
+static int opt_handler(int opt, int opt_index, void *data)
+{
+	switch (opt) {
+	case 's':
+		object_size = atoi(optarg);
+		break;
+	default:
+		return IGT_OPT_HANDLER_ERROR;
+	}
+
+	return IGT_OPT_HANDLER_SUCCESS;
+}
+
+const char *help_str = "  -s\tObject size in bytes\n";
+
+igt_main_args("s:", NULL, help_str, opt_handler, NULL)
 {
-	int object_size = 0;
 	uint32_t buf[20];
 	int count;
 
-	igt_subtest_init(argc, argv);
 	igt_skip_on_simulation();
 
-	if (argc > 1)
-		object_size = atoi(argv[1]);
 	if (object_size == 0)
 		object_size = OBJECT_SIZE;
 	object_size = (object_size + 3) & -4;
@@ -405,6 +417,4 @@ int main(int argc, char **argv)
 
 		close(fd);
 	}
-
-	igt_exit();
 }
-- 
2.19.1



More information about the igt-dev mailing list