Skip to content

Commit abb6919

Browse files
authored
[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`
1 parent 1e5c1a3 commit abb6919

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
Make sure the getting a variable path works and doesn't crash.
33
"""
44

5-
65
import lldb
76
import lldbsuite.test.lldbutil as lldbutil
87
from lldbsuite.test.decorators import *
@@ -142,7 +141,12 @@ def test_overwrite_vtable(self):
142141
"\x01\x01\x01\x01\x01\x01\x01\x01" if is_64bit else "\x01\x01\x01\x01"
143142
)
144143
error = lldb.SBError()
145-
process.WriteMemory(vtable_addr, data, error)
144+
bytes_written = process.WriteMemory(vtable_addr, data, error)
145+
146+
self.assertSuccess(error)
147+
self.assertGreater(
148+
bytes_written, 0, "Failed to overwrite first entry in vtable"
149+
)
146150

147151
scribbled_child = vtable.GetChildAtIndex(0)
148152
self.assertEqual(

0 commit comments

Comments
 (0)