node/test/abort/test-signal-handler.js
Michaël Zasso 3c82d48cc0
test: allow SIGBUS in signal-handler abort test
FreeBSD uses SIGBUS after update to v12.4.

Refs: https://github.com/nodejs/build/issues/3134
PR-URL: https://github.com/nodejs/node/pull/47851
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2023-05-05 11:03:38 +00:00

28 lines
931 B
JavaScript

'use strict';
const common = require('../common');
if (common.isWindows)
common.skip('No signals on Window');
const assert = require('assert');
const { spawnSync } = require('child_process');
// Test that a hard crash does not cause an endless loop.
if (process.argv[2] === 'child') {
const { internalBinding } = require('internal/test/binding');
const { causeSegfault } = internalBinding('process_methods');
causeSegfault();
} else {
const child = spawnSync(process.execPath,
['--expose-internals', __filename, 'child'],
{ stdio: 'inherit' });
// FreeBSD uses SIGILL (v12.2) or SIGBUS (v12.4 and greater) for this kind of crash.
// macOS uses SIGILL or SIGTRAP (arm64) for this kind of crash.
const allowedSignals = ['SIGSEGV', 'SIGILL', 'SIGTRAP', 'SIGBUS'];
assert(
allowedSignals.includes(child.signal),
`child.signal = ${child.signal}`,
);
}