Skip to content

Commit d338ec7

Browse files
Merge pull request #924 from shirishaganta1/clean-crash-proper
Fix crash folder cleanup issue in OpTestKernelDump.py
2 parents 3d36abb + 682c364 commit d338ec7

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

testcases/OpTestKernelDump.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,10 @@ def verify_dump_file(self, boot_type=BootType.NORMAL, dump_place="local"):
274274
self.crash_content = list(filter(lambda x: re.search('\d{4}-\d{2}-\d{2}-\d{2}-\d{2}', x), self.crash_content))
275275
else:
276276
self.crash_content = list(filter(lambda x: re.search('\d{4}-\d{2}-\d{2}-\d{2}:\d{2}', x), self.crash_content))
277-
if len(self.crash_content):
277+
if not self.crash_content:
278+
raise OpTestError("Dump directory not created")
279+
# We'll use try...finally to guarantee cleanup
280+
try:
278281
if dump_place == "net":
279282
#if user is not root, cannot copy/list vmcore files due to permission issue, because the owner of vmcore dir will be root.
280283
if self.dump_server_user == 'root':
@@ -304,11 +307,10 @@ def verify_dump_file(self, boot_type=BootType.NORMAL, dump_place="local"):
304307
if boot_type == BootType.MPIPL:
305308
self.c.run_command("ls /var/crash/%s/opalcore*" %
306309
self.crash_content[0])
307-
else:
308-
msg = "Dump directory not created"
309-
raise OpTestError(msg)
310-
if self.dump_server_user == 'root':
311-
self.c.run_command("rm -rf /var/crash/%s; sync" % self.crash_content[0])
310+
finally:
311+
if dump_place == "local" and self.dump_server_user == 'root':
312+
log.info("Cleaning up crash directory /var/crash/%s" % self.crash_content[0])
313+
self.c.run_command("rm -rf /var/crash/%s; sync" % self.crash_content[0])
312314

313315
def verify_fadump_reg(self):
314316
'''

0 commit comments

Comments
 (0)