mirror of https://github.com/nodejs/node.git
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: https://github.com/nodejs/node/issues/29286 PR-URL: https://github.com/nodejs/node/pull/29478 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com>pull/29373/head
parent
695e819517
commit
821799024e
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
const common = require('../common');
|
||||
const assert = require('assert');
|
||||
const { spawnSync, fork } = require('child_process');
|
||||
const { spawnSync } = require('child_process');
|
||||
const async_hooks = require('async_hooks');
|
||||
const initHooks = require('./init-hooks');
|
||||
|
||||
|
@ -58,39 +58,31 @@ assert.ok(!arg);
|
|||
{
|
||||
console.log('start case 3');
|
||||
console.time('end case 3');
|
||||
const opts = {
|
||||
execArgv: ['--abort-on-uncaught-exception'],
|
||||
silent: true
|
||||
};
|
||||
const child = fork(__filename, ['test_callback_abort'], opts);
|
||||
|
||||
let stdout = '';
|
||||
child.stdout.on('data', (data) => {
|
||||
stdout += data;
|
||||
});
|
||||
|
||||
let stderr = '';
|
||||
child.stderr.on('data', (data) => {
|
||||
stderr += data;
|
||||
});
|
||||
|
||||
child.on('close', (code, signal) => {
|
||||
if (common.isWindows) {
|
||||
assert.strictEqual(code, 134);
|
||||
assert.strictEqual(signal, null);
|
||||
} else {
|
||||
assert.strictEqual(code, null);
|
||||
// Most posix systems will show 'SIGABRT', but alpine34 does not
|
||||
if (signal !== 'SIGABRT') {
|
||||
console.log(`parent received signal ${signal}\nchild's stderr:`);
|
||||
console.log(stderr);
|
||||
process.exit(1);
|
||||
}
|
||||
assert.strictEqual(signal, 'SIGABRT');
|
||||
let program = process.execPath;
|
||||
let args = [
|
||||
'--abort-on-uncaught-exception', __filename, 'test_callback_abort' ];
|
||||
const options = { encoding: 'utf8' };
|
||||
if (!common.isWindows) {
|
||||
program = `ulimit -c 0 && exec ${program} ${args.join(' ')}`;
|
||||
args = [];
|
||||
options.shell = true;
|
||||
}
|
||||
const child = spawnSync(program, args, options);
|
||||
if (common.isWindows) {
|
||||
assert.strictEqual(child.status, 134);
|
||||
assert.strictEqual(child.signal, null);
|
||||
} else {
|
||||
assert.strictEqual(child.status, null);
|
||||
// Most posix systems will show 'SIGABRT', but alpine34 does not
|
||||
if (child.signal !== 'SIGABRT') {
|
||||
console.log(`parent received signal ${child.signal}\nchild's stderr:`);
|
||||
console.log(child.stderr);
|
||||
process.exit(1);
|
||||
}
|
||||
assert.strictEqual(stdout, '');
|
||||
const firstLineStderr = stderr.split(/[\r\n]+/g)[0].trim();
|
||||
assert.strictEqual(firstLineStderr, 'Error: test_callback_abort');
|
||||
});
|
||||
assert.strictEqual(child.signal, 'SIGABRT');
|
||||
}
|
||||
assert.strictEqual(child.stdout, '');
|
||||
const firstLineStderr = child.stderr.split(/[\r\n]+/g)[0].trim();
|
||||
assert.strictEqual(firstLineStderr, 'Error: test_callback_abort');
|
||||
console.timeEnd('end case 3');
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue