Skip to content

Commit 259d7da

Browse files
pridhivirajstewartsmith
authored andcommitted
Fix testcase failures for run_command api changes.
Signed-off-by: Pridhiviraj Paidipeddi <[email protected]> Signed-off-by: Stewart Smith <[email protected]>
1 parent 6e9d2ee commit 259d7da

13 files changed

+132
-139
lines changed

common/OpTestConstants.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -402,8 +402,8 @@ class OpTestConstants():
402402
IPMI_FIREWALL_INFO = "firewall info channel 1 lun 0"
403403
IPMI_PEF_INFO = "pef info"
404404
IPMI_PEF_STATUS = "pef status"
405-
IPMI_PEF_POLICY = "pef policy"
406-
IPMI_PEF_LIST = "pef list"
405+
IPMI_PEF_POLICY = "pef policy help"
406+
IPMI_PEF_LIST = "pef policy list"
407407
IPMI_RAW_POH = "-v raw 0x0 0xf"
408408
IPMI_SDR_GET = "sdr get "
409409

common/OpTestHost.py

+17-3
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ def host_check_command(self, *i_cmd):
294294
try:
295295
l_res = self.host_run_command(l_cmd)
296296
except CommandFailed as c:
297-
l_msg = "host_check_command: (%s) not present on host. output of '%s': %s" % (','.join(i_cmd), l_cmd, '\n'.join(l_res))
297+
l_msg = "host_check_command: (%s) not present on host. output of '%s': %s" % (','.join(i_cmd), l_cmd, '\n'.join(c.output))
298298
print l_msg
299299
raise OpTestError(l_msg)
300300

@@ -928,10 +928,24 @@ def host_clear_all_dumps(self):
928928
def host_disable_kdump_service(self, os_level):
929929
if "Ubuntu" in os_level:
930930
self.host_run_command("systemctl stop kdump-tools.service")
931-
self.host_run_command("systemctl status kdump-tools.service")
931+
try:
932+
self.host_run_command("systemctl status kdump-tools.service")
933+
except CommandFailed as cf:
934+
if cf.exitcode == 3:
935+
pass
936+
else:
937+
print str(cf)
938+
raise OpTestError("kdump-tools service is failed to stop")
932939
else:
933940
self.host_run_command("systemctl stop kdump.service")
934-
self.host_run_command("systemctl status kdump.service")
941+
try:
942+
self.host_run_command("systemctl status kdump.service")
943+
except CommandFailed as cf:
944+
if cf.exitcode == 3:
945+
pass
946+
else:
947+
print str(cf)
948+
raise OpTestError("kdump service is failed to stop")
935949

936950
##
937951
# @brief This function disables kdump service

common/OpTestSystem.py

-6
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,6 @@ def run_OFF(self, state):
150150
if state == OpSystemState.PETITBOOT:
151151
self.cv_IPMI.ipmi_set_boot_to_petitboot()
152152

153-
# Make sure system is in standby state before power on.
154-
# otherwise ipmi power on will be non functional
155-
r = self.sys_wait_for_standby_state()
156-
if r == BMC_CONST.FW_FAILED:
157-
raise "Invalid state transition from runtime to runtime"
158-
159153
r = self.sys_power_on()
160154
# Only retry once
161155
if r == BMC_CONST.FW_FAILED:

op-test

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ from testcases import OpalErrorLog
6565
from testcases import LightPathDiagnostics
6666
from testcases import DPO
6767
from testcases import EPOW
68+
from testcases import OpTestKernel
6869
import testcases
6970

7071
args, remaining_args = OpTestConfiguration.conf.parse_args(sys.argv)

testcases/EPOW.py

+1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ def get_epow_limits(self):
8585
print limits
8686
cmd = cmd + "| cut -d '#' -f 1"
8787
limits = self.cv_FSP.fspc.run_command(cmd)
88+
limits = limits.splitlines()
8889
dic = {}
8990
for i in range(len(limits)):
9091
pair = ((limits[i]).replace(" ", "")).replace("\t", "")

testcases/OpTestDumps.py

+8-9
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ def tearDown(self):
5757
self.cv_HOST.host_gather_opal_msg_log()
5858
self.cv_HOST.host_gather_kernel_log()
5959

60-
6160
def fipsdump_initiate_from_host(self):
6261
dumpname = self.cv_FSP.fsp_run_command("fipsdump -l | sed 's/\ .*//'")
6362
self.cv_HOST.host_run_command('echo 1 > /sys/firmware/opal/dump/initiate_dump')
@@ -92,7 +91,7 @@ def fipsdump_initiate_from_host(self):
9291
for j in range(1, tries):
9392
time.sleep(4)
9493
res = self.cv_HOST.host_run_command('ls /var/log/dump')
95-
if res.__contains__(new_dumpname):
94+
if '\n'.join(res).__contains__(new_dumpname):
9695
print "fips dump transfered to host"
9796
break
9897
self.assertIn(new_dumpname, res,
@@ -105,13 +104,13 @@ def verify_fipsdump(self, dumpname, size_fsp):
105104
for j in range(1, tries):
106105
time.sleep(5)
107106
res = self.cv_HOST.host_run_command('ls /var/log/dump')
108-
if res.__contains__(dumpname):
107+
if '\n'.join(res).__contains__(dumpname):
109108
print "FipS dump transfered to Host"
110109
break
111-
self.assertIn(dumpname, res,
110+
self.assertIn(dumpname, '\n'.join(res),
112111
"fips dump file transfer to host is failed when initiates from host")
113112
cmd = "ls /var/log/dump/%s -l| awk '{print $5}'" % dumpname
114-
size_host = (self.cv_HOST.host_run_command(cmd)).strip()
113+
size_host = '\n'.join((self.cv_HOST.host_run_command(cmd))).strip()
115114
if size_fsp.__contains__(size_host):
116115
print "Total size of FSP dump file transfered to host from fsp"
117116
else:
@@ -133,7 +132,7 @@ def runTest(self):
133132
if "FSP" not in self.bmc_type:
134133
self.skipTest("FSP Platform OPAL specific dump tests")
135134
self.cv_HOST.host_check_command("opal-dump-parse")
136-
self.cv_HOST.host_run_command("rm -rf /var/log/dump/SYSDUMP* \r")
135+
self.cv_HOST.host_run_command("rm -rf /var/log/dump/SYSDUMP*")
137136
self.cv_FSP.fsp_get_console()
138137
if not self.cv_FSP.mount_exists():
139138
raise OpTestError("Please mount NFS and retry the test")
@@ -156,9 +155,9 @@ def runTest(self):
156155
print res
157156
res = self.cv_HOST.host_run_command("opal-dump-parse -l /var/log/dump/SYSDUMP*")
158157
print res
159-
self.assertIn("Opal", res, "sysdump test failed in dumping Opal-log section")
160-
self.assertIn("HostBoot-Runtime-log", res, "sysdump test failed in dumping HBRT section")
161-
self.assertIn("printk", res, "sysdump test failed in dumping printk section")
158+
self.assertIn("Opal", '\n'.join(res), "sysdump test failed in dumping Opal-log section")
159+
self.assertIn("HostBoot-Runtime-log", '\n'.join(res), "sysdump test failed in dumping HBRT section")
160+
self.assertIn("printk", '\n'.join(res), "sysdump test failed in dumping printk section")
162161

163162
class FIPS_DUMP(OpTestDumps):
164163

testcases/OpTestEM.py

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import OpTestConfiguration
4343
from common.OpTestUtil import OpTestUtil
4444
from common.OpTestSystem import OpSystemState
45+
from common.Exceptions import CommandFailed
4546

4647

4748
class OpTestEM():

testcases/OpTestEnergyScale.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def setUp(self):
5959
#
6060
def run_ipmi_cmd(self, i_cmd):
6161
l_cmd = i_cmd
62-
l_res = self.cv_IPMI.ipmitool_run(l_cmd)
62+
l_res = self.cv_IPMI.ipmitool.run(l_cmd)
6363
print l_res
6464
return l_res
6565

@@ -163,7 +163,7 @@ class OpTestEnergyScaleRuntime(OpTestEnergyScale):
163163
# @return BMC_CONST.FW_SUCCESS or BMC_CONST.FW_FAILED
164164
#
165165
def runTest(self):
166-
self.cv_SYSTEM.goto_state(OpSystemState.PETITBOOT_SHELL)
166+
self.cv_SYSTEM.goto_state(OpSystemState.OS)
167167

168168
print "Energy Scale Test 2: Get, Set, activate and deactivate platform power limit at runtime"
169169
l_power_limit_low, l_power_limit_high = self.get_platform_power_limits(self.cv_PLATFORM)
@@ -244,7 +244,7 @@ def runTest(self):
244244

245245
class OpTestEnergyScaleDCMIruntime(OpTestEnergyScale):
246246
def runTest(self):
247-
self.cv_SYSTEM.goto_state(OpSystemState.PETITBOOT_SHELL)
247+
self.cv_SYSTEM.goto_state(OpSystemState.OS)
248248

249249
print "Performing a IPMI Power ON Operation"
250250
# Perform a IPMI Power ON Operation

testcases/OpTestHMIHandling.py

+61-72
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,21 @@ def ipmi_monitor_sol_ipl(self, console, timeout):
8989
self.assertTrue(ipl_status, "HMI Core checkstop: IPL not started/finished")
9090
return
9191

92+
def verify_proc_recovery(self, l_res):
93+
if any("Processor Recovery done" in line for line in l_res) and \
94+
any("Harmless Hypervisor Maintenance interrupt [Recovered]" in line for line in l_res):
95+
print "Processor recovery done"
96+
return
97+
else:
98+
raise Exception("HMI handling failed to log message: for proc_recv_done")
99+
100+
def verify_timer_facility_recovery(self, l_res):
101+
if any("Timer facility experienced an error" in line for line in l_res) and \
102+
any("Severe Hypervisor Maintenance interrupt [Recovered]" in line for line in l_res):
103+
print "Timer facility experienced an error and got recovered"
104+
return
105+
else:
106+
raise Exception("HMI handling failed to log message")
92107

93108
def init_test(self):
94109
self.cv_SYSTEM.goto_state(OpSystemState.OS)
@@ -253,28 +268,22 @@ def _test_proc_recv_done(self):
253268
console = self.cv_SYSTEM.sys_get_ipmi_console()
254269
console.run_command("dmesg -C")
255270
try:
256-
l_res = console.run_command(l_cmd)
271+
l_res = console.run_command(l_cmd,timeout=120)
257272
except CommandFailed as cf:
258-
if cf.exitcode == 5:
273+
if cf.exitcode == 1:
259274
pass
260275
else:
261-
raise cf
262-
else:
263-
if any("Kernel panic - not syncing" in line for line in l_res):
264-
raise Exception("Processor recovery failed: Kernel got panic")
265-
elif any("Petitboot" in line for line in l_res):
266-
raise Exception("System reached petitboot:Processor recovery failed")
267-
elif any("ISTEP" in line for line in l_res):
268-
raise Exception("System started booting: Processor recovery failed")
269-
else:
270-
raise Exception("Failed to inject thread hang recoverable error")
271-
276+
if any("Kernel panic - not syncing" in line for line in l_res):
277+
raise Exception("Processor recovery failed: Kernel got panic")
278+
elif any("Petitboot" in line for line in l_res):
279+
raise Exception("System reached petitboot:Processor recovery failed")
280+
elif any("ISTEP" in line for line in l_res):
281+
raise Exception("System started booting: Processor recovery failed")
282+
else:
283+
raise Exception("Failed to inject thread hang recoverable error %s", str(cf))
284+
time.sleep(0.2)
272285
l_res = console.run_command("dmesg")
273-
if any("Processor Recovery done" in line for line in l_res) and \
274-
any("Harmless Hypervisor Maintenance interrupt [Recovered]" in line for line in l_res):
275-
print "Processor recovery done"
276-
else:
277-
raise Exception("HMI handling failed to log message: for proc_recv_done")
286+
self.verify_proc_recovery(l_res)
278287
return
279288

280289
##
@@ -290,28 +299,22 @@ def _test_proc_recv_error_masked(self):
290299
console = self.cv_SYSTEM.sys_get_ipmi_console()
291300
console.run_command("dmesg -C")
292301
try:
293-
l_res = console.run_command(l_cmd)
302+
l_res = console.run_command(l_cmd, timeout=120)
294303
except CommandFailed as cf:
295304
if cf.exitcode == 1:
296305
pass
297306
else:
298-
raise cf
299-
else:
300-
if any("Kernel panic - not syncing" in line for line in l_res):
301-
raise Exception("Processor recovery failed: Kernel got panic")
302-
elif any("Petitboot" in line for line in l_res):
303-
raise Exception("System reached petitboot:Processor recovery failed")
304-
elif any("ISTEP" in line for line in l_res):
305-
raise Exception("System started booting: Processor recovery failed")
306-
else:
307-
raise Exception("Failed to inject thread hang recoverable error")
308-
307+
if any("Kernel panic - not syncing" in line for line in l_res):
308+
raise Exception("Processor recovery failed: Kernel got panic")
309+
elif any("Petitboot" in line for line in l_res):
310+
raise Exception("System reached petitboot:Processor recovery failed")
311+
elif any("ISTEP" in line for line in l_res):
312+
raise Exception("System started booting: Processor recovery failed")
313+
else:
314+
raise Exception("Failed to inject thread hang recoverable error %s", str(cf))
315+
time.sleep(0.2)
309316
l_res = console.run_command("dmesg")
310-
if any("Processor Recovery done" in line for line in l_res) and \
311-
any("Harmless Hypervisor Maintenance interrupt [Recovered]" in line for line in l_res):
312-
print "Processor recovery done"
313-
else:
314-
raise Exception("HMI handling failed to log message")
317+
self.verify_proc_recovery(l_res)
315318
return
316319

317320
##
@@ -376,30 +379,23 @@ def _testTFMR_Errors(self, i_error):
376379
console = self.cv_SYSTEM.sys_get_ipmi_console()
377380
console.run_command("dmesg -C")
378381
try:
379-
l_res = console.run_command(l_cmd)
382+
l_res = console.run_command(l_cmd, timeout=120)
380383
except CommandFailed as cf:
381384
if cf.exitcode == 1:
382385
pass
383386
else:
384-
raise cf
385-
else:
386-
if any("Kernel panic - not syncing" in line for line in l_res):
387-
l_msg = "TFMR error injection: Kernel got panic"
388-
elif any("Petitboot" in line for line in l_res):
389-
l_msg = "System reached petitboot:TFMR error injection recovery failed"
390-
elif any("ISTEP" in line for line in l_res):
391-
l_msg = "System started booting: TFMR error injection recovery failed"
392-
else:
393-
raise Exception("Failed to inject TFMR error %s " % l_error)
387+
if any("Kernel panic - not syncing" in line for line in l_res):
388+
l_msg = "TFMR error injection: Kernel got panic"
389+
elif any("Petitboot" in line for line in l_res):
390+
l_msg = "System reached petitboot:TFMR error injection recovery failed"
391+
elif any("ISTEP" in line for line in l_res):
392+
l_msg = "System started booting: TFMR error injection recovery failed"
393+
else:
394+
raise Exception("Failed to inject TFMR error %s " % str(cf))
394395

395396
time.sleep(0.2)
396397
l_res = console.run_command("dmesg")
397-
if any("Timer facility experienced an error" in line for line in l_res) and \
398-
any("Severe Hypervisor Maintenance interrupt [Recovered]" in line for line in l_res):
399-
print "Timer facility experienced an error and got recovered"
400-
else:
401-
raise Exception("HMI handling failed to log message")
402-
398+
self.verify_timer_facility_recovery(l_res)
403399
return
404400

405401
##
@@ -425,31 +421,24 @@ def _test_tod_errors(self, i_error):
425421
# But getscom to TOD error reg there is no access
426422
# TOD Error reg has only WO access and there is no read access
427423
try:
428-
l_res = console.run_command(l_cmd)
424+
l_res = console.run_command(l_cmd, timeout=120)
429425
except CommandFailed as cf:
430426
if cf.exitcode == 1:
431427
pass
432428
else:
433-
raise cf
434-
else:
435-
if any("Kernel panic - not syncing" in line for line in l_res):
436-
print "TOD ERROR Injection-kernel got panic"
437-
elif any("login:" in line for line in l_res):
438-
print "System booted to host OS without any kernel panic message"
439-
elif any("Petitboot" in line for line in l_res):
440-
print "System reached petitboot without any kernel panic message"
441-
elif any("ISTEP" in line for line in l_res):
442-
print "System started booting without any kernel panic message"
443-
else:
444-
raise Exception("TOD: PSS Hamming distance error injection failed")
445-
429+
if any("Kernel panic - not syncing" in line for line in l_res):
430+
print "TOD ERROR Injection-kernel got panic"
431+
elif any("login:" in line for line in l_res):
432+
print "System booted to host OS without any kernel panic message"
433+
elif any("Petitboot" in line for line in l_res):
434+
print "System reached petitboot without any kernel panic message"
435+
elif any("ISTEP" in line for line in l_res):
436+
print "System started booting without any kernel panic message"
437+
else:
438+
raise Exception("TOD: PSS Hamming distance error injection failed %s", str(c))
439+
time.sleep(0.2)
446440
l_res = console.run_command("dmesg")
447-
if any("Timer facility experienced an error" in line for line in l_res) and \
448-
any("Severe Hypervisor Maintenance interrupt [Recovered]" in line for line in l_res):
449-
print "Timer facility experienced an error and got recovered"
450-
else:
451-
raise Exception("HMI handling failed to log message")
452-
441+
self.verify_timer_facility_recovery(l_res)
453442
return
454443

455444
##

0 commit comments

Comments
 (0)