lib/core: Add optional reason for timeout failure
PATCH 1/3 lib/core: Add optional reason for timeout failure
"Timed out" isn't a terribly informative message, allow users to set something more informative. Inspired by a request from Jesse.
--- lib/igt_core.c | 12 ++++++++++-- lib/igt_core.h | 3 ++- lib/igt_debugfs.c | 4 ++-- lib/tests/igt_timeout.c | 2 +- tests/kms_flip.c | 4 ++-- 5 files changed, 17 insertions(+), 8 deletions(-)
lib/igt_core.c +10 -2
@@ -1748,9 +1748,13 @@ out:free (line); } +static const char *timeout_op;static void igt_alarm_handler (int signal) { -igt_info ("Timed out\n" ); +if (timeout_op) +igt_info ("Timed out: %s\n" , timeout_op); +else +igt_info ("Timed out\n" );/* exit with failure status */ igt_fail (IGT_EXIT_FAILURE );
@@ -1759,6 +1763,7 @@ static void igt_alarm_handler(int signal)/** * igt_set_timeout: * @seconds: number of seconds before timeout +* @op: Optional string to explain what operation has timed out in the debug log * * Fail a test and exit with #IGT_EXIT_FAILURE status after the specified * number of seconds have elapsed. If the current test has subtests and the
@@ -1768,7 +1773,8 @@ static void igt_alarm_handler(int signal)* Any previous timer is cancelled and no timeout is scheduled if @seconds is * zero. */ -void igt_set_timeout (unsigned int seconds) +void igt_set_timeout (unsigned int seconds, +const char *op) {struct sigaction sa;
@@ -1776,6 +1782,8 @@ void igt_set_timeout(unsigned int seconds)sigemptyset (&sa.sa_mask); sa.sa_flags =0 ; + timeout_op = op; +if (seconds ==0 )sigaction (SIGALRM ,NULL ,NULL );else
lib/igt_core.h +2 -1
@@ -732,7 +732,8 @@ extern enum igt_log_level igt_log_level; }while (0 ) -void igt_set_timeout(unsigned int seconds); +void igt_set_timeout(unsigned int seconds, + const char *op);FILE *__igt_fopen_data (const char * igt_srcdir,const char * igt_datadir,const char * filename);
lib/igt_debugfs.c +2 -2
@@ -463,9 +463,9 @@ static bool read_one_crc(igt_pipe_crc_t *pipe_crc, igt_crc_t *out)ssize_t bytes_read;char buf[pipe_crc->buffer_len]; -igt_set_timeout (5 ); +igt_set_timeout (5 ,"CRC reading" ); bytes_read =read (pipe_crc->crc_fd, &buf, pipe_crc->line_len); -igt_set_timeout (0 ); +igt_set_timeout (0 ,NULL );igt_assert_eq (bytes_read, pipe_crc->line_len); buf[bytes_read] ='\0' ;
lib/tests/igt_timeout.c +1 -1
@@ -3,6 +3,6 @@ igt_simple_main { -igt_set_timeout (1 ); +igt_set_timeout (1 ,"Testcase" );sleep (5 ); }
tests/kms_flip.c +2 -2
@@ -1614,9 +1614,9 @@ static void test_nonblocking_read(int in) }igt_require (ret !=-1 ); -igt_set_timeout (5 ); +igt_set_timeout (5 ,"Nonblocking DRM fd reading" ); ret =read (fd, buffer,sizeof (buffer)); -igt_set_timeout (0 ); +igt_set_timeout (0 ,NULL );igt_assert_eq (ret,-1 );igt_assert_eq (errno,EAGAIN );
Signature · 6 lines
2.5.0 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/3 lib/core: Add igt_reset_timeout
Convenience wrapper suggested by Chris for igt_set_timeout(0, NULL).
v2: While at it add an empty line in kms_flip to make set/reset_timeout a visual block.
--- lib/igt_core.c | 14 +++++++++++++- lib/igt_core.h | 2 ++ lib/igt_debugfs.c | 2 +- tests/kms_flip.c | 3 ++- 4 files changed, 18 insertions(+), 3 deletions(-)
lib/igt_core.c +13 -1
@@ -1771,7 +1771,8 @@ static void igt_alarm_handler(int signal)* marked as failed. * * Any previous timer is cancelled and no timeout is scheduled if @seconds is -* zero. +* zero. But for clarity the timeout set with this function should be cleared +* with igt_reset_timeout(). */ void igt_set_timeout (unsigned int seconds,const char *op)
@@ -1792,6 +1793,17 @@ void igt_set_timeout(unsigned int seconds,alarm (seconds); } +/** +* igt_reset_timeout - reset timeout to default +* +* This function resets a timeout set by igt_set_timeout() and disables any +* timer set up by the former function. +*/ +void igt_reset_timeout (void ) +{ +igt_set_timeout (0 ,NULL ); +} +FILE *__igt_fopen_data (const char * igt_srcdir,const char * igt_datadir,const char * filename) {
lib/igt_core.h +2 -0
@@ -735,6 +735,8 @@ extern enum igt_log_level igt_log_level;void igt_set_timeout (unsigned int seconds,const char *op); +void igt_reset_timeout (void ); +FILE *__igt_fopen_data (const char * igt_srcdir,const char * igt_datadir,const char * filename);/**
lib/igt_debugfs.c +1 -1
@@ -465,7 +465,7 @@ static bool read_one_crc(igt_pipe_crc_t *pipe_crc, igt_crc_t *out)igt_set_timeout (5 ,"CRC reading" ); bytes_read =read (pipe_crc->crc_fd, &buf, pipe_crc->line_len); -igt_set_timeout (0 ,NULL ); +igt_reset_timeout ();igt_assert_eq (bytes_read, pipe_crc->line_len); buf[bytes_read] ='\0' ;
tests/kms_flip.c +2 -1
@@ -1616,7 +1616,8 @@ static void test_nonblocking_read(int in)igt_set_timeout (5 ,"Nonblocking DRM fd reading" ); ret =read (fd, buffer,sizeof (buffer)); -igt_set_timeout (0 ,NULL ); +igt_reset_timeout (); +igt_assert_eq (ret,-1 );igt_assert_eq (errno,EAGAIN );
Signature · 6 lines
2.5.0 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 3/3 tests: Document ABI extension catchers
In reply to Daniel VetterOur invalid-flags/params testcases are meant to catch abi extensions by just testing for the next available flag/param. Unfortunately we need that since without those we forgot to write testcases for these new flags way too often :(
But it's not entirely clear why this is, so document this trick with comments.
Also gem_wait wasn't this paranoid, so change the testcase to be so.
--- tests/gem_ctx_param_basic.c | 3 +++ tests/gem_exec_params.c | 3 +++ tests/gem_wait.c | 5 ++++- 3 files changed, 10 insertions(+), 1 deletion(-)
tests/gem_ctx_param_basic.c +3 -0
@@ -149,6 +149,9 @@ igt_mainTEST_SUCCESS (LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM ); } +/* NOTE: This testcase intentionally tests for the next free parameter +* to catch ABI extensions. Don't "fix" this testcase without adding all +* the tests for the new param first. */ ctx_param.param =LOCAL_CONTEXT_PARAM_NO_ZEROMAP +1 ; igt_subtest("invalid-param-get") {
tests/gem_exec_params.c +3 -0
@@ -221,6 +221,9 @@ igt_main/* HANDLE_LUT and NO_RELOC are already exercised by gem_exec_lut_handle */ igt_subtest("invalid-flag") { +/* NOTE: This test intentionally exercise the next available +* flag. Don't "fix" this testcase without adding the required +* tests for the new flag first. */ execbuf.flags =I915_EXEC_RENDER | (LOCAL_I915_EXEC_RESOURCE_STREAMER <<1 );RUN_FAIL (EINVAL ); }
tests/gem_wait.c +4 -1
@@ -236,7 +236,10 @@ static void invalid_flags(int fd) wait.bo_handle = handle; wait.timeout_ns =1 ; - wait.flags =0xffffffff ; +/* NOTE: This test intentionally tests for just the next available flag. +* Don't "fix" this testcase without the ABI testcases for new flags +* first. */ + wait.flags =1 ; ret =drmIoctl (fd,DRM_IOCTL_I915_GEM_WAIT , &wait);igt_assert (ret !=0 && errno ==EINVAL );
Signature · 6 lines
2.5.0 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 108 lines · Daniel Vetter
"Timed out" isn't a terribly informative message, allow users to set something more informative. Inspired by a request from Jesse.
Cc Jesse Barnes <[email protected]>Signed-off-by Daniel Vetter <[email protected]>--- lib/igt_core.c | 12 ++++++++++-- lib/igt_core.h | 3 ++- lib/igt_debugfs.c | 4 ++-- lib/tests/igt_timeout.c | 2 +- tests/kms_flip.c | 4 ++-- 5 files changed, 17 insertions(+), 8 deletions(-)lib/igt_core.c +10
-2@@ -1748,9 +1748,13 @@ out:free (line); } +static const char *timeout_op;static void igt_alarm_handler (int signal) { -igt_info ("Timed out\n" ); +if (timeout_op) +igt_info ("Timed out: %s\n" , timeout_op); +else +igt_info ("Timed out\n" );/* exit with failure status */ igt_fail (IGT_EXIT_FAILURE );@@ -1759,6 +1763,7 @@ static void igt_alarm_handler(int signal)/** * igt_set_timeout: * @seconds: number of seconds before timeout +* @op: Optional string to explain what operation has timed out in the debug log * * Fail a test and exit with #IGT_EXIT_FAILURE status after the specified * number of seconds have elapsed. If the current test has subtests and the @@ -1768,7 +1773,8 @@ static void igt_alarm_handler(int signal)* Any previous timer is cancelled and no timeout is scheduled if @seconds is * zero. */ -void igt_set_timeout (unsigned int seconds) +void igt_set_timeout (unsigned int seconds, +const char *op) {struct sigaction sa;@@ -1776,6 +1782,8 @@ void igt_set_timeout(unsigned int seconds)sigemptyset (&sa.sa_mask); sa.sa_flags =0 ; + timeout_op = op; +if (seconds ==0 )sigaction (SIGALRM ,NULL ,NULL );else lib/igt_core.h +2
-1@@ -732,7 +732,8 @@ extern enum igt_log_level igt_log_level; }while (0 ) -void igt_set_timeout(unsigned int seconds); +void igt_set_timeout(unsigned int seconds, + const char *op);FILE *__igt_fopen_data (const char * igt_srcdir,const char * igt_datadir,const char * filename);lib/igt_debugfs.c +2
-2@@ -463,9 +463,9 @@ static bool read_one_crc(igt_pipe_crc_t *pipe_crc, igt_crc_t *out)ssize_t bytes_read;char buf[pipe_crc->buffer_len]; -igt_set_timeout (5 ); +igt_set_timeout (5 ,"CRC reading" ); bytes_read =read (pipe_crc->crc_fd, &buf, pipe_crc->line_len); -igt_set_timeout (0 ); +igt_set_timeout (0 ,NULL );igt_assert_eq (bytes_read, pipe_crc->line_len); buf[bytes_read] ='\0' ;lib/tests/igt_timeout.c +1
-1@@ -3,6 +3,6 @@ igt_simple_main { -igt_set_timeout (1 ); +igt_set_timeout (1 ,"Testcase" );sleep (5 ); }tests/kms_flip.c +0
-0@@ -1614,9 +1614,9 @@ static void test_nonblocking_read(int in) }
tests/kms_flip.c static void test_nonblocking_read(int in) · line 1622
Quoted 10 lines
tests/kms_flip.c +2
-2igt_require (ret !=-1 ); -igt_set_timeout (5 ); +igt_set_timeout (5 ,"Nonblocking DRM fd reading" ); ret =read (fd, buffer,sizeof (buffer)); -igt_set_timeout (0 ); +igt_set_timeout (0 ,NULL );igt_assert_eq (ret,-1 );igt_assert_eq (errno,EAGAIN );
The earlier version worked like a charm.
Thanks,
Jesse
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 110 lines · Jesse Barnes
Quoted 109 lines · Daniel Vetter
"Timed out" isn't a terribly informative message, allow users to set something more informative. Inspired by a request from Jesse.
Cc Jesse Barnes <[email protected]>Signed-off-by Daniel Vetter <[email protected]>--- lib/igt_core.c | 12 ++++++++++-- lib/igt_core.h | 3 ++- lib/igt_debugfs.c | 4 ++-- lib/tests/igt_timeout.c | 2 +- tests/kms_flip.c | 4 ++-- 5 files changed, 17 insertions(+), 8 deletions(-)lib/igt_core.c +10
-2@@ -1748,9 +1748,13 @@ out:free (line); } +static const char *timeout_op;static void igt_alarm_handler (int signal) { -igt_info ("Timed out\n" ); +if (timeout_op) +igt_info ("Timed out: %s\n" , timeout_op); +else +igt_info ("Timed out\n" );/* exit with failure status */ igt_fail (IGT_EXIT_FAILURE );@@ -1759,6 +1763,7 @@ static void igt_alarm_handler(int signal)/** * igt_set_timeout: * @seconds: number of seconds before timeout +* @op: Optional string to explain what operation has timed out in the debug log * * Fail a test and exit with #IGT_EXIT_FAILURE status after the specified * number of seconds have elapsed. If the current test has subtests and the @@ -1768,7 +1773,8 @@ static void igt_alarm_handler(int signal)* Any previous timer is cancelled and no timeout is scheduled if @seconds is * zero. */ -void igt_set_timeout (unsigned int seconds) +void igt_set_timeout (unsigned int seconds, +const char *op) {struct sigaction sa;@@ -1776,6 +1782,8 @@ void igt_set_timeout(unsigned int seconds)sigemptyset (&sa.sa_mask); sa.sa_flags =0 ; + timeout_op = op; +if (seconds ==0 )sigaction (SIGALRM ,NULL ,NULL );else lib/igt_core.h +2
-1@@ -732,7 +732,8 @@ extern enum igt_log_level igt_log_level; }while (0 ) -void igt_set_timeout(unsigned int seconds); +void igt_set_timeout(unsigned int seconds, + const char *op);FILE *__igt_fopen_data (const char * igt_srcdir,const char * igt_datadir,const char * filename);lib/igt_debugfs.c +2
-2@@ -463,9 +463,9 @@ static bool read_one_crc(igt_pipe_crc_t *pipe_crc, igt_crc_t *out)ssize_t bytes_read;char buf[pipe_crc->buffer_len]; -igt_set_timeout (5 ); +igt_set_timeout (5 ,"CRC reading" ); bytes_read =read (pipe_crc->crc_fd, &buf, pipe_crc->line_len); -igt_set_timeout (0 ); +igt_set_timeout (0 ,NULL );igt_assert_eq (bytes_read, pipe_crc->line_len); buf[bytes_read] ='\0' ;lib/tests/igt_timeout.c +1
-1@@ -3,6 +3,6 @@ igt_simple_main { -igt_set_timeout (1 ); +igt_set_timeout (1 ,"Testcase" );sleep (5 ); }tests/kms_flip.c +0
-0@@ -1614,9 +1614,9 @@ static void test_nonblocking_read(int in) }igt_require (ret !=-1 );
Quoted 11 lines
tests/kms_flip.c static void test_nonblocking_read(int in) · line 1622
Quoted 9 lines
tests/kms_flip.c +2
-2-igt_set_timeout (5 ); +igt_set_timeout (5 ,"Nonblocking DRM fd reading" ); ret =read (fd, buffer,sizeof (buffer)); -igt_set_timeout (0 ); +igt_set_timeout (0 ,NULL );igt_assert_eq (ret,-1 );igt_assert_eq (errno,EAGAIN );Reviewed-by Jesse Barnes <[email protected]>
Thanks for the review, pushed this patch + the other two + David's patch to test NO_ZEROMAP to fix the gem_ctx_param_basic regression. -Daniel
Quoted 5 lines
The earlier version worked like a charm.
Thanks,
Jesse
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx