File tree Expand file tree Collapse file tree 5 files changed +16
-7
lines changed Expand file tree Collapse file tree 5 files changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,8 @@ function metrics_example(iterations)
18
18
u = createUpDownCounter(m , " updowncounter" );
19
19
h = createHistogram(m , " histogram" );
20
20
21
+ % wait a little before starting
22
+ pause(2 );
21
23
for i = 1 : iterations
22
24
c .add(randi(10 ));
23
25
u .add(randi([-10 10 ]));
Original file line number Diff line number Diff line change @@ -260,8 +260,8 @@ function testWebread(testCase)
260
260
server = fullfile(serverfolder , " webread_example_server" );
261
261
262
262
% start the C++ server
263
- % system(server + '&');
264
263
testCase .applyFixture(CppServerFixture(server , testCase ));
264
+ pause(3 ); % wait a little for server to start up
265
265
266
266
% run the example
267
267
webread_example();
Original file line number Diff line number Diff line change @@ -3,8 +3,8 @@ function commonTeardown(testCase)
3
3
4
4
% Copyright 2023-2024 The MathWorks, Inc.
5
5
6
- % Terminate Collector if it is still running
7
- terminateProcess(testCase , testCase .OtelcolName );
6
+ % Terminate Collector if it is still running. Use interrupt signal.
7
+ terminateProcess(testCase , testCase .OtelcolName , testCase . Sigint );
8
8
9
9
% Close command window if opened
10
10
closeWindow(testCase );
Original file line number Diff line number Diff line change 3
3
4
4
% Copyright 2023-2024 The MathWorks, Inc.
5
5
6
- % terminate the collector
7
- terminateProcess(testCase , testCase .OtelcolName );
6
+ % terminate the collector, using interrupt signal
7
+ terminateProcess(testCase , testCase .OtelcolName , testCase . Sigint );
8
8
9
9
assert(exist(testCase .JsonFile , " file" ));
10
10
Original file line number Diff line number Diff line change 1
- function terminateProcess(testCase , process )
1
+ function terminateProcess(testCase , process , terminatecmd )
2
2
% Terminate a process started in a test
3
3
4
4
% Copyright 2023-2024 The MathWorks, Inc.
5
5
6
+ if nargin < 3
7
+ terminatecmd = testCase .Sigterm ; % defaults to terminate signal
8
+ end
9
+
6
10
system(testCase .ListPid(process ) + " > " + testCase .PidFile );
7
11
tbl = testCase .ReadPidList(testCase .PidFile );
8
12
pid = testCase .ExtractPid(tbl );
9
13
retry = 0 ;
10
14
% sometimes kill will fail with a RuntimeError: windows-kill-library: ctrl-routine:findAddress:checkAddressIsNotNull
11
15
% Retry up to 3 times
12
16
while ~isempty(pid ) && retry < 4
13
- system(testCase .Sigint(pid ));
17
+ % kill all if multiple instances found
18
+ for i = 1 : numel(pid )
19
+ system(terminatecmd(pid(i )));
20
+ end
14
21
pause(2 ); % give a little time for the collector to shut down
15
22
system(testCase .ListPid(process ) + " > " + testCase .PidFile );
16
23
tbl = testCase .ReadPidList(testCase .PidFile );
You can’t perform that action at this time.
0 commit comments