Skip to content

Commit b1291e6

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 f722140 commit b1291e6

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
@@ -463,16 +463,6 @@ def log_data(self):
463463
return ""
464464
return self.log_file.read_text()
465465

466-
@property
467-
def console_data(self):
468-
"""Return the output of microVM's console"""
469-
if self.screen_log is None:
470-
return None
471-
file = Path(self.screen_log)
472-
if not file.exists():
473-
return None
474-
return file.read_text(encoding="utf-8")
475-
476466
@property
477467
def state(self):
478468
"""Get the InstanceInfo property and return the state field."""

0 commit comments

Comments
 (0)