Skip to content

Commit 909c669

Browse files
bnoordhuisBridgeAR
authored andcommitted
test: disable core dumps before running crash test
The test spawns a subprocess with the `--abort-on-uncaught-exception` flag and expects it to terminate with a SIGABRT signal. On systems where core dumps are enabled, that actually generates an unnecessary core dump. Set `ulimit -c 0` before spawning the subprocess. Fixes: #29286 PR-URL: #29478 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: David Carlier <[email protected]>
1 parent 9e63f91 commit 909c669

File tree

1 file changed

+26
-34
lines changed

1 file changed

+26
-34
lines changed

test/async-hooks/test-callback-error.js

+26-34
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22
const common = require('../common');
33
const assert = require('assert');
4-
const { spawnSync, fork } = require('child_process');
4+
const { spawnSync } = require('child_process');
55
const async_hooks = require('async_hooks');
66
const initHooks = require('./init-hooks');
77

@@ -58,39 +58,31 @@ assert.ok(!arg);
5858
{
5959
console.log('start case 3');
6060
console.time('end case 3');
61-
const opts = {
62-
execArgv: ['--abort-on-uncaught-exception'],
63-
silent: true
64-
};
65-
const child = fork(__filename, ['test_callback_abort'], opts);
66-
67-
let stdout = '';
68-
child.stdout.on('data', (data) => {
69-
stdout += data;
70-
});
71-
72-
let stderr = '';
73-
child.stderr.on('data', (data) => {
74-
stderr += data;
75-
});
76-
77-
child.on('close', (code, signal) => {
78-
if (common.isWindows) {
79-
assert.strictEqual(code, 134);
80-
assert.strictEqual(signal, null);
81-
} else {
82-
assert.strictEqual(code, null);
83-
// Most posix systems will show 'SIGABRT', but alpine34 does not
84-
if (signal !== 'SIGABRT') {
85-
console.log(`parent received signal ${signal}\nchild's stderr:`);
86-
console.log(stderr);
87-
process.exit(1);
88-
}
89-
assert.strictEqual(signal, 'SIGABRT');
61+
let program = process.execPath;
62+
let args = [
63+
'--abort-on-uncaught-exception', __filename, 'test_callback_abort' ];
64+
const options = { encoding: 'utf8' };
65+
if (!common.isWindows) {
66+
program = `ulimit -c 0 && exec ${program} ${args.join(' ')}`;
67+
args = [];
68+
options.shell = true;
69+
}
70+
const child = spawnSync(program, args, options);
71+
if (common.isWindows) {
72+
assert.strictEqual(child.status, 134);
73+
assert.strictEqual(child.signal, null);
74+
} else {
75+
assert.strictEqual(child.status, null);
76+
// Most posix systems will show 'SIGABRT', but alpine34 does not
77+
if (child.signal !== 'SIGABRT') {
78+
console.log(`parent received signal ${child.signal}\nchild's stderr:`);
79+
console.log(child.stderr);
80+
process.exit(1);
9081
}
91-
assert.strictEqual(stdout, '');
92-
const firstLineStderr = stderr.split(/[\r\n]+/g)[0].trim();
93-
assert.strictEqual(firstLineStderr, 'Error: test_callback_abort');
94-
});
82+
assert.strictEqual(child.signal, 'SIGABRT');
83+
}
84+
assert.strictEqual(child.stdout, '');
85+
const firstLineStderr = child.stderr.split(/[\r\n]+/g)[0].trim();
86+
assert.strictEqual(firstLineStderr, 'Error: test_callback_abort');
9587
console.timeEnd('end case 3');
9688
}

0 commit comments

Comments
 (0)