This infrastructure has proven proven its worth, so give it a more prominent place. My immediate motivation for this is the desire to reuse this infrastructure for qemu platform testing, but I believe this move makes sense independently of that. Moving this code to the packages tree will allow as to add more structure to the gdb client tests -- currently they are all crammed into the same test folder as that was the only way they could access this code. I'm splitting the code into two parts while moving it. The first once contains just the generic gdb protocol wrappers, while the other one contains the unit test glue. The reason for that is that for qemu testing, I need to run the gdb code in a separate process, so I will only be using the first part there. Differential Revision: https://reviews.llvm.org/D113893
54 lines
2.1 KiB
Python
54 lines
2.1 KiB
Python
import lldb
|
|
from lldbsuite.test.lldbtest import *
|
|
from lldbsuite.test.decorators import *
|
|
from lldbsuite.test.gdbclientutils import *
|
|
from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase
|
|
|
|
|
|
class TestThreadSelectionBug(GDBRemoteTestBase):
|
|
|
|
mydir = TestBase.compute_mydir(__file__)
|
|
|
|
def test(self):
|
|
class MyResponder(MockGDBServerResponder):
|
|
def cont(self):
|
|
# Simulate process stopping due to a raise(SIGINT)
|
|
return "T01reason:signal"
|
|
|
|
self.server.responder = MyResponder()
|
|
target = self.createTarget("a.yaml")
|
|
process = self.connect(target)
|
|
python_os_plugin_path = os.path.join(self.getSourceDir(),
|
|
'operating_system.py')
|
|
command = "settings set target.process.python-os-plugin-path '{}'".format(
|
|
python_os_plugin_path)
|
|
self.dbg.HandleCommand(command)
|
|
|
|
self.assertTrue(process, PROCESS_IS_VALID)
|
|
self.assertEqual(process.GetNumThreads(), 3)
|
|
|
|
# Verify our OS plug-in threads showed up
|
|
thread = process.GetThreadByID(0x1)
|
|
self.assertTrue(
|
|
thread.IsValid(),
|
|
"Make sure there is a thread 0x1 after we load the python OS plug-in")
|
|
thread = process.GetThreadByID(0x2)
|
|
self.assertTrue(
|
|
thread.IsValid(),
|
|
"Make sure there is a thread 0x2 after we load the python OS plug-in")
|
|
thread = process.GetThreadByID(0x3)
|
|
self.assertTrue(
|
|
thread.IsValid(),
|
|
"Make sure there is a thread 0x3 after we load the python OS plug-in")
|
|
|
|
# Verify that a thread other than 3 is selected.
|
|
thread = process.GetSelectedThread()
|
|
self.assertNotEqual(thread.GetThreadID(), 0x3)
|
|
|
|
# Verify that we select the thread backed by physical thread 1, rather
|
|
# than virtual thread 1. The mapping comes from the OS plugin, where we
|
|
# specified that thread 3 is backed by real thread 1.
|
|
process.Continue()
|
|
thread = process.GetSelectedThread()
|
|
self.assertEqual(thread.GetThreadID(), 0x3)
|