Skip to content

Commit 0bb9915

Browse files
committed
Allow for configurable extra vm dump checks for present/absent messages
The typical use for this is when dumping extra logs and wanting to make sure certain information is always present (e.g. startup, etc.) and certain information is always absent (e.g. segfaults, etc.). Signed-off-by: Plamen Dimitrov <plamen.dimitrov@intra2net.com>
1 parent de845c0 commit 0bb9915

1 file changed

Lines changed: 38 additions & 11 deletions

File tree

virttest/env_process.py

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import time
1313

1414
import six
15+
from aexpect import ops_linux as ops
1516
from aexpect import remote
1617
from avocado.core import exceptions
1718
from avocado.utils import archive
@@ -665,21 +666,13 @@ def postprocess_vm(test, params, env, name):
665666
serial_login=serial_login,
666667
)
667668

668-
# Close all SSH sessions that might be active to this VM
669-
for s in vm.remote_sessions[:]:
670-
try:
671-
s.close()
672-
vm.remote_sessions.remove(s)
673-
except Exception:
674-
pass
675-
676-
utils_logfile.close_log_file()
677-
678669
if params.get("vm_extra_dump_paths") is not None:
679670
vm_extra_dumps = os.path.join(test.outputdir, "vm_extra_dumps")
680671
if not os.path.exists(vm_extra_dumps):
681672
os.makedirs(vm_extra_dumps)
682-
for dump_path in params.get("vm_extra_dump_paths").split(";"):
673+
for i, dump_path in enumerate(
674+
params.get_list("vm_extra_dump_paths", delimiter=";")
675+
):
683676
try:
684677
vm.copy_files_from(dump_path, vm_extra_dumps)
685678
except:
@@ -688,6 +681,40 @@ def postprocess_vm(test, params, env, name):
688681
dump_path,
689682
vm.name,
690683
)
684+
if params.get_boolean(f"verify_vm_extra_dump_{i}"):
685+
if not vm.session or not vm.session.is_responsive():
686+
LOG.warning(
687+
"Cannot verify dump '%s' for VM '%s': session unavailable",
688+
dump_path,
689+
vm.name,
690+
)
691+
continue
692+
for message in params.get_list(
693+
f"expected_vm_extra_dump_{i}", delimiter=";"
694+
):
695+
LOG.info(f"Checking for expected message in {dump_path}")
696+
if not ops.grep(vm.session, message, dump_path, check=True):
697+
raise exceptions.TestFail(
698+
f"Missing expected message '{message}' in {vm.name} extra dump {dump_path}"
699+
)
700+
for message in params.get_list(
701+
f"unexpected_vm_extra_dump_{i}", delimiter=";"
702+
):
703+
LOG.info(f"Checking for unexpected message in {dump_path}")
704+
if ops.grep(vm.session, message, dump_path, check=True):
705+
raise exceptions.TestFail(
706+
f"Redundant unexpected message '{message}' in {vm.name} extra dump {dump_path}"
707+
)
708+
709+
# Close all SSH sessions that might be active to this VM
710+
for s in vm.remote_sessions[:]:
711+
try:
712+
s.close()
713+
vm.remote_sessions.remove(s)
714+
except Exception:
715+
pass
716+
717+
utils_logfile.close_log_file()
691718

692719
if params.get("kill_vm") == "yes":
693720
kill_vm_timeout = float(params.get("kill_vm_timeout", 0))

0 commit comments

Comments
 (0)