blob: baad1c4464a170ed436fab07b8cd4599400b7655 [file] [log] [blame]
Johnny Chen31fdfb12011-10-21 20:19:51 +00001"""Test lldb's response time for 'frame variable' command."""
2
Zachary Turner35d017f2015-10-23 17:04:29 +00003from __future__ import print_function
4
Zachary Turner0a0490b2015-10-27 20:12:05 +00005import use_lldb_suite
Zachary Turner77db4a82015-10-22 20:06:20 +00006
Johnny Chen31fdfb12011-10-21 20:19:51 +00007import os, sys
Johnny Chen31fdfb12011-10-21 20:19:51 +00008import lldb
Johnny Chen31fdfb12011-10-21 20:19:51 +00009from lldbbench import *
10
11class FrameVariableResponseBench(BenchBase):
12
Greg Clayton4570d3e2013-12-10 23:19:29 +000013 mydir = TestBase.compute_mydir(__file__)
Johnny Chen31fdfb12011-10-21 20:19:51 +000014
15 def setUp(self):
16 BenchBase.setUp(self)
17 if lldb.bmExecutable:
18 self.exe = lldb.bmExecutable
19 else:
Vince Harron790d95c2015-05-18 19:39:03 +000020 self.exe = lldbtest_config.lldbExec
Johnny Chen31fdfb12011-10-21 20:19:51 +000021 if lldb.bmBreakpointSpec:
22 self.break_spec = lldb.bmBreakpointSpec
23 else:
24 self.break_spec = '-n main'
25
26 self.count = lldb.bmIterationCount
27 if self.count <= 0:
28 self.count = 20
29
30 @benchmarks_test
Tamas Berghammerc8fd1302015-09-30 10:12:40 +000031 @no_debug_info_test
Zachary Turner0c426312015-01-20 22:36:03 +000032 @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows")
Johnny Chen31fdfb12011-10-21 20:19:51 +000033 def test_startup_delay(self):
34 """Test response time for the 'frame variable' command."""
Zachary Turner35d017f2015-10-23 17:04:29 +000035 print()
Johnny Chen31fdfb12011-10-21 20:19:51 +000036 self.run_frame_variable_bench(self.exe, self.break_spec, self.count)
Zachary Turner35d017f2015-10-23 17:04:29 +000037 print("lldb frame variable benchmark:", self.stopwatch)
Johnny Chen31fdfb12011-10-21 20:19:51 +000038
39 def run_frame_variable_bench(self, exe, break_spec, count):
Zachary Turner045fde52014-07-18 01:02:02 +000040 import pexpect
Johnny Chen31fdfb12011-10-21 20:19:51 +000041 # Set self.child_prompt, which is "(lldb) ".
42 self.child_prompt = '(lldb) '
43 prompt = self.child_prompt
44
45 # Reset the stopwatchs now.
46 self.stopwatch.reset()
47 for i in range(count):
48 # So that the child gets torn down after the test.
Vince Harron790d95c2015-05-18 19:39:03 +000049 self.child = pexpect.spawn('%s %s %s' % (lldbtest_config.lldbExec, self.lldbOption, exe))
Johnny Chen31fdfb12011-10-21 20:19:51 +000050 child = self.child
51
52 # Turn on logging for what the child sends back.
53 if self.TraceOn():
54 child.logfile_read = sys.stdout
55
56 # Set our breakpoint.
57 child.sendline('breakpoint set %s' % break_spec)
58 child.expect_exact(prompt)
59
60 # Run the target and expect it to be stopped due to breakpoint.
61 child.sendline('run') # Aka 'process launch'.
62 child.expect_exact(prompt)
63
64 with self.stopwatch:
65 # Measure the 'frame variable' response time.
66 child.sendline('frame variable')
67 child.expect_exact(prompt)
68
69 child.sendline('quit')
70 try:
71 self.child.expect(pexpect.EOF)
72 except:
73 pass
74
75 # The test is about to end and if we come to here, the child process has
76 # been terminated. Mark it so.
77 self.child = None