[Lldb-commits] [lldb] 3265164 - [lldb/test] Try to fix TestSBModule failure

Med Ismail Bennani via lldb-commits lldb-commits at lists.llvm.org
Wed Jan 26 16:00:36 PST 2022


Author: Med Ismail Bennani
Date: 2022-01-27T01:00:29+01:00
New Revision: 326516448c839d8f9cc515b20a34d0f3a6ee2374

URL: https://github.com/llvm/llvm-project/commit/326516448c839d8f9cc515b20a34d0f3a6ee2374
DIFF: https://github.com/llvm/llvm-project/commit/326516448c839d8f9cc515b20a34d0f3a6ee2374.diff

LOG: [lldb/test] Try to fix TestSBModule failure

This should fix https://lab.llvm.org/buildbot/#/builders/68/builds/25571

Signed-off-by: Med Ismail Bennani <medismail.bennani at gmail.com>

Added: 
    

Modified: 
    lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py
    lldb/test/API/python_api/sbmodule/TestSBModule.py

Removed: 
    


################################################################################
diff  --git a/lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py b/lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py
index 0c215f082c5d3..3a9c74bb73c67 100644
--- a/lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py
+++ b/lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py
@@ -19,6 +19,8 @@ def setUp(self):
 
     def tearDown(self):
         TestBase.tearDown(self)
+        if "SKIP_SCRIPTED_PROCESS_LAUNCH" in os.environ:
+          del os.environ["SKIP_SCRIPTED_PROCESS_LAUNCH"]
 
     def test_python_plugin_package(self):
         """Test that the lldb python module has a `plugins.scripted_process`
@@ -53,10 +55,6 @@ def test_invalid_scripted_register_context(self):
         self.assertTrue(os.path.isfile(log_file))
 
         os.environ['SKIP_SCRIPTED_PROCESS_LAUNCH'] = '1'
-        def cleanup():
-          del os.environ["SKIP_SCRIPTED_PROCESS_LAUNCH"]
-        self.addTearDownHook(cleanup)
-
         scripted_process_example_relpath = 'invalid_scripted_process.py'
         self.runCmd("command script import " + os.path.join(self.getSourceDir(),
                                                             scripted_process_example_relpath))
@@ -89,10 +87,6 @@ def test_scripted_process_and_scripted_thread(self):
         self.assertTrue(target, VALID_TARGET)
 
         os.environ['SKIP_SCRIPTED_PROCESS_LAUNCH'] = '1'
-        def cleanup():
-          del os.environ["SKIP_SCRIPTED_PROCESS_LAUNCH"]
-        self.addTearDownHook(cleanup)
-
         scripted_process_example_relpath = 'dummy_scripted_process.py'
         self.runCmd("command script import " + os.path.join(self.getSourceDir(),
                                                             scripted_process_example_relpath))
@@ -160,10 +154,6 @@ def test_launch_scripted_process_stack_frames(self):
         self.assertTrue(error.Success(), "Reloading main module at offset 0 failed.")
 
         os.environ['SKIP_SCRIPTED_PROCESS_LAUNCH'] = '1'
-        def cleanup():
-          del os.environ["SKIP_SCRIPTED_PROCESS_LAUNCH"]
-        self.addTearDownHook(cleanup)
-
         scripted_process_example_relpath = 'stack_core_scripted_process.py'
         self.runCmd("command script import " + os.path.join(self.getSourceDir(),
                                                             scripted_process_example_relpath))

diff  --git a/lldb/test/API/python_api/sbmodule/TestSBModule.py b/lldb/test/API/python_api/sbmodule/TestSBModule.py
index ab6a9a20884a3..e3ab9bcb299f6 100644
--- a/lldb/test/API/python_api/sbmodule/TestSBModule.py
+++ b/lldb/test/API/python_api/sbmodule/TestSBModule.py
@@ -47,12 +47,12 @@ def test_module_is_file_backed(self):
         error = lldb.SBError()
         process = target.AttachToProcessWithID(self.dbg.GetListener(),
                                                self.background_pid, error)
-        self.assertTrue(error.Success() and process,  PROCESS_IS_VALID)
+        self.assertTrue(error.Success(),  PROCESS_IS_VALID)
         main_module = target.GetModuleAtIndex(0)
         self.assertEqual(main_module.GetFileSpec().GetFilename(), "a.out")
         self.assertFalse(main_module.IsFileBacked(),
                          "The module should not be backed by a file on disk.")
 
-        error = process.Destroy()
+        error = process.Detach()
         self.assertTrue(error.Success(), "couldn't destroy process %s" % background_process.pid)
 


        


More information about the lldb-commits mailing list