Skip to content

Commit d799b1c

Browse files
qbitMylesBorins
authored andcommittedApr 13, 2018
test: update a few tests to work on OpenBSD
PR-URL: #18543 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 77a405b commit d799b1c

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed
 

‎test/common/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ exports.isLinuxPPCBE = (process.platform === 'linux') &&
2929
(os.endianness() === 'BE');
3030
exports.isSunOS = process.platform === 'sunos';
3131
exports.isFreeBSD = process.platform === 'freebsd';
32+
exports.isOpenBSD = process.platform === 'openbsd';
3233
exports.isLinux = process.platform === 'linux';
3334
exports.isOSX = process.platform === 'darwin';
3435

‎test/parallel/test-child-process-exec-timeout.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,22 @@ const cmd = `"${process.execPath}" "${__filename}" child`;
1616

1717
// Test the case where a timeout is set, and it expires.
1818
cp.exec(cmd, { timeout: 1 }, common.mustCall((err, stdout, stderr) => {
19+
let sigterm = 'SIGTERM';
1920
assert.strictEqual(err.killed, true);
20-
assert.strictEqual(err.code, null);
21+
// TODO OpenBSD returns a null signal and 143 for code
22+
if (common.isOpenBSD) {
23+
assert.strictEqual(err.code, 143);
24+
sigterm = null;
25+
} else {
26+
assert.strictEqual(err.code, null);
27+
}
2128
// At least starting with Darwin Kernel Version 16.4.0, sending a SIGTERM to a
2229
// process that is still starting up kills it with SIGKILL instead of SIGTERM.
2330
// See: https://github.com/libuv/libuv/issues/1226
2431
if (common.isOSX)
2532
assert.ok(err.signal === 'SIGTERM' || err.signal === 'SIGKILL');
2633
else
27-
assert.strictEqual(err.signal, 'SIGTERM');
34+
assert.strictEqual(err.signal, sigterm);
2835
assert.strictEqual(err.cmd, cmd);
2936
assert.strictEqual(stdout.trim(), '');
3037
assert.strictEqual(stderr.trim(), '');

‎test/parallel/test-net-dns-error.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,21 @@ const net = require('net');
66

77
const host = '*'.repeat(256);
88

9+
let errCode = 'ENOTFOUND';
10+
if (common.isOpenBSD)
11+
errCode = 'EAI_FAIL';
12+
913
function do_not_call() {
1014
throw new Error('This function should not have been called.');
1115
}
1216

1317
const socket = net.connect(42, host, do_not_call);
1418
socket.on('error', common.mustCall(function(err) {
15-
assert.strictEqual(err.code, 'ENOTFOUND');
19+
assert.strictEqual(err.code, errCode);
1620
}));
1721
socket.on('lookup', function(err, ip, type) {
1822
assert(err instanceof Error);
19-
assert.strictEqual(err.code, 'ENOTFOUND');
23+
assert.strictEqual(err.code, errCode);
2024
assert.strictEqual(ip, undefined);
2125
assert.strictEqual(type, undefined);
2226
});

‎test/parallel/test-setproctitle.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ exec(cmd, common.mustCall((error, stdout, stderr) => {
3030
assert.strictEqual(stderr, '');
3131

3232
// freebsd always add ' (procname)' to the process title
33-
if (common.isFreeBSD)
33+
if (common.isFreeBSD || common.isOpenBSD)
3434
title += ` (${path.basename(process.execPath)})`;
3535

3636
// omitting trailing whitespace and \n

0 commit comments

Comments
 (0)