Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
  • Loading branch information
bnoordhuis committed Sep 6, 2019
commit 0e5a29f6b0a910f80802d13a87f63ba25cc39903
60 changes: 26 additions & 34 deletions test/async-hooks/test-callback-error.js
Original file line number Diff line number Diff line change
@@ -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');

Expand Down Expand Up @@ -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');
}