Skip to contentSkip to conversation

lib/tests: add a test for igt_set_timeout

PATCH New Thomas Wood 1 participant 3 messages Nov 13, 2014 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 lib/tests: add a test for igt_set_timeout

---
 lib/tests/.gitignore       | 1 +
 lib/tests/Makefile.sources | 2 ++
 lib/tests/igt_timeout.c    | 8 ++++++++
 3 files changed, 11 insertions(+)
 create mode 100644 lib/tests/igt_timeout.c
lib/tests/.gitignore +1 -0
index caf5348..9fd8580 100644
@@ -5,3 +5,4 @@ igt_no_exit
 igt_no_exit_list_only
 igt_no_subtest
 igt_simulation
+igt_timeout
lib/tests/Makefile.sources +2 -0
index d64c89c..4208a26 100644
@@ -5,6 +5,7 @@ check_PROGRAMS = \
 	igt_list_only \
 	igt_no_subtest \
 	igt_simulation \
+	igt_timeout \
 	$(NULL)
 
 check_SCRIPTS = \
@@ -22,4 +23,5 @@ XFAIL_TESTS = \
 	igt_no_exit \
 	igt_no_exit_list_only \
 	igt_no_subtest \
+	igt_timeout \
 	$(NULL)
lib/tests/igt_timeout.c new file +8 -0
new file mode 100644
index 0000000..8affa61
@@ -0,0 +1,8 @@
+#include "igt_core.h"
+#include <unistd.h>
+
+igt_simple_main
+{
+	igt_set_timeout(1);
+	sleep(5);
+}
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

PATCH 2/3 tests/kms_flip: add a timeout for the nonblocking-read test

kms_flip/nonblocking-read will block indefinitely if it fails, so introduce a timeout to indicate test failure.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=85718

---
 tests/kms_flip.c | 2 ++
 1 file changed, 2 insertions(+)
tests/kms_flip.c +2 -0
index 612d7a9..cce9594 100644
@@ -1521,7 +1521,9 @@ static void test_nonblocking_read(int in)
 	}
 	igt_require(ret != -1);
 
+	igt_set_timeout(5);
 	ret = read(fd, buffer, sizeof(buffer));
+	igt_set_timeout(0);
 	igt_assert_eq(ret, -1);
 	igt_assert_eq(errno, EAGAIN);
 
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

PATCH 3/3 lib: only skip subsequent tests if a timeout occurs outside of a subtest

In reply to Thomas Wood

Make timeout behaviour more consistent with igt_fail, where subsequent subtests are only skipped if the failure occurs outside of a subtest.

---
 lib/igt_core.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
lib/igt_core.c +6 -7
index 3861121..b937f43 100644
@@ -1481,9 +1481,6 @@ void igt_vlog(enum igt_log_level level, const char *format, va_list args)
 
 static void igt_alarm_handler(int signal)
 {
-	/* subsequent tests are skipped */
-	skip_subtests_henceforth = SKIP;
-
 	/* exit with timeout status */
 	igt_fail(IGT_EXIT_TIMEOUT);
 }
@@ -1492,11 +1489,13 @@ static void igt_alarm_handler(int signal)
  * igt_set_timeout:
  * @seconds: number of seconds before timeout
  *
- * Stop the current test and skip any subsequent tests after the specified
- * number of seconds have elapsed. The test will exit with #IGT_EXIT_TIMEOUT
- * status. Any previous timer is cancelled and no timeout is scheduled if
- * @seconds is zero.
+ * Fail a test and exit with #IGT_EXIT_TIMEOUT status after the specified
+ * number of seconds have elapsed. If the current test has subtests and the
+ * timeout occurs outside a subtest, subsequent subtests will be skipped and
+ * marked as failed.
  *
+ * Any previous timer is cancelled and no timeout is scheduled if @seconds is
+ * zero.
  */
 void igt_set_timeout(unsigned int seconds)
 {
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx