Skip to content

Commit 20e1f1e

Browse files
pridhivirajstewartsmith
authored andcommitted
FSP Reset Reload Testcases.
Added basic fsp rr tests(both fir & hir) and torture tests. Signed-off-by: Pridhiviraj Paidipeddi <[email protected]> Signed-off-by: Stewart Smith <[email protected]>
1 parent 259d7da commit 20e1f1e

File tree

2 files changed

+245
-0
lines changed

2 files changed

+245
-0
lines changed

op-test

+2
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ from testcases import LightPathDiagnostics
6666
from testcases import DPO
6767
from testcases import EPOW
6868
from testcases import OpTestKernel
69+
from testcases import fspresetReload
6970
import testcases
7071

7172
args, remaining_args = OpTestConfiguration.conf.parse_args(sys.argv)
@@ -252,6 +253,7 @@ class FspOpalSuite():
252253
self.s.addTest(OpalErrorLog.BasicTest())
253254
self.s.addTest(OpalErrorLog.FullTest())
254255
self.s.addTest(LightPathDiagnostics.extended_suite())
256+
self.s.addTest(fspresetReload.suite())
255257
self.s.addTest(EPOW.suite())
256258
self.s.addTest(OpTestOCC.OCCRESET_FSP())
257259
def suite(self):

testcases/fspresetReload.py

+243
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,243 @@
1+
#!/usr/bin/python
2+
# IBM_PROLOG_BEGIN_TAG
3+
# This is an automatically generated prolog.
4+
#
5+
# OpenPOWER Automated Test Project
6+
#
7+
# Contributors Listed Below - COPYRIGHT 2015
8+
# [+] International Business Machines Corp.
9+
#
10+
#
11+
# Licensed under the Apache License, Version 2.0 (the "License");
12+
# you may not use this file except in compliance with the License.
13+
# You may obtain a copy of the License at
14+
#
15+
# http://www.apache.org/licenses/LICENSE-2.0
16+
#
17+
# Unless required by applicable law or agreed to in writing, software
18+
# distributed under the License is distributed on an "AS IS" BASIS,
19+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
20+
# implied. See the License for the specific language governing
21+
# permissions and limitations under the License.
22+
#
23+
# IBM_PROLOG_END_TAG
24+
25+
# @package fspresetReload
26+
# FSP initiated reset
27+
# Host initiated reset
28+
# Once reset is done, verify host-fsp firmware interfaces
29+
30+
import time
31+
import subprocess
32+
import re
33+
34+
from common.OpTestIPMI import OpTestIPMI
35+
from common.OpTestConstants import OpTestConstants as BMC_CONST
36+
from common.OpTestError import OpTestError
37+
38+
import unittest
39+
import OpTestConfiguration
40+
from common.OpTestSystem import OpSystemState
41+
from common.Exceptions import CommandFailed
42+
43+
class fspresetReload(unittest.TestCase):
44+
def setUp(self):
45+
conf = OpTestConfiguration.conf
46+
self.cv_IPMI = conf.ipmi()
47+
self.cv_SYSTEM = conf.system()
48+
self.cv_FSP = self.cv_SYSTEM.bmc
49+
self.cv_HOST = conf.host()
50+
self.util = self.cv_SYSTEM.util
51+
self.bmc_type = conf.args.bmc_type
52+
self.cv_SYSTEM.goto_state(OpSystemState.OS)
53+
54+
def tearDown(self):
55+
self.cv_HOST.host_gather_opal_msg_log()
56+
self.cv_HOST.host_gather_kernel_log()
57+
58+
def number_of_resets(self):
59+
return 1
60+
61+
# FSP initiated reset(FIR)
62+
def trigger_fir(self):
63+
cmd = "smgr resetReload"
64+
print "Running the cmd %s on FSP" % cmd
65+
self.cv_FSP.fspc.issue_forget(cmd)
66+
67+
# Host initiated reset(HIR)
68+
def trigger_hir(self):
69+
cmd = "putmemproc 300000f8 0x00000000deadbeef"
70+
print "Running the cmd %s on FSP" % cmd
71+
self.cv_FSP.fspc.issue_forget(cmd)
72+
73+
def trigger_rr(self):
74+
if self.test == "fir":
75+
self.trigger_fir()
76+
elif self.test == "hir":
77+
self.trigger_hir()
78+
else:
79+
raise Exception("Unknown fsp rr test type")
80+
81+
def wait_for_fsp_ping(self):
82+
self.util.PingFunc(self.cv_FSP.host_name, BMC_CONST.PING_RETRY_POWERCYCLE)
83+
84+
# Wait for psi link active
85+
def check_psi_link_active(self):
86+
tries = 120
87+
for i in range(0, tries):
88+
if self.look_for_in_opal_log("Found active link!"):
89+
return True
90+
time.sleep(5)
91+
return False
92+
93+
# check the surveilance b/w opal and fsp
94+
def check_for_surveillance(self):
95+
tries = 20
96+
for i in range(0, tries):
97+
if self.look_for_in_opal_log("Received heartbeat acknowledge from FSP"):
98+
return True
99+
time.sleep(6)
100+
return False
101+
102+
# check for inband ipmi interface
103+
def check_for_inbandipmi(self):
104+
try:
105+
self.cv_HOST.host_run_command("ipmitool sensor list")
106+
except CommandFailed as cf:
107+
print str(cf)
108+
return False
109+
return True
110+
111+
# check for in-band sensors
112+
def check_for_sensors(self):
113+
try:
114+
self.cv_HOST.host_run_command("sensors")
115+
except CommandFailed as cf:
116+
print str(cf)
117+
return False
118+
return True
119+
120+
# check for nvram interface
121+
def check_for_nvram(self):
122+
try:
123+
self.cv_HOST.host_run_command("nvram --update-config test-cfg-rr=test-value")
124+
except CommandFailed as cf:
125+
print str(cf)
126+
return False
127+
try:
128+
output = self.cv_HOST.host_run_command("nvram --print-config")
129+
except CommandFailed as cf:
130+
print str(cf)
131+
return False
132+
if "test-cfg-rr=test-value" in ' '.join(output):
133+
return True
134+
return False
135+
136+
# check for sol console, whether we are able to use or not
137+
def check_for_sol_console(self):
138+
self.cv_SYSTEM.host_console_login()
139+
self.cv_SYSTEM.host_console_unique_prompt()
140+
l_con = self.cv_SYSTEM.sys_get_ipmi_console()
141+
r = l_con.run_command("echo 'Hello World'")
142+
self.assertIn("Hello World", r)
143+
try:
144+
r = l_con.run_command("false")
145+
except CommandFailed as r:
146+
self.assertEqual(r.exitcode, 1)
147+
148+
# check RTC TOD read/write interface
149+
def check_for_rtc(self):
150+
try:
151+
self.cv_HOST.host_read_hwclock()
152+
self.cv_HOST.host_set_hwclock_time("2015-01-01 10:10:10")
153+
except CommandFailed as cf:
154+
print str(cf)
155+
return False
156+
return True
157+
158+
# Check all these fsp-host interfaces are working fine after fsp rr
159+
def check_for_fsp_host_interfaces(self):
160+
self.assertTrue(self.check_psi_link_active(), "PSI Link is not active after fsp rr")
161+
self.assertTrue(self.check_for_surveillance(), "Surveilance failed after fsp rr")
162+
self.assertTrue(self.check_for_rtc(), "Set/Read HW Clock failed after fsp rr")
163+
self.assertTrue(self.check_for_inbandipmi(), "inband ipmi interface failed after fsp rr")
164+
self.assertTrue(self.check_for_sensors(), "inband sensors failed after fsp rr")
165+
self.assertTrue(self.check_for_nvram(), "nvram interface failed after fsp rr")
166+
self.check_for_sol_console()
167+
168+
169+
def look_for_in_opal_log(self, pattern):
170+
try:
171+
output = self.cv_HOST.host_run_command("cat /sys/firmware/opal/msglog | diff - /tmp/opal_msglog")
172+
except CommandFailed as cf:
173+
if cf.exitcode == 1:
174+
output = cf.output
175+
for line in output:
176+
if len(line) and (line.find(pattern) > 0 ):
177+
return True
178+
return False
179+
180+
def prepare_opal_log(self):
181+
self.cv_HOST.host_run_command("cat /sys/firmware/opal/msglog > /tmp/opal_msglog")
182+
183+
def gather_opal_errors(self):
184+
cmd = "cat /sys/firmware/opal/msglog | diff - /tmp/opal_msglog | grep ',[0-4]\]'"
185+
try:
186+
output = self.cv_HOST.host_run_command(cmd)
187+
except CommandFailed as cf:
188+
if cf.exitcode == 1:
189+
print cf.output
190+
191+
class resetReload(fspresetReload):
192+
193+
def runTest(self):
194+
if "FSP" not in self.bmc_type:
195+
self.skipTest("FSP Platform OPAL specific fsp resetreload tests")
196+
self.cv_FSP.fsp_get_console()
197+
if not self.cv_FSP.mount_exists():
198+
raise OpTestError("Please mount NFS and re-try the test")
199+
self.set_up()
200+
self.cv_HOST.host_check_command("nvram","ipmitool","sensors","hwclock")
201+
self.cv_FSP.clear_fsp_errors()
202+
self.cv_SYSTEM.load_ipmi_drivers(True)
203+
for i in range(0, self.number_of_resets()):
204+
print "====================FSP R&R iteration %d=====================" % i
205+
self.prepare_opal_log()
206+
self.trigger_rr()
207+
# Let fsp goes down
208+
time.sleep(10)
209+
self.wait_for_fsp_ping()
210+
time.sleep(10)
211+
self.cv_FSP.fsp_get_console()
212+
self.cv_FSP.wait_for_runtime()
213+
self.check_for_fsp_host_interfaces()
214+
self.cv_FSP.list_all_errorlogs_in_fsp()
215+
self.gather_opal_errors()
216+
217+
class FIR(resetReload):
218+
def set_up(self):
219+
self.test = "fir"
220+
221+
class HIR(resetReload):
222+
def set_up(self):
223+
self.test = "hir"
224+
225+
class FIRTorture(FIR):
226+
def number_of_resets(self):
227+
return 20
228+
229+
class HIRTorture(HIR):
230+
def number_of_resets(self):
231+
return 20
232+
233+
def suite():
234+
s = unittest.TestSuite()
235+
s.addTest(FIR())
236+
s.addTest(HIR())
237+
return s
238+
239+
def torture_suite():
240+
s = unittest.TestSuite()
241+
s.addTest(FIRTorture())
242+
s.addTest(HIRTorture())
243+
return s

0 commit comments

Comments
 (0)