[Lldb-commits] [PATCH] D107821: [lldb] [gdb-server] Add tests for more vFile packets
Michał Górny via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Tue Aug 10 05:51:02 PDT 2021
mgorny created this revision.
mgorny added reviewers: krytarowski, labath, emaste, jasonmolenda, JDevlieghere.
mgorny requested review of this revision.
https://reviews.llvm.org/D107821
Files:
lldb/test/API/tools/lldb-server/TestGdbRemotePlatformFile.py
Index: lldb/test/API/tools/lldb-server/TestGdbRemotePlatformFile.py
===================================================================
--- lldb/test/API/tools/lldb-server/TestGdbRemotePlatformFile.py
+++ lldb/test/API/tools/lldb-server/TestGdbRemotePlatformFile.py
@@ -100,6 +100,80 @@
True)
self.expect_gdbremote_sequence()
+ @skipIfWindows
+ @add_test_categories(["llgs"])
+ def test_platform_file_size(self):
+ server = self.connect_to_debug_monitor()
+ self.assertIsNotNone(server)
+
+ with tempfile.NamedTemporaryFile() as temp_file:
+ test_data = b"test data of some length"
+ temp_file.write(test_data)
+ temp_file.flush()
+
+ self.do_handshake()
+ self.test_sequence.add_log_lines(
+ ["read packet: $vFile:size:%s#00" % (
+ binascii.b2a_hex(temp_file.name.encode()).decode(),),
+ {"direction": "send",
+ "regex": r"^\$F([0-9a-fA-F]+)+#[0-9a-fA-F]{2}$",
+ "capture": {1: "size"}}],
+ True)
+ context = self.expect_gdbremote_sequence()
+ self.assertEqual(int(context["size"], 16), len(test_data))
+
+ @skipIfWindows
+ @add_test_categories(["llgs"])
+ def test_platform_file_mode(self):
+ server = self.connect_to_debug_monitor()
+ self.assertIsNotNone(server)
+
+ with tempfile.NamedTemporaryFile() as temp_file:
+ test_mode = 0o751
+ os.chmod(temp_file.fileno(), test_mode)
+
+ self.do_handshake()
+ self.test_sequence.add_log_lines(
+ ["read packet: $vFile:mode:%s#00" % (
+ binascii.b2a_hex(temp_file.name.encode()).decode(),),
+ {"direction": "send",
+ "regex": r"^\$F([0-9a-fA-F]+)+#[0-9a-fA-F]{2}$",
+ "capture": {1: "mode"}}],
+ True)
+ context = self.expect_gdbremote_sequence()
+ self.assertEqual(int(context["mode"], 16), test_mode)
+
+ @skipIfWindows
+ @add_test_categories(["llgs"])
+ def test_platform_file_exists(self):
+ server = self.connect_to_debug_monitor()
+ self.assertIsNotNone(server)
+
+ with tempfile.NamedTemporaryFile() as temp_file:
+ self.do_handshake()
+ self.test_sequence.add_log_lines(
+ ["read packet: $vFile:exists:%s#00" % (
+ binascii.b2a_hex(temp_file.name.encode()).decode(),),
+ "send packet: $F,1#00"],
+ True)
+ self.expect_gdbremote_sequence()
+
+ @skipIfWindows
+ @add_test_categories(["llgs"])
+ def test_platform_file_exists_not(self):
+ server = self.connect_to_debug_monitor()
+ self.assertIsNotNone(server)
+
+ with tempfile.TemporaryDirectory() as temp_dir:
+ test_path = os.path.join(temp_dir, "nonexist")
+ self.do_handshake()
+ self.test_sequence.add_log_lines(
+ ["read packet: $vFile:exists:%s#00" % (
+ binascii.b2a_hex(test_path.encode()).decode(),),
+ "send packet: $F,0#00"],
+ True)
+ self.expect_gdbremote_sequence()
+
def expect_error(self):
self.test_sequence.add_log_lines(
[{"direction": "send",
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107821.365451.patch
Type: text/x-patch
Size: 3391 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210810/82da66a1/attachment.bin>
More information about the lldb-commits
mailing list