Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: disable core dumps before running crash test #29478

Closed
wants to merge 1 commit into from
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
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');
}