Skip to content

Commit 6521be5

Browse files
committed
test: stop printing host dmesg on test failure
Because we're storing dmesg in a local variable, if an exception occurs while killing a microvm, python will end up printing the entirety of the host dmesg output to stderr, because it dumps local variables as part of the backtrace. This is fine in CI because instances are shortlived, but when running tests locally, it takes my terminal multiple minutes to catch up with the amount of text that ends up being printed. Fix this by not storing dmesg in a local variable anymore, and instead inline it to its only use-site. Signed-off-by: Patrick Roy <[email protected]>
1 parent 5a378ce commit 6521be5

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

tests/conftest.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,11 +336,12 @@ def microvm_factory(request, record_property, results_dir, netns_factory):
336336
# if the test failed, save important files from the root of the uVM into `test_results` for troubleshooting
337337
report = request.node.stash[PHASE_REPORT_KEY]
338338
if "call" in report and report["call"].failed:
339-
dmesg = utils.run_cmd(["dmesg", "-dPx"])
340339
for uvm in uvm_factory.vms:
341340
uvm_data = results_dir / uvm.id
342341
uvm_data.mkdir()
343-
uvm_data.joinpath("host-dmesg.log").write_text(dmesg.stdout)
342+
uvm_data.joinpath("host-dmesg.log").write_text(
343+
utils.run_cmd(["dmesg", "-dPx"]).stdout
344+
)
344345
shutil.copy(f"/firecracker/build/img/{platform.machine()}/id_rsa", uvm_data)
345346

346347
uvm_root = Path(uvm.chroot())

0 commit comments

Comments
 (0)