mirror of https://github.com/nodejs/node.git
test: update a few tests to work on OpenBSD
PR-URL: https://github.com/nodejs/node/pull/18543 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>pull/18744/merge
parent
bd4350ca08
commit
ef0e92eb82
|
@ -55,6 +55,7 @@ exports.isLinuxPPCBE = (process.platform === 'linux') &&
|
|||
(os.endianness() === 'BE');
|
||||
exports.isSunOS = process.platform === 'sunos';
|
||||
exports.isFreeBSD = process.platform === 'freebsd';
|
||||
exports.isOpenBSD = process.platform === 'openbsd';
|
||||
exports.isLinux = process.platform === 'linux';
|
||||
exports.isOSX = process.platform === 'darwin';
|
||||
|
||||
|
|
|
@ -16,15 +16,22 @@ const cmd = `"${process.execPath}" "${__filename}" child`;
|
|||
|
||||
// Test the case where a timeout is set, and it expires.
|
||||
cp.exec(cmd, { timeout: 1 }, common.mustCall((err, stdout, stderr) => {
|
||||
let sigterm = 'SIGTERM';
|
||||
assert.strictEqual(err.killed, true);
|
||||
assert.strictEqual(err.code, null);
|
||||
// TODO OpenBSD returns a null signal and 143 for code
|
||||
if (common.isOpenBSD) {
|
||||
assert.strictEqual(err.code, 143);
|
||||
sigterm = null;
|
||||
} else {
|
||||
assert.strictEqual(err.code, null);
|
||||
}
|
||||
// At least starting with Darwin Kernel Version 16.4.0, sending a SIGTERM to a
|
||||
// process that is still starting up kills it with SIGKILL instead of SIGTERM.
|
||||
// See: https://github.com/libuv/libuv/issues/1226
|
||||
if (common.isOSX)
|
||||
assert.ok(err.signal === 'SIGTERM' || err.signal === 'SIGKILL');
|
||||
else
|
||||
assert.strictEqual(err.signal, 'SIGTERM');
|
||||
assert.strictEqual(err.signal, sigterm);
|
||||
assert.strictEqual(err.cmd, cmd);
|
||||
assert.strictEqual(stdout.trim(), '');
|
||||
assert.strictEqual(stderr.trim(), '');
|
||||
|
|
|
@ -178,8 +178,8 @@ process.on('exit', function() {
|
|||
const path = `${tmpdir.path}/test-utimes-precision`;
|
||||
fs.writeFileSync(path, '');
|
||||
|
||||
// test Y2K38 for all platforms [except 'arm', and 'SunOS']
|
||||
if (!process.arch.includes('arm') && !common.isSunOS) {
|
||||
// test Y2K38 for all platforms [except 'arm', 'OpenBSD' and 'SunOS']
|
||||
if (!process.arch.includes('arm') && !common.isOpenBSD && !common.isSunOS) {
|
||||
// because 2 ** 31 doesn't look right
|
||||
// eslint-disable-next-line space-infix-ops
|
||||
const Y2K38_mtime = 2**31;
|
||||
|
|
|
@ -32,6 +32,10 @@ const https = require('https');
|
|||
const host = '*'.repeat(256);
|
||||
const MAX_TRIES = 5;
|
||||
|
||||
let errCode = 'ENOTFOUND';
|
||||
if (common.isOpenBSD)
|
||||
errCode = 'EAI_FAIL';
|
||||
|
||||
function tryGet(mod, tries) {
|
||||
// Bad host name should not throw an uncatchable exception.
|
||||
// Ensure that there is time to attach an error listener.
|
||||
|
@ -41,7 +45,7 @@ function tryGet(mod, tries) {
|
|||
tryGet(mod, ++tries);
|
||||
return;
|
||||
}
|
||||
assert.strictEqual(err.code, 'ENOTFOUND');
|
||||
assert.strictEqual(err.code, errCode);
|
||||
}));
|
||||
// http.get() called req1.end() for us
|
||||
}
|
||||
|
@ -57,7 +61,7 @@ function tryRequest(mod, tries) {
|
|||
tryRequest(mod, ++tries);
|
||||
return;
|
||||
}
|
||||
assert.strictEqual(err.code, 'ENOTFOUND');
|
||||
assert.strictEqual(err.code, errCode);
|
||||
}));
|
||||
req.end();
|
||||
}
|
||||
|
|
|
@ -27,17 +27,21 @@ const net = require('net');
|
|||
|
||||
const host = '*'.repeat(256);
|
||||
|
||||
let errCode = 'ENOTFOUND';
|
||||
if (common.isOpenBSD)
|
||||
errCode = 'EAI_FAIL';
|
||||
|
||||
function do_not_call() {
|
||||
throw new Error('This function should not have been called.');
|
||||
}
|
||||
|
||||
const socket = net.connect(42, host, do_not_call);
|
||||
socket.on('error', common.mustCall(function(err) {
|
||||
assert.strictEqual(err.code, 'ENOTFOUND');
|
||||
assert.strictEqual(err.code, errCode);
|
||||
}));
|
||||
socket.on('lookup', function(err, ip, type) {
|
||||
assert(err instanceof Error);
|
||||
assert.strictEqual(err.code, 'ENOTFOUND');
|
||||
assert.strictEqual(err.code, errCode);
|
||||
assert.strictEqual(ip, undefined);
|
||||
assert.strictEqual(type, undefined);
|
||||
});
|
||||
|
|
|
@ -12,6 +12,9 @@ const args = [process.execPath];
|
|||
if (common.isAIX)
|
||||
args.unshift('-Xany', '-B');
|
||||
|
||||
if (common.isOpenBSD)
|
||||
common.skip('no v8 debug symbols on OpenBSD');
|
||||
|
||||
const nm = spawnSync('nm', args);
|
||||
|
||||
if (nm.error && nm.error.errno === 'ENOENT')
|
||||
|
|
|
@ -34,7 +34,7 @@ exec(cmd, common.mustCall((error, stdout, stderr) => {
|
|||
assert.strictEqual(stderr, '');
|
||||
|
||||
// freebsd always add ' (procname)' to the process title
|
||||
if (common.isFreeBSD)
|
||||
if (common.isFreeBSD || common.isOpenBSD)
|
||||
title += ` (${path.basename(process.execPath)})`;
|
||||
|
||||
// omitting trailing whitespace and \n
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
'use strict';
|
||||
require('../common');
|
||||
const common = require('../common');
|
||||
const assert = require('assert');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
@ -189,7 +189,10 @@ try {
|
|||
require(`${loadOrder}file3`);
|
||||
} catch (e) {
|
||||
// Not a real .node module, but we know we require'd the right thing.
|
||||
assert.ok(/file3\.node/.test(e.message.replace(backslash, '/')));
|
||||
if (common.isOpenBSD) // OpenBSD errors with non-ELF object error
|
||||
assert.ok(/File not an ELF object/.test(e.message.replace(backslash, '/')));
|
||||
else
|
||||
assert.ok(/file3\.node/.test(e.message.replace(backslash, '/')));
|
||||
}
|
||||
assert.strictEqual(require(`${loadOrder}file4`).file4, 'file4.reg', msg);
|
||||
assert.strictEqual(require(`${loadOrder}file5`).file5, 'file5.reg2', msg);
|
||||
|
@ -197,7 +200,10 @@ try {
|
|||
try {
|
||||
require(`${loadOrder}file7`);
|
||||
} catch (e) {
|
||||
assert.ok(/file7\/index\.node/.test(e.message.replace(backslash, '/')));
|
||||
if (common.isOpenBSD)
|
||||
assert.ok(/File not an ELF object/.test(e.message.replace(backslash, '/')));
|
||||
else
|
||||
assert.ok(/file7\/index\.node/.test(e.message.replace(backslash, '/')));
|
||||
}
|
||||
assert.strictEqual(require(`${loadOrder}file8`).file8, 'file8/index.reg',
|
||||
msg);
|
||||
|
|
Loading…
Reference in New Issue