blob: 7f738f1196893b8a99f02f2a9f1eab039b44255a [file] [log] [blame]
Johnny Chen31fdfb12011-10-21 20:19:51 +00001"""Test lldb's response time for 'frame variable' command."""
2
3import os, sys
4import unittest2
5import lldb
Johnny Chen31fdfb12011-10-21 20:19:51 +00006from lldbbench import *
7
8class FrameVariableResponseBench(BenchBase):
9
Greg Clayton4570d3e2013-12-10 23:19:29 +000010 mydir = TestBase.compute_mydir(__file__)
Johnny Chen31fdfb12011-10-21 20:19:51 +000011
12 def setUp(self):
13 BenchBase.setUp(self)
14 if lldb.bmExecutable:
15 self.exe = lldb.bmExecutable
16 else:
Vince Harron790d95c2015-05-18 19:39:03 +000017 self.exe = lldbtest_config.lldbExec
Johnny Chen31fdfb12011-10-21 20:19:51 +000018 if lldb.bmBreakpointSpec:
19 self.break_spec = lldb.bmBreakpointSpec
20 else:
21 self.break_spec = '-n main'
22
23 self.count = lldb.bmIterationCount
24 if self.count <= 0:
25 self.count = 20
26
27 @benchmarks_test
Zachary Turner0c426312015-01-20 22:36:03 +000028 @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows")
Johnny Chen31fdfb12011-10-21 20:19:51 +000029 def test_startup_delay(self):
30 """Test response time for the 'frame variable' command."""
31 print
32 self.run_frame_variable_bench(self.exe, self.break_spec, self.count)
33 print "lldb frame variable benchmark:", self.stopwatch
34
35 def run_frame_variable_bench(self, exe, break_spec, count):
Zachary Turner045fde52014-07-18 01:02:02 +000036 import pexpect
Johnny Chen31fdfb12011-10-21 20:19:51 +000037 # Set self.child_prompt, which is "(lldb) ".
38 self.child_prompt = '(lldb) '
39 prompt = self.child_prompt
40
41 # Reset the stopwatchs now.
42 self.stopwatch.reset()
43 for i in range(count):
44 # So that the child gets torn down after the test.
Vince Harron790d95c2015-05-18 19:39:03 +000045 self.child = pexpect.spawn('%s %s %s' % (lldbtest_config.lldbExec, self.lldbOption, exe))
Johnny Chen31fdfb12011-10-21 20:19:51 +000046 child = self.child
47
48 # Turn on logging for what the child sends back.
49 if self.TraceOn():
50 child.logfile_read = sys.stdout
51
52 # Set our breakpoint.
53 child.sendline('breakpoint set %s' % break_spec)
54 child.expect_exact(prompt)
55
56 # Run the target and expect it to be stopped due to breakpoint.
57 child.sendline('run') # Aka 'process launch'.
58 child.expect_exact(prompt)
59
60 with self.stopwatch:
61 # Measure the 'frame variable' response time.
62 child.sendline('frame variable')
63 child.expect_exact(prompt)
64
65 child.sendline('quit')
66 try:
67 self.child.expect(pexpect.EOF)
68 except:
69 pass
70
71 # The test is about to end and if we come to here, the child process has
72 # been terminated. Mark it so.
73 self.child = None
74
75
76if __name__ == '__main__':
77 import atexit
78 lldb.SBDebugger.Initialize()
79 atexit.register(lambda: lldb.SBDebugger.Terminate())
80 unittest2.main()