diff options
author | Jose Luis Duran <jlduran@gmail.com> | 2023-10-12 15:14:44 +0000 |
---|---|---|
committer | Mark Johnston <markj@FreeBSD.org> | 2023-10-13 19:31:30 +0000 |
commit | a1eb150ce215f51abbbb34aed0533bced93e5502 (patch) | |
tree | 8c98ba026379aef859229a7132359ec596d66fc9 | |
parent | 7964a28ccfc9f1d353fa851f5ecd83d17ab75b09 (diff) | |
download | src-a1eb150ce215f51abbbb34aed0533bced93e5502.tar.gz src-a1eb150ce215f51abbbb34aed0533bced93e5502.zip |
atf_python: vnet: Use absolute paths within helpers
Usually tests are run in sterile environments; however, there is a
slight chance that the PATH overrides the utilities used for testing.
Pedantically use absolute paths, even inside VNETs, to avoid ambiguity.
Chiefly, jexec -> /usr/sbin/jexec, and ifconfig -> /sbin/ifconfig.
Reviewed by: markj
MFC after: 1 week
Pull Request: https://github.com/freebsd/freebsd-src/pull/865
-rw-r--r-- | tests/atf_python/sys/net/vnet.py | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/tests/atf_python/sys/net/vnet.py b/tests/atf_python/sys/net/vnet.py index bfe7984b440b..7c855b19f2c0 100644 --- a/tests/atf_python/sys/net/vnet.py +++ b/tests/atf_python/sys/net/vnet.py @@ -82,13 +82,9 @@ class VnetInterface(object): def set_jailed(self, jailed: bool): self.jailed = jailed - def run_cmd( - self, - cmd, - verbose=False, - ): + def run_cmd(self, cmd, verbose=False): if self.vnet_name and not self.jailed: - cmd = "jexec {} {}".format(self.vnet_name, cmd) + cmd = "/usr/sbin/jexec {} {}".format(self.vnet_name, cmd) return run_cmd(cmd, verbose) @classmethod @@ -189,7 +185,7 @@ class IfaceFactory(object): def cleanup_vnet_interfaces(self, vnet_name: str) -> List[str]: """Destroys""" ifaces_lst = ToolsHelper.get_output( - "/usr/sbin/jexec {} ifconfig -l".format(vnet_name) + "/usr/sbin/jexec {} /sbin/ifconfig -l".format(vnet_name) ) for iface_name in ifaces_lst.split(): if not self.is_autodeleted(iface_name): @@ -197,7 +193,7 @@ class IfaceFactory(object): print("Skipping interface {}:{}".format(vnet_name, iface_name)) continue run_cmd( - "/usr/sbin/jexec {} ifconfig {} destroy".format(vnet_name, iface_name) + "/usr/sbin/jexec {} /sbin/ifconfig {} destroy".format(vnet_name, iface_name) ) def cleanup(self): @@ -231,7 +227,7 @@ class VnetInstance(object): def run_vnet_cmd(self, cmd): if not self.attached: - cmd = "jexec {} {}".format(self.name, cmd) + cmd = "/usr/sbin/jexec {} {}".format(self.name, cmd) return run_cmd(cmd) def disable_dad(self): @@ -269,7 +265,7 @@ class VnetFactory(object): @staticmethod def _wait_interfaces(vnet_name: str, ifaces: List[str]) -> List[str]: - cmd = "jexec {} /sbin/ifconfig -l".format(vnet_name) + cmd = "/usr/sbin/jexec {} /sbin/ifconfig -l".format(vnet_name) not_matched: List[str] = [] for i in range(50): vnet_ifaces = run_cmd(cmd).strip().split(" ") |