summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/igt_core.c14
-rw-r--r--lib/igt_core.h2
-rw-r--r--lib/igt_debugfs.c2
-rw-r--r--tests/kms_flip.c3
4 files changed, 18 insertions, 3 deletions
diff --git a/lib/igt_core.c b/lib/igt_core.c
index e2c2502b..c70176fb 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -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)
{
diff --git a/lib/igt_core.h b/lib/igt_core.h
index 1a324ee8..1d77f452 100644
--- a/lib/igt_core.h
+++ b/lib/igt_core.h
@@ -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);
/**
diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index 6180a2aa..3cbc981d 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -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';
diff --git a/tests/kms_flip.c b/tests/kms_flip.c
index 214cd696..a595d9f1 100644
--- a/tests/kms_flip.c
+++ b/tests/kms_flip.c
@@ -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);