mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
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: https://github.com/nodejs/node/pull/44824 Refs: https://github.com/nodejs/node/issues/44821 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
1 parent
ccf31d8bca
commit
c54cee1c3f
1 file changed
+12
-1
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user