mgorny updated this revision to Diff 371844. mgorny added a comment. Sorry about missing that. Done now.
CHANGES SINCE LAST ACTION https://reviews.llvm.org/D109585/new/ https://reviews.llvm.org/D109585 Files: lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteDiskFileCompletion.py lldb/test/API/functionalities/gdb_remote_client/TestGDBRemotePlatformFile.py lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py
Index: lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py =================================================================== --- lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py +++ lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py @@ -566,3 +566,23 @@ 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 connect://" + + self.server.get_connect_address()) + self.assertTrue(self.dbg.GetSelectedPlatform().IsConnected()) + + def tearDown(self): + self.dbg.GetSelectedPlatform().DisconnectRemote() + super().tearDown() 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,6 +1,6 @@ from gdbclientutils import * -class TestGDBRemotePlatformFile(GDBRemoteTestBase): +class TestGDBRemotePlatformFile(GDBPlatformClientTestBase): def test_file(self): """Test mock operations on a remote file""" @@ -19,28 +19,20 @@ self.server.responder = Responder() - try: - self.runCmd("platform select remote-gdb-server") - self.runCmd("platform connect connect://" + - self.server.get_connect_address()) - self.assertTrue(self.dbg.GetSelectedPlatform().IsConnected()) - - self.match("platform file open /some/file.txt -v 0755", - [r"File Descriptor = 16"]) - self.match("platform file read 16 -o 11 -c 13", - [r"Return = 11\nData = \"frobnicator\""]) - self.match("platform file write 16 -o 11 -d teststring", - [r"Return = 10"]) - self.match("platform file close 16", - [r"file 16 closed."]) - self.assertPacketLogContains([ - "vFile:open:2f736f6d652f66696c652e747874,00000202,000001ed", - "vFile:pread:10,d,b", - "vFile:pwrite:10,b,teststring", - "vFile:close:10", - ]) - finally: - self.dbg.GetSelectedPlatform().DisconnectRemote() + self.match("platform file open /some/file.txt -v 0755", + [r"File Descriptor = 16"]) + self.match("platform file read 16 -o 11 -c 13", + [r"Return = 11\nData = \"frobnicator\""]) + self.match("platform file write 16 -o 11 -d teststring", + [r"Return = 10"]) + self.match("platform file close 16", + [r"file 16 closed."]) + self.assertPacketLogContains([ + "vFile:open:2f736f6d652f66696c652e747874,00000202,000001ed", + "vFile:pread:10,d,b", + "vFile:pwrite:10,b,teststring", + "vFile:close:10", + ]) def test_file_fail(self): """Test mocked failures of remote operations""" @@ -51,32 +43,24 @@ self.server.responder = Responder() - try: - self.runCmd("platform select remote-gdb-server") - self.runCmd("platform connect connect://" + - self.server.get_connect_address()) - self.assertTrue(self.dbg.GetSelectedPlatform().IsConnected()) - - self.match("platform file open /some/file.txt -v 0755", - [r"error: Invalid argument"], - error=True) - self.match("platform file read 16 -o 11 -c 13", - [r"error: Invalid argument"], - error=True) - self.match("platform file write 16 -o 11 -d teststring", - [r"error: Invalid argument"], - error=True) - self.match("platform file close 16", - [r"error: Invalid argument"], - error=True) - self.assertPacketLogContains([ - "vFile:open:2f736f6d652f66696c652e747874,00000202,000001ed", - "vFile:pread:10,d,b", - "vFile:pwrite:10,b,teststring", - "vFile:close:10", - ]) - finally: - self.dbg.GetSelectedPlatform().DisconnectRemote() + self.match("platform file open /some/file.txt -v 0755", + [r"error: Invalid argument"], + error=True) + self.match("platform file read 16 -o 11 -c 13", + [r"error: Invalid argument"], + error=True) + self.match("platform file write 16 -o 11 -d teststring", + [r"error: Invalid argument"], + error=True) + self.match("platform file close 16", + [r"error: Invalid argument"], + error=True) + self.assertPacketLogContains([ + "vFile:open:2f736f6d652f66696c652e747874,00000202,000001ed", + "vFile:pread:10,d,b", + "vFile:pwrite:10,b,teststring", + "vFile:close:10", + ]) def test_file_size(self): """Test 'platform get-size'""" @@ -87,19 +71,11 @@ self.server.responder = Responder() - try: - self.runCmd("platform select remote-gdb-server") - self.runCmd("platform connect connect://" + - self.server.get_connect_address()) - self.assertTrue(self.dbg.GetSelectedPlatform().IsConnected()) - - self.match("platform get-size /some/file.txt", - [r"File size of /some/file\.txt \(remote\): 4096"]) - self.assertPacketLogContains([ - "vFile:size:2f736f6d652f66696c652e747874", - ]) - finally: - self.dbg.GetSelectedPlatform().DisconnectRemote() + self.match("platform get-size /some/file.txt", + [r"File size of /some/file\.txt \(remote\): 4096"]) + self.assertPacketLogContains([ + "vFile:size:2f736f6d652f66696c652e747874", + ]) def test_file_size_fallback(self): """Test 'platform get-size fallback to vFile:fstat'""" @@ -116,19 +92,11 @@ self.server.responder = Responder() - try: - self.runCmd("platform select remote-gdb-server") - self.runCmd("platform connect connect://" + - self.server.get_connect_address()) - self.assertTrue(self.dbg.GetSelectedPlatform().IsConnected()) - - self.match("platform get-size /some/file.txt", - [r"File size of /some/file\.txt \(remote\): 66051"]) - self.assertPacketLogContains([ - "vFile:size:2f736f6d652f66696c652e747874", - "vFile:open:2f736f6d652f66696c652e747874,00000000,00000000", - "vFile:fstat:5", - "vFile:close:5", - ]) - finally: - self.dbg.GetSelectedPlatform().DisconnectRemote() + self.match("platform get-size /some/file.txt", + [r"File size of /some/file\.txt \(remote\): 66051"]) + self.assertPacketLogContains([ + "vFile:size:2f736f6d652f66696c652e747874", + "vFile:open:2f736f6d652f66696c652e747874,00000000,00000000", + "vFile:fstat:5", + "vFile:close:5", + ]) 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,6 +1,6 @@ from gdbclientutils import * -class TestGDBRemoteDiskFileCompletion(GDBRemoteTestBase): +class TestGDBRemoteDiskFileCompletion(GDBPlatformClientTestBase): def test_autocomplete_request(self): """Test remote disk completion on remote-gdb-server plugin""" @@ -14,16 +14,8 @@ self.server.responder = Responder() - try: - self.runCmd("platform select remote-gdb-server") - self.runCmd("platform connect connect://" + - self.server.get_connect_address()) - self.assertTrue(self.dbg.GetSelectedPlatform().IsConnected()) - - self.complete_from_to('platform get-size ', ['test', '123']) - self.complete_from_to('platform get-file ', ['test', '123']) - self.complete_from_to('platform put-file foo ', ['test', '123']) - self.complete_from_to('platform file open ', ['test', '123']) - self.complete_from_to('platform settings -w ', ['test', '123']) - finally: - self.dbg.GetSelectedPlatform().DisconnectRemote() + self.complete_from_to('platform get-size ', ['test', '123']) + self.complete_from_to('platform get-file ', ['test', '123']) + self.complete_from_to('platform put-file foo ', ['test', '123']) + self.complete_from_to('platform file open ', ['test', '123']) + self.complete_from_to('platform settings -w ', ['test', '123'])
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits