summaryrefslogtreecommitdiffstats
path: root/lldb/test/python_api/value
diff options
context:
space:
mode:
authorJohnny Chen <johnny.chen@apple.com>2011-07-26 20:57:10 +0000
committerJohnny Chen <johnny.chen@apple.com>2011-07-26 20:57:10 +0000
commite33b166da1586296b44d609c9edd1d9d89a4e54e (patch)
tree20f82a3d10823913253b856431c7ad2f45b583c4 /lldb/test/python_api/value
parent2aedba6c5e18fa3e62a0eca95d50c6ab77abd109 (diff)
downloadbcm5719-llvm-e33b166da1586296b44d609c9edd1d9d89a4e54e.tar.gz
bcm5719-llvm-e33b166da1586296b44d609c9edd1d9d89a4e54e.zip
We can do better with the SBValue.linked_list_iter() API by supplying a default
end of list test function as __eol_test__. The simple example can be reduced to: for t in task_head.linked_list_iter('next'): print t Modify the test program to exercise the API for both cases: supplying or not supplying an end of list test function. llvm-svn: 136144
Diffstat (limited to 'lldb/test/python_api/value')
-rw-r--r--lldb/test/python_api/value/linked_list/TestValueAPILinkedList.py36
1 files changed, 26 insertions, 10 deletions
diff --git a/lldb/test/python_api/value/linked_list/TestValueAPILinkedList.py b/lldb/test/python_api/value/linked_list/TestValueAPILinkedList.py
index d915f99d29a..6456a2ea380 100644
--- a/lldb/test/python_api/value/linked_list/TestValueAPILinkedList.py
+++ b/lldb/test/python_api/value/linked_list/TestValueAPILinkedList.py
@@ -54,16 +54,6 @@ class ValueAsLinkedListTestCase(TestBase):
process = target.LaunchSimple(None, None, os.getcwd())
self.assertTrue(process, PROCESS_IS_VALID)
- def eol(val):
- """Test function to determine end of list."""
- # End of list is reached if either the value object is invalid
- # or it corresponds to a null pointer.
- if not val or int(val.GetValue(), 16) == 0:
- return True
-
- # Otherwise, return False.
- return False
-
# Get Frame #0.
self.assertTrue(process.GetState() == lldb.eStateStopped)
thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint)
@@ -80,6 +70,32 @@ class ValueAsLinkedListTestCase(TestBase):
list = []
cvf = lldbutil.ChildVisitingFormatter(indent_child=2)
+ for t in task_head.linked_list_iter('next'):
+ self.assertTrue(t, VALID_VARIABLE)
+ # Make sure that 'next' corresponds to an SBValue with pointer type.
+ self.assertTrue(t.TypeIsPointerType())
+ if self.TraceOn():
+ print cvf.format(t)
+ list.append(int(t.GetChildMemberWithName("id").GetValue()))
+
+ # Sanity checks that the we visited all the items (no more, no less).
+ if self.TraceOn():
+ print "visited IDs:", list
+ self.assertTrue(visitedIDs == list)
+
+ # Let's exercise the linked_list_iter() API again, this time supplying
+ # our end of list test function.
+ def eol(val):
+ """Test function to determine end of list."""
+ # End of list is reached if either the value object is invalid
+ # or it corresponds to a null pointer.
+ if not val or int(val.GetValue(), 16) == 0:
+ return True
+
+ # Otherwise, return False.
+ return False
+
+ list = []
for t in task_head.linked_list_iter('next', eol):
self.assertTrue(t, VALID_VARIABLE)
# Make sure that 'next' corresponds to an SBValue with pointer type.
OpenPOWER on IntegriCloud