tests: drm_open_any doesn't fail
PATCH 1/3 tests: drm_open_any doesn't fail
Or more precisely: It already has an igt_require. So we cant ditch it from tests.
--- tests/kms_cursor_crc.c | 1 - tests/kms_fbc_crc.c | 1 - tests/kms_pipe_crc_basic.c | 1 - 3 files changed, 3 deletions(-)
tests/kms_cursor_crc.c +0 -1
@@ -338,7 +338,6 @@ igt_mainconst char *cmd ="pipe A none" ; data.drm_fd =drm_open_any (); -igt_require (data.drm_fd >=0 );igt_set_vt_graphics_mode ();
tests/kms_fbc_crc.c +0 -1
@@ -492,7 +492,6 @@ igt_mainFILE *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);
tests/kms_pipe_crc_basic.c +0 -1
@@ -219,7 +219,6 @@ igt_mainconst char *cmd ="pipe A none" ; data.drm_fd =drm_open_any (); -igt_require (data.drm_fd >=0 );igt_set_vt_graphics_mode ();
Signature · 1 line
1.8.4.3
PATCH 2/3 lib: add igt_pipe_crc_check
No need to duplicate this all over the place.
--- 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(-)
lib/igt_debugfs.c +18 -0
@@ -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)
lib/igt_debugfs.h +1 -0
@@ -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);
tests/kms_cursor_crc.c +2 -16
@@ -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_mainigt_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); - } }
tests/kms_fbc_crc.c +1 -13
@@ -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_mainigt_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); } }
tests/kms_pipe_crc_basic.c +8 -17
@@ -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_mainigt_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_maindisplay_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); } }
Signature · 1 line
1.8.4.3
Re: [PATCH 2/3] lib: add igt_pipe_crc_check
Quoted 3 lines · Daniel Vetter
No need to duplicate this all over the place.
Signed-off-by Daniel Vetter <[email protected]>
(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).
Quoted 212 lines
--- 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(-)lib/igt_debugfs.c +18
-0@@ -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)lib/igt_debugfs.h +1
-0@@ -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);tests/kms_cursor_crc.c +2
-16@@ -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_mainigt_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); - } }tests/kms_fbc_crc.c +1
-13@@ -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_mainigt_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); } }tests/kms_pipe_crc_basic.c +8
-17@@ -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_mainigt_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_maindisplay_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); } }Signature · 6 lines
1.8.4.3 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 3/3 lib: make igt_pipe_crc_start never fail
In reply to Daniel VetterIt's what callers expect - pipe_crc_new is the function where we pass a potential failure back to callers.
--- lib/igt_debugfs.c | 7 ++----- lib/igt_debugfs.h | 2 +- tests/kms_pipe_crc_basic.c | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-)
lib/igt_debugfs.c +2 -5
@@ -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)
lib/igt_debugfs.h +1 -1
@@ -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);
tests/kms_pipe_crc_basic.c +1 -1
@@ -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);
Signature · 1 line
1.8.4.3
Re: [PATCH 3/3] lib: make igt_pipe_crc_start never fail
Quoted 4 lines · Daniel Vetter
It's what callers expect -
pipe_crc_newis the function where we pass a potential failure back to callers.Signed-off-by Daniel Vetter <[email protected]>
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.
Quoted 67 lines
--- lib/igt_debugfs.c | 7 ++----- lib/igt_debugfs.h | 2 +- tests/kms_pipe_crc_basic.c | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-)lib/igt_debugfs.c +2
-5@@ -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)lib/igt_debugfs.h +1
-1@@ -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);tests/kms_pipe_crc_basic.c +1
-1@@ -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);Signature · 6 lines
1.8.4.3 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 4 lines · Daniel Vetter
Or more precisely: It already has an
igt_require. So we cant ditch it from tests.Signed-off-by Daniel Vetter <[email protected]>
Quoted 49 lines
--- tests/kms_cursor_crc.c | 1 - tests/kms_fbc_crc.c | 1 - tests/kms_pipe_crc_basic.c | 1 - 3 files changed, 3 deletions(-)tests/kms_cursor_crc.c +0
-1@@ -338,7 +338,6 @@ igt_mainconst char *cmd ="pipe A none" ; data.drm_fd =drm_open_any (); -igt_require (data.drm_fd >=0 );igt_set_vt_graphics_mode ();tests/kms_fbc_crc.c +0
-1@@ -492,7 +492,6 @@ igt_mainFILE *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);tests/kms_pipe_crc_basic.c +0
-1@@ -219,7 +219,6 @@ igt_mainconst char *cmd ="pipe A none" ; data.drm_fd =drm_open_any (); -igt_require (data.drm_fd >=0 );igt_set_vt_graphics_mode ();Signature · 6 lines
1.8.4.3 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx