forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 339
/
Copy pathTestSwiftTaskInfo.py
46 lines (37 loc) · 1.6 KB
/
TestSwiftTaskInfo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import TestBase
import lldbsuite.test.lldbutil as lldbutil
import re
def _tail(output):
"""Delete the first line of output text."""
result, _ = re.subn(r"^.*\n", "", output, count=1)
return result
class TestCase(TestBase):
@skipUnlessDarwin
def test_compare_printed_task_variable_to_task_info(self):
"""Compare the output of a printed Task to the output of `task info`."""
self.build()
lldbutil.run_to_source_breakpoint(
self, "break here", lldb.SBFileSpec("main.swift")
)
self.runCmd("frame variable task")
frame_variable_output = self.res.GetOutput()
self.runCmd("task info")
task_info_output = self.res.GetOutput()
self.assertEqual(_tail(task_info_output), _tail(frame_variable_output))
@skipUnlessDarwin
def test_compare_printed_task_variable_to_task_info_with_address(self):
"""Compare the output of a printed Task to the output of `task info <address>`."""
self.build()
_, _, thread, _ = lldbutil.run_to_source_breakpoint(
self, "break here", lldb.SBFileSpec("main.swift")
)
frame = thread.frames[0]
task = frame.FindVariable("task")
task_addr = task.GetChildMemberWithName("address").unsigned
self.runCmd("frame variable task")
frame_variable_output = self.res.GetOutput()
self.runCmd(f"task info {task_addr}")
task_info_output = self.res.GetOutput()
self.assertEqual(_tail(task_info_output), _tail(frame_variable_output))