Skip to content

Commit

Permalink
test: update a few tests to work on OpenBSD
Browse files Browse the repository at this point in the history
PR-URL: #18543
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
qbit authored and MylesBorins committed Apr 13, 2018
1 parent 77a405b commit d799b1c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
1 change: 1 addition & 0 deletions test/common/index.js
Expand Up @@ -29,6 +29,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';

Expand Down
11 changes: 9 additions & 2 deletions test/parallel/test-child-process-exec-timeout.js
Expand Up @@ -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(), '');
Expand Down
8 changes: 6 additions & 2 deletions test/parallel/test-net-dns-error.js
Expand Up @@ -6,17 +6,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);
});
2 changes: 1 addition & 1 deletion test/parallel/test-setproctitle.js
Expand Up @@ -30,7 +30,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
Expand Down

0 comments on commit d799b1c

Please sign in to comment.