-
Notifications
You must be signed in to change notification settings - Fork 40
/
dynamicBreakpointOptions.spec.ts
156 lines (143 loc) · 5.43 KB
/
dynamicBreakpointOptions.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/*********************************************************************
* Copyright (c) 2023 Renesas Electronics Corporation and others
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*********************************************************************/
import * as path from 'path';
import * as os from 'os';
import { expect } from 'chai';
import { CdtDebugClient } from './debugClient';
import { standardBeforeEach, testProgramsDir, fillDefaults } from './utils';
// This mock adapter is overriding the getBreakpointOptions method.
const adapter =
'integration-tests/mocks/debugAdapters/dynamicBreakpointOptions.js';
const argHardwareBreakpointTrue = '--hardware-breakpoint-true';
const argHardwareBreakpointFalse = '--hardware-breakpoint-false';
const argThrowError = '--throw-error';
describe('dynamic breakpoint options with hardware set to false', async () => {
let dc: CdtDebugClient;
beforeEach(async function () {
// Overriding breakpoint option hardware to false
dc = await standardBeforeEach(adapter, [argHardwareBreakpointFalse]);
await dc.launchRequest(
fillDefaults(this.currentTest, {
program: path.join(testProgramsDir, 'count'),
hardwareBreakpoint: true,
})
);
});
afterEach(async () => {
await dc.stop();
});
it('insert breakpoint as software breakpoint', async () => {
const bpResp = await dc.setBreakpointsRequest({
source: {
name: 'count.c',
path: path.join(testProgramsDir, 'count.c'),
},
breakpoints: [
{
column: 1,
line: 4,
},
],
});
expect(bpResp.body.breakpoints.length).eq(1);
expect(bpResp.body.breakpoints[0].verified).eq(true);
expect(bpResp.body.breakpoints[0].message).eq(undefined);
await dc.configurationDoneRequest();
let isCorrect;
let outputs;
while (!isCorrect) {
// Cover the case of getting event in Linux environment.
// If cannot get correct event, program timeout and test case failed.
outputs = await dc.waitForEvent('output');
isCorrect = outputs.body.output.includes('breakpoint-modified');
}
expect(outputs?.body.output).includes('type="breakpoint"');
});
});
describe('dynamic breakpoint options with hardware set to true', async () => {
let dc: CdtDebugClient;
beforeEach(async function () {
// Overriding breakpoint option hardware to true
dc = await standardBeforeEach(adapter, [argHardwareBreakpointTrue]);
await dc.launchRequest(
fillDefaults(this.currentTest, {
program: path.join(testProgramsDir, 'count'),
hardwareBreakpoint: false,
})
);
});
afterEach(async () => {
await dc.stop();
});
it('insert breakpoint as hardware breakpoint', async function () {
// Hardware breakpoints are not supported for Windows
if (os.platform() === 'win32') {
this.skip();
}
const bpResp = await dc.setBreakpointsRequest({
source: {
name: 'count.c',
path: path.join(testProgramsDir, 'count.c'),
},
breakpoints: [
{
column: 1,
line: 4,
},
],
});
expect(bpResp.body.breakpoints.length).eq(1);
expect(bpResp.body.breakpoints[0].verified).eq(true);
expect(bpResp.body.breakpoints[0].message).eq(undefined);
await dc.configurationDoneRequest();
let isCorrect;
let outputs;
while (!isCorrect) {
// Cover the case of getting event in Linux environment.
// If cannot get correct event, program timeout and test case failed.
outputs = await dc.waitForEvent('output');
isCorrect = outputs.body.output.includes('breakpoint-modified');
}
expect(outputs?.body.output).includes('type="hw breakpoint"');
});
});
describe('dynamic breakpoint options with throwing error', async () => {
let dc: CdtDebugClient;
beforeEach(async function () {
// Overriding breakpoint options and throwing error when getBreakpointOptions invoked
dc = await standardBeforeEach(adapter, [argThrowError]);
await dc.launchRequest(
fillDefaults(this.currentTest, {
program: path.join(testProgramsDir, 'count'),
hardwareBreakpoint: false,
})
);
});
afterEach(async () => {
await dc.stop();
});
it('insert breakpoint is not performed', async () => {
const bpResp = await dc.setBreakpointsRequest({
source: {
name: 'count.c',
path: path.join(testProgramsDir, 'count.c'),
},
breakpoints: [
{
column: 1,
line: 4,
},
],
});
expect(bpResp.body.breakpoints.length).eq(1);
expect(bpResp.body.breakpoints[0].verified).eq(false);
expect(bpResp.body.breakpoints[0].message).not.eq(undefined);
});
});