diff mbox series

[ptest-runner,2/5] Only collect system state on timeout

Message ID 20230718172614.469304-3-JPEWhacker@gmail.com
State New
Headers show
Series Fix ptest timeout errors | expand

Commit Message

Joshua Watt July 18, 2023, 5:26 p.m. UTC
To match the behavior of the previous ptest-runner, only collect system
state when a test has timed out

Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
---
 utils.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)
diff mbox series

Patch

diff --git a/utils.c b/utils.c
index 34ca2f0..d0e6a99 100644
--- a/utils.c
+++ b/utils.c
@@ -556,21 +556,18 @@  run_ptests(struct ptest_list *head, const struct ptest_options opts,
 						}
 					}
 				}
-				collect_system_state(_child_reader.fps[0]);
 
-				for (int i = 0; i < 2; i++) {
-					fflush(_child_reader.fps[i]);
-				}
-
-				/*
-				 * This kill is just in case the child did
-				 * something really silly like close its
-				 * stdout and stderr but then go into an
-				 * infinite loop and never exit. Normally, it
-				 * will just fail because the child is already
-				 * dead
-				 */
-				if (!_child_reader.timeouted) {
+				if (_child_reader.timeouted) {
+					collect_system_state(fp);
+				} else {
+					/*
+					 * This kill is just in case the child did
+					 * something really silly like close its
+					 * stdout and stderr but then go into an
+					 * infinite loop and never exit. Normally, it
+					 * will just fail because the child is already
+					 * dead
+					 */
 					kill(-child, SIGKILL);
 				}
 				waitpid(child, &status, 0);