[PATCH i-g-t] runner: Use 'abort' as result if a test caused an abort

Petri Latvala petri.latvala at intel.com
Fri Nov 11 13:44:46 UTC 2022


... when possible, which is when using socket comms.

Signed-off-by: Petri Latvala <petri.latvala at intel.com>
---
 runner/executor.c | 40 +++++++++++++++++++++++++++++++++++++++-
 1 file changed, 39 insertions(+), 1 deletion(-)

diff --git a/runner/executor.c b/runner/executor.c
index 2feef2c9..0c88ac8d 100644
--- a/runner/executor.c
+++ b/runner/executor.c
@@ -2164,6 +2164,31 @@ static void code_coverage_stop(struct settings *settings, const char *job_name,
 	run_as_root(argv, sigfd, abortreason);
 }
 
+/* Open the comms file if the test used socket comms */
+static int open_comms_if_valid(int resdirfd, size_t testidx)
+{
+	struct comms_visitor emptyvisitor = {};
+	char name[32];
+	int dirfd, commsfd;
+
+	snprintf(name, sizeof(name), "%zd", testidx);
+	dirfd = openat(resdirfd, name, O_DIRECTORY | O_RDONLY);
+	if (dirfd < 0)
+		return -1;
+
+	commsfd = openat(dirfd, "comms", O_RDWR);
+	close(dirfd);
+
+	if (commsfd < 0)
+		return -1;
+
+	if (comms_read_dump(commsfd, &emptyvisitor) == COMMSPARSE_SUCCESS)
+		return commsfd;
+
+	close(commsfd);
+	return -1;
+}
+
 bool execute(struct execute_state *state,
 	     struct settings *settings,
 	     struct job_list *job_list)
@@ -2320,7 +2345,20 @@ bool execute(struct execute_state *state,
 			char *next = (state->next + 1 < job_list->size ?
 				      entry_display_name(&job_list->entries[state->next + 1]) :
 				      strdup("nothing"));
-			write_abort_file(resdirfd, reason, prev, next);
+			int commsfd;
+
+			commsfd = open_comms_if_valid(resdirfd, state->next);
+			if (commsfd >= 0) {
+				lseek(commsfd, 0, SEEK_END);
+				write_packet_with_canary(commsfd, runnerpacket_log(STDOUT_FILENO, "This test caused an abort condition:\n\n"), false);
+				write_packet_with_canary(commsfd, runnerpacket_log(STDOUT_FILENO, reason), false);
+				write_packet_with_canary(commsfd, runnerpacket_resultoverride("abort"), settings->sync);
+
+				close(commsfd);
+			} else {
+				write_abort_file(resdirfd, reason, prev, next);
+			}
+
 			free(prev);
 			free(next);
 			free(reason);
-- 
2.30.2



More information about the Intel-gfx-trybot mailing list