Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 30 additions & 3 deletions tests/test_os_ops_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2860,6 +2860,8 @@ def test_get_process_children__with_child(
logging.info(f"Parent PID from stdout: {parent_pid}")
logging.info(f"Expected Child PID from stdout: {expected_child_pid}")

assert parent_pid == p1.pid

# A short pause to ensure registration in the OS
# time.sleep(0.5)

Expand Down Expand Up @@ -2911,9 +2913,9 @@ def test_get_process_children__with_three_children(
script = (
"import time, os, subprocess; "
"s = str(os.getpid()); "
"p1 = subprocess.Popen('exec sleep 60', shell=True, stdout=subprocess.PIPE); "
"p2 = subprocess.Popen('exec sleep 60', shell=True, stdout=subprocess.PIPE); "
"p3 = subprocess.Popen('exec sleep 60', shell=True, stdout=subprocess.PIPE); "
"p1 = subprocess.Popen(['sleep', '60'], shell=False, stdout=subprocess.PIPE); "
"p2 = subprocess.Popen(['sleep', '60'], shell=False, stdout=subprocess.PIPE); "
"p3 = subprocess.Popen(['sleep', '60'], shell=False, stdout=subprocess.PIPE); "
"s += ':' + str(p1.pid) + ':' + str(p2.pid) + ':' + str(p3.pid); "
"print(s, flush=True); "
"time.sleep(60)"
Expand Down Expand Up @@ -2943,6 +2945,8 @@ def test_get_process_children__with_three_children(
# A short pause to ensure registration in the OS
# time.sleep(0.5)

assert parent_pid == p.pid

childs = os_ops.get_process_children(parent_pid)

assert childs is not None
Expand All @@ -2954,6 +2958,29 @@ def test_get_process_children__with_three_children(

assert actual_child_pids == expected_child_pids

for i in range(len(childs)):
child_cmdline = childs[i].cmdline()

logging.info("child cmdline: {}".format(
child_cmdline,
))
assert type(child_cmdline) is list

if child_cmdline == ["sleep", "60"]:
pass
elif child_cmdline == ['/usr/bin/coreutils', '--coreutils-prog-shebang=sleep', '/usr/bin/sleep', '60']:
# Rocky Linux
pass
elif child_cmdline == ['/bin/sh', '-c', 'exec sleep 60']:
# Rocky Linux 10 (GitHub CI)
pass
else:
logging.error("Unknown child[{}] cmdline {}".format(
i,
child_cmdline,
))
continue

p.terminate()
p.wait()
return
Expand Down