Skip to content
Browse files
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

PR-URL: #44824
Refs: #44821
Reviewed-By: Luigi Pinca <>
Reviewed-By: Rich Trott <>
Reviewed-By: James M Snell <>
  • Loading branch information
richardlau authored and danielleadams committed Oct 5, 2022
1 parent ccf31d8 commit c54cee1c3f604d87ee4a7317bd14fca8575acbb1
Showing 1 changed file with 12 additions and 1 deletion.
@@ -23,7 +23,18 @@ const server = spawn(common.opensslCli, [
'-psk_hint', IDENTITY,
], { 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) => {

0 comments on commit c54cee1

Please sign in to comment.