Skip to content

Commit

Permalink
test: fix IPv6 checks on IBM i
Browse files Browse the repository at this point in the history
PR-URL: #46546
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
abmusse authored Feb 23, 2023
1 parent 9e06ef0 commit c2c61e0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
9 changes: 8 additions & 1 deletion test/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,14 @@ const common = {

get hasIPv6() {
const iFaces = require('os').networkInterfaces();
const re = isWindows ? /Loopback Pseudo-Interface/ : /lo/;
let re;
if (isWindows) {
re = /Loopback Pseudo-Interface/;
} else if (this.isIBMi) {
re = /\*LOOPBACK/;
} else {
re = /lo/;
}
return Object.keys(iFaces).some((name) => {
return re.test(name) &&
iFaces[name].some(({ family }) => family === 'IPv6');
Expand Down
4 changes: 4 additions & 0 deletions test/parallel/test-net-autoselectfamily.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ if (common.hasIPv6) {
assert.strictEqual(error.message, `connect ECONNREFUSED ::1:${port}`);
} else if (error.code === 'EAFNOSUPPORT') {
assert.strictEqual(error.message, `connect EAFNOSUPPORT ::1:${port} - Local (undefined:undefined)`);
} else if (common.isIBMi) {
// IBMi returns EUNATCH (ERRNO 42) when IPv6 is disabled
// keep this errno assertion until EUNATCH is recognized by libuv
assert.strictEqual(error.errno, -42);
} else {
assert.strictEqual(error.code, 'EADDRNOTAVAIL');
assert.strictEqual(error.message, `connect EADDRNOTAVAIL ::1:${port} - Local (:::0)`);
Expand Down
4 changes: 4 additions & 0 deletions test/parallel/test-net-autoselectfamilydefault.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ function createDnsServer(ipv6Addr, ipv4Addr, cb) {
assert.strictEqual(error.message, `connect ECONNREFUSED ::1:${port}`);
} else if (error.code === 'EAFNOSUPPORT') {
assert.strictEqual(error.message, `connect EAFNOSUPPORT ::1:${port} - Local (undefined:undefined)`);
} else if (common.isIBMi) {
// IBMi returns EUNATCH (ERRNO 42) when IPv6 is disabled
// keep this errno assertion until EUNATCH is recognized by libuv
assert.strictEqual(error.errno, -42);
} else {
assert.strictEqual(error.code, 'EADDRNOTAVAIL');
assert.strictEqual(error.message, `connect EADDRNOTAVAIL ::1:${port} - Local (:::0)`);
Expand Down

0 comments on commit c2c61e0

Please sign in to comment.