https://github.com/Jlalond updated https://github.com/llvm/llvm-project/pull/108602
>From 41bb7f8a13483e55f677d51e049e3d79d763088b Mon Sep 17 00:00:00 2001 From: Jacob Lalonde <jalalo...@fb.com> Date: Fri, 13 Sep 2024 09:29:46 -0700 Subject: [PATCH 1/2] Add multiplatform minidump determinism test --- .../TestProcessSaveCoreMinidump.py | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidump.py b/lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidump.py index ccdb6653cf16f8..d4eaa40b13f7ee 100644 --- a/lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidump.py +++ b/lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidump.py @@ -522,3 +522,42 @@ def minidump_deleted_on_save_failure(self): finally: self.assertTrue(self.dbg.DeleteTarget(target)) + + def minidump_deterministic_difference(self): + """Test that verifies that two minidumps produced are identical.""" + + self.build() + exe = self.getBuildArtifact("a.out") + try: + target = self.dbg.CreateTarget(exe) + process = target.LaunchSimple( + None, None, self.get_process_working_directory() + ) + self.assertState(process.GetState(), lldb.eStateStopped) + + core_styles = [lldb.eSaveCoreStackOnly, lldb.eSaveCoreDirtyOnly, lldb.eSaveCoreFull] + for style in core_styles: + spec_one = lldb.SBFileSpec(self.getBuildArtifact("core.one.dmp")) + spec_two = lldb.SBFileSpec(self.getBuildArtifact("core.two.dmp")) + options = lldb.SBSaveCoreOptions() + options.SetOutputFile(spec_one) + options.SetPluginName("minidump") + options.SetStyle(style) + error = process.SaveCore(options) + self.assertTrue(error.Success()) + options.SetOutputFile(spec_two) + error = process.SaveCore(options) + self.assertTrue(error.Success()) + + file_one = None + file_two = None + with open(spec_one.GetFileName(), mode='rb') as file: # b is important -> binary + file_one = file.read() + with open(spec_two.GetFileName(), mode='rb') as file: + file_two = file.read() + self.assertEqual(file_one, file_two) + self.assertTrue(os.unlink(spec_one.GetFileName())) + self.assertTrue(os.unlink(spec_two.GetFileName())) + + finally: + self.assertTrue(self.dbg.DeleteTarget(target)) >From b52d9e4b80a35c3f1e58d53b7134b01e5b44bf30 Mon Sep 17 00:00:00 2001 From: Jacob Lalonde <jalalo...@fb.com> Date: Fri, 13 Sep 2024 10:08:51 -0700 Subject: [PATCH 2/2] Comment cleanup --- .../TestProcessSaveCoreMinidump.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidump.py b/lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidump.py index d4eaa40b13f7ee..e994dd75645400 100644 --- a/lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidump.py +++ b/lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidump.py @@ -535,7 +535,11 @@ def minidump_deterministic_difference(self): ) self.assertState(process.GetState(), lldb.eStateStopped) - core_styles = [lldb.eSaveCoreStackOnly, lldb.eSaveCoreDirtyOnly, lldb.eSaveCoreFull] + core_styles = [ + lldb.eSaveCoreStackOnly, + lldb.eSaveCoreDirtyOnly, + lldb.eSaveCoreFull, + ] for style in core_styles: spec_one = lldb.SBFileSpec(self.getBuildArtifact("core.one.dmp")) spec_two = lldb.SBFileSpec(self.getBuildArtifact("core.two.dmp")) @@ -551,9 +555,11 @@ def minidump_deterministic_difference(self): file_one = None file_two = None - with open(spec_one.GetFileName(), mode='rb') as file: # b is important -> binary + with open( + spec_one.GetFileName(), mode="rb" + ) as file: file_one = file.read() - with open(spec_two.GetFileName(), mode='rb') as file: + with open(spec_two.GetFileName(), mode="rb") as file: file_two = file.read() self.assertEqual(file_one, file_two) self.assertTrue(os.unlink(spec_one.GetFileName())) _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits