test: simplify ASan build checks

Always use `process.config.variables.asan`.
This removes the need for a special ASAN env var.

PR-URL: https://github.com/nodejs/node/pull/52430
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
This commit is contained in:
Michaël Zasso 2024-04-11 09:29:27 +02:00 committed by GitHub
parent 52f8dcfccc
commit 05cb16dc1a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 15 additions and 15 deletions

View File

@ -45,7 +45,6 @@ jobs:
CXX: clang++
LINK: clang++
CONFIG_FLAGS: --enable-asan
ASAN: true
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:

View File

@ -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
@ -965,7 +965,7 @@ const common = {
hasMultiLocalhost,
invalidArgTypeHelper,
isAlive,
isAsan,
isASan,
isDumbTerminal,
isFreeBSD,
isLinux,

View File

@ -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');

View File

@ -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');

View File

@ -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');

View File

@ -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}`);

View File

@ -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');

View File

@ -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