Skip to content

Commit 4d84167

Browse files
OpTestKernelDump.py: Add Pstore verification testcase
Introduce a new testcase that validates pstore functionality during kdump/fadump. The test checks whether files under /sys/fs/pstore are updated before and after triggering a kernel dump. Signed-off-by: Shirisha G <shirisha@linux.ibm.com>
1 parent 97a7848 commit 4d84167

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
'''
@@ -1987,6 +2007,26 @@ def runTest(self):
19872007
self.check_wd_overNFS()
19882008
self.check_wd_action_zero()
19892009

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

19912031
def crash_suite():
19922032
s = unittest.TestSuite()
@@ -2024,5 +2064,6 @@ def crash_suite():
20242064
s.addTest(KernelCrash_DisableAll())
20252065
s.addTest(SkirootKernelCrash())
20262066
s.addTest(OPALCrash_MPIPL())
2067+
s.addTest(PstoreCheck())
20272068

20282069
return s

0 commit comments

Comments
 (0)