Skip to content

Commit e02d7fc

Browse files
Merge pull request #936 from shirishaganta1/Pstore
OpTestKernelDump.py: Add Pstore verification testcase
2 parents 88623ac + 4d84167 commit e02d7fc

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

testcases/OpTestKernelDump.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,26 @@ def is_fadump_supported(self):
224224
except CommandFailed:
225225
return False
226226

227+
def get_pstore_timestamps(self):
228+
"""
229+
Returns a dict of all files under /sys/fs/pstore with their mtime.
230+
Example:
231+
{
232+
'dmesg-nvram-0': 1708001201,
233+
'rtas-nvram-0': 1708001205
234+
}
235+
"""
236+
ts = {}
237+
cmd = "ls -1 /sys/fs/pstore 2>/dev/null"
238+
files = self.c.run_command(cmd)
239+
for f in files:
240+
f = f.strip()
241+
if not f:
242+
continue
243+
out = self.c.run_command(f"stat -c '%Y' /sys/fs/pstore/{f}")
244+
ts[f] = int(out[0].strip())
245+
return ts
246+
227247
# Verify /ibm,opal/dump node is present int DT or not
228248
def is_mpipl_supported(self):
229249
'''
@@ -1995,6 +2015,26 @@ def runTest(self):
19952015
self.check_wd_overNFS()
19962016
self.check_wd_action_zero()
19972017

2018+
class PstoreCheck(OptestKernelDump):
2019+
def runTest(self):
2020+
conf = OpTestConfiguration.conf
2021+
pre_ts = self.get_pstore_timestamps()
2022+
log.info(f"Pre-crash pstore files: {pre_ts}")
2023+
# Step 3: Trigger crash
2024+
boot_type = self.kernel_crash(crash_type="hmc")
2025+
post_ts = self.get_pstore_timestamps()
2026+
log.info(f"Post-crash pstore files: {post_ts}")
2027+
updated_files = []
2028+
for f, post_time in post_ts.items():
2029+
pre_time = pre_ts.get(f)
2030+
if pre_time is None:
2031+
updated_files.append(f) # new file
2032+
elif post_time > pre_time:
2033+
updated_files.append(f) # existing file updated
2034+
2035+
if not updated_files:
2036+
raise OpTestError("No pstore files were updated after crash")
2037+
log.info(f"Pstore files updated after crash: {updated_files}")
19982038

19992039
def crash_suite():
20002040
s = unittest.TestSuite()
@@ -2032,5 +2072,6 @@ def crash_suite():
20322072
s.addTest(KernelCrash_DisableAll())
20332073
s.addTest(SkirootKernelCrash())
20342074
s.addTest(OPALCrash_MPIPL())
2075+
s.addTest(PstoreCheck())
20352076

20362077
return s

0 commit comments

Comments
 (0)