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>
diff --git a/lib/igt_core.c b/lib/igt_core.c
index af3d873..e2c2502 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -1748,9 +1748,13 @@
 	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 @@
 /**
  * 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 @@
  * 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 @@
 	sigemptyset(&sa.sa_mask);
 	sa.sa_flags = 0;
 
+	timeout_op = op;
+
 	if (seconds == 0)
 		sigaction(SIGALRM, NULL, NULL);
 	else