Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor host dmesg verification into a Setuper #3994

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 2 additions & 21 deletions virttest/env_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
CheckRunningAsRoot,
)
from virttest.test_setup.storage import StorageConfig
from virttest.test_setup.verify import VerifyHostDMesg
from virttest.test_setup.vms import UnrequestedVMHandler
from virttest.utils_version import VersionInterval

Expand Down Expand Up @@ -1030,12 +1031,8 @@ def preprocess(test, params, env):
)
a_process.system(reset_cmd, shell=True)

# Check host for any errors to start with and just report and
# clear it off, so that we do not get the false test failures.
if params.get("verify_host_dmesg", "yes") == "yes":
utils_misc.verify_dmesg(ignore_result=True)

_setup_manager.initialize(test, params, env)
_setup_manager.register(VerifyHostDMesg)
_setup_manager.register(SwitchSMTOff)
_setup_manager.register(CheckRunningAsRoot)
_setup_manager.register(CheckInstalledCMDs)
Expand Down Expand Up @@ -1774,22 +1771,6 @@ def postprocess(test, params, env):
err += "\nPostprocess command: %s" % str(details).replace("\n", "\n ")
LOG.error(details)

if params.get("verify_host_dmesg", "yes") == "yes":
dmesg_log_file = params.get("host_dmesg_logfile", "host_dmesg.log")
level = params.get("host_dmesg_level", 3)
expected_host_dmesg = params.get("expected_host_dmesg", "")
ignore_result = params.get("host_dmesg_ignore", "no") == "yes"
dmesg_log_file = utils_misc.get_path(test.debugdir, dmesg_log_file)
try:
utils_misc.verify_dmesg(
dmesg_log_file=dmesg_log_file,
ignore_result=ignore_result,
level_check=level,
expected_dmesg=expected_host_dmesg,
)
except exceptions.TestFail as details:
err += "\nHost dmesg verification failed: %s" % details

err += "\n".join(_setup_manager.do_cleanup())

# Run this hook after any vms are actually off to ensure data is
Expand Down
25 changes: 25 additions & 0 deletions virttest/test_setup/verify.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from virttest import utils_misc
from virttest.test_setup.core import Setuper


class VerifyHostDMesg(Setuper):
def setup(self):
# Check host for any errors to start with and just report and
# clear it off, so that we do not get the false test failures.
if self.params.get("verify_host_dmesg", "yes") == "yes":
utils_misc.verify_dmesg(ignore_result=True)

def cleanup(self):
if self.params.get("verify_host_dmesg", "yes") == "yes":
dmesg_log_file = self.params.get("host_dmesg_logfile", "host_dmesg.log")
level = self.params.get("host_dmesg_level", 3)
expected_host_dmesg = self.params.get("expected_host_dmesg", "")
ignore_result = self.params.get("host_dmesg_ignore", "no") == "yes"
dmesg_log_file = utils_misc.get_path(self.test.debugdir, dmesg_log_file)
# exception will be propagated so setup_manager handles it instead
utils_misc.verify_dmesg(
dmesg_log_file=dmesg_log_file,
ignore_result=ignore_result,
level_check=level,
expected_dmesg=expected_host_dmesg,
)
Loading