[Lldb-commits] [PATCH] D66331: Save / restore selected platform in tests that may change it
Jason Molenda via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Thu Aug 15 19:44:40 PDT 2019
jasonmolenda created this revision.
jasonmolenda added a reviewer: labath.
Herald added a subscriber: abidh.
Herald added a project: LLDB.
Running the testsuite against an iOS device, it seems like I can lose the remote platform when certain tests run (and running in single-threaded mode aka no-multiprocess mode). Attached is a patch to use the setUp/tearDown test class methods to save/restore the platform.
I'm not sure if fixing this on a test-by-test basis is the right place for it. It might be better to have dotest.py's run_suite() save the remote platform and lldbtest.py's class Base setUpClass() method re-set the platform before the test is invoked, in case it was mutated during a test run.
Pavel, what do you think about this?
Repository:
rLLDB LLDB
https://reviews.llvm.org/D66331
Files:
packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestWriteMemory.py
packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/TestGCore.py
packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/TestLinuxCoreThreads.py
packages/Python/lldbsuite/test/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py
Index: packages/Python/lldbsuite/test/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py
===================================================================
--- packages/Python/lldbsuite/test/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py
+++ packages/Python/lldbsuite/test/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py
@@ -11,6 +11,14 @@
class TestPlatformProcessConnect(gdbremote_testcase.GdbRemoteTestCaseBase):
mydir = TestBase.compute_mydir(__file__)
+ def setUp(self):
+ super(TestPlatformProcessConnect, self).setUp()
+ self._initial_platform = lldb.DBG.GetSelectedPlatform()
+
+ def tearDown(self):
+ lldb.DBG.SetSelectedPlatform(self._initial_platform)
+ super(TestPlatformProcessConnect, self).tearDown()
+
@llgs_test
@no_debug_info_test
@skipIf(remote=False)
Index: packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/TestLinuxCoreThreads.py
===================================================================
--- packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/TestLinuxCoreThreads.py
+++ packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/TestLinuxCoreThreads.py
@@ -15,8 +15,15 @@
NO_DEBUG_INFO_TESTCASE = True
mydir = TestBase.compute_mydir(__file__)
- _initial_platform = lldb.DBG.GetSelectedPlatform()
+ def setUp(self):
+ super(LinuxCoreThreadsTestCase, self).setUp()
+ self._initial_platform = lldb.DBG.GetSelectedPlatform()
+
+ def tearDown(self):
+ lldb.DBG.SetSelectedPlatform(self._initial_platform)
+ super(LinuxCoreThreadsTestCase, self).tearDown()
+
_i386_pid = 5193
_x86_64_pid = 5222
@@ -56,4 +63,3 @@
self.assertEqual(signal, 0)
self.dbg.DeleteTarget(target)
- lldb.DBG.SetSelectedPlatform(self._initial_platform)
Index: packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/TestGCore.py
===================================================================
--- packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/TestGCore.py
+++ packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/TestGCore.py
@@ -15,8 +15,14 @@
NO_DEBUG_INFO_TESTCASE = True
mydir = TestBase.compute_mydir(__file__)
- _initial_platform = lldb.DBG.GetSelectedPlatform()
+ def setUp(self):
+ super(GCoreTestCase, self).setUp()
+ self._initial_platform = lldb.DBG.GetSelectedPlatform()
+ def tearDown(self):
+ lldb.DBG.SetSelectedPlatform(self._initial_platform)
+ super(GCoreTestCase, self).tearDown()
+
_i386_pid = 5586
_x86_64_pid = 5669
@@ -47,4 +53,3 @@
self.assertEqual(signal, 19)
self.dbg.DeleteTarget(target)
- lldb.DBG.SetSelectedPlatform(self._initial_platform)
Index: packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestWriteMemory.py
===================================================================
--- packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestWriteMemory.py
+++ packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestWriteMemory.py
@@ -13,6 +13,14 @@
def setBreakpoint(self, packet):
return "OK"
+ def setUp(self):
+ super(TestWriteMemory, self).setUp()
+ self._initial_platform = lldb.DBG.GetSelectedPlatform()
+
+ def tearDown(self):
+ lldb.DBG.SetSelectedPlatform(self._initial_platform)
+ super(TestWriteMemory, self).tearDown()
+
self.server.responder = MyResponder()
target = self.dbg.CreateTargetWithFileAndTargetTriple('', 'x86_64-pc-linux')
process = self.connect(target)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66331.215529.patch
Type: text/x-patch
Size: 3818 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190816/2d1d02d0/attachment.bin>
More information about the lldb-commits
mailing list