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