public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
* [PATCH 1/3] tests: drm_open_any doesn't fail
@ 2013-12-06  9:48 Daniel Vetter
  2013-12-06  9:48 ` [PATCH 2/3] lib: add igt_pipe_crc_check Daniel Vetter
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Daniel Vetter @ 2013-12-06  9:48 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter

Or more precisely: It already has an igt_require. So we cant ditch it
from tests.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 tests/kms_cursor_crc.c     | 1 -
 tests/kms_fbc_crc.c        | 1 -
 tests/kms_pipe_crc_basic.c | 1 -
 3 files changed, 3 deletions(-)

diff --git a/tests/kms_cursor_crc.c b/tests/kms_cursor_crc.c
index 74da32eb7497..b78ea7863585 100644
--- a/tests/kms_cursor_crc.c
+++ b/tests/kms_cursor_crc.c
@@ -338,7 +338,6 @@ igt_main
 		const char *cmd = "pipe A none";
 
 		data.drm_fd = drm_open_any();
-		igt_require(data.drm_fd >= 0);
 
 		igt_set_vt_graphics_mode();
 
diff --git a/tests/kms_fbc_crc.c b/tests/kms_fbc_crc.c
index 660086290f28..7a7f3903667b 100644
--- a/tests/kms_fbc_crc.c
+++ b/tests/kms_fbc_crc.c
@@ -492,7 +492,6 @@ igt_main
 		FILE *status;
 
 		data.drm_fd = drm_open_any();
-		igt_require(data.drm_fd);
 		igt_set_vt_graphics_mode();
 
 		data.devid = intel_get_drm_devid(data.drm_fd);
diff --git a/tests/kms_pipe_crc_basic.c b/tests/kms_pipe_crc_basic.c
index 3bc9eb0ee361..0e793cdf617d 100644
--- a/tests/kms_pipe_crc_basic.c
+++ b/tests/kms_pipe_crc_basic.c
@@ -219,7 +219,6 @@ igt_main
 		const char *cmd = "pipe A none";
 
 		data.drm_fd = drm_open_any();
-		igt_require(data.drm_fd >= 0);
 
 		igt_set_vt_graphics_mode();
 
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] lib: add igt_pipe_crc_check
  2013-12-06  9:48 [PATCH 1/3] tests: drm_open_any doesn't fail Daniel Vetter
@ 2013-12-06  9:48 ` Daniel Vetter
  2013-12-06 12:56   ` Damien Lespiau
  2013-12-06  9:48 ` [PATCH 3/3] lib: make igt_pipe_crc_start never fail Daniel Vetter
  2013-12-06 12:58 ` [PATCH 1/3] tests: drm_open_any doesn't fail Damien Lespiau
  2 siblings, 1 reply; 6+ messages in thread
From: Daniel Vetter @ 2013-12-06  9:48 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter

No need to duplicate this all over the place.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 lib/igt_debugfs.c          | 18 ++++++++++++++++++
 lib/igt_debugfs.h          |  1 +
 tests/kms_cursor_crc.c     | 18 ++----------------
 tests/kms_fbc_crc.c        | 14 +-------------
 tests/kms_pipe_crc_basic.c | 25 ++++++++-----------------
 5 files changed, 30 insertions(+), 46 deletions(-)

diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index 1ceaf59db11f..139be893f75b 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -205,6 +205,24 @@ static void pipe_crc_exit_handler(int sig)
 	igt_pipe_crc_reset();
 }
 
+void igt_pipe_crc_check(igt_debugfs_t *debugfs)
+{
+	const char *cmd = "pipe A none";
+	FILE *ctl;
+	size_t written;
+	int ret;
+
+	ctl = igt_debugfs_fopen(debugfs, "i915_display_crc_ctl", "r+");
+	igt_require_f(ctl,
+		      "No display_crc_ctl found, kernel too old\n");
+	written = fwrite(cmd, 1, strlen(cmd), ctl);
+	ret = fflush(ctl);
+	igt_require_f((written == strlen(cmd) && ret == 0) || errno != ENODEV,
+		      "CRCs not supported on this platform\n");
+
+	fclose(ctl);
+}
+
 igt_pipe_crc_t *
 igt_pipe_crc_new(igt_debugfs_t *debugfs, int drm_fd, enum pipe pipe,
 		 enum intel_pipe_crc_source source)
diff --git a/lib/igt_debugfs.h b/lib/igt_debugfs.h
index 40d9d28fd49b..393b5767adbe 100644
--- a/lib/igt_debugfs.h
+++ b/lib/igt_debugfs.h
@@ -70,6 +70,7 @@ bool igt_crc_is_null(igt_crc_t *crc);
 bool igt_crc_equal(igt_crc_t *a, igt_crc_t *b);
 char *igt_crc_to_string(igt_crc_t *crc);
 
+void igt_pipe_crc_check(igt_debugfs_t *debugfs);
 igt_pipe_crc_t *
 igt_pipe_crc_new(igt_debugfs_t *debugfs, int drm_fd, enum pipe pipe,
 		 enum intel_pipe_crc_source source);
diff --git a/tests/kms_cursor_crc.c b/tests/kms_cursor_crc.c
index b78ea7863585..d80695f67e2f 100644
--- a/tests/kms_cursor_crc.c
+++ b/tests/kms_cursor_crc.c
@@ -53,7 +53,6 @@ typedef struct {
 	int drm_fd;
 	igt_debugfs_t debugfs;
 	drmModeRes *resources;
-	FILE *ctl;
 	uint32_t fb_id[NUM_CURSOR_TYPES];
 	struct kmstest_fb fb[NUM_CURSOR_TYPES];
 	igt_pipe_crc_t **pipe_crc;
@@ -333,23 +332,12 @@ igt_main
 	igt_skip_on_simulation();
 
 	igt_fixture {
-		size_t written;
-		int ret;
-		const char *cmd = "pipe A none";
-
 		data.drm_fd = drm_open_any();
 
 		igt_set_vt_graphics_mode();
 
 		igt_debugfs_init(&data.debugfs);
-		data.ctl = igt_debugfs_fopen(&data.debugfs,
-					     "i915_display_crc_ctl", "r+");
-		igt_require_f(data.ctl,
-			      "No display_crc_ctl found, kernel too old\n");
-		written = fwrite(cmd, 1, strlen(cmd), data.ctl);
-		ret = fflush(data.ctl);
-		igt_require_f((written == strlen(cmd) && ret == 0) || errno != ENODEV,
-			      "CRCs not supported on this platform\n");
+		igt_pipe_crc_check(&data.debugfs);
 
 		display_init(&data);
 
@@ -376,8 +364,6 @@ igt_main
 	igt_subtest("cursor-black-invisible-offscreen")
 		run_test(&data, BLACK_INVISIBLE, false);
 
-	igt_fixture {
+	igt_fixture
 		display_fini(&data);
-		fclose(data.ctl);
-	}
 }
diff --git a/tests/kms_fbc_crc.c b/tests/kms_fbc_crc.c
index 7a7f3903667b..4cddd27428d0 100644
--- a/tests/kms_fbc_crc.c
+++ b/tests/kms_fbc_crc.c
@@ -60,7 +60,6 @@ typedef struct {
 	int drm_fd;
 	igt_debugfs_t debugfs;
 	drmModeRes *resources;
-	FILE *ctl;
 	igt_crc_t ref_crc[2];
 	igt_pipe_crc_t **pipe_crc;
 	drm_intel_bufmgr *bufmgr;
@@ -485,9 +484,6 @@ igt_main
 	igt_skip_on_simulation();
 
 	igt_fixture {
-		size_t written;
-		int ret;
-		const char *cmd = "pipe A none";
 		char buf[64];
 		FILE *status;
 
@@ -497,14 +493,7 @@ igt_main
 		data.devid = intel_get_drm_devid(data.drm_fd);
 
 		igt_debugfs_init(&data.debugfs);
-		data.ctl = igt_debugfs_fopen(&data.debugfs,
-					     "i915_display_crc_ctl", "r+");
-		igt_require_f(data.ctl,
-			      "No display_crc_ctl found, kernel too old\n");
-		written = fwrite(cmd, 1, strlen(cmd), data.ctl);
-		ret = fflush(data.ctl);
-		igt_require_f((written == strlen(cmd) && ret == 0) || errno != ENODEV,
-			      "CRCs not supported on this platform\n");
+		igt_pipe_crc_check(&data.debugfs);
 
 		status = igt_debugfs_fopen(&data.debugfs, "i915_fbc_status", "r");
 		igt_require_f(status, "No i915_fbc_status found\n");
@@ -532,6 +521,5 @@ igt_main
 	igt_fixture {
 		drm_intel_bufmgr_destroy(data.bufmgr);
 		display_fini(&data);
-		fclose(data.ctl);
 	}
 }
diff --git a/tests/kms_pipe_crc_basic.c b/tests/kms_pipe_crc_basic.c
index 0e793cdf617d..90d9b9404877 100644
--- a/tests/kms_pipe_crc_basic.c
+++ b/tests/kms_pipe_crc_basic.c
@@ -45,18 +45,21 @@ typedef struct {
 	drmModeRes *resources;
 	int n_connectors;
 	connector_t *connectors;
-	FILE *ctl;
 } data_t;
 
 static void test_bad_command(data_t *data, const char *cmd)
 {
+	FILE *ctl;
 	size_t written;
 
-	written = fwrite(cmd, 1, strlen(cmd), data->ctl);
-	fflush(data->ctl);
+	ctl = igt_debugfs_fopen(&data->debugfs, "i915_display_crc_ctl", "r+");
+	written = fwrite(cmd, 1, strlen(cmd), ctl);
+	fflush(ctl);
 	igt_assert_cmpint(written, ==, (strlen(cmd)));
-	igt_assert(ferror(data->ctl));
+	igt_assert(ferror(ctl));
 	igt_assert_cmpint(errno, ==, EINVAL);
+
+	fclose(ctl);
 }
 
 static void connector_init(data_t *data, connector_t *connector,
@@ -214,10 +217,6 @@ igt_main
 	igt_skip_on_simulation();
 
 	igt_fixture {
-		size_t written;
-		int ret;
-		const char *cmd = "pipe A none";
-
 		data.drm_fd = drm_open_any();
 
 		igt_set_vt_graphics_mode();
@@ -225,14 +224,7 @@ igt_main
 		display_init(&data);
 
 		igt_debugfs_init(&data.debugfs);
-		data.ctl = igt_debugfs_fopen(&data.debugfs,
-					     "i915_display_crc_ctl", "r+");
-		igt_require_f(data.ctl,
-			      "No display_crc_ctl found, kernel too old\n");
-		written = fwrite(cmd, 1, strlen(cmd), data.ctl);
-		ret = fflush(data.ctl);
-		igt_require_f((written == strlen(cmd) && ret == 0) || errno != ENODEV,
-			      "CRCs not supported on this platform\n");
+		igt_pipe_crc_check(&data.debugfs);
 	}
 
 	igt_subtest("bad-pipe")
@@ -257,6 +249,5 @@ igt_main
 
 	igt_fixture {
 		display_fini(&data);
-		fclose(data.ctl);
 	}
 }
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] lib: make igt_pipe_crc_start never fail
  2013-12-06  9:48 [PATCH 1/3] tests: drm_open_any doesn't fail Daniel Vetter
  2013-12-06  9:48 ` [PATCH 2/3] lib: add igt_pipe_crc_check Daniel Vetter
@ 2013-12-06  9:48 ` Daniel Vetter
  2013-12-06 12:52   ` Damien Lespiau
  2013-12-06 12:58 ` [PATCH 1/3] tests: drm_open_any doesn't fail Damien Lespiau
  2 siblings, 1 reply; 6+ messages in thread
From: Daniel Vetter @ 2013-12-06  9:48 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter

It's what callers expect - pipe_crc_new is the function where
we pass a potential failure back to callers.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 lib/igt_debugfs.c          | 7 ++-----
 lib/igt_debugfs.h          | 2 +-
 tests/kms_pipe_crc_basic.c | 2 +-
 3 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index 139be893f75b..4b96521331af 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -269,12 +269,11 @@ void igt_pipe_crc_free(igt_pipe_crc_t *pipe_crc)
 	free(pipe_crc);
 }
 
-bool igt_pipe_crc_start(igt_pipe_crc_t *pipe_crc)
+void igt_pipe_crc_start(igt_pipe_crc_t *pipe_crc)
 {
 	igt_crc_t *crcs = NULL;
 
-	if (!igt_pipe_crc_do_start(pipe_crc))
-		return false;
+	igt_assert(igt_pipe_crc_do_start(pipe_crc));
 
 	/*
 	 * For some no yet identified reason, the first CRC is bonkers. So
@@ -282,8 +281,6 @@ bool igt_pipe_crc_start(igt_pipe_crc_t *pipe_crc)
 	 */
 	igt_pipe_crc_get_crcs(pipe_crc, 1, &crcs);
 	free(crcs);
-
-	return true;
 }
 
 void igt_pipe_crc_stop(igt_pipe_crc_t *pipe_crc)
diff --git a/lib/igt_debugfs.h b/lib/igt_debugfs.h
index 393b5767adbe..075e44625213 100644
--- a/lib/igt_debugfs.h
+++ b/lib/igt_debugfs.h
@@ -75,7 +75,7 @@ igt_pipe_crc_t *
 igt_pipe_crc_new(igt_debugfs_t *debugfs, int drm_fd, enum pipe pipe,
 		 enum intel_pipe_crc_source source);
 void igt_pipe_crc_free(igt_pipe_crc_t *pipe_crc);
-bool igt_pipe_crc_start(igt_pipe_crc_t *pipe_crc);
+void igt_pipe_crc_start(igt_pipe_crc_t *pipe_crc);
 void igt_pipe_crc_stop(igt_pipe_crc_t *pipe_crc);
 void igt_pipe_crc_get_crcs(igt_pipe_crc_t *pipe_crc, int n_crcs,
 			   igt_crc_t **out_crcs);
diff --git a/tests/kms_pipe_crc_basic.c b/tests/kms_pipe_crc_basic.c
index 90d9b9404877..3fc59344d90d 100644
--- a/tests/kms_pipe_crc_basic.c
+++ b/tests/kms_pipe_crc_basic.c
@@ -180,7 +180,7 @@ static void test_read_crc(data_t *data, int pipe, unsigned flags)
 			continue;
 		valid_connectors++;
 
-		igt_assert(igt_pipe_crc_start(pipe_crc));
+		igt_pipe_crc_start(pipe_crc);
 
 		/* wait for 3 vblanks and the corresponding 3 CRCs */
 		igt_pipe_crc_get_crcs(pipe_crc, 3, &crcs);
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 3/3] lib: make igt_pipe_crc_start never fail
  2013-12-06  9:48 ` [PATCH 3/3] lib: make igt_pipe_crc_start never fail Daniel Vetter
@ 2013-12-06 12:52   ` Damien Lespiau
  0 siblings, 0 replies; 6+ messages in thread
From: Damien Lespiau @ 2013-12-06 12:52 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Intel Graphics Development

On Fri, Dec 06, 2013 at 10:48:44AM +0100, Daniel Vetter wrote:
> It's what callers expect - pipe_crc_new is the function where
> we pass a potential failure back to callers.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>

Oh, yes, initially ono had to specify the point at _start() time, but I
moved it to _new() mid-development and forgot to remove the return
value.

Reviewed-by: Damien Lespiau <damien.lespiau@intel.com>

> ---
>  lib/igt_debugfs.c          | 7 ++-----
>  lib/igt_debugfs.h          | 2 +-
>  tests/kms_pipe_crc_basic.c | 2 +-
>  3 files changed, 4 insertions(+), 7 deletions(-)
> 
> diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
> index 139be893f75b..4b96521331af 100644
> --- a/lib/igt_debugfs.c
> +++ b/lib/igt_debugfs.c
> @@ -269,12 +269,11 @@ void igt_pipe_crc_free(igt_pipe_crc_t *pipe_crc)
>  	free(pipe_crc);
>  }
>  
> -bool igt_pipe_crc_start(igt_pipe_crc_t *pipe_crc)
> +void igt_pipe_crc_start(igt_pipe_crc_t *pipe_crc)
>  {
>  	igt_crc_t *crcs = NULL;
>  
> -	if (!igt_pipe_crc_do_start(pipe_crc))
> -		return false;
> +	igt_assert(igt_pipe_crc_do_start(pipe_crc));
>  
>  	/*
>  	 * For some no yet identified reason, the first CRC is bonkers. So
> @@ -282,8 +281,6 @@ bool igt_pipe_crc_start(igt_pipe_crc_t *pipe_crc)
>  	 */
>  	igt_pipe_crc_get_crcs(pipe_crc, 1, &crcs);
>  	free(crcs);
> -
> -	return true;
>  }
>  
>  void igt_pipe_crc_stop(igt_pipe_crc_t *pipe_crc)
> diff --git a/lib/igt_debugfs.h b/lib/igt_debugfs.h
> index 393b5767adbe..075e44625213 100644
> --- a/lib/igt_debugfs.h
> +++ b/lib/igt_debugfs.h
> @@ -75,7 +75,7 @@ igt_pipe_crc_t *
>  igt_pipe_crc_new(igt_debugfs_t *debugfs, int drm_fd, enum pipe pipe,
>  		 enum intel_pipe_crc_source source);
>  void igt_pipe_crc_free(igt_pipe_crc_t *pipe_crc);
> -bool igt_pipe_crc_start(igt_pipe_crc_t *pipe_crc);
> +void igt_pipe_crc_start(igt_pipe_crc_t *pipe_crc);
>  void igt_pipe_crc_stop(igt_pipe_crc_t *pipe_crc);
>  void igt_pipe_crc_get_crcs(igt_pipe_crc_t *pipe_crc, int n_crcs,
>  			   igt_crc_t **out_crcs);
> diff --git a/tests/kms_pipe_crc_basic.c b/tests/kms_pipe_crc_basic.c
> index 90d9b9404877..3fc59344d90d 100644
> --- a/tests/kms_pipe_crc_basic.c
> +++ b/tests/kms_pipe_crc_basic.c
> @@ -180,7 +180,7 @@ static void test_read_crc(data_t *data, int pipe, unsigned flags)
>  			continue;
>  		valid_connectors++;
>  
> -		igt_assert(igt_pipe_crc_start(pipe_crc));
> +		igt_pipe_crc_start(pipe_crc);
>  
>  		/* wait for 3 vblanks and the corresponding 3 CRCs */
>  		igt_pipe_crc_get_crcs(pipe_crc, 3, &crcs);
> -- 
> 1.8.4.3
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/3] lib: add igt_pipe_crc_check
  2013-12-06  9:48 ` [PATCH 2/3] lib: add igt_pipe_crc_check Daniel Vetter
@ 2013-12-06 12:56   ` Damien Lespiau
  0 siblings, 0 replies; 6+ messages in thread
From: Damien Lespiau @ 2013-12-06 12:56 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Intel Graphics Development

On Fri, Dec 06, 2013 at 10:48:43AM +0100, Daniel Vetter wrote:
> No need to duplicate this all over the place.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>

(note that the use of buffered fopen/fwrite operations and the need to
flush the internal buffer could be just replaced with raw open/write and
was a left over from the initial implementation, but who cares).

Reviewed-by: Damien Lespiau <damien.lespiau@intel.com>

> ---
>  lib/igt_debugfs.c          | 18 ++++++++++++++++++
>  lib/igt_debugfs.h          |  1 +
>  tests/kms_cursor_crc.c     | 18 ++----------------
>  tests/kms_fbc_crc.c        | 14 +-------------
>  tests/kms_pipe_crc_basic.c | 25 ++++++++-----------------
>  5 files changed, 30 insertions(+), 46 deletions(-)
> 
> diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
> index 1ceaf59db11f..139be893f75b 100644
> --- a/lib/igt_debugfs.c
> +++ b/lib/igt_debugfs.c
> @@ -205,6 +205,24 @@ static void pipe_crc_exit_handler(int sig)
>  	igt_pipe_crc_reset();
>  }
>  
> +void igt_pipe_crc_check(igt_debugfs_t *debugfs)
> +{
> +	const char *cmd = "pipe A none";
> +	FILE *ctl;
> +	size_t written;
> +	int ret;
> +
> +	ctl = igt_debugfs_fopen(debugfs, "i915_display_crc_ctl", "r+");
> +	igt_require_f(ctl,
> +		      "No display_crc_ctl found, kernel too old\n");
> +	written = fwrite(cmd, 1, strlen(cmd), ctl);
> +	ret = fflush(ctl);
> +	igt_require_f((written == strlen(cmd) && ret == 0) || errno != ENODEV,
> +		      "CRCs not supported on this platform\n");
> +
> +	fclose(ctl);
> +}
> +
>  igt_pipe_crc_t *
>  igt_pipe_crc_new(igt_debugfs_t *debugfs, int drm_fd, enum pipe pipe,
>  		 enum intel_pipe_crc_source source)
> diff --git a/lib/igt_debugfs.h b/lib/igt_debugfs.h
> index 40d9d28fd49b..393b5767adbe 100644
> --- a/lib/igt_debugfs.h
> +++ b/lib/igt_debugfs.h
> @@ -70,6 +70,7 @@ bool igt_crc_is_null(igt_crc_t *crc);
>  bool igt_crc_equal(igt_crc_t *a, igt_crc_t *b);
>  char *igt_crc_to_string(igt_crc_t *crc);
>  
> +void igt_pipe_crc_check(igt_debugfs_t *debugfs);
>  igt_pipe_crc_t *
>  igt_pipe_crc_new(igt_debugfs_t *debugfs, int drm_fd, enum pipe pipe,
>  		 enum intel_pipe_crc_source source);
> diff --git a/tests/kms_cursor_crc.c b/tests/kms_cursor_crc.c
> index b78ea7863585..d80695f67e2f 100644
> --- a/tests/kms_cursor_crc.c
> +++ b/tests/kms_cursor_crc.c
> @@ -53,7 +53,6 @@ typedef struct {
>  	int drm_fd;
>  	igt_debugfs_t debugfs;
>  	drmModeRes *resources;
> -	FILE *ctl;
>  	uint32_t fb_id[NUM_CURSOR_TYPES];
>  	struct kmstest_fb fb[NUM_CURSOR_TYPES];
>  	igt_pipe_crc_t **pipe_crc;
> @@ -333,23 +332,12 @@ igt_main
>  	igt_skip_on_simulation();
>  
>  	igt_fixture {
> -		size_t written;
> -		int ret;
> -		const char *cmd = "pipe A none";
> -
>  		data.drm_fd = drm_open_any();
>  
>  		igt_set_vt_graphics_mode();
>  
>  		igt_debugfs_init(&data.debugfs);
> -		data.ctl = igt_debugfs_fopen(&data.debugfs,
> -					     "i915_display_crc_ctl", "r+");
> -		igt_require_f(data.ctl,
> -			      "No display_crc_ctl found, kernel too old\n");
> -		written = fwrite(cmd, 1, strlen(cmd), data.ctl);
> -		ret = fflush(data.ctl);
> -		igt_require_f((written == strlen(cmd) && ret == 0) || errno != ENODEV,
> -			      "CRCs not supported on this platform\n");
> +		igt_pipe_crc_check(&data.debugfs);
>  
>  		display_init(&data);
>  
> @@ -376,8 +364,6 @@ igt_main
>  	igt_subtest("cursor-black-invisible-offscreen")
>  		run_test(&data, BLACK_INVISIBLE, false);
>  
> -	igt_fixture {
> +	igt_fixture
>  		display_fini(&data);
> -		fclose(data.ctl);
> -	}
>  }
> diff --git a/tests/kms_fbc_crc.c b/tests/kms_fbc_crc.c
> index 7a7f3903667b..4cddd27428d0 100644
> --- a/tests/kms_fbc_crc.c
> +++ b/tests/kms_fbc_crc.c
> @@ -60,7 +60,6 @@ typedef struct {
>  	int drm_fd;
>  	igt_debugfs_t debugfs;
>  	drmModeRes *resources;
> -	FILE *ctl;
>  	igt_crc_t ref_crc[2];
>  	igt_pipe_crc_t **pipe_crc;
>  	drm_intel_bufmgr *bufmgr;
> @@ -485,9 +484,6 @@ igt_main
>  	igt_skip_on_simulation();
>  
>  	igt_fixture {
> -		size_t written;
> -		int ret;
> -		const char *cmd = "pipe A none";
>  		char buf[64];
>  		FILE *status;
>  
> @@ -497,14 +493,7 @@ igt_main
>  		data.devid = intel_get_drm_devid(data.drm_fd);
>  
>  		igt_debugfs_init(&data.debugfs);
> -		data.ctl = igt_debugfs_fopen(&data.debugfs,
> -					     "i915_display_crc_ctl", "r+");
> -		igt_require_f(data.ctl,
> -			      "No display_crc_ctl found, kernel too old\n");
> -		written = fwrite(cmd, 1, strlen(cmd), data.ctl);
> -		ret = fflush(data.ctl);
> -		igt_require_f((written == strlen(cmd) && ret == 0) || errno != ENODEV,
> -			      "CRCs not supported on this platform\n");
> +		igt_pipe_crc_check(&data.debugfs);
>  
>  		status = igt_debugfs_fopen(&data.debugfs, "i915_fbc_status", "r");
>  		igt_require_f(status, "No i915_fbc_status found\n");
> @@ -532,6 +521,5 @@ igt_main
>  	igt_fixture {
>  		drm_intel_bufmgr_destroy(data.bufmgr);
>  		display_fini(&data);
> -		fclose(data.ctl);
>  	}
>  }
> diff --git a/tests/kms_pipe_crc_basic.c b/tests/kms_pipe_crc_basic.c
> index 0e793cdf617d..90d9b9404877 100644
> --- a/tests/kms_pipe_crc_basic.c
> +++ b/tests/kms_pipe_crc_basic.c
> @@ -45,18 +45,21 @@ typedef struct {
>  	drmModeRes *resources;
>  	int n_connectors;
>  	connector_t *connectors;
> -	FILE *ctl;
>  } data_t;
>  
>  static void test_bad_command(data_t *data, const char *cmd)
>  {
> +	FILE *ctl;
>  	size_t written;
>  
> -	written = fwrite(cmd, 1, strlen(cmd), data->ctl);
> -	fflush(data->ctl);
> +	ctl = igt_debugfs_fopen(&data->debugfs, "i915_display_crc_ctl", "r+");
> +	written = fwrite(cmd, 1, strlen(cmd), ctl);
> +	fflush(ctl);
>  	igt_assert_cmpint(written, ==, (strlen(cmd)));
> -	igt_assert(ferror(data->ctl));
> +	igt_assert(ferror(ctl));
>  	igt_assert_cmpint(errno, ==, EINVAL);
> +
> +	fclose(ctl);
>  }
>  
>  static void connector_init(data_t *data, connector_t *connector,
> @@ -214,10 +217,6 @@ igt_main
>  	igt_skip_on_simulation();
>  
>  	igt_fixture {
> -		size_t written;
> -		int ret;
> -		const char *cmd = "pipe A none";
> -
>  		data.drm_fd = drm_open_any();
>  
>  		igt_set_vt_graphics_mode();
> @@ -225,14 +224,7 @@ igt_main
>  		display_init(&data);
>  
>  		igt_debugfs_init(&data.debugfs);
> -		data.ctl = igt_debugfs_fopen(&data.debugfs,
> -					     "i915_display_crc_ctl", "r+");
> -		igt_require_f(data.ctl,
> -			      "No display_crc_ctl found, kernel too old\n");
> -		written = fwrite(cmd, 1, strlen(cmd), data.ctl);
> -		ret = fflush(data.ctl);
> -		igt_require_f((written == strlen(cmd) && ret == 0) || errno != ENODEV,
> -			      "CRCs not supported on this platform\n");
> +		igt_pipe_crc_check(&data.debugfs);
>  	}
>  
>  	igt_subtest("bad-pipe")
> @@ -257,6 +249,5 @@ igt_main
>  
>  	igt_fixture {
>  		display_fini(&data);
> -		fclose(data.ctl);
>  	}
>  }
> -- 
> 1.8.4.3
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/3] tests: drm_open_any doesn't fail
  2013-12-06  9:48 [PATCH 1/3] tests: drm_open_any doesn't fail Daniel Vetter
  2013-12-06  9:48 ` [PATCH 2/3] lib: add igt_pipe_crc_check Daniel Vetter
  2013-12-06  9:48 ` [PATCH 3/3] lib: make igt_pipe_crc_start never fail Daniel Vetter
@ 2013-12-06 12:58 ` Damien Lespiau
  2 siblings, 0 replies; 6+ messages in thread
From: Damien Lespiau @ 2013-12-06 12:58 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Intel Graphics Development

On Fri, Dec 06, 2013 at 10:48:42AM +0100, Daniel Vetter wrote:
> Or more precisely: It already has an igt_require. So we cant ditch it
> from tests.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>

Reviewed-by: Damien Lespiau <damien.lespiau@intel.com>

> ---
>  tests/kms_cursor_crc.c     | 1 -
>  tests/kms_fbc_crc.c        | 1 -
>  tests/kms_pipe_crc_basic.c | 1 -
>  3 files changed, 3 deletions(-)
> 
> diff --git a/tests/kms_cursor_crc.c b/tests/kms_cursor_crc.c
> index 74da32eb7497..b78ea7863585 100644
> --- a/tests/kms_cursor_crc.c
> +++ b/tests/kms_cursor_crc.c
> @@ -338,7 +338,6 @@ igt_main
>  		const char *cmd = "pipe A none";
>  
>  		data.drm_fd = drm_open_any();
> -		igt_require(data.drm_fd >= 0);
>  
>  		igt_set_vt_graphics_mode();
>  
> diff --git a/tests/kms_fbc_crc.c b/tests/kms_fbc_crc.c
> index 660086290f28..7a7f3903667b 100644
> --- a/tests/kms_fbc_crc.c
> +++ b/tests/kms_fbc_crc.c
> @@ -492,7 +492,6 @@ igt_main
>  		FILE *status;
>  
>  		data.drm_fd = drm_open_any();
> -		igt_require(data.drm_fd);
>  		igt_set_vt_graphics_mode();
>  
>  		data.devid = intel_get_drm_devid(data.drm_fd);
> diff --git a/tests/kms_pipe_crc_basic.c b/tests/kms_pipe_crc_basic.c
> index 3bc9eb0ee361..0e793cdf617d 100644
> --- a/tests/kms_pipe_crc_basic.c
> +++ b/tests/kms_pipe_crc_basic.c
> @@ -219,7 +219,6 @@ igt_main
>  		const char *cmd = "pipe A none";
>  
>  		data.drm_fd = drm_open_any();
> -		igt_require(data.drm_fd >= 0);
>  
>  		igt_set_vt_graphics_mode();
>  
> -- 
> 1.8.4.3
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-12-06 12:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-06  9:48 [PATCH 1/3] tests: drm_open_any doesn't fail Daniel Vetter
2013-12-06  9:48 ` [PATCH 2/3] lib: add igt_pipe_crc_check Daniel Vetter
2013-12-06 12:56   ` Damien Lespiau
2013-12-06  9:48 ` [PATCH 3/3] lib: make igt_pipe_crc_start never fail Daniel Vetter
2013-12-06 12:52   ` Damien Lespiau
2013-12-06 12:58 ` [PATCH 1/3] tests: drm_open_any doesn't fail Damien Lespiau

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox