All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petri Latvala <petri.latvala@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Tomi Sarvela <tomi.p.sarvela@intel.com>,
	Petri Latvala <petri.latvala@intel.com>,
	Chris Wilson <chris@chris-wilson.co.uk>
Subject: [igt-dev] [PATCH i-g-t 1/2] runner: Introduce a way to stop testing without marking tests incomplete
Date: Thu, 21 Jan 2021 11:50:14 +0200	[thread overview]
Message-ID: <20210121095015.12102-1-petri.latvala@intel.com> (raw)

Killing igt_runner with SIGHUP will now still kill the currently
running test, but it will mark that test as being "notrun" instead of
"incomplete". This allows for external tools to interrupt the testing
without messing the results.

Incidentally, Intel CI's testing procedures occasionally falsely
determine that the machine being tested is unreachable and as its next
step, will ssh in and issue a reboot in preparation for the next round
of testing, causing igt_runner to be killed with a SIGHUP...

v2:
 - Fix typo SIGUP -> SIGHUP
 - Make runner print that a graceful exit will be done
 - Explain the code flow regarding handling of signals to the runner process
 - Use GRACEFUL_EXITCODE instead of -SIGHUP directly

Signed-off-by: Petri Latvala <petri.latvala@intel.com>
Cc: Tomi Sarvela <tomi.p.sarvela@intel.com>
Cc: Arkadiusz Hiler <arek@hiler.eu>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
---
 runner/executor.c  | 31 +++++++++++++++++++++++++++++++
 runner/resultgen.c | 10 +++++++---
 2 files changed, 38 insertions(+), 3 deletions(-)

diff --git a/runner/executor.c b/runner/executor.c
index c1a0545a..3ca2d20a 100644
--- a/runner/executor.c
+++ b/runner/executor.c
@@ -1008,6 +1008,37 @@ static int monitor_output(pid_t child,
 					     get_cmdline(siginfo.ssi_pid, comm, sizeof(comm)),
 					     siginfo.ssi_pid,
 					     strsignal(siginfo.ssi_signo));
+
+					if (siginfo.ssi_signo == SIGHUP) {
+						/*
+						 * If taken down with
+						 * SIGHUP, arrange the
+						 * current test to be
+						 * marked as notrun
+						 * instead of
+						 * incomplete. For
+						 * other signals we
+						 * don't need to do
+						 * anything, the lack
+						 * of a completion
+						 * marker of any kind
+						 * in the logs will
+						 * mark those tests as
+						 * incomplete. Note
+						 * that since we set
+						 * 'aborting' to true
+						 * we're going to skip
+						 * all other journal
+						 * writes later.
+						 */
+
+						outf("Exiting gracefully, currently running test will have a 'notrun' result\n");
+						dprintf(outputs[_F_JOURNAL], "%s%d (%.3fs)\n",
+							EXECUTOR_EXIT,
+							-SIGHUP, 0.0);
+						if (settings->sync)
+							fdatasync(outputs[_F_JOURNAL]);
+					}
 				}
 
 				aborting = true;
diff --git a/runner/resultgen.c b/runner/resultgen.c
index 46007803..8d0c6249 100644
--- a/runner/resultgen.c
+++ b/runner/resultgen.c
@@ -17,11 +17,13 @@
 #include "executor.h"
 #include "output_strings.h"
 
-#define INCOMPLETE_EXITCODE -1
+#define INCOMPLETE_EXITCODE -1234
+#define GRACEFUL_EXITCODE -SIGHUP
 
 _Static_assert(INCOMPLETE_EXITCODE != IGT_EXIT_SKIP, "exit code clash");
 _Static_assert(INCOMPLETE_EXITCODE != IGT_EXIT_SUCCESS, "exit code clash");
 _Static_assert(INCOMPLETE_EXITCODE != IGT_EXIT_INVALID, "exit code clash");
+_Static_assert(INCOMPLETE_EXITCODE != GRACEFUL_EXITCODE, "exit code clash");
 
 struct subtest
 {
@@ -1106,6 +1108,8 @@ static const char *result_from_exitcode(int exitcode)
 		return "abort";
 	case INCOMPLETE_EXITCODE:
 		return "incomplete";
+	case GRACEFUL_EXITCODE:
+		return "notrun";
 	default:
 		return "fail";
 	}
@@ -1180,7 +1184,7 @@ static void fill_from_journal(int fd,
 		}
 	}
 
-	if (subtests->size && exitcode == IGT_EXIT_ABORT) {
+	if (subtests->size && (exitcode == IGT_EXIT_ABORT || exitcode == GRACEFUL_EXITCODE)) {
 		char *last_subtest = subtests->subs[subtests->size - 1].name;
 		char subtest_piglit_name[256];
 		struct json_object *subtest_obj;
@@ -1188,7 +1192,7 @@ static void fill_from_journal(int fd,
 		generate_piglit_name(entry->binary, last_subtest, subtest_piglit_name, sizeof(subtest_piglit_name));
 		subtest_obj = get_or_create_json_object(tests, subtest_piglit_name);
 
-		set_result(subtest_obj, "abort");
+		set_result(subtest_obj, exitcode == IGT_EXIT_ABORT ? "abort" : "notrun");
 	}
 
 	if (subtests->size == 0) {
-- 
2.29.2

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

             reply	other threads:[~2021-01-21  9:50 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-21  9:50 Petri Latvala [this message]
2021-01-21  9:50 ` [igt-dev] [PATCH i-g-t 2/2] runner: Add json test for handling graceful exit via SIGHUP Petri Latvala
2021-01-21 21:41   ` Arkadiusz Hiler
2021-01-21 10:02 ` [igt-dev] [PATCH i-g-t 1/2] runner: Introduce a way to stop testing without marking tests incomplete Chris Wilson
2021-01-21 10:32 ` [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,1/2] " Patchwork
2021-01-21 10:38   ` Petri Latvala
2021-01-22  3:14     ` Vudum, Lakshminarayana
2021-01-22  3:11 ` [igt-dev] ✓ Fi.CI.BAT: success " Patchwork
2021-01-22  6:41 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork

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=20210121095015.12102-1-petri.latvala@intel.com \
    --to=petri.latvala@intel.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=tomi.p.sarvela@intel.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.