mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-26 01:06:23 +00:00
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. Cc: Jesse Barnes <jbarnes@virtuousgeek.org> Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
This commit is contained in:
parent
24617ef82a
commit
370c989723
@ -1748,8 +1748,12 @@ out:
|
|||||||
free(line);
|
free(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char *timeout_op;
|
||||||
static void igt_alarm_handler(int signal)
|
static void igt_alarm_handler(int signal)
|
||||||
{
|
{
|
||||||
|
if (timeout_op)
|
||||||
|
igt_info("Timed out: %s\n", timeout_op);
|
||||||
|
else
|
||||||
igt_info("Timed out\n");
|
igt_info("Timed out\n");
|
||||||
|
|
||||||
/* exit with failure status */
|
/* exit with failure status */
|
||||||
@ -1759,6 +1763,7 @@ static void igt_alarm_handler(int signal)
|
|||||||
/**
|
/**
|
||||||
* igt_set_timeout:
|
* igt_set_timeout:
|
||||||
* @seconds: number of seconds before 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
|
* 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
|
* 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
|
* Any previous timer is cancelled and no timeout is scheduled if @seconds is
|
||||||
* zero.
|
* zero.
|
||||||
*/
|
*/
|
||||||
void igt_set_timeout(unsigned int seconds)
|
void igt_set_timeout(unsigned int seconds,
|
||||||
|
const char *op)
|
||||||
{
|
{
|
||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
|
|
||||||
@ -1776,6 +1782,8 @@ void igt_set_timeout(unsigned int seconds)
|
|||||||
sigemptyset(&sa.sa_mask);
|
sigemptyset(&sa.sa_mask);
|
||||||
sa.sa_flags = 0;
|
sa.sa_flags = 0;
|
||||||
|
|
||||||
|
timeout_op = op;
|
||||||
|
|
||||||
if (seconds == 0)
|
if (seconds == 0)
|
||||||
sigaction(SIGALRM, NULL, NULL);
|
sigaction(SIGALRM, NULL, NULL);
|
||||||
else
|
else
|
||||||
|
@ -732,7 +732,8 @@ extern enum igt_log_level igt_log_level;
|
|||||||
} while (0)
|
} 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,
|
FILE *__igt_fopen_data(const char* igt_srcdir, const char* igt_datadir,
|
||||||
const char* filename);
|
const char* filename);
|
||||||
|
@ -463,9 +463,9 @@ static bool read_one_crc(igt_pipe_crc_t *pipe_crc, igt_crc_t *out)
|
|||||||
ssize_t bytes_read;
|
ssize_t bytes_read;
|
||||||
char buf[pipe_crc->buffer_len];
|
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);
|
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);
|
igt_assert_eq(bytes_read, pipe_crc->line_len);
|
||||||
buf[bytes_read] = '\0';
|
buf[bytes_read] = '\0';
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
|
|
||||||
igt_simple_main
|
igt_simple_main
|
||||||
{
|
{
|
||||||
igt_set_timeout(1);
|
igt_set_timeout(1, "Testcase");
|
||||||
sleep(5);
|
sleep(5);
|
||||||
}
|
}
|
||||||
|
@ -1614,9 +1614,9 @@ static void test_nonblocking_read(int in)
|
|||||||
}
|
}
|
||||||
igt_require(ret != -1);
|
igt_require(ret != -1);
|
||||||
|
|
||||||
igt_set_timeout(5);
|
igt_set_timeout(5, "Nonblocking DRM fd reading");
|
||||||
ret = read(fd, buffer, sizeof(buffer));
|
ret = read(fd, buffer, sizeof(buffer));
|
||||||
igt_set_timeout(0);
|
igt_set_timeout(0, NULL);
|
||||||
igt_assert_eq(ret, -1);
|
igt_assert_eq(ret, -1);
|
||||||
igt_assert_eq(errno, EAGAIN);
|
igt_assert_eq(errno, EAGAIN);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user