Log command stdout when using isctest.run.cmd()

The command's stdout may provide useful debug info, so make sure we log
it by default. It doesn't seem to have a significant impact on the log
size.
This commit is contained in:
Nicki Křížek 2025-06-26 16:18:01 +02:00
parent 56fec9ba04
commit 9f3f6ec38e
9 changed files with 16 additions and 24 deletions

View file

@ -44,7 +44,7 @@ def run_rndc(server, rndc_command):
cmdline = [rndc, "-c", "../_common/rndc.conf", "-p", port, "-s", server]
cmdline.extend(rndc_command)
isctest.run.cmd(cmdline, log_stdout=True)
isctest.run.cmd(cmdline)
def test_dnstap_dispatch_socket_addresses():
@ -64,7 +64,6 @@ def test_dnstap_dispatch_socket_addresses():
# Read the contents of the dnstap file using dnstap-read.
run = isctest.run.cmd(
[isctest.vars.ALL["DNSTAPREAD"], "dnstap.out.resolver_addresses"],
log_stdout=True,
)
# Check whether all frames contain the expected addresses.

View file

@ -459,7 +459,7 @@ class Key:
str(self.keyfile),
]
out = isctest.run.cmd(dsfromkey_command, log_stdout=True)
out = isctest.run.cmd(dsfromkey_command)
dsfromkey = out.stdout.decode("utf-8").split()
rdata_fromfile = " ".join(dsfromkey[:7])

View file

@ -24,7 +24,7 @@ def cmd(
timeout=60,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
log_stdout=False,
log_stdout=True,
log_stderr=True,
input_text: Optional[bytes] = None,
raise_on_exception=True,
@ -111,7 +111,6 @@ class Dig:
"""Run the dig command with the given parameters and return the decoded output."""
return cmd(
[os.environ.get("DIG")] + f"{self.base_params} {params}".split(),
log_stdout=True,
).stdout.decode("utf-8")

View file

@ -1258,7 +1258,7 @@ def test_kasp_dnssec_keygen():
zone,
]
return isctest.run.cmd(keygen_command, log_stdout=True).stdout.decode("utf-8")
return isctest.run.cmd(keygen_command).stdout.decode("utf-8")
# check that 'dnssec-keygen -k' (configured policy) creates valid files.
keyprops = [
@ -1294,7 +1294,7 @@ def test_kasp_dnssec_keygen():
str(publish),
key.path,
]
out = isctest.run.cmd(settime, log_stdout=True).stdout.decode("utf-8")
out = isctest.run.cmd(settime).stdout.decode("utf-8")
isctest.check.file_contents_equal(f"{key.statefile}", f"{key.statefile}.backup")
assert key.get_metadata("Publish", file=key.privatefile) == str(publish)
@ -1343,7 +1343,7 @@ def test_kasp_dnssec_keygen():
str(now),
key.path,
]
out = isctest.run.cmd(settime, log_stdout=True).stdout.decode("utf-8")
out = isctest.run.cmd(settime).stdout.decode("utf-8")
isctest.kasp.check_keys("kasp", keys, expected)
isctest.kasp.check_keytimes(keys, expected)
@ -1378,7 +1378,7 @@ def test_kasp_dnssec_keygen():
str(now),
key.path,
]
out = isctest.run.cmd(settime, log_stdout=True).stdout.decode("utf-8")
out = isctest.run.cmd(settime).stdout.decode("utf-8")
isctest.kasp.check_keys("kasp", keys, expected)
isctest.kasp.check_keytimes(keys, expected)
@ -1423,7 +1423,7 @@ def test_kasp_dnssec_keygen():
str(soon),
key.path,
]
out = isctest.run.cmd(settime, log_stdout=True).stdout.decode("utf-8")
out = isctest.run.cmd(settime).stdout.decode("utf-8")
isctest.kasp.check_keys("kasp", keys, expected)
isctest.kasp.check_keytimes(keys, expected)

View file

@ -70,13 +70,12 @@ def token_init_and_cleanup():
isctest.run.cmd(
token_cleanup_command,
env=EMPTY_OPENSSL_CONF_ENV,
log_stdout=True,
raise_on_exception=False,
)
try:
output = isctest.run.cmd(
token_init_command, env=EMPTY_OPENSSL_CONF_ENV, log_stdout=True
token_init_command, env=EMPTY_OPENSSL_CONF_ENV
).stdout.decode("utf-8")
assert "The token has been initialized and is reassigned to slot" in output
yield
@ -84,7 +83,6 @@ def token_init_and_cleanup():
output = isctest.run.cmd(
token_cleanup_command,
env=EMPTY_OPENSSL_CONF_ENV,
log_stdout=True,
raise_on_exception=False,
).stdout.decode("utf-8")
assert re.search("Found token (.*) with matching token label", output)
@ -129,7 +127,7 @@ def test_keyfromlabel(alg_name, alg_type, alg_bits):
]
output = isctest.run.cmd(
pkcs11_command, env=EMPTY_OPENSSL_CONF_ENV, log_stdout=True
pkcs11_command, env=EMPTY_OPENSSL_CONF_ENV
).stdout.decode("utf-8")
assert "Key pair generated" in output
@ -147,7 +145,7 @@ def test_keyfromlabel(alg_name, alg_type, alg_bits):
zone,
]
output = isctest.run.cmd(keyfrlab_command, log_stdout=True)
output = isctest.run.cmd(keyfrlab_command)
output_decoded = output.stdout.decode("utf-8").rstrip() + ".key"
assert os.path.exists(output_decoded)
@ -186,6 +184,6 @@ def test_keyfromlabel(alg_name, alg_type, alg_bits):
zone,
zone_file,
]
isctest.run.cmd(signer_command, log_stdout=True)
isctest.run.cmd(signer_command)
assert os.path.exists(f"{zone_file}.signed")

View file

@ -96,9 +96,7 @@ def ksr(zone, policy, action, options="", raise_on_exception=True):
zone,
]
out = isctest.run.cmd(
ksr_command, log_stdout=True, raise_on_exception=raise_on_exception
)
out = isctest.run.cmd(ksr_command, raise_on_exception=raise_on_exception)
return out.stdout.decode("utf-8"), out.stderr.decode("utf-8")

View file

@ -265,7 +265,7 @@ def test_rollover_multisigner(servers):
zone,
]
return isctest.run.cmd(keygen_command, log_stdout=True).stdout.decode("utf-8")
return isctest.run.cmd(keygen_command).stdout.decode("utf-8")
zone = "multisigner-model2.kasp"

View file

@ -42,7 +42,7 @@ def test_max_rsa_exponent_size_good(exponent_size, templates):
def test_max_rsa_exponent_size_bad(exponent_size, templates):
templates.render("options.conf", {"max_rsa_exponent_size": exponent_size})
with pytest.raises(subprocess.CalledProcessError):
isctest.run.cmd([CHECKCONF, "options.conf"], log_stdout=True)
isctest.run.cmd([CHECKCONF, "options.conf"])
def test_rsa_big_exponent_keys_cant_load():

View file

@ -47,7 +47,7 @@ VERIFY = os.environ.get("VERIFY")
],
)
def test_verify_good_zone_files(zone):
isctest.run.cmd([VERIFY, "-z", "-o", zone, f"zones/{zone}.good"], log_stdout=True)
isctest.run.cmd([VERIFY, "-z", "-o", zone, f"zones/{zone}.good"])
def test_verify_good_zone_nsec_next_name_case_mismatch():
@ -58,7 +58,6 @@ def test_verify_good_zone_nsec_next_name_case_mismatch():
"nsec-next-name-case-mismatch",
"zones/nsec-next-name-case-mismatch.good",
],
log_stdout=True,
)
@ -67,7 +66,6 @@ def get_bad_zone_output(zone):
output = isctest.run.cmd(
[VERIFY, *only_opt, "-o", zone, f"zones/{zone}.bad"],
raise_on_exception=False,
log_stdout=True,
)
stream = (output.stdout + output.stderr).decode("utf-8").replace("\n", "")
return stream