From fff52eb4de4bc5cdafee5c795689c6466dbaf32e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Tue, 9 Apr 2024 08:26:41 +0200 Subject: [PATCH 1/2] test: simplify ASan build checks Always use `process.config.variables.asan`. This removes the need for a special ASAN env var. --- .github/workflows/test-asan.yml | 1 - test/common/index.js | 2 +- test/parallel/test-crypto-dh-leak.js | 4 ++-- test/parallel/test-crypto-secure-heap.js | 4 ++-- test/parallel/test-v8-serialize-leak.js | 4 ++-- test/pummel/test-vm-memleak.js | 4 ++-- tools/test.py | 7 ++++--- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/test-asan.yml b/.github/workflows/test-asan.yml index 26284547f5bd10..495f6679d950d5 100644 --- a/.github/workflows/test-asan.yml +++ b/.github/workflows/test-asan.yml @@ -45,7 +45,6 @@ jobs: CXX: clang++ LINK: clang++ CONFIG_FLAGS: --enable-asan - ASAN: true steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 with: diff --git a/test/common/index.js b/test/common/index.js index 74e583603fda3b..7c2d5646f37fad 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -128,7 +128,7 @@ const isFreeBSD = process.platform === 'freebsd'; const isOpenBSD = process.platform === 'openbsd'; const isLinux = process.platform === 'linux'; const isOSX = process.platform === 'darwin'; -const isAsan = process.env.ASAN !== undefined; +const isAsan = process.config.variables.asan === 1; const isPi = (() => { try { // Normal Raspberry Pi detection is to find the `Raspberry Pi` string in diff --git a/test/parallel/test-crypto-dh-leak.js b/test/parallel/test-crypto-dh-leak.js index 920cfd766dc9b1..b84ad7c432a8f2 100644 --- a/test/parallel/test-crypto-dh-leak.js +++ b/test/parallel/test-crypto-dh-leak.js @@ -4,8 +4,8 @@ const common = require('../common'); if (!common.hasCrypto) common.skip('missing crypto'); -if (process.config.variables.asan) - common.skip('ASAN messes with memory measurements'); +if (common.isAsan) + common.skip('ASan messes with memory measurements'); const assert = require('assert'); const crypto = require('crypto'); diff --git a/test/parallel/test-crypto-secure-heap.js b/test/parallel/test-crypto-secure-heap.js index fd6a90658d129d..208bc158b79919 100644 --- a/test/parallel/test-crypto-secure-heap.js +++ b/test/parallel/test-crypto-secure-heap.js @@ -7,8 +7,8 @@ if (!common.hasCrypto) if (common.isWindows) common.skip('Not supported on Windows'); -if (process.config.variables.asan) - common.skip('ASAN does not play well with secure heap allocations'); +if (common.isAsan) + common.skip('ASan does not play well with secure heap allocations'); const assert = require('assert'); const { fork } = require('child_process'); diff --git a/test/parallel/test-v8-serialize-leak.js b/test/parallel/test-v8-serialize-leak.js index 89b36c4a248dd4..eccc3e8f4b1f68 100644 --- a/test/parallel/test-v8-serialize-leak.js +++ b/test/parallel/test-v8-serialize-leak.js @@ -18,8 +18,8 @@ for (let i = 0; i < 1000000; i++) { async function main() { await common.gcUntil('RSS should go down', () => { const after = process.memoryUsage.rss(); - if (process.config.variables.asan) { - console.log(`asan: before=${before} after=${after}`); + if (common.isAsan) { + console.log(`ASan: before=${before} after=${after}`); return after < before * 10; } else if (process.config.variables.node_builtin_modules_path) { console.log(`node_builtin_modules_path: before=${before} after=${after}`); diff --git a/test/pummel/test-vm-memleak.js b/test/pummel/test-vm-memleak.js index be29dfe867f293..b11c2aea1939ec 100644 --- a/test/pummel/test-vm-memleak.js +++ b/test/pummel/test-vm-memleak.js @@ -24,8 +24,8 @@ const common = require('../common'); -if (process.config.variables.asan) { - common.skip('ASAN messes with memory measurements'); +if (common.isAsan) { + common.skip('ASan messes with memory measurements'); } const assert = require('assert'); diff --git a/tools/test.py b/tools/test.py index 5a2bcb3b6d92ca..13ea6d12082bfc 100755 --- a/tools/test.py +++ b/tools/test.py @@ -1588,8 +1588,9 @@ def get_env_type(vm, options_type, context): return env_type -def get_asan_state(): - return "on" if os.environ.get('ASAN') is not None else "off" +def get_asan_state(vm, context): + asan = Execute([vm, '-p', 'process.config.variables.asan'], context).stdout + return "on" if asan == "1" else "off" def Main(): @@ -1684,7 +1685,7 @@ def Main(): 'system': utils.GuessOS(), 'arch': vmArch, 'type': get_env_type(vm, options.type, context), - 'asan': get_asan_state(), + 'asan': get_asan_state(vm, context), } test_list = root.ListTests([], path, context, arch, mode) unclassified_tests += test_list From bb7f700078edab317e2cc50f24293eb5903c85f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Tue, 9 Apr 2024 11:32:39 +0200 Subject: [PATCH 2/2] fixup! test: simplify ASan build checks isASan --- test/common/index.js | 4 ++-- test/parallel/test-crypto-dh-leak.js | 2 +- test/parallel/test-crypto-secure-heap.js | 2 +- test/parallel/test-strace-openat-openssl.js | 2 +- test/parallel/test-v8-serialize-leak.js | 2 +- test/pummel/test-vm-memleak.js | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/test/common/index.js b/test/common/index.js index 7c2d5646f37fad..d4dd021ec27e26 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -128,7 +128,7 @@ const isFreeBSD = process.platform === 'freebsd'; const isOpenBSD = process.platform === 'openbsd'; const isLinux = process.platform === 'linux'; const isOSX = process.platform === 'darwin'; -const isAsan = process.config.variables.asan === 1; +const isASan = process.config.variables.asan === 1; const isPi = (() => { try { // Normal Raspberry Pi detection is to find the `Raspberry Pi` string in @@ -965,7 +965,7 @@ const common = { hasMultiLocalhost, invalidArgTypeHelper, isAlive, - isAsan, + isASan, isDumbTerminal, isFreeBSD, isLinux, diff --git a/test/parallel/test-crypto-dh-leak.js b/test/parallel/test-crypto-dh-leak.js index b84ad7c432a8f2..1998d61d4affd7 100644 --- a/test/parallel/test-crypto-dh-leak.js +++ b/test/parallel/test-crypto-dh-leak.js @@ -4,7 +4,7 @@ const common = require('../common'); if (!common.hasCrypto) common.skip('missing crypto'); -if (common.isAsan) +if (common.isASan) common.skip('ASan messes with memory measurements'); const assert = require('assert'); diff --git a/test/parallel/test-crypto-secure-heap.js b/test/parallel/test-crypto-secure-heap.js index 208bc158b79919..0e5788f00e4a44 100644 --- a/test/parallel/test-crypto-secure-heap.js +++ b/test/parallel/test-crypto-secure-heap.js @@ -7,7 +7,7 @@ if (!common.hasCrypto) if (common.isWindows) common.skip('Not supported on Windows'); -if (common.isAsan) +if (common.isASan) common.skip('ASan does not play well with secure heap allocations'); const assert = require('assert'); diff --git a/test/parallel/test-strace-openat-openssl.js b/test/parallel/test-strace-openat-openssl.js index f5202eea8a7b24..13882e67aec0f2 100644 --- a/test/parallel/test-strace-openat-openssl.js +++ b/test/parallel/test-strace-openat-openssl.js @@ -9,7 +9,7 @@ if (!common.hasCrypto) common.skip('missing crypto'); if (!common.isLinux) common.skip('linux only'); -if (common.isAsan) +if (common.isASan) common.skip('strace does not work well with address sanitizer builds'); if (spawnSync('strace').error !== undefined) { common.skip('missing strace'); diff --git a/test/parallel/test-v8-serialize-leak.js b/test/parallel/test-v8-serialize-leak.js index eccc3e8f4b1f68..ce0a06196e9fb1 100644 --- a/test/parallel/test-v8-serialize-leak.js +++ b/test/parallel/test-v8-serialize-leak.js @@ -18,7 +18,7 @@ for (let i = 0; i < 1000000; i++) { async function main() { await common.gcUntil('RSS should go down', () => { const after = process.memoryUsage.rss(); - if (common.isAsan) { + if (common.isASan) { console.log(`ASan: before=${before} after=${after}`); return after < before * 10; } else if (process.config.variables.node_builtin_modules_path) { diff --git a/test/pummel/test-vm-memleak.js b/test/pummel/test-vm-memleak.js index b11c2aea1939ec..179dc3e5705c2e 100644 --- a/test/pummel/test-vm-memleak.js +++ b/test/pummel/test-vm-memleak.js @@ -24,7 +24,7 @@ const common = require('../common'); -if (common.isAsan) { +if (common.isASan) { common.skip('ASan messes with memory measurements'); }