Skip to content

Commit c54cee1

Browse files
richardlaudanielleadams
authored andcommitted
test: check server status in test-tls-psk-client
Add assertions to sequential/test-tls-psk-client to check if the spawned OpenSSL server has exited in any way except for the expected termination by the cleanUp() function. The added assertions will prevent the test from spinning forever trying to connect to the non-existent server in the case that the spawned process has exited. Include stderr and stdout in the assertion failure message to aid debugging. PR-URL: #44824 Refs: #44821 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent ccf31d8 commit c54cee1

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

test/sequential/test-tls-psk-client.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,18 @@ const server = spawn(common.opensslCli, [
2323
'-psk_hint', IDENTITY,
2424
'-nocert',
2525
'-rev',
26-
]);
26+
], { encoding: 'utf8' });
27+
let serverErr = '';
28+
let serverOut = '';
29+
server.stderr.on('data', (data) => serverErr += data);
30+
server.stdout.on('data', (data) => serverOut += data);
31+
server.on('error', common.mustNotCall());
32+
server.on('exit', (code, signal) => {
33+
// Server is expected to be terminated by cleanUp().
34+
assert.strictEqual(code, null,
35+
`'${server.spawnfile} ${server.spawnargs.join(' ')}' unexpected exited with output:\n${serverOut}\n${serverErr}`);
36+
assert.strictEqual(signal, 'SIGTERM');
37+
});
2738

2839
const cleanUp = (err) => {
2940
clearTimeout(timeout);

0 commit comments

Comments
 (0)