Skip to content

Commit 138b29a

Browse files
committed
fixes example test failures on Mac
1 parent f88ed69 commit 138b29a

File tree

5 files changed

+16
-7
lines changed

5 files changed

+16
-7
lines changed

examples/metrics/metrics_example.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ function metrics_example(iterations)
1818
u = createUpDownCounter(m, "updowncounter");
1919
h = createHistogram(m, "histogram");
2020

21+
% wait a little before starting
22+
pause(2);
2123
for i = 1:iterations
2224
c.add(randi(10));
2325
u.add(randi([-10 10]));

test/texamples.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,8 @@ function testWebread(testCase)
260260
server = fullfile(serverfolder, "webread_example_server");
261261

262262
% start the C++ server
263-
%system(server + '&');
264263
testCase.applyFixture(CppServerFixture(server, testCase));
264+
pause(3); % wait a little for server to start up
265265

266266
% run the example
267267
webread_example();

test/utils/commonTeardown.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ function commonTeardown(testCase)
33

44
% Copyright 2023-2024 The MathWorks, Inc.
55

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);
88

99
% Close command window if opened
1010
closeWindow(testCase);

test/utils/readJsonResults.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
% Copyright 2023-2024 The MathWorks, Inc.
55

6-
% terminate the collector
7-
terminateProcess(testCase, testCase.OtelcolName);
6+
% terminate the collector, using interrupt signal
7+
terminateProcess(testCase, testCase.OtelcolName, testCase.Sigint);
88

99
assert(exist(testCase.JsonFile, "file"));
1010

test/utils/terminateProcess.m

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
1-
function terminateProcess(testCase, process)
1+
function terminateProcess(testCase, process, terminatecmd)
22
% Terminate a process started in a test
33

44
% Copyright 2023-2024 The MathWorks, Inc.
55

6+
if nargin < 3
7+
terminatecmd = testCase.Sigterm; % defaults to terminate signal
8+
end
9+
610
system(testCase.ListPid(process) + " > " + testCase.PidFile);
711
tbl = testCase.ReadPidList(testCase.PidFile);
812
pid = testCase.ExtractPid(tbl);
913
retry = 0;
1014
% sometimes kill will fail with a RuntimeError: windows-kill-library: ctrl-routine:findAddress:checkAddressIsNotNull
1115
% Retry up to 3 times
1216
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
1421
pause(2); % give a little time for the collector to shut down
1522
system(testCase.ListPid(process) + " > " + testCase.PidFile);
1623
tbl = testCase.ReadPidList(testCase.PidFile);

0 commit comments

Comments
 (0)