[Lldb-commits] [lldb] abb6919 - [lldb] Add additional assertions to TestVTableValue.test_overwrite_vtable (#118719)

via lldb-commits lldb-commits at lists.llvm.org
Thu Dec 5 10:38:27 PST 2024


Author: Alex Langford
Date: 2024-12-05T10:38:23-08:00
New Revision: abb6919a63c7ef017bb4f9c86057adcdb8129964

URL: https://github.com/llvm/llvm-project/commit/abb6919a63c7ef017bb4f9c86057adcdb8129964
DIFF: https://github.com/llvm/llvm-project/commit/abb6919a63c7ef017bb4f9c86057adcdb8129964.diff

LOG: [lldb] Add additional assertions to TestVTableValue.test_overwrite_vtable (#118719)

If this test fails, you're likely going to see something like "Assertion
Error: A != B" which doesn't really give much explanation for why this
failed.

Instead of ignoring the error, we should assert that it succeeded. This
will lead to a better error message, for example:
`AssertionError: 'memory write failed for 0x102d7c018' is not success`

Added: 
    

Modified: 
    lldb/test/API/functionalities/vtable/TestVTableValue.py

Removed: 
    


################################################################################
diff  --git a/lldb/test/API/functionalities/vtable/TestVTableValue.py b/lldb/test/API/functionalities/vtable/TestVTableValue.py
index bfc910614afa9e..f0076ea28f7599 100644
--- a/lldb/test/API/functionalities/vtable/TestVTableValue.py
+++ b/lldb/test/API/functionalities/vtable/TestVTableValue.py
@@ -2,7 +2,6 @@
 Make sure the getting a variable path works and doesn't crash.
 """
 
-
 import lldb
 import lldbsuite.test.lldbutil as lldbutil
 from lldbsuite.test.decorators import *
@@ -142,7 +141,12 @@ def test_overwrite_vtable(self):
             "\x01\x01\x01\x01\x01\x01\x01\x01" if is_64bit else "\x01\x01\x01\x01"
         )
         error = lldb.SBError()
-        process.WriteMemory(vtable_addr, data, error)
+        bytes_written = process.WriteMemory(vtable_addr, data, error)
+
+        self.assertSuccess(error)
+        self.assertGreater(
+            bytes_written, 0, "Failed to overwrite first entry in vtable"
+        )
 
         scribbled_child = vtable.GetChildAtIndex(0)
         self.assertEqual(


        


More information about the lldb-commits mailing list