[Lldb-commits] [lldb] [lldb-dap][test] Fix `readMemory` test (PR #109057)

Adrian Vogelsgesang via lldb-commits lldb-commits at lists.llvm.org
Tue Sep 17 15:25:15 PDT 2024


https://github.com/vogelsgesang created https://github.com/llvm/llvm-project/pull/109057

So far, the test case was also testing the offset -1. This test cases failed if the string is immediately at the beginning of the memory region, though, and the offset -1 hence belonged to a different memory region.

The fix is rather straightforward:
Passing an offset of -1 is not used by any actual clients of lldb-dap, anyway. As such, this commit simply removes the corresponding test case.

>From 2a30bef69682b669661d1a4122a9f5e3f1a4fd85 Mon Sep 17 00:00:00 2001
From: Adrian Vogelsgesang <avogelsgesang at salesforce.com>
Date: Tue, 17 Sep 2024 22:21:32 +0000
Subject: [PATCH] [lldb-dap][test] Fix `readMemory` test

So far, the test case was also testing the offset -1. This test cases
failed if the string is immediately at the beginning of the memory
region, though, and the offset -1 hence belonged to a different memory
region.

The fix is rather straightforward:
Passing an offset of -1 is not used by any actual clients of lldb-dap,
anyway. As such, this commit simply removes the corresponding test case.
---
 lldb/test/API/tools/lldb-dap/memory/TestDAP_memory.py | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/lldb/test/API/tools/lldb-dap/memory/TestDAP_memory.py b/lldb/test/API/tools/lldb-dap/memory/TestDAP_memory.py
index 3d8aaeda7f4b85..1082541aebcf7c 100644
--- a/lldb/test/API/tools/lldb-dap/memory/TestDAP_memory.py
+++ b/lldb/test/API/tools/lldb-dap/memory/TestDAP_memory.py
@@ -74,10 +74,6 @@ def test_memory_refs_set_variable(self):
             ].keys(),
         )
 
-    # lldb-dap assumes that all reads will be within the same region. On Windows
-    # the target string is at the very start of a region so the -1 offset causes
-    # the read to only read from the previous region and only return 1 byte.
-    @skipIfWindows
     def test_readMemory(self):
         """
         Tests the 'readMemory' request
@@ -104,10 +100,6 @@ def test_readMemory(self):
         mem = self.dap_server.request_readMemory(memref, 2, 3)["body"]
         self.assertEqual(b64decode(mem["data"]), b"ad\0")
 
-        # Use a negative offset
-        mem = self.dap_server.request_readMemory(memref, -1, 6)["body"]
-        self.assertEqual(b64decode(mem["data"])[1:], b"dead\0")
-
         # Reads of size 0 are successful
         # VS-Code sends those in order to check if a `memoryReference` can actually be dereferenced.
         mem = self.dap_server.request_readMemory(memref, 0, 0)



More information about the lldb-commits mailing list