From b6832d2fab3c8133ecbbf10bc077e1e718705851 Mon Sep 17 00:00:00 2001 From: Sergey Chernyshev Date: Thu, 25 Apr 2024 01:51:42 +0200 Subject: [PATCH] test: fix IPv6 checks on IBM i PR-URL: https://github.com/nodejs/node/pull/46546 Reviewed-By: Luigi Pinca Reviewed-By: Richard Lau Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- graal-nodejs/test/common/index.js | 9 ++++++++- graal-nodejs/test/parallel/test-net-autoselectfamily.js | 4 ++++ .../test/parallel/test-net-autoselectfamilydefault.js | 4 ++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/graal-nodejs/test/common/index.js b/graal-nodejs/test/common/index.js index f456ba50124..d07eb99a46b 100644 --- a/graal-nodejs/test/common/index.js +++ b/graal-nodejs/test/common/index.js @@ -949,7 +949,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'); diff --git a/graal-nodejs/test/parallel/test-net-autoselectfamily.js b/graal-nodejs/test/parallel/test-net-autoselectfamily.js index 6990b57652f..904b795f927 100644 --- a/graal-nodejs/test/parallel/test-net-autoselectfamily.js +++ b/graal-nodejs/test/parallel/test-net-autoselectfamily.js @@ -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)`); diff --git a/graal-nodejs/test/parallel/test-net-autoselectfamilydefault.js b/graal-nodejs/test/parallel/test-net-autoselectfamilydefault.js index a3faa9c3c1e..be110a836a0 100644 --- a/graal-nodejs/test/parallel/test-net-autoselectfamilydefault.js +++ b/graal-nodejs/test/parallel/test-net-autoselectfamilydefault.js @@ -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)`);