diff mbox

[CI,4/5] igt/gem_workarounds: Reduce manual list to combinatorial loops

Message ID 20171003134045.7600-4-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show

Commit Message

Chris Wilson Oct. 3, 2017, 1:40 p.m. UTC
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 tests/gem_workarounds.c | 50 ++++++++++++++++++++++++-------------------------
 1 file changed, 24 insertions(+), 26 deletions(-)

Comments

Mika Kuoppala Oct. 4, 2017, 1:47 p.m. UTC | #1
Chris Wilson <chris@chris-wilson.co.uk> writes:

> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

Reviewed-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>

> ---
>  tests/gem_workarounds.c | 50 ++++++++++++++++++++++++-------------------------
>  1 file changed, 24 insertions(+), 26 deletions(-)
>
> diff --git a/tests/gem_workarounds.c b/tests/gem_workarounds.c
> index 1c514a62..74bb11d2 100644
> --- a/tests/gem_workarounds.c
> +++ b/tests/gem_workarounds.c
> @@ -215,6 +215,24 @@ static void check_workarounds(int fd, enum operation op, unsigned int flags)
>  igt_main
>  {
>  	int device = -1;
> +	const struct {
> +		const char *name;
> +		enum operation op;
> +	} ops[] =   {
> +		{ "basic-read", SIMPLE_READ },
> +		{ "reset", GPU_RESET },
> +		{ "suspend-resume", SUSPEND_RESUME },
> +		{ }
> +	}, *op;
> +	const struct {
> +		const char *name;
> +		unsigned int flags;
> +	} modes[] =   {
> +		{ "", 0 },
> +		{ "-context", CONTEXT },
> +		{ "-fd", FDS },
> +		{ }
> +	}, *m;
>  
>  	igt_fixture {
>  		FILE *file;
> @@ -254,30 +272,10 @@ igt_main
>  		close(fd);
>  	}
>  
> -	igt_subtest("basic-read")
> -		check_workarounds(device, SIMPLE_READ, 0);
> -
> -	igt_subtest("basic-read-context")
> -		check_workarounds(device, SIMPLE_READ, CONTEXT);
> -
> -	igt_subtest("basic-read-fd")
> -		check_workarounds(device, SIMPLE_READ, FDS);
> -
> -	igt_subtest("reset")
> -		check_workarounds(device, GPU_RESET, 0);
> -
> -	igt_subtest("reset-context")
> -		check_workarounds(device, GPU_RESET, CONTEXT);
> -
> -	igt_subtest("reset-fd")
> -		check_workarounds(device, GPU_RESET, FDS);
> -
> -	igt_subtest("suspend-resume")
> -		check_workarounds(device, SUSPEND_RESUME, 0);
> -
> -	igt_subtest("suspend-resume-context")
> -		check_workarounds(device, SUSPEND_RESUME, CONTEXT);
> -
> -	igt_subtest("suspend-resume-fd")
> -		check_workarounds(device, SUSPEND_RESUME, FDS);
> +	for (op = ops; op->name; op++) {
> +		for (m = modes; m->name; m++) {
> +			igt_subtest_f("%s%s", op->name, m->name)
> +				check_workarounds(device, op->op, m->flags);
> +		}
> +	}
>  }
> -- 
> 2.14.2
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
diff mbox

Patch

diff --git a/tests/gem_workarounds.c b/tests/gem_workarounds.c
index 1c514a62..74bb11d2 100644
--- a/tests/gem_workarounds.c
+++ b/tests/gem_workarounds.c
@@ -215,6 +215,24 @@  static void check_workarounds(int fd, enum operation op, unsigned int flags)
 igt_main
 {
 	int device = -1;
+	const struct {
+		const char *name;
+		enum operation op;
+	} ops[] =   {
+		{ "basic-read", SIMPLE_READ },
+		{ "reset", GPU_RESET },
+		{ "suspend-resume", SUSPEND_RESUME },
+		{ }
+	}, *op;
+	const struct {
+		const char *name;
+		unsigned int flags;
+	} modes[] =   {
+		{ "", 0 },
+		{ "-context", CONTEXT },
+		{ "-fd", FDS },
+		{ }
+	}, *m;
 
 	igt_fixture {
 		FILE *file;
@@ -254,30 +272,10 @@  igt_main
 		close(fd);
 	}
 
-	igt_subtest("basic-read")
-		check_workarounds(device, SIMPLE_READ, 0);
-
-	igt_subtest("basic-read-context")
-		check_workarounds(device, SIMPLE_READ, CONTEXT);
-
-	igt_subtest("basic-read-fd")
-		check_workarounds(device, SIMPLE_READ, FDS);
-
-	igt_subtest("reset")
-		check_workarounds(device, GPU_RESET, 0);
-
-	igt_subtest("reset-context")
-		check_workarounds(device, GPU_RESET, CONTEXT);
-
-	igt_subtest("reset-fd")
-		check_workarounds(device, GPU_RESET, FDS);
-
-	igt_subtest("suspend-resume")
-		check_workarounds(device, SUSPEND_RESUME, 0);
-
-	igt_subtest("suspend-resume-context")
-		check_workarounds(device, SUSPEND_RESUME, CONTEXT);
-
-	igt_subtest("suspend-resume-fd")
-		check_workarounds(device, SUSPEND_RESUME, FDS);
+	for (op = ops; op->name; op++) {
+		for (m = modes; m->name; m++) {
+			igt_subtest_f("%s%s", op->name, m->name)
+				check_workarounds(device, op->op, m->flags);
+		}
+	}
 }