diff --git a/test/abort/test-addon-uv-handle-leak.js b/test/abort/test-addon-uv-handle-leak.js index 3944cb79c78494..96608f8dda95fd 100644 --- a/test/abort/test-addon-uv-handle-leak.js +++ b/test/abort/test-addon-uv-handle-leak.js @@ -6,6 +6,7 @@ const fs = require('fs'); const path = require('path'); const cp = require('child_process'); const { Worker } = require('worker_threads'); +const { spawnSync } = require('child_process'); // This is a sibling test to test/addons/uv-handle-leak. @@ -49,9 +50,25 @@ if (process.argv[2] === 'child') { // Close callback: 0x7f2df31de220 CloseCallback(uv_handle_s*) [...] // Data: 0x42 + function isGlibc() { + try { + const lddOut = spawnSync('ldd', [process.execPath]).stdout; + const libcInfo = lddOut.toString().split('\n').map( + (line) => line.match(/libc\.so.+=>\s*(\S+)\s/)).filter((info) => info); + if (libcInfo.length === 0) + return false; + const nmOut = spawnSync('nm', ['-D', libcInfo[0][1]]).stdout; + if (/gnu_get_libc_version/.test(nmOut)) + return true; + } catch { + return false; + } + } + + if (!(common.isFreeBSD || common.isAIX || - (common.isLinux && !common.isGlibc()) || + (common.isLinux && !isGlibc()) || common.isWindows)) { assert(stderr.includes('ExampleOwnerClass'), stderr); assert(stderr.includes('CloseCallback'), stderr); diff --git a/test/common/index.js b/test/common/index.js index 742a78e3679917..8254f541016505 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -66,23 +66,6 @@ exports.isOpenBSD = process.platform === 'openbsd'; exports.isLinux = process.platform === 'linux'; exports.isOSX = process.platform === 'darwin'; -let isGlibc; -exports.isGlibc = () => { - if (isGlibc !== undefined) - return isGlibc; - try { - const lddOut = spawnSync('ldd', [process.execPath]).stdout; - const libcInfo = lddOut.toString().split('\n').map( - (line) => line.match(/libc\.so.+=>\s*(\S+)\s/)).filter((info) => info); - if (libcInfo.length === 0) - return isGlibc = false; - const nmOut = spawnSync('nm', ['-D', libcInfo[0][1]]).stdout; - if (/gnu_get_libc_version/.test(nmOut)) - return isGlibc = true; - } catch {} - return isGlibc = false; -}; - exports.enoughTestMem = os.totalmem() > 0x70000000; /* 1.75 Gb */ const cpus = os.cpus(); exports.enoughTestCpu = Array.isArray(cpus) && diff --git a/test/common/index.mjs b/test/common/index.mjs index 74194975f1fc26..3ad51d4cae7e0e 100644 --- a/test/common/index.mjs +++ b/test/common/index.mjs @@ -13,7 +13,6 @@ const { isOpenBSD, isLinux, isOSX, - isGlibc, enoughTestMem, enoughTestCpu, rootDir, @@ -71,7 +70,6 @@ export { isOpenBSD, isLinux, isOSX, - isGlibc, enoughTestMem, enoughTestCpu, rootDir,