Skip to content

Commit

Permalink
test: check server status in test-tls-psk-client
Browse files Browse the repository at this point in the history
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 <luigipinca@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
richardlau authored Oct 2, 2022
1 parent aa7167f commit 0ee6643
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion test/sequential/test-tls-psk-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,18 @@ const server = spawn(common.opensslCli, [
'-psk_hint', IDENTITY,
'-nocert',
'-rev',
]);
], { encoding: 'utf8' });
let serverErr = '';
let serverOut = '';
server.stderr.on('data', (data) => serverErr += data);
server.stdout.on('data', (data) => serverOut += data);
server.on('error', common.mustNotCall());
server.on('exit', (code, signal) => {
// Server is expected to be terminated by cleanUp().
assert.strictEqual(code, null,
`'${server.spawnfile} ${server.spawnargs.join(' ')}' unexpected exited with output:\n${serverOut}\n${serverErr}`);
assert.strictEqual(signal, 'SIGTERM');
});

const cleanUp = (err) => {
clearTimeout(timeout);
Expand Down

0 comments on commit 0ee6643

Please # to comment.