public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Jesse Barnes <jbarnes@virtuousgeek.org>
To: Daniel Vetter <daniel.vetter@ffwll.ch>,
	Intel Graphics Development <intel-gfx@lists.freedesktop.org>
Cc: Daniel Vetter <daniel.vetter@intel.com>
Subject: Re: [PATCH i-g-t 1/3] lib/core: Add optional reason for timeout failure
Date: Fri, 07 Aug 2015 11:10:22 -0700	[thread overview]
Message-ID: <55C4F48E.9030905@virtuousgeek.org> (raw)
In-Reply-To: <1438968558-1036-1-git-send-email-daniel.vetter@ffwll.ch>

On 08/07/2015 10:29 AM, Daniel Vetter wrote:
> "Timed out" isn't a terribly informative message, allow users to set
> something more informative. Inspired by a request from Jesse.
> 
> Cc: Jesse Barnes <jbarnes@virtuousgeek.org>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> ---
>  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(-)
> 
> diff --git a/lib/igt_core.c b/lib/igt_core.c
> index af3d87316857..e2c2502bd147 100644
> --- a/lib/igt_core.c
> +++ b/lib/igt_core.c
> @@ -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
> diff --git a/lib/igt_core.h b/lib/igt_core.h
> index 83eac02b28bf..1a324ee85514 100644
> --- a/lib/igt_core.h
> +++ b/lib/igt_core.h
> @@ -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);
> diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
> index 568154ac0e80..6180a2aa56db 100644
> --- a/lib/igt_debugfs.c
> +++ b/lib/igt_debugfs.c
> @@ -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';
> diff --git a/lib/tests/igt_timeout.c b/lib/tests/igt_timeout.c
> index 8affa61f3d79..d228041d493b 100644
> --- a/lib/tests/igt_timeout.c
> +++ b/lib/tests/igt_timeout.c
> @@ -3,6 +3,6 @@
>  
>  igt_simple_main
>  {
> -	igt_set_timeout(1);
> +	igt_set_timeout(1, "Testcase");
>  	sleep(5);
>  }
> diff --git a/tests/kms_flip.c b/tests/kms_flip.c
> index 25c924305c32..214cd696fd2f 100644
> --- a/tests/kms_flip.c
> +++ b/tests/kms_flip.c
> @@ -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);
>  
> 

Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org>

The earlier version worked like a charm.

Thanks,
Jesse
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2015-08-07 18:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-07 17:29 [PATCH i-g-t 1/3] lib/core: Add optional reason for timeout failure Daniel Vetter
2015-08-07 17:29 ` [PATCH i-g-t 2/3] lib/core: Add igt_reset_timeout Daniel Vetter
2015-08-07 17:29 ` [PATCH i-g-t 3/3] tests: Document ABI extension catchers Daniel Vetter
2015-08-07 18:10 ` Jesse Barnes [this message]
2015-08-12 12:47   ` [PATCH i-g-t 1/3] lib/core: Add optional reason for timeout failure Daniel Vetter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55C4F48E.9030905@virtuousgeek.org \
    --to=jbarnes@virtuousgeek.org \
    --cc=daniel.vetter@ffwll.ch \
    --cc=daniel.vetter@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox