diff --git a/bin/tests/system/isctest/run.py b/bin/tests/system/isctest/run.py index 2f421c2808..3fbc6ac341 100644 --- a/bin/tests/system/isctest/run.py +++ b/bin/tests/system/isctest/run.py @@ -83,15 +83,17 @@ def cmd( return CmdResult(exc) -class Dig: - def __init__(self, base_params: str = ""): - self.base_params = base_params +class EnvCmd: + """Helper for executing binaries from env with optional base parameters.""" - def __call__(self, params: str) -> CmdResult: - """Run the dig command with the given parameters.""" - return cmd( - [os.environ.get("DIG")] + f"{self.base_params} {params}".split(), - ) + def __init__(self, name: str, base_params: str = ""): + self.bin_path = os.environ[name] + self.base_params = base_params.split() + + def __call__(self, params: str, **kwargs) -> CmdResult: + """Call the command. Keyword arguments from isctest.run.cmd() are supported.""" + args = self.base_params + params.split() + return cmd([self.bin_path] + args, **kwargs) def retry_with_timeout(func, timeout, delay=1, msg=None): diff --git a/bin/tests/system/keepalive/tests_keepalive.py b/bin/tests/system/keepalive/tests_keepalive.py index 243525636c..169810de60 100644 --- a/bin/tests/system/keepalive/tests_keepalive.py +++ b/bin/tests/system/keepalive/tests_keepalive.py @@ -28,7 +28,7 @@ def test_dig_tcp_keepalive_handling(named_port, servers): options_received = line.split()[0] return int(options_received) - dig = isctest.run.Dig(f"-p {str(named_port)}") + dig = isctest.run.EnvCmd("DIG", f"-p {str(named_port)}") isctest.log.info("check that dig handles TCP keepalive in query") assert "; TCP KEEPALIVE" in dig("+qr +keepalive foo.example. @10.53.0.2").out