From da7f047d439a65f6eaae1260d5b1c21dadd4015a Mon Sep 17 00:00:00 2001 From: Richard Lau Date: Wed, 16 Nov 2016 19:30:03 -0500 Subject: [PATCH] Fix test-exception.js for PPC On PPC architectures, --abort_on_uncaught_exception (currently set by nodereport for the `exception` event) exits with SIGTRAP instead of SIGILL. --- test/common.js | 8 ++++++++ test/test-exception.js | 5 +++-- test/test-signal.js | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/test/common.js b/test/common.js index 9bb24d4..e50fd33 100644 --- a/test/common.js +++ b/test/common.js @@ -17,6 +17,14 @@ exports.findReports = (pid) => { return files.filter((file) => filePattern.test(file)); }; +exports.isPPC = () => { + return process.arch.startsWith('ppc'); +}; + +exports.isWindows = () => { + return process.platform === 'win32'; +}; + exports.validate = (t, report, pid) => { t.test('Validating ' + report, (t) => { fs.readFile(report, (err, data) => { diff --git a/test/test-exception.js b/test/test-exception.js index 6fa442a..a434b51 100644 --- a/test/test-exception.js +++ b/test/test-exception.js @@ -22,8 +22,9 @@ if (process.argv[2] === 'child') { const child = spawn(process.execPath, [__filename, 'child']); child.on('exit', (code, signal) => { - const expectedExitCode = process.platform === 'win32' ? 0xC0000005 : null; - const expectedSignal = process.platform === 'win32' ? null : 'SIGILL'; + const expectedExitCode = common.isWindows() ? 0xC0000005 : null; + const expectedSignal = common.isWindows() ? null : + common.isPPC() ? 'SIGTRAP' : 'SIGILL'; tap.plan(4); tap.equal(code, expectedExitCode, 'Process should not exit cleanly'); tap.equal(signal, expectedSignal, diff --git a/test/test-signal.js b/test/test-signal.js index dfd5317..183dbb3 100644 --- a/test/test-signal.js +++ b/test/test-signal.js @@ -36,7 +36,7 @@ if (process.argv[2] === 'child') { const fork = require('child_process').fork; const tap = require('tap'); - if (process.platform === 'win32') { + if (common.isWindows()) { tap.fail('Unsupported on Windows', { skip: true }); return; }