From de0939cfb7ec18d0cf7b0c25304ea8ef7ef73f3f Mon Sep 17 00:00:00 2001 From: Richard Lau Date: Thu, 28 Sep 2023 13:51:44 +0100 Subject: [PATCH] test: disambiguate AIX and IBM i When built with Python 3.9 on IBM i, `process.platform` will return `os400` instead of `aix`. In preparation for this, make `common.isAIX` only return true for AIX and update the tests to add checks for `common.isIBMi` where they were missing. PR-URL: https://github.com/nodejs/node/pull/48056 Refs: https://github.com/nodejs/node/pull/46739 Refs: https://github.com/nodejs/build/pull/3358 Reviewed-By: Moshe Atlow Reviewed-By: Michael Dawson Reviewed-By: Luigi Pinca --- test/abort/test-addon-uv-handle-leak.js | 1 + test/common/index.js | 9 ++++++--- test/known_issues/test-cwd-enoent-file.js | 2 +- test/parallel/test-cwd-enoent-preload.js | 2 +- test/parallel/test-cwd-enoent-repl.js | 2 +- test/parallel/test-cwd-enoent.js | 2 +- test/parallel/test-fs-readfile-pipe-large.js | 2 +- test/parallel/test-fs-readfile-pipe.js | 2 +- test/parallel/test-fs-readfilesync-pipe-large.js | 2 +- test/parallel/test-fs-realpath-pipe.js | 2 +- test/parallel/test-fs-utimes.js | 2 +- test/parallel/test-os.js | 13 ++++++++----- .../test-process-dlopen-error-message-crash.js | 2 +- 13 files changed, 25 insertions(+), 18 deletions(-) diff --git a/test/abort/test-addon-uv-handle-leak.js b/test/abort/test-addon-uv-handle-leak.js index e494b12f2de558..d2c4f8e646f457 100644 --- a/test/abort/test-addon-uv-handle-leak.js +++ b/test/abort/test-addon-uv-handle-leak.js @@ -78,6 +78,7 @@ if (process.argv[2] === 'child') { if (!(common.isFreeBSD || common.isAIX || + common.isIBMi || (common.isLinux && !isGlibc()) || common.isWindows)) { assert(stderr.includes('ExampleOwnerClass'), stderr); diff --git a/test/common/index.js b/test/common/index.js index 9d8accf939a1ff..cdb14b3c70cc30 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -123,7 +123,6 @@ if (process.argv.length === 2 && } const isWindows = process.platform === 'win32'; -const isAIX = process.platform === 'aix'; const isSunOS = process.platform === 'sunos'; const isFreeBSD = process.platform === 'freebsd'; const isOpenBSD = process.platform === 'openbsd'; @@ -274,7 +273,7 @@ function platformTimeout(ms) { if (process.features.debug) ms = multipliers.two * ms; - if (isAIX) + if (exports.isAIX || exports.isIBMi) return multipliers.two * ms; // Default localhost speed is slower on AIX if (isPi) @@ -928,7 +927,6 @@ const common = { hasQuic, hasMultiLocalhost, invalidArgTypeHelper, - isAIX, isAlive, isAsan, isDumbTerminal, @@ -999,7 +997,12 @@ const common = { }, // On IBMi, process.platform and os.platform() both return 'aix', + // when built with Python versions earlier than 3.9. // It is not enough to differentiate between IBMi and real AIX system. + get isAIX() { + return require('os').type() === 'AIX'; + }, + get isIBMi() { return require('os').type() === 'OS400'; }, diff --git a/test/known_issues/test-cwd-enoent-file.js b/test/known_issues/test-cwd-enoent-file.js index 0f75896134f7e3..6d99987895baf4 100644 --- a/test/known_issues/test-cwd-enoent-file.js +++ b/test/known_issues/test-cwd-enoent-file.js @@ -5,7 +5,7 @@ const common = require('../common'); const assert = require('assert'); -if (common.isSunOS || common.isWindows || common.isAIX) { +if (common.isSunOS || common.isWindows || common.isAIX || common.isIBMi) { // The current working directory cannot be removed on these platforms. // Change this to common.skip() when this is no longer a known issue test. assert.fail('cannot rmdir current working directory'); diff --git a/test/parallel/test-cwd-enoent-preload.js b/test/parallel/test-cwd-enoent-preload.js index 2077d9c1478335..21b20d6d035672 100644 --- a/test/parallel/test-cwd-enoent-preload.js +++ b/test/parallel/test-cwd-enoent-preload.js @@ -1,7 +1,7 @@ 'use strict'; const common = require('../common'); // Fails with EINVAL on SmartOS, EBUSY on Windows, EBUSY on AIX. -if (common.isSunOS || common.isWindows || common.isAIX) +if (common.isSunOS || common.isWindows || common.isAIX || common.isIBMi) common.skip('cannot rmdir current working directory'); if (!common.isMainThread) common.skip('process.chdir is not available in Workers'); diff --git a/test/parallel/test-cwd-enoent-repl.js b/test/parallel/test-cwd-enoent-repl.js index 5ea8abc7e42b52..0a61cbfbced9b4 100644 --- a/test/parallel/test-cwd-enoent-repl.js +++ b/test/parallel/test-cwd-enoent-repl.js @@ -1,7 +1,7 @@ 'use strict'; const common = require('../common'); // Fails with EINVAL on SmartOS, EBUSY on Windows, EBUSY on AIX. -if (common.isSunOS || common.isWindows || common.isAIX) +if (common.isSunOS || common.isWindows || common.isAIX || common.isIBMi) common.skip('cannot rmdir current working directory'); if (!common.isMainThread) common.skip('process.chdir is not available in Workers'); diff --git a/test/parallel/test-cwd-enoent.js b/test/parallel/test-cwd-enoent.js index 8beb1e3fbe0a05..876888bc2be518 100644 --- a/test/parallel/test-cwd-enoent.js +++ b/test/parallel/test-cwd-enoent.js @@ -1,7 +1,7 @@ 'use strict'; const common = require('../common'); // Fails with EINVAL on SmartOS, EBUSY on Windows, EBUSY on AIX. -if (common.isSunOS || common.isWindows || common.isAIX) +if (common.isSunOS || common.isWindows || common.isAIX || common.isIBMi) common.skip('cannot rmdir current working directory'); if (!common.isMainThread) common.skip('process.chdir is not available in Workers'); diff --git a/test/parallel/test-fs-readfile-pipe-large.js b/test/parallel/test-fs-readfile-pipe-large.js index 1a685ebc612b85..4376774bb411d6 100644 --- a/test/parallel/test-fs-readfile-pipe-large.js +++ b/test/parallel/test-fs-readfile-pipe-large.js @@ -3,7 +3,7 @@ const common = require('../common'); // Simulate `cat readfile.js | node readfile.js` -if (common.isWindows || common.isAIX) +if (common.isWindows || common.isAIX || common.isIBMi) common.skip(`No /dev/stdin on ${process.platform}.`); const assert = require('assert'); diff --git a/test/parallel/test-fs-readfile-pipe.js b/test/parallel/test-fs-readfile-pipe.js index 0cffbd0f5aa162..79d5699fef64a4 100644 --- a/test/parallel/test-fs-readfile-pipe.js +++ b/test/parallel/test-fs-readfile-pipe.js @@ -24,7 +24,7 @@ const common = require('../common'); // Simulate `cat readfile.js | node readfile.js` -if (common.isWindows || common.isAIX) +if (common.isWindows || common.isAIX || common.isIBMi) common.skip(`No /dev/stdin on ${process.platform}.`); const assert = require('assert'); diff --git a/test/parallel/test-fs-readfilesync-pipe-large.js b/test/parallel/test-fs-readfilesync-pipe-large.js index 2cb857a329fbee..5450337c4f680a 100644 --- a/test/parallel/test-fs-readfilesync-pipe-large.js +++ b/test/parallel/test-fs-readfilesync-pipe-large.js @@ -3,7 +3,7 @@ const common = require('../common'); // Simulate `cat readfile.js | node readfile.js` -if (common.isWindows || common.isAIX) +if (common.isWindows || common.isAIX || common.isIBMi) common.skip(`No /dev/stdin on ${process.platform}.`); const assert = require('assert'); diff --git a/test/parallel/test-fs-realpath-pipe.js b/test/parallel/test-fs-realpath-pipe.js index 29fe1d3b7d28e1..f637642ca21d67 100644 --- a/test/parallel/test-fs-realpath-pipe.js +++ b/test/parallel/test-fs-realpath-pipe.js @@ -2,7 +2,7 @@ const common = require('../common'); -if (common.isWindows || common.isAIX) +if (common.isWindows || common.isAIX || common.isIBMi) common.skip(`No /dev/stdin on ${process.platform}.`); const assert = require('assert'); diff --git a/test/parallel/test-fs-utimes.js b/test/parallel/test-fs-utimes.js index 8f8286f8a3343f..e6ae75d4e33a5f 100644 --- a/test/parallel/test-fs-utimes.js +++ b/test/parallel/test-fs-utimes.js @@ -39,7 +39,7 @@ function stat_resource(resource, statSync = fs.statSync) { const stats = fs.fstatSync(resource); // Ensure mtime has been written to disk // except for directories on AIX where it cannot be synced - if (common.isAIX && stats.isDirectory()) + if ((common.isAIX || common.isIBMi) && stats.isDirectory()) return stats; fs.fsyncSync(resource); return fs.fstatSync(resource); diff --git a/test/parallel/test-os.js b/test/parallel/test-os.js index d82f2ece3159a6..f7059260ce507e 100644 --- a/test/parallel/test-os.js +++ b/test/parallel/test-os.js @@ -81,11 +81,14 @@ const hostname = os.hostname(); is.string(hostname); assert.ok(hostname.length > 0); -const DUMMY_PRIORITY = 10; -os.setPriority(DUMMY_PRIORITY); -const priority = os.getPriority(); -is.number(priority); -assert.strictEqual(priority, DUMMY_PRIORITY); +// IBMi process priority is different. +if (!common.isIBMi) { + const DUMMY_PRIORITY = 10; + os.setPriority(DUMMY_PRIORITY); + const priority = os.getPriority(); + is.number(priority); + assert.strictEqual(priority, DUMMY_PRIORITY); +} // On IBMi, os.uptime() returns 'undefined' if (!common.isIBMi) { diff --git a/test/parallel/test-process-dlopen-error-message-crash.js b/test/parallel/test-process-dlopen-error-message-crash.js index d678021764e8f4..de8b3033195a46 100644 --- a/test/parallel/test-process-dlopen-error-message-crash.js +++ b/test/parallel/test-process-dlopen-error-message-crash.js @@ -17,7 +17,7 @@ assert.throws(() => { }, ({ name, code, message }) => { assert.strictEqual(name, 'Error'); assert.strictEqual(code, 'ERR_DLOPEN_FAILED'); - if (!common.isAIX) { + if (!common.isAIX && !common.isIBMi) { assert.match(message, /foo-%s\.node/); } return true;