about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2025-02-07 21:31:01 +0100
committerGitHub <noreply@github.com>2025-02-07 21:31:01 +0100
commit8aa6cfbe53577c0769874361bd647b54e12672b5 (patch)
tree6be49e2de2f0e79fc2a867fdf5d0f8ffd461abe6
parent7ca0fd18f6c7927de9f50bd3a229967d0c88e9f7 (diff)
parentbdaf7a8fd7b3c670a6a5c506e065fa032432b401 (diff)
downloadrust-8aa6cfbe53577c0769874361bd647b54e12672b5.tar.gz
rust-8aa6cfbe53577c0769874361bd647b54e12672b5.zip
Rollup merge of #136556 - amy-kwan:amy-kwan/update_wait-forked-but-failed-child.rs, r=joboet
[AIX] Update tests/ui/wait-forked-but-failed-child.rs to accomodate exiting and idle processes.

The `wait-forked-but-failed-child.rs` test expects to see an integer PPID in the
output of the command: `ps -A -o pid,ppid,args`.

However, on AIX, sometimes an integer PPID is not available when a process is
either exiting or idle, as documented in https://www.ibm.com/docs/en/aix/7.3?topic=p-ps-command.
In these situations, a `-` is instead shown in the PPID column of the `ps` output.

This PR updates the test to accommodate this behaviour on AIX by first filtering out the
lines of the `ps` output where a `-` is found in the `PPID` column.
-rw-r--r--tests/ui/wait-forked-but-failed-child.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/tests/ui/wait-forked-but-failed-child.rs b/tests/ui/wait-forked-but-failed-child.rs
index 04f1c1a65d5..4a7f2bee9d9 100644
--- a/tests/ui/wait-forked-but-failed-child.rs
+++ b/tests/ui/wait-forked-but-failed-child.rs
@@ -31,8 +31,17 @@ fn find_zombies() {
     // https://pubs.opengroup.org/onlinepubs/9699919799/utilities/ps.html
     let ps_cmd_output = Command::new("ps").args(&["-A", "-o", "pid,ppid,args"]).output().unwrap();
     let ps_output = String::from_utf8_lossy(&ps_cmd_output.stdout);
+    // On AIX, the PPID is not always present, such as when a process is blocked
+    // (marked as <exiting>), or if a process is idle. In these situations,
+    // the PPID column contains a "-" for the respective process.
+    // Filter out any lines that have a "-" as the PPID as the PPID is
+    // expected to be an integer.
+    let filtered_ps: Vec<_> = ps_output
+        .lines()
+        .filter(|line| line.split_whitespace().nth(1) != Some("-"))
+        .collect();
 
-    for (line_no, line) in ps_output.split('\n').enumerate() {
+    for (line_no, line) in filtered_ps.into_iter().enumerate() {
         if 0 < line_no && 0 < line.len() &&
            my_pid == line.split(' ').filter(|w| 0 < w.len()).nth(1)
                          .expect("1st column should be PPID")