labath created this revision. labath added reviewers: JDevlieghere, mgorny. Herald added subscribers: kbarton, sbc100, nemanjai. labath requested review of this revision. Herald added a subscriber: aheejin. Herald added a project: LLDB.
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. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D113893 Files: lldb/packages/Python/lldbsuite/test/gdbclientutils.py lldb/packages/Python/lldbsuite/test/lldbgdbclient.py lldb/test/API/functionalities/gdb_remote_client/TestAArch64XMLRegOffsets.py lldb/test/API/functionalities/gdb_remote_client/TestArmRegisterDefinition.py lldb/test/API/functionalities/gdb_remote_client/TestFork.py lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteDiskFileCompletion.py lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteLoad.py lldb/test/API/functionalities/gdb_remote_client/TestGDBRemotePlatformFile.py lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py lldb/test/API/functionalities/gdb_remote_client/TestIOSSimulator.py lldb/test/API/functionalities/gdb_remote_client/TestJLink6Armv7RegisterDefinition.py lldb/test/API/functionalities/gdb_remote_client/TestMemoryRegionDirtyPages.py lldb/test/API/functionalities/gdb_remote_client/TestMultiprocess.py lldb/test/API/functionalities/gdb_remote_client/TestNestedRegDefinitions.py lldb/test/API/functionalities/gdb_remote_client/TestNoGPacketSupported.py lldb/test/API/functionalities/gdb_remote_client/TestNoWatchpointSupportInfo.py lldb/test/API/functionalities/gdb_remote_client/TestPartialGPacket.py lldb/test/API/functionalities/gdb_remote_client/TestPlatformClient.py lldb/test/API/functionalities/gdb_remote_client/TestPlatformKill.py lldb/test/API/functionalities/gdb_remote_client/TestProcessConnect.py lldb/test/API/functionalities/gdb_remote_client/TestPty.py lldb/test/API/functionalities/gdb_remote_client/TestQemuAArch64TargetXml.py lldb/test/API/functionalities/gdb_remote_client/TestRecognizeBreakpoint.py lldb/test/API/functionalities/gdb_remote_client/TestRegDefinitionInParts.py lldb/test/API/functionalities/gdb_remote_client/TestRemoteRegNums.py lldb/test/API/functionalities/gdb_remote_client/TestRestartBug.py lldb/test/API/functionalities/gdb_remote_client/TestStopPCs.py lldb/test/API/functionalities/gdb_remote_client/TestTargetXMLArch.py lldb/test/API/functionalities/gdb_remote_client/TestThreadInfoTrailingComma.py lldb/test/API/functionalities/gdb_remote_client/TestThreadSelectionBug.py lldb/test/API/functionalities/gdb_remote_client/TestWasm.py lldb/test/API/functionalities/gdb_remote_client/TestWriteMemory.py lldb/test/API/functionalities/gdb_remote_client/TestqOffsets.py lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py
Index: lldb/test/API/functionalities/gdb_remote_client/TestqOffsets.py =================================================================== --- lldb/test/API/functionalities/gdb_remote_client/TestqOffsets.py +++ lldb/test/API/functionalities/gdb_remote_client/TestqOffsets.py @@ -1,11 +1,13 @@ import lldb from lldbsuite.test.lldbtest import * from lldbsuite.test.decorators import * -from gdbclientutils import * - +from lldbsuite.test.gdbclientutils import * +from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase class TestqOffsets(GDBRemoteTestBase): + mydir = TestBase.compute_mydir(__file__) + class Responder(MockGDBServerResponder): def qOffsets(self): return 'Text=470000;Data=470000' Index: lldb/test/API/functionalities/gdb_remote_client/TestWriteMemory.py =================================================================== --- lldb/test/API/functionalities/gdb_remote_client/TestWriteMemory.py +++ lldb/test/API/functionalities/gdb_remote_client/TestWriteMemory.py @@ -1,11 +1,13 @@ import lldb from lldbsuite.test.lldbtest import * from lldbsuite.test.decorators import * -from gdbclientutils import * - +from lldbsuite.test.gdbclientutils import * +from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase class TestWriteMemory(GDBRemoteTestBase): + mydir = TestBase.compute_mydir(__file__) + def test(self): class MyResponder(MockGDBServerResponder): Index: lldb/test/API/functionalities/gdb_remote_client/TestWasm.py =================================================================== --- lldb/test/API/functionalities/gdb_remote_client/TestWasm.py +++ lldb/test/API/functionalities/gdb_remote_client/TestWasm.py @@ -2,7 +2,8 @@ import binascii from lldbsuite.test.lldbtest import * from lldbsuite.test.decorators import * -from gdbclientutils import * +from lldbsuite.test.gdbclientutils import * +from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase LLDB_INVALID_ADDRESS = lldb.LLDB_INVALID_ADDRESS load_address = 0x400000000 @@ -86,6 +87,8 @@ class TestWasm(GDBRemoteTestBase): + mydir = TestBase.compute_mydir(__file__) + @skipIfAsan @skipIfXmlSupportMissing def test_load_module_with_embedded_symbols_from_remote(self): Index: lldb/test/API/functionalities/gdb_remote_client/TestThreadSelectionBug.py =================================================================== --- lldb/test/API/functionalities/gdb_remote_client/TestThreadSelectionBug.py +++ lldb/test/API/functionalities/gdb_remote_client/TestThreadSelectionBug.py @@ -1,10 +1,14 @@ import lldb from lldbsuite.test.lldbtest import * from lldbsuite.test.decorators import * -from gdbclientutils 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): Index: lldb/test/API/functionalities/gdb_remote_client/TestThreadInfoTrailingComma.py =================================================================== --- lldb/test/API/functionalities/gdb_remote_client/TestThreadInfoTrailingComma.py +++ lldb/test/API/functionalities/gdb_remote_client/TestThreadInfoTrailingComma.py @@ -1,11 +1,13 @@ import lldb from lldbsuite.test.lldbtest import * from lldbsuite.test.decorators import * -from gdbclientutils import * - +from lldbsuite.test.gdbclientutils import * +from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase class TestThreadInfoTrailingComma(GDBRemoteTestBase): + mydir = TestBase.compute_mydir(__file__) + def test(self): class MyResponder(MockGDBServerResponder): def haltReason(self): Index: lldb/test/API/functionalities/gdb_remote_client/TestTargetXMLArch.py =================================================================== --- lldb/test/API/functionalities/gdb_remote_client/TestTargetXMLArch.py +++ lldb/test/API/functionalities/gdb_remote_client/TestTargetXMLArch.py @@ -2,7 +2,8 @@ import lldb from lldbsuite.test.lldbtest import * from lldbsuite.test.decorators import * -from gdbclientutils import * +from lldbsuite.test.gdbclientutils import * +from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase class MyResponder(MockGDBServerResponder): def qXferRead(self, obj, annex, offset, length): @@ -101,6 +102,8 @@ class TestTargetXMLArch(GDBRemoteTestBase): + mydir = TestBase.compute_mydir(__file__) + @skipIfXmlSupportMissing @expectedFailureAll(archs=["i386"]) @skipIfRemote Index: lldb/test/API/functionalities/gdb_remote_client/TestStopPCs.py =================================================================== --- lldb/test/API/functionalities/gdb_remote_client/TestStopPCs.py +++ lldb/test/API/functionalities/gdb_remote_client/TestStopPCs.py @@ -1,11 +1,14 @@ import lldb from lldbsuite.test.lldbtest import * from lldbsuite.test.decorators import * -from gdbclientutils import * +from lldbsuite.test.gdbclientutils import * +from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase class TestStopPCs(GDBRemoteTestBase): + mydir = TestBase.compute_mydir(__file__) + @skipIfXmlSupportMissing def test(self): class MyResponder(MockGDBServerResponder): Index: lldb/test/API/functionalities/gdb_remote_client/TestRestartBug.py =================================================================== --- lldb/test/API/functionalities/gdb_remote_client/TestRestartBug.py +++ lldb/test/API/functionalities/gdb_remote_client/TestRestartBug.py @@ -2,11 +2,14 @@ import lldb from lldbsuite.test.lldbtest import * from lldbsuite.test.decorators import * -from gdbclientutils import * +from lldbsuite.test.gdbclientutils import * +from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase class TestRestartBug(GDBRemoteTestBase): + mydir = TestBase.compute_mydir(__file__) + @expectedFailureAll(bugnumber="llvm.org/pr24530") def test(self): """ Index: lldb/test/API/functionalities/gdb_remote_client/TestRemoteRegNums.py =================================================================== --- lldb/test/API/functionalities/gdb_remote_client/TestRemoteRegNums.py +++ lldb/test/API/functionalities/gdb_remote_client/TestRemoteRegNums.py @@ -2,7 +2,8 @@ import lldb from lldbsuite.test.lldbtest import * from lldbsuite.test.decorators import * -from gdbclientutils import * +from lldbsuite.test.gdbclientutils import * +from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase # This test case checks for register number mismatch between lldb and gdb stub. @@ -16,6 +17,8 @@ class TestRemoteRegNums(GDBRemoteTestBase): + mydir = TestBase.compute_mydir(__file__) + @skipIfXmlSupportMissing def test(self): class MyResponder(MockGDBServerResponder): Index: lldb/test/API/functionalities/gdb_remote_client/TestRegDefinitionInParts.py =================================================================== --- lldb/test/API/functionalities/gdb_remote_client/TestRegDefinitionInParts.py +++ lldb/test/API/functionalities/gdb_remote_client/TestRegDefinitionInParts.py @@ -3,10 +3,13 @@ import time from lldbsuite.test.lldbtest import * from lldbsuite.test.decorators import * -from gdbclientutils import * +from lldbsuite.test.gdbclientutils import * +from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase class TestRegDefinitionInParts(GDBRemoteTestBase): + mydir = TestBase.compute_mydir(__file__) + @skipIfXmlSupportMissing @skipIfRemote def test(self): Index: lldb/test/API/functionalities/gdb_remote_client/TestRecognizeBreakpoint.py =================================================================== --- lldb/test/API/functionalities/gdb_remote_client/TestRecognizeBreakpoint.py +++ lldb/test/API/functionalities/gdb_remote_client/TestRecognizeBreakpoint.py @@ -1,10 +1,14 @@ import lldb from lldbsuite.test.lldbtest import * from lldbsuite.test.decorators import * -from gdbclientutils import * +from lldbsuite.test.gdbclientutils import * +from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase class TestRecognizeBreakpoint(GDBRemoteTestBase): + + mydir = TestBase.compute_mydir(__file__) + """ This tests the case where the gdb-remote server doesn't support any of the thread-info packets, and just tells which thread got the stop signal with: Index: lldb/test/API/functionalities/gdb_remote_client/TestQemuAArch64TargetXml.py =================================================================== --- lldb/test/API/functionalities/gdb_remote_client/TestQemuAArch64TargetXml.py +++ lldb/test/API/functionalities/gdb_remote_client/TestQemuAArch64TargetXml.py @@ -1,7 +1,8 @@ from lldbsuite.test.lldbtest import * from lldbsuite.test.decorators import * -from gdbclientutils import * +from lldbsuite.test.gdbclientutils import * from textwrap import dedent +from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase class MyResponder(MockGDBServerResponder): def qXferRead(self, obj, annex, offset, length): @@ -52,6 +53,8 @@ class TestQemuAarch64TargetXml(GDBRemoteTestBase): + mydir = TestBase.compute_mydir(__file__) + @skipIfXmlSupportMissing @skipIfRemote @skipIfLLVMTargetMissing("AArch64") Index: lldb/test/API/functionalities/gdb_remote_client/TestPty.py =================================================================== --- lldb/test/API/functionalities/gdb_remote_client/TestPty.py +++ lldb/test/API/functionalities/gdb_remote_client/TestPty.py @@ -1,7 +1,8 @@ import lldb from lldbsuite.test.lldbtest import * from lldbsuite.test.decorators import * -from gdbclientutils import * +from lldbsuite.test.gdbclientutils import * +from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase @skipIfWindows Index: lldb/test/API/functionalities/gdb_remote_client/TestProcessConnect.py =================================================================== --- lldb/test/API/functionalities/gdb_remote_client/TestProcessConnect.py +++ lldb/test/API/functionalities/gdb_remote_client/TestProcessConnect.py @@ -3,12 +3,15 @@ import os from lldbsuite.test.lldbtest import * from lldbsuite.test.decorators import * -from gdbclientutils import * +from lldbsuite.test.gdbclientutils import * +from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase @skipIfRemote class TestProcessConnect(GDBRemoteTestBase): + mydir = TestBase.compute_mydir(__file__) + NO_DEBUG_INFO_TESTCASE = True def test_gdb_remote_sync(self): Index: lldb/test/API/functionalities/gdb_remote_client/TestPlatformKill.py =================================================================== --- lldb/test/API/functionalities/gdb_remote_client/TestPlatformKill.py +++ lldb/test/API/functionalities/gdb_remote_client/TestPlatformKill.py @@ -2,10 +2,13 @@ import time from lldbsuite.test.lldbtest import * from lldbsuite.test.decorators import * -from gdbclientutils import * +from lldbsuite.test.gdbclientutils import * +from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase class TestPlatformKill(GDBRemoteTestBase): + mydir = TestBase.compute_mydir(__file__) + @skipIfRemote @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr52451") def test_kill_different_platform(self): Index: lldb/test/API/functionalities/gdb_remote_client/TestPlatformClient.py =================================================================== --- lldb/test/API/functionalities/gdb_remote_client/TestPlatformClient.py +++ lldb/test/API/functionalities/gdb_remote_client/TestPlatformClient.py @@ -4,13 +4,16 @@ import time from lldbsuite.test.lldbtest import * from lldbsuite.test.decorators import * -from gdbclientutils import * +from lldbsuite.test.gdbclientutils import * +from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase def hexlify(string): return binascii.hexlify(string.encode()).decode() class TestPlatformClient(GDBRemoteTestBase): + mydir = TestBase.compute_mydir(__file__) + def test_process_list_with_all_users(self): """Test connecting to a remote linux platform""" Index: lldb/test/API/functionalities/gdb_remote_client/TestPartialGPacket.py =================================================================== --- lldb/test/API/functionalities/gdb_remote_client/TestPartialGPacket.py +++ lldb/test/API/functionalities/gdb_remote_client/TestPartialGPacket.py @@ -2,11 +2,14 @@ import lldb from lldbsuite.test.lldbtest import * from lldbsuite.test.decorators import * -from gdbclientutils import * +from lldbsuite.test.gdbclientutils import * +from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase class TestPartialGPacket(GDBRemoteTestBase): + mydir = TestBase.compute_mydir(__file__) + @skipIfXmlSupportMissing @skipIfRemote def test(self): Index: lldb/test/API/functionalities/gdb_remote_client/TestNoWatchpointSupportInfo.py =================================================================== --- lldb/test/API/functionalities/gdb_remote_client/TestNoWatchpointSupportInfo.py +++ lldb/test/API/functionalities/gdb_remote_client/TestNoWatchpointSupportInfo.py @@ -2,10 +2,13 @@ import lldb from lldbsuite.test.lldbtest import * from lldbsuite.test.decorators import * -from gdbclientutils import * +from lldbsuite.test.gdbclientutils import * +from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase class TestNoWatchpointSupportInfo(GDBRemoteTestBase): + mydir = TestBase.compute_mydir(__file__) + @skipIfXmlSupportMissing @skipIfRemote def test(self): Index: lldb/test/API/functionalities/gdb_remote_client/TestNoGPacketSupported.py =================================================================== --- lldb/test/API/functionalities/gdb_remote_client/TestNoGPacketSupported.py +++ lldb/test/API/functionalities/gdb_remote_client/TestNoGPacketSupported.py @@ -2,7 +2,8 @@ import lldb from lldbsuite.test.lldbtest import * from lldbsuite.test.decorators import * -from gdbclientutils import * +from lldbsuite.test.gdbclientutils import * +from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase # This test case is testing three things: @@ -22,6 +23,8 @@ class TestNoGPacketSupported(GDBRemoteTestBase): + mydir = TestBase.compute_mydir(__file__) + @skipIfXmlSupportMissing def test(self): class MyResponder(MockGDBServerResponder): Index: lldb/test/API/functionalities/gdb_remote_client/TestNestedRegDefinitions.py =================================================================== --- lldb/test/API/functionalities/gdb_remote_client/TestNestedRegDefinitions.py +++ lldb/test/API/functionalities/gdb_remote_client/TestNestedRegDefinitions.py @@ -2,10 +2,13 @@ import lldb from lldbsuite.test.lldbtest import * from lldbsuite.test.decorators import * -from gdbclientutils import * +from lldbsuite.test.gdbclientutils import * +from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase class TestNestedRegDefinitions(GDBRemoteTestBase): + mydir = TestBase.compute_mydir(__file__) + @skipIfXmlSupportMissing @skipIfRemote def test(self): Index: lldb/test/API/functionalities/gdb_remote_client/TestMultiprocess.py =================================================================== --- lldb/test/API/functionalities/gdb_remote_client/TestMultiprocess.py +++ lldb/test/API/functionalities/gdb_remote_client/TestMultiprocess.py @@ -3,10 +3,14 @@ import unittest from lldbsuite.test.lldbtest import * from lldbsuite.test.decorators import * -from gdbclientutils import * +from lldbsuite.test.gdbclientutils import * +from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase class TestMultiprocess(GDBRemoteTestBase): + + mydir = TestBase.compute_mydir(__file__) + def test_qfThreadInfo(self): class MyResponder(MockGDBServerResponder): def qfThreadInfo(self): Index: lldb/test/API/functionalities/gdb_remote_client/TestMemoryRegionDirtyPages.py =================================================================== --- lldb/test/API/functionalities/gdb_remote_client/TestMemoryRegionDirtyPages.py +++ lldb/test/API/functionalities/gdb_remote_client/TestMemoryRegionDirtyPages.py @@ -1,11 +1,14 @@ import lldb from lldbsuite.test.lldbtest import * from lldbsuite.test.decorators import * -from gdbclientutils import * +from lldbsuite.test.gdbclientutils import * +from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase class TestMemoryRegionDirtyPages(GDBRemoteTestBase): + mydir = TestBase.compute_mydir(__file__) + @skipIfXmlSupportMissing def test(self): class MyResponder(MockGDBServerResponder): Index: lldb/test/API/functionalities/gdb_remote_client/TestJLink6Armv7RegisterDefinition.py =================================================================== --- lldb/test/API/functionalities/gdb_remote_client/TestJLink6Armv7RegisterDefinition.py +++ lldb/test/API/functionalities/gdb_remote_client/TestJLink6Armv7RegisterDefinition.py @@ -2,10 +2,13 @@ import lldb from lldbsuite.test.lldbtest import * from lldbsuite.test.decorators import * -from gdbclientutils import * +from lldbsuite.test.gdbclientutils import * +from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase class TestJLink6Armv7RegisterDefinition(GDBRemoteTestBase): + mydir = TestBase.compute_mydir(__file__) + @skipIfXmlSupportMissing @skipIfRemote def test(self): Index: lldb/test/API/functionalities/gdb_remote_client/TestIOSSimulator.py =================================================================== --- lldb/test/API/functionalities/gdb_remote_client/TestIOSSimulator.py +++ lldb/test/API/functionalities/gdb_remote_client/TestIOSSimulator.py @@ -1,9 +1,13 @@ import lldb from lldbsuite.test.lldbtest import * from lldbsuite.test.decorators import * -from gdbclientutils import * +from lldbsuite.test.gdbclientutils import * +from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase class TestIOSSimulator(GDBRemoteTestBase): + + mydir = TestBase.compute_mydir(__file__) + """ Test that an ios simulator process is recognized as such. """ Index: lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py =================================================================== --- lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py +++ lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py @@ -2,10 +2,14 @@ import lldb from lldbsuite.test.lldbtest import * from lldbsuite.test.decorators import * -from gdbclientutils import * +from lldbsuite.test.gdbclientutils import * +from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase class TestGDBServerTargetXML(GDBRemoteTestBase): + + mydir = TestBase.compute_mydir(__file__) + @skipIfXmlSupportMissing @skipIfRemote @skipIfLLVMTargetMissing("X86") Index: lldb/test/API/functionalities/gdb_remote_client/TestGDBRemotePlatformFile.py =================================================================== --- lldb/test/API/functionalities/gdb_remote_client/TestGDBRemotePlatformFile.py +++ lldb/test/API/functionalities/gdb_remote_client/TestGDBRemotePlatformFile.py @@ -1,9 +1,11 @@ -from gdbclientutils import * - +from lldbsuite.test.gdbclientutils import * from lldbsuite.test.decorators import * +from lldbsuite.test.lldbgdbclient import GDBPlatformClientTestBase class TestGDBRemotePlatformFile(GDBPlatformClientTestBase): + mydir = GDBPlatformClientTestBase.compute_mydir(__file__) + def test_file(self): """Test mock operations on a remote file""" Index: lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteLoad.py =================================================================== --- lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteLoad.py +++ lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteLoad.py @@ -1,11 +1,14 @@ import lldb from lldbsuite.test.lldbtest import * from lldbsuite.test.decorators import * -from gdbclientutils import * +from lldbsuite.test.gdbclientutils import * +from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase class TestGDBRemoteLoad(GDBRemoteTestBase): + mydir = TestBase.compute_mydir(__file__) + @expectedFailureAll(archs=["aarch64"], oslist=["freebsd"], bugnumber="llvm.org/pr49414") def test_module_load_address(self): Index: lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteDiskFileCompletion.py =================================================================== --- lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteDiskFileCompletion.py +++ lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteDiskFileCompletion.py @@ -1,7 +1,10 @@ -from gdbclientutils import * +from lldbsuite.test.gdbclientutils import * +from lldbsuite.test.lldbgdbclient import GDBPlatformClientTestBase class TestGDBRemoteDiskFileCompletion(GDBPlatformClientTestBase): + mydir = GDBPlatformClientTestBase.compute_mydir(__file__) + def test_autocomplete_request(self): """Test remote disk completion on remote-gdb-server plugin""" Index: lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py =================================================================== --- lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py +++ lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py @@ -3,11 +3,14 @@ import os.path from lldbsuite.test.lldbtest import * from lldbsuite.test.decorators import * -from gdbclientutils import * +from lldbsuite.test.gdbclientutils import * +from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase class TestGDBRemoteClient(GDBRemoteTestBase): + mydir = TestBase.compute_mydir(__file__) + class gPacketResponder(MockGDBServerResponder): registers = [ "name:rax;bitsize:64;offset:0;encoding:uint;format:hex;set:General Purpose Registers;ehframe:0;dwarf:0;", Index: lldb/test/API/functionalities/gdb_remote_client/TestFork.py =================================================================== --- lldb/test/API/functionalities/gdb_remote_client/TestFork.py +++ lldb/test/API/functionalities/gdb_remote_client/TestFork.py @@ -3,10 +3,14 @@ import unittest from lldbsuite.test.lldbtest import * from lldbsuite.test.decorators import * -from gdbclientutils import * +from lldbsuite.test.gdbclientutils import * +from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase class TestMultiprocess(GDBRemoteTestBase): + + mydir = TestBase.compute_mydir(__file__) + def base_test(self, variant): class MyResponder(MockGDBServerResponder): def __init__(self): Index: lldb/test/API/functionalities/gdb_remote_client/TestArmRegisterDefinition.py =================================================================== --- lldb/test/API/functionalities/gdb_remote_client/TestArmRegisterDefinition.py +++ lldb/test/API/functionalities/gdb_remote_client/TestArmRegisterDefinition.py @@ -2,10 +2,13 @@ import lldb from lldbsuite.test.lldbtest import * from lldbsuite.test.decorators import * -from gdbclientutils import * +from lldbsuite.test.gdbclientutils import * +from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase class TestArmRegisterDefinition(GDBRemoteTestBase): + mydir = TestBase.compute_mydir(__file__) + @skipIfXmlSupportMissing @skipIfRemote def test(self): Index: lldb/test/API/functionalities/gdb_remote_client/TestAArch64XMLRegOffsets.py =================================================================== --- lldb/test/API/functionalities/gdb_remote_client/TestAArch64XMLRegOffsets.py +++ lldb/test/API/functionalities/gdb_remote_client/TestAArch64XMLRegOffsets.py @@ -3,7 +3,8 @@ import lldb from lldbsuite.test.lldbtest import * from lldbsuite.test.decorators import * -from gdbclientutils import * +from lldbsuite.test.gdbclientutils import * +from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase class MyResponder(MockGDBServerResponder): @@ -92,6 +93,8 @@ class TestAArch64XMLRegOffsets(GDBRemoteTestBase): + mydir = TestBase.compute_mydir(__file__) + @skipIfXmlSupportMissing @skipIfRemote @skipIfLLVMTargetMissing("AArch64") Index: lldb/packages/Python/lldbsuite/test/lldbgdbclient.py =================================================================== --- /dev/null +++ lldb/packages/Python/lldbsuite/test/lldbgdbclient.py @@ -0,0 +1,101 @@ +import os +import os.path +import lldb +from lldbsuite.test.lldbtest import * +from lldbsuite.test.gdbclientutils import * + +class GDBRemoteTestBase(TestBase): + """ + Base class for GDB client tests. + + This class will setup and start a mock GDB server for the test to use. + It also provides assertPacketLogContains, which simplifies the checking + of packets sent by the client. + """ + + NO_DEBUG_INFO_TESTCASE = True + server = None + server_socket_class = TCPServerSocket + + def setUp(self): + TestBase.setUp(self) + self.server = MockGDBServer(socket_class=self.server_socket_class) + self.server.start() + + def tearDown(self): + # TestBase.tearDown will kill the process, but we need to kill it early + # so its client connection closes and we can stop the server before + # finally calling the base tearDown. + if self.process() is not None: + self.process().Kill() + self.server.stop() + TestBase.tearDown(self) + + def createTarget(self, yaml_path): + """ + Create a target by auto-generating the object based on the given yaml + instructions. + + This will track the generated object so it can be automatically removed + during tearDown. + """ + yaml_base, ext = os.path.splitext(yaml_path) + obj_path = self.getBuildArtifact(yaml_base) + self.yaml2obj(yaml_path, obj_path) + return self.dbg.CreateTarget(obj_path) + + def connect(self, target): + """ + Create a process by connecting to the mock GDB server. + + Includes assertions that the process was successfully created. + """ + listener = self.dbg.GetListener() + error = lldb.SBError() + process = target.ConnectRemote(listener, + self.server.get_connect_url(), "gdb-remote", error) + self.assertTrue(error.Success(), error.description) + self.assertTrue(process, PROCESS_IS_VALID) + return process + + def assertPacketLogContains(self, packets): + """ + Assert that the mock server's packet log contains the given packets. + + The packet log includes all packets sent by the client and received + by the server. This fuction makes it easy to verify that the client + sent the expected packets to the server. + + The check does not require that the packets be consecutive, but does + require that they are ordered in the log as they ordered in the arg. + """ + i = 0 + j = 0 + log = self.server.responder.packetLog + + while i < len(packets) and j < len(log): + if log[j] == packets[i]: + i += 1 + j += 1 + if i < len(packets): + self.fail(u"Did not receive: %s\nLast 10 packets:\n\t%s" % + (packets[i], u'\n\t'.join(log))) + + +class GDBPlatformClientTestBase(GDBRemoteTestBase): + """ + Base class for platform server clients. + + This class extends GDBRemoteTestBase by automatically connecting + via "platform connect" in the setUp() method. + """ + + def setUp(self): + super().setUp() + self.runCmd("platform select remote-gdb-server") + self.runCmd("platform connect " + self.server.get_connect_url()) + self.assertTrue(self.dbg.GetSelectedPlatform().IsConnected()) + + def tearDown(self): + self.dbg.GetSelectedPlatform().DisconnectRemote() + super().tearDown() Index: lldb/packages/Python/lldbsuite/test/gdbclientutils.py =================================================================== --- lldb/packages/Python/lldbsuite/test/gdbclientutils.py +++ lldb/packages/Python/lldbsuite/test/gdbclientutils.py @@ -1,17 +1,10 @@ import ctypes import errno import io -import os -import os.path import threading import socket -import lldb -import binascii import traceback from lldbsuite.support import seven -from lldbsuite.test.lldbtest import * -from lldbsuite.test import lldbtest_config - def checksum(message): """ @@ -618,100 +611,3 @@ class InvalidPacketException(Exception): pass - -class GDBRemoteTestBase(TestBase): - """ - Base class for GDB client tests. - - This class will setup and start a mock GDB server for the test to use. - It also provides assertPacketLogContains, which simplifies the checking - of packets sent by the client. - """ - - NO_DEBUG_INFO_TESTCASE = True - mydir = TestBase.compute_mydir(__file__) - server = None - server_socket_class = TCPServerSocket - - def setUp(self): - TestBase.setUp(self) - self.server = MockGDBServer(socket_class=self.server_socket_class) - self.server.start() - - def tearDown(self): - # TestBase.tearDown will kill the process, but we need to kill it early - # so its client connection closes and we can stop the server before - # finally calling the base tearDown. - if self.process() is not None: - self.process().Kill() - self.server.stop() - TestBase.tearDown(self) - - def createTarget(self, yaml_path): - """ - Create a target by auto-generating the object based on the given yaml - instructions. - - This will track the generated object so it can be automatically removed - during tearDown. - """ - yaml_base, ext = os.path.splitext(yaml_path) - obj_path = self.getBuildArtifact(yaml_base) - self.yaml2obj(yaml_path, obj_path) - return self.dbg.CreateTarget(obj_path) - - def connect(self, target): - """ - Create a process by connecting to the mock GDB server. - - Includes assertions that the process was successfully created. - """ - listener = self.dbg.GetListener() - error = lldb.SBError() - process = target.ConnectRemote(listener, - self.server.get_connect_url(), "gdb-remote", error) - self.assertTrue(error.Success(), error.description) - self.assertTrue(process, PROCESS_IS_VALID) - return process - - def assertPacketLogContains(self, packets): - """ - Assert that the mock server's packet log contains the given packets. - - The packet log includes all packets sent by the client and received - by the server. This fuction makes it easy to verify that the client - sent the expected packets to the server. - - The check does not require that the packets be consecutive, but does - require that they are ordered in the log as they ordered in the arg. - """ - i = 0 - j = 0 - log = self.server.responder.packetLog - - while i < len(packets) and j < len(log): - if log[j] == packets[i]: - i += 1 - j += 1 - if i < len(packets): - self.fail(u"Did not receive: %s\nLast 10 packets:\n\t%s" % - (packets[i], u'\n\t'.join(log))) - - -class GDBPlatformClientTestBase(GDBRemoteTestBase): - """ - Base class for platform server clients. - - This class extends GDBRemoteTestBase by automatically connecting - via "platform connect" in the setUp() method. - """ - - def setUp(self): - super().setUp() - self.runCmd("platform select remote-gdb-server") - self.runCmd("platform connect " + self.server.get_connect_url()) - self.assertTrue(self.dbg.GetSelectedPlatform().IsConnected()) - - def tearDown(self): - self.dbg.GetSelectedPlatform().DisconnectRemote() - super().tearDown()
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits