Skip to content

Commit 455dc60

Browse files
committed
test: update a few test scripts to work on OpenBSD
1 parent 13192a9 commit 455dc60

7 files changed

+27
-10
lines changed

test/common/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ exports.isLinuxPPCBE = (process.platform === 'linux') &&
5555
(os.endianness() === 'BE');
5656
exports.isSunOS = process.platform === 'sunos';
5757
exports.isFreeBSD = process.platform === 'freebsd';
58+
exports.isOpenBSD = process.platform === 'openbsd';
5859
exports.isLinux = process.platform === 'linux';
5960
exports.isOSX = process.platform === 'darwin';
6061

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,18 @@ const cmd = `"${process.execPath}" "${__filename}" child`;
1717
// Test the case where a timeout is set, and it expires.
1818
cp.exec(cmd, { timeout: 1 }, common.mustCall((err, stdout, stderr) => {
1919
assert.strictEqual(err.killed, true);
20-
assert.strictEqual(err.code, null);
20+
// TODO OpenBSD returns a null code
21+
if (!common.isOpenBSD)
22+
assert.strictEqual(err.code, null);
23+
else
24+
sigterm = null;
2125
// At least starting with Darwin Kernel Version 16.4.0, sending a SIGTERM to a
2226
// process that is still starting up kills it with SIGKILL instead of SIGTERM.
2327
// See: https://github.com/libuv/libuv/issues/1226
2428
if (common.isOSX)
2529
assert.ok(err.signal === 'SIGTERM' || err.signal === 'SIGKILL');
2630
else
27-
assert.strictEqual(err.signal, 'SIGTERM');
31+
assert.strictEqual(err.signal, sigterm);
2832
assert.strictEqual(err.cmd, cmd);
2933
assert.strictEqual(stdout.trim(), '');
3034
assert.strictEqual(stderr.trim(), '');

test/parallel/test-child-process-spawnsync-validation-errors.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,17 @@ const spawnSync = require('child_process').spawnSync;
55
const signals = process.binding('constants').os.signals;
66

77
let invalidArgTypeError;
8+
let errCode = 56;
9+
if (common.isOpenBSD)
10+
errCode = 46;
811

912
if (common.isWindows) {
1013
invalidArgTypeError =
1114
common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError }, 36);
1215
} else {
1316
invalidArgTypeError =
14-
common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError }, 56);
17+
common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError },
18+
errCode);
1519
}
1620

1721
const invalidRangeError =

test/parallel/test-fs-utimes.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,8 @@ process.on('exit', function() {
178178
const path = `${tmpdir.path}/test-utimes-precision`;
179179
fs.writeFileSync(path, '');
180180

181-
// test Y2K38 for all platforms [except 'arm', and 'SunOS']
182-
if (!process.arch.includes('arm') && !common.isSunOS) {
181+
// test Y2K38 for all platforms [except 'arm', 'OpenBSD' and 'SunOS']
182+
if (!process.arch.includes('arm') && !common.isOpenBSD && !common.isSunOS) {
183183
// because 2 ** 31 doesn't look right
184184
// eslint-disable-next-line space-infix-ops
185185
const Y2K38_mtime = 2**31;

test/parallel/test-http-dns-error.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ const https = require('https');
3232
const host = '*'.repeat(256);
3333
const MAX_TRIES = 5;
3434

35+
let errCode = 'ENOTFOUND';
36+
if (common.isOpenBSD)
37+
errCode = 'EAI_FAIL';
38+
3539
function tryGet(mod, tries) {
3640
// Bad host name should not throw an uncatchable exception.
3741
// Ensure that there is time to attach an error listener.
@@ -41,7 +45,7 @@ function tryGet(mod, tries) {
4145
tryGet(mod, ++tries);
4246
return;
4347
}
44-
assert.strictEqual(err.code, 'ENOTFOUND');
48+
assert.strictEqual(err.code, errCode);
4549
}));
4650
// http.get() called req1.end() for us
4751
}
@@ -57,7 +61,7 @@ function tryRequest(mod, tries) {
5761
tryRequest(mod, ++tries);
5862
return;
5963
}
60-
assert.strictEqual(err.code, 'ENOTFOUND');
64+
assert.strictEqual(err.code, errCode);
6165
}));
6266
req.end();
6367
}

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,21 @@ const net = require('net');
2727

2828
const host = '*'.repeat(256);
2929

30+
let errCode = 'ENOTFOUND';
31+
if (common.isOpenBSD)
32+
errCode = 'EAI_FAIL';
33+
3034
function do_not_call() {
3135
throw new Error('This function should not have been called.');
3236
}
3337

3438
const socket = net.connect(42, host, do_not_call);
3539
socket.on('error', common.mustCall(function(err) {
36-
assert.strictEqual(err.code, 'ENOTFOUND');
40+
assert.strictEqual(err.code, errCode);
3741
}));
3842
socket.on('lookup', function(err, ip, type) {
3943
assert(err instanceof Error);
40-
assert.strictEqual(err.code, 'ENOTFOUND');
44+
assert.strictEqual(err.code, errCode);
4145
assert.strictEqual(ip, undefined);
4246
assert.strictEqual(type, undefined);
4347
});

test/parallel/test-setproctitle.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ exec(cmd, common.mustCall((error, stdout, stderr) => {
3434
assert.strictEqual(stderr, '');
3535

3636
// freebsd always add ' (procname)' to the process title
37-
if (common.isFreeBSD)
37+
if (common.isFreeBSD || common.isOpenBSD)
3838
title += ` (${path.basename(process.execPath)})`;
3939

4040
// omitting trailing whitespace and \n

0 commit comments

Comments
 (0)