tests/gem_seqno_wrap: skip if debugfs entry is not there
PATCH 1/1 tests/gem_seqno_wrap: skip if debugfs entry is not there
Return error code 77 to skip test if debugfs entry is not available.
Signed-off-by Mika Kuoppala <[email protected]>
--- tests/gem_seqno_wrap.c | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-)
tests/gem_seqno_wrap.c +29 -14
@@ -49,6 +49,7 @@#include "rendercopy.h" static int devid; +static int card_index =0 ;static uint32_t last_seqno =0 ;static struct intel_batchbuffer *batch_blt;
@@ -355,7 +356,27 @@ static int run_cmd(char *s)return r; } -static const char *debug_fs_entry ="/sys/kernel/debug/dri/0/i915_next_seqno" ; +static const char *dfs_base ="/sys/kernel/debug/dri" ; +static const char *dfs_entry ="i915_next_seqno" ; + +static int dfs_open (int mode) +{ +char fname[FILENAME_MAX ]; +int fh; + +snprintf (fname,FILENAME_MAX ,"%s/%i/%s" , + dfs_base, card_index, dfs_entry); + + fh =open (fname, mode); +if (fh ==-1 ) { +fprintf (stderr, +"error %d opening '%s/%d/%s'. too old kernel?\n" , + errno, dfs_base, card_index, dfs_entry); +exit (77 ); + } + +return fh; +}static int __read_seqno (uint32_t *seqno) {
@@ -365,12 +386,7 @@ static int __read_seqno(uint32_t *seqno)char *p;unsigned long int tmp; - fh =open (debug_fs_entry,O_RDWR ); -if (fh ==-1 ) { -perror ("open" ); -fprintf (stderr,"no %s found, too old kernel?\n" , debug_fs_entry); -return -errno; - } + fh =dfs_open (O_RDONLY ); r =read (fh, buf,sizeof (buf) -1 );close (fh);
@@ -385,8 +401,9 @@ static int __read_seqno(uint32_t *seqno)if (!p) p = buf; + errno =0 ; tmp =strtoul (p,NULL ,0 ); -if (tmp ==ULONG_MAX ) { +if (tmp ==ULONG_MAX && errno) {perror ("strtoul" );return -errno; }
@@ -425,12 +442,7 @@ static int write_seqno(uint32_t seqno)if (options.dontwrap)return 0 ; - fh =open (debug_fs_entry,O_RDWR ); -if (fh ==-1 ) { -perror ("open" ); -return -errno; - } - + fh =dfs_open (O_RDWR );assert (snprintf (buf,sizeof (buf),"0x%x" , seqno) >0 ); r =write (fh, buf,strnlen (buf,sizeof (buf)));
@@ -627,6 +639,9 @@ int main(int argc, char **argv)parse_options (argc, argv); + card_index =drm_get_card (0 ); +assert (card_index !=-1 ); +srandom (time (NULL ));while (options.rounds ==0 || wcount < options.rounds) {
Signature · 1 line
1.7.9.5
Quoted 4 lines · Mika Kuoppala
Return error code 77 to skip test if debugfs entry is not available.
Signed-off-by Mika Kuoppala <[email protected]>
Applied (with the bz link added), thanks for the patch. -Daniel
Quoted 101 lines
--- tests/gem_seqno_wrap.c | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-)tests/gem_seqno_wrap.c +29
-14@@ -49,6 +49,7 @@#include "rendercopy.h" static int devid; +static int card_index =0 ;static uint32_t last_seqno =0 ;static struct intel_batchbuffer *batch_blt;@@ -355,7 +356,27 @@ static int run_cmd(char *s)return r; } -static const char *debug_fs_entry ="/sys/kernel/debug/dri/0/i915_next_seqno" ; +static const char *dfs_base ="/sys/kernel/debug/dri" ; +static const char *dfs_entry ="i915_next_seqno" ; + +static int dfs_open (int mode) +{ +char fname[FILENAME_MAX ]; +int fh; + +snprintf (fname,FILENAME_MAX ,"%s/%i/%s" , + dfs_base, card_index, dfs_entry); + + fh =open (fname, mode); +if (fh ==-1 ) { +fprintf (stderr, +"error %d opening '%s/%d/%s'. too old kernel?\n" , + errno, dfs_base, card_index, dfs_entry); +exit (77 ); + } + +return fh; +}static int __read_seqno (uint32_t *seqno) {@@ -365,12 +386,7 @@ static int __read_seqno(uint32_t *seqno)char *p;unsigned long int tmp; - fh =open (debug_fs_entry,O_RDWR ); -if (fh ==-1 ) { -perror ("open" ); -fprintf (stderr,"no %s found, too old kernel?\n" , debug_fs_entry); -return -errno; - } + fh =dfs_open (O_RDONLY ); r =read (fh, buf,sizeof (buf) -1 );close (fh);@@ -385,8 +401,9 @@ static int __read_seqno(uint32_t *seqno)if (!p) p = buf; + errno =0 ; tmp =strtoul (p,NULL ,0 ); -if (tmp ==ULONG_MAX ) { +if (tmp ==ULONG_MAX && errno) {perror ("strtoul" );return -errno; }@@ -425,12 +442,7 @@ static int write_seqno(uint32_t seqno)if (options.dontwrap)return 0 ; - fh =open (debug_fs_entry,O_RDWR ); -if (fh ==-1 ) { -perror ("open" ); -return -errno; - } - + fh =dfs_open (O_RDWR );assert (snprintf (buf,sizeof (buf),"0x%x" , seqno) >0 ); r =write (fh, buf,strnlen (buf,sizeof (buf)));@@ -627,6 +639,9 @@ int main(int argc, char **argv)parse_options (argc, argv); + card_index =drm_get_card (0 ); +assert (card_index !=-1 ); +srandom (time (NULL ));while (options.rounds ==0 || wcount < options.rounds) {Signature · 6 lines
1.7.9.5 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch