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 <luigipinca@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
abmusse authored and targos committed Nov 10, 2023
1 parent bcf97ab commit cb6ef74
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 @@ -948,7 +948,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 @@ -282,6 +282,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 cb6ef74

Please sign in to comment.