Skip to content

Commit 4737442

Browse files
committed
refactor(test): capture screen log via file copy
Copy the screen log file (which contains firecracker's stdout/guest dmesg if non-daemonized / no log file specified) to the test_results directory, to be included in artifacts, instead of explicitly reading one file and subsequently writing another file in Python code. Signed-off-by: Patrick Roy <[email protected]>
1 parent 3e1db4b commit 4737442

File tree

2 files changed

+2
-13
lines changed

2 files changed

+2
-13
lines changed

tests/conftest.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,8 @@ def microvm_factory(request, record_property, results_dir, netns_factory):
392392
utils.run_cmd(["dmesg", "-dPx"]).stdout
393393
)
394394
shutil.copy(f"/firecracker/build/img/{platform.machine()}/id_rsa", uvm_data)
395+
if Path(uvm.screen_log).exists():
396+
shutil.copy(uvm.screen_log, uvm_data)
395397

396398
uvm_root = Path(uvm.chroot())
397399
for item in os.listdir(uvm_root):
@@ -400,9 +402,6 @@ def microvm_factory(request, record_property, results_dir, netns_factory):
400402
continue
401403
dst = uvm_data / item
402404
shutil.copy(src, dst)
403-
console_data = uvm.console_data
404-
if console_data:
405-
uvm_data.joinpath("guest-console.log").write_text(console_data)
406405

407406
uvm_factory.kill()
408407

tests/framework/microvm.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -458,16 +458,6 @@ def log_data(self):
458458
return ""
459459
return self.log_file.read_text()
460460

461-
@property
462-
def console_data(self):
463-
"""Return the output of microVM's console"""
464-
if self.screen_log is None:
465-
return None
466-
file = Path(self.screen_log)
467-
if not file.exists():
468-
return None
469-
return file.read_text(encoding="utf-8")
470-
471461
@property
472462
def state(self):
473463
"""Get the InstanceInfo property and return the state field."""

0 commit comments

Comments
 (0)