diff --git a/common/OpTestConstants.py b/common/OpTestConstants.py index 454b77d0f..e3a72d35d 100644 --- a/common/OpTestConstants.py +++ b/common/OpTestConstants.py @@ -110,6 +110,7 @@ class OpTestConstants(): CLEAR_GARD_CMD = '/gard clear all' LIST_GARD_CMD = '/gard list' OPAL_MSG_LOG = "cat /sys/firmware/opal/msglog" + ULTRAVISOR_MSG_LOG = "cat /sys/firmware/ultravisor/msglog" PROC_CMDLINE = "cat /proc/cmdline" OPAL_DUMP_NODE = "/proc/device-tree/ibm,opal/dump/" NVRAM_PRINT_CFG = "nvram --print-config" diff --git a/common/OpTestHost.py b/common/OpTestHost.py index 74886b089..83ccdd8ec 100644 --- a/common/OpTestHost.py +++ b/common/OpTestHost.py @@ -33,26 +33,17 @@ import sys import os -import string import time -import random import subprocess import re -import telnetlib -import socket -import select -import pty -import pexpect import subprocess -import OpTestConfiguration from .OpTestConstants import OpTestConstants as BMC_CONST from .OpTestError import OpTestError from .OpTestSSH import OpTestSSH from . import OpTestQemu -from .Exceptions import CommandFailed, NoKernelConfig, KernelModuleNotLoaded, KernelConfigNotSet, ParameterCheck +from .Exceptions import CommandFailed, NoKernelConfig, KernelModuleNotLoaded, KernelConfigNotSet -import logging import OpTestLogger log = OpTestLogger.optest_logger_glob.get_logger(__name__) @@ -232,6 +223,37 @@ def host_gather_opal_msg_log(self, console=0): with open(fn, 'w') as f: f.write(l_data) + def host_gather_uv_msg_log(self, console=0): + ''' + Gather Ultravisor logs(from the host) and store in a file + ''' + uv_enabled_cmd = '[ -d /sys/firmware/devicetree/base/ibm,ultravisor ] && echo "enabled"' + if "enabled" in self.host_run_command(uv_enabled_cmd, console=console): + try: + l_data = '\n'.join(self.host_run_command( + BMC_CONST.ULTRAVISOR_MSG_LOG, console=console)) + except OpTestError: + l_msg = "Failed to gather ULTRAVISOR message logs" + raise OpTestError(l_msg) + + if not self.results_dir: + log.debug(l_data) + return + + l_res = (time.asctime(time.localtime())).replace(" ", "_") + l_logFile = "Ultravisor_msglog_%s.log" % l_res + fn = os.path.join(self.results_dir, l_logFile) + log.debug(fn) + with open(fn, 'w') as f: + f.write(l_data) + + def host_gather_fw_logs(self, console=0): + ''' + Wrapper function to gather all firmware related logs + ''' + self.host_gather_opal_msg_log(console) + self.host_gather_uv_msg_log(console) + def host_check_command(self, *i_cmd, **kwargs): ''' Check if one or more binaries are present on host @@ -666,7 +688,7 @@ def host_check_pkg_kdump(self, i_oslevel, console=0): def host_is_kdump_active(self, os_level, console=0): ''' - This function will check whether the kdump service is running/active or not. + This function will check whether the kdump service is running/active or not. ''' if "Ubuntu" in os_level: try: @@ -683,7 +705,6 @@ def host_is_kdump_active(self, os_level, console=0): except CommandFailed: return False - def host_disable_kdump_service(self, os_level, console=0): ''' This function disables kdump service. Needs the OS version (from `/etc/os-release`) to @@ -799,7 +820,7 @@ def host_get_cores(self, console=0): # Supported on OpenPower and P9 FSP system def host_prd_supported(self, bmc_type, console=0): - if not "FSP" in bmc_type: + if "FSP" not in bmc_type: return True proc_gen = self.host_get_proc_gen(console=console) @@ -984,16 +1005,24 @@ class OpTestLPAR(OpTestHost): Methods not applicable for an LPAR are overridden here ''' - def __init__(self, i_hostip, i_hostuser, i_hostpasswd, i_bmcip, i_results_dir, - scratch_disk="", proxy="", logfile=sys.stdout, + def __init__(self, i_hostip, i_hostuser, i_hostpasswd, i_bmcip, + i_results_dir, scratch_disk="", proxy="", logfile=sys.stdout, check_ssh_keys=False, known_hosts_file=None, conf=None): super(OpTestLPAR, self).__init__(i_hostip, - i_hostuser, i_hostpasswd, i_bmcip, i_results_dir, scratch_disk, - proxy, logfile, check_ssh_keys, known_hosts_file, conf) + i_hostuser, i_hostpasswd, i_bmcip, + i_results_dir, scratch_disk, proxy, + logfile, check_ssh_keys, + known_hosts_file, conf) def host_gather_opal_msg_log(self, *args): pass + def host_gather_uv_msg_log(self, *args): + pass + + def host_gather_fw_logs(self, *args): + pass + def host_pflash_get_partition(self, *args): pass @@ -1042,9 +1071,6 @@ def host_clear_error_logs(self, *args): def host_clear_all_dumps(self, *args): pass - def host_get_list_of_chips(self, *args): - pass - def host_prd_supported(self, *args): pass diff --git a/testcases/InstallUpstreamKernel.py b/testcases/InstallUpstreamKernel.py index 5e6269122..b701715f6 100644 --- a/testcases/InstallUpstreamKernel.py +++ b/testcases/InstallUpstreamKernel.py @@ -152,7 +152,7 @@ def is_url(path): if self.conf.args.host_cmd: con.run_command(self.conf.args.host_cmd, timeout=self.host_cmd_timeout) - self.cv_HOST.host_gather_opal_msg_log() + self.cv_HOST.host_gather_fw_logs() self.cv_HOST.host_gather_kernel_log() finally: if self.console_thread.isAlive(): diff --git a/testcases/RunHostTest.py b/testcases/RunHostTest.py index 0e2197ae1..8bd7772c0 100644 --- a/testcases/RunHostTest.py +++ b/testcases/RunHostTest.py @@ -78,4 +78,6 @@ def runTest(self): self.host_cmd_resultpath) def tearDown(self): + self.self.cv_SYSTEM.cv_HOST.host_gather_fw_logs() + self.self.cv_SYSTEM.cv_HOST.host_gather_kernel_log() self.console_thread.console_terminate()