diff --git a/lib/test/container-test-driver/test_driver/__init__.py b/lib/test/container-test-driver/test_driver/__init__.py index 42c26979b..78ed0d66a 100644 --- a/lib/test/container-test-driver/test_driver/__init__.py +++ b/lib/test/container-test-driver/test_driver/__init__.py @@ -187,6 +187,22 @@ class Machine: if line_pattern.match(line) ) + def nsenter_command(self, command: str) -> list[str]: + return [ + "nsenter", + "--target", + str(self.container_pid), + "--mount", + "--uts", + "--ipc", + "--net", + "--pid", + "--cgroup", + "/bin/sh", + "-c", + command, + ] + def execute( self, command: str, @@ -231,20 +247,7 @@ class Machine: command = f"set -eo pipefail; source /etc/profile; set -u; {command}" proc = subprocess.run( - [ - "nsenter", - "--target", - str(self.container_pid), - "--mount", - "--uts", - "--ipc", - "--net", - "--pid", - "--cgroup", - "/bin/sh", - "-c", - command, - ], + self.nsenter_command(command), timeout=timeout, check=False, stdout=subprocess.PIPE, @@ -465,6 +468,9 @@ class Driver: print(f"Starting {machine.name}") machine.start() + for machine in self.machines: + print(machine.nsenter_command("bash")) + def test_symbols(self) -> dict[str, Any]: general_symbols = { "start_all": self.start_all,