Commit 88f40f4947 for frr

commit 88f40f49477a6cb0096de1417365acd1f4b79f56
Author: Lincoln Thurlow <lincoln@isi.edu>
Date:   Tue Dec 1 09:58:59 2026 -0800

    tests: start the mock PCE without a shell

    The pathd PCEP steering topotest starts its mock PCE with shell
    syntax that does not work on every platform.

    setup_module() runs "nohup python3 mock_pce.py ... &" in rt1, and
    nothing stops the mock PCE at teardown.

    This commit starts the mock PCE with the router's popen(), using the
    test's Python interpreter, and terminates it at teardown.

    Signed-off-by: Lincoln Thurlow <lincoln@isi.edu>

diff --git a/tests/topotests/pathd_pcep_steering_topo1/test_pathd_pcep_steering_topo1.py b/tests/topotests/pathd_pcep_steering_topo1/test_pathd_pcep_steering_topo1.py
index dda315e54d..0fc468bb69 100644
--- a/tests/topotests/pathd_pcep_steering_topo1/test_pathd_pcep_steering_topo1.py
+++ b/tests/topotests/pathd_pcep_steering_topo1/test_pathd_pcep_steering_topo1.py
@@ -40,6 +40,7 @@ import os
 import re
 import sys
 import json
+import subprocess
 import pytest

 CWD = os.path.dirname(os.path.realpath(__file__))
@@ -111,27 +112,60 @@ def setup_module(mod):
     # retries the PCEP connection, so starting it after the routers
     # is fine.  The command file drives the churn tests: the PCE polls
     # it for 'add'/'remove' lines.
-    pce_log = os.path.join(tgen.logdir, "rt1", "mock_pce.log")
-    pce_commands = os.path.join(tgen.logdir, "rt1", "pce_commands")
-    tgen.gears["rt1"].run(
-        "nohup python3 {}/mock_pce.py "
-        "--policy {},{},test-steer "
-        "--policy {},{},test-steer-v6 "
-        "--pcc-address 192.0.2.1 --pcc-address6 2001:db8::1 "
-        "--command-file {} "
-        "--log {} > /dev/null 2>&1 &".format(
-            CWD, ENDPOINT, LABEL, ENDPOINT6, LABEL6, pce_commands, pce_log
-        )
-    )
+    start_pce()


 def teardown_module():
     "Teardown the pytest environment"

     tgen = get_topogen()
+    kill_pce()
     tgen.stop_topology()


+# The running mock PCE
+PCE_PROC = [None]
+
+
+def start_pce():
+    "Start the scripted PCE inside rt1's network namespace"
+
+    tgen = get_topogen()
+    pce_log = os.path.join(tgen.logdir, "rt1", "mock_pce.log")
+    pce_commands = os.path.join(tgen.logdir, "rt1", "pce_commands")
+    PCE_PROC[0] = tgen.gears["rt1"].popen(
+        [
+            sys.executable,
+            os.path.join(CWD, "mock_pce.py"),
+            "--policy",
+            "{},{},test-steer".format(ENDPOINT, LABEL),
+            "--policy",
+            "{},{},test-steer-v6".format(ENDPOINT6, LABEL6),
+            "--pcc-address",
+            "192.0.2.1",
+            "--pcc-address6",
+            "2001:db8::1",
+            "--command-file",
+            pce_commands,
+            "--log",
+            pce_log,
+        ],
+        stdin=subprocess.DEVNULL,
+        stdout=subprocess.DEVNULL,
+        stderr=subprocess.DEVNULL,
+    )
+
+
+def kill_pce():
+    "Stop the scripted PCE"
+
+    proc = PCE_PROC[0]
+    PCE_PROC[0] = None
+    if proc is not None and proc.poll() is None:
+        proc.terminate()
+        proc.wait()
+
+
 def print_pce_log():
     "Dump the mock PCE's session log to the test log for debugging"