Skip to content

Commit 771be24

Browse files
committed
Add test to ensure file is deleted upon failure
1 parent fe34580 commit 771be24

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidump.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,3 +493,29 @@ def test_save_minidump_custom_save_style_duplicated_regions(self):
493493

494494
finally:
495495
self.assertTrue(self.dbg.DeleteTarget(target))
496+
497+
@skipUnlessPlatform(["linux"])
498+
def minidump_deleted_on_save_failure(self):
499+
"""Test that verifies the minidump file is deleted after an error"""
500+
501+
self.build()
502+
exe = self.getBuildArtifact("a.out")
503+
try:
504+
target = self.dbg.CreateTarget(exe)
505+
process = target.LaunchSimple(
506+
None, None, self.get_process_working_directory()
507+
)
508+
self.assertState(process.GetState(), lldb.eStateStopped)
509+
510+
custom_file = self.getBuildArtifact("core.should.be.deleted.custom.dmp")
511+
options = lldb.SBSaveCoreOptions()
512+
options.SetOutputFile(lldb.SBFileSpec(custom_file))
513+
options.SetPluginName("minidump")
514+
options.SetStyle(lldb.eSaveCoreCustomOnly)
515+
# We set custom only and have no thread list and have no memory.
516+
error = process.SaveCore(options)
517+
self.assertTrue(error.Fail())
518+
self.assertTrue(not os.path.isfile(custom_file))
519+
520+
finally:
521+
self.assertTrue(self.dbg.DeleteTarget(target))

0 commit comments

Comments
 (0)