Skip to contentSkip to conversation

lib/igt_core: capture logs for child processes

PATCH Superseded Pawel Sikora 1 participant 2 messages Mar 21, 2025 Library code

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover lib/igt_core: capture logs for child processes

Add a fix for proper log collection from child processes by the IGT runner.

This change addresses the issue of missing logs for child processes in the IGT runner:
https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/2178

The '_igt_log_buffer_dump()' function is now called before exiting child processes, ensuring that logs are properly captured and not lost when IGT fails and child processes dump logs before exiting.

Also, removing unnecessary comment about silent exit.

v2: Make the dump conditional based on active comms (Kamil)

Pawel Sikora (1):
lib/igt_core: capture logs for child processes

 lib/igt_core.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH v2 1/1 lib/igt_core: capture logs for child processes

This change addresses the issue of missing logs for child processes in the IGT runner.

The '_igt_log_buffer_dump()' function is now called before exiting child processes, ensuring that logs are properly captured and not lost when IGT fails and child processes dump logs before exiting.

v2: Make the dump conditional based on active comms (Kamil)

---
 lib/igt_core.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
lib/igt_core.c +9 -2
index c19689a51..512d88437 100644
@@ -296,6 +296,7 @@ static bool in_fixture = false;
 static bool test_with_subtests = false;
 static bool in_atexit_handler = false;
 static bool show_ftrace = false;
+static bool has_comms = false;
 static enum {
 	CONT = 0, SKIP, FAIL
 } skip_subtests_henceforth = CONT;
@@ -1905,11 +1906,17 @@ void igt_fail(int exitcode)
 		failed_one = true;
 	}
 
-	/* Silent exit, parent will do the yelling. */
+	/* If igt_runner uses comms, it could grab each child's logs without
+	 * them interleaving in stdout/stderr. */
+	has_comms = runner_connected();
+	if (has_comms)
+		_igt_log_buffer_dump();
+
 	if (test_child)
 		exit(exitcode);
 
-	_igt_log_buffer_dump();
+	if (!has_comms)
+		_igt_log_buffer_dump();
 
 	if (test_multi_fork_child)
 		exit(exitcode);
Signature · 1 line
2.34.1