]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/benchmarks/frame_variable/TestFrameVariableResponse.py
Vendor import of lldb trunk r256945:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / benchmarks / frame_variable / TestFrameVariableResponse.py
1 """Test lldb's response time for 'frame variable' command."""
2
3 from __future__ import print_function
4
5
6
7 import os, sys
8 import lldb
9 from lldbsuite.test import configuration
10 from lldbsuite.test import lldbtest_config
11 from lldbsuite.test.lldbbench import *
12
13 class FrameVariableResponseBench(BenchBase):
14
15     mydir = TestBase.compute_mydir(__file__)
16
17     def setUp(self):
18         BenchBase.setUp(self)
19         self.exe = lldbtest_config.lldbExec
20         self.break_spec = '-n main'
21         self.count = 20
22
23     @benchmarks_test
24     @no_debug_info_test
25     @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows")
26     def test_startup_delay(self):
27         """Test response time for the 'frame variable' command."""
28         print()
29         self.run_frame_variable_bench(self.exe, self.break_spec, self.count)
30         print("lldb frame variable benchmark:", self.stopwatch)
31
32     def run_frame_variable_bench(self, exe, break_spec, count):
33         import pexpect
34         # Set self.child_prompt, which is "(lldb) ".
35         self.child_prompt = '(lldb) '
36         prompt = self.child_prompt
37
38         # Reset the stopwatchs now.
39         self.stopwatch.reset()
40         for i in range(count):
41             # So that the child gets torn down after the test.
42             self.child = pexpect.spawn('%s %s %s' % (lldbtest_config.lldbExec, self.lldbOption, exe))
43             child = self.child
44
45             # Turn on logging for what the child sends back.
46             if self.TraceOn():
47                 child.logfile_read = sys.stdout
48
49             # Set our breakpoint.
50             child.sendline('breakpoint set %s' % break_spec)
51             child.expect_exact(prompt)
52
53             # Run the target and expect it to be stopped due to breakpoint.
54             child.sendline('run') # Aka 'process launch'.
55             child.expect_exact(prompt)
56         
57             with self.stopwatch:
58                 # Measure the 'frame variable' response time.
59                 child.sendline('frame variable')
60                 child.expect_exact(prompt)
61
62             child.sendline('quit')
63             try:
64                 self.child.expect(pexpect.EOF)
65             except:
66                 pass
67
68         # The test is about to end and if we come to here, the child process has
69         # been terminated.  Mark it so.
70         self.child = None