|
10 | 10 | import re
|
11 | 11 | import json
|
12 | 12 |
|
13 |
| -class TestVSCode_terminatedEvent(lldbvscode_testcase.VSCodeTestCaseBase): |
| 13 | +class TestVSCode_eventStatistic(lldbvscode_testcase.VSCodeTestCaseBase): |
| 14 | + |
| 15 | + def check_statistic(self, statistics): |
| 16 | + self.assertTrue(statistics['totalDebugInfoByteSize'] > 0) |
| 17 | + self.assertTrue(statistics['totalDebugInfoEnabled'] > 0) |
| 18 | + self.assertTrue(statistics['totalModuleCountHasDebugInfo'] > 0) |
| 19 | + |
| 20 | + self.assertIsNotNone(statistics['memory']) |
| 21 | + self.assertNotIn('modules', statistics.keys()) |
| 22 | + |
| 23 | + def check_target(self, statistics): |
| 24 | + # lldb-vscode debugs one target at a time |
| 25 | + target = json.loads(statistics['targets'])[0] |
| 26 | + self.assertTrue(target['totalBreakpointResolveTime'] > 0) |
| 27 | + |
| 28 | + breakpoints = target['breakpoints'] |
| 29 | + self.assertIn('foo', |
| 30 | + breakpoints[0]['details']['Breakpoint']['BKPTResolver']['Options']['SymbolNames'], |
| 31 | + 'foo is a symbol breakpoint') |
| 32 | + self.assertTrue(breakpoints[1]['details']['Breakpoint']['BKPTResolver']['Options']['FileName'].endswith('main.cpp'), |
| 33 | + 'target has source line breakpoint in main.cpp') |
14 | 34 |
|
15 | 35 | @skipIfWindows
|
16 | 36 | @skipIfRemote
|
@@ -45,20 +65,33 @@ def test_terminated_event(self):
|
45 | 65 | self.continue_to_exit()
|
46 | 66 |
|
47 | 67 | statistics = self.vscode.wait_for_terminated()['statistics']
|
48 |
| - self.assertTrue(statistics['totalDebugInfoByteSize'] > 0) |
49 |
| - self.assertTrue(statistics['totalDebugInfoEnabled'] > 0) |
50 |
| - self.assertTrue(statistics['totalModuleCountHasDebugInfo'] > 0) |
| 68 | + self.check_statistic(statistics) |
| 69 | + self.check_target(statistics) |
51 | 70 |
|
52 |
| - self.assertIsNotNone(statistics['memory']) |
53 |
| - self.assertNotIn('modules', statistics.keys()) |
| 71 | + @skipIfWindows |
| 72 | + @skipIfRemote |
| 73 | + def test_initialized_event(self): |
| 74 | + ''' |
| 75 | + Initialized Event |
| 76 | + Now contains the statistics of a debug session: |
| 77 | + totalDebugInfoByteSize > 0 |
| 78 | + totalDebugInfoEnabled > 0 |
| 79 | + totalModuleCountHasDebugInfo > 0 |
| 80 | + totalBreakpointResolveTime > 0 |
| 81 | + ... |
| 82 | + ''' |
54 | 83 |
|
55 |
| - # lldb-vscode debugs one target at a time |
56 |
| - target = json.loads(statistics['targets'])[0] |
57 |
| - self.assertTrue(target['totalBreakpointResolveTime'] > 0) |
| 84 | + program_basename = "a.out.stripped" |
| 85 | + program = self.getBuildArtifact(program_basename) |
| 86 | + self.build_and_launch(program) |
| 87 | + # Set breakpoints |
| 88 | + functions = ['foo'] |
| 89 | + breakpoint_ids = self.set_function_breakpoints(functions) |
| 90 | + self.assertEquals(len(breakpoint_ids), len(functions), 'expect one breakpoint') |
| 91 | + main_bp_line = line_number('main.cpp', '// main breakpoint 1') |
| 92 | + breakpoint_ids.append(self.set_source_breakpoints('main.cpp', [main_bp_line])) |
58 | 93 |
|
59 |
| - breakpoints = target['breakpoints'] |
60 |
| - self.assertIn('foo', |
61 |
| - breakpoints[0]['details']['Breakpoint']['BKPTResolver']['Options']['SymbolNames'], |
62 |
| - 'foo is a symbol breakpoint') |
63 |
| - self.assertTrue(breakpoints[1]['details']['Breakpoint']['BKPTResolver']['Options']['FileName'].endswith('main.cpp'), |
64 |
| - 'target has source line breakpoint in main.cpp') |
| 94 | + self.continue_to_breakpoints(breakpoint_ids) |
| 95 | + statistics = self.vscode.initialized_event['statistics'] |
| 96 | + self.check_statistic(statistics) |
| 97 | + self.continue_to_exit() |
0 commit comments