Skip to content

Commit 5b758b9

Browse files
targosmarco-ippolito
authored andcommittedMay 3, 2024
test: simplify ASan build checks
Always use `process.config.variables.asan`. This removes the need for a special ASAN env var. PR-URL: #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>
1 parent 17d5ba9 commit 5b758b9

File tree

8 files changed

+15
-15
lines changed

8 files changed

+15
-15
lines changed
 

‎.github/workflows/test-asan.yml

-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ jobs:
4545
CXX: clang++
4646
LINK: clang++
4747
CONFIG_FLAGS: --enable-asan
48-
ASAN: true
4948
steps:
5049
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
5150
with:

‎test/common/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ const isFreeBSD = process.platform === 'freebsd';
128128
const isOpenBSD = process.platform === 'openbsd';
129129
const isLinux = process.platform === 'linux';
130130
const isOSX = process.platform === 'darwin';
131-
const isAsan = process.env.ASAN !== undefined;
131+
const isASan = process.config.variables.asan === 1;
132132
const isPi = (() => {
133133
try {
134134
// Normal Raspberry Pi detection is to find the `Raspberry Pi` string in
@@ -960,7 +960,7 @@ const common = {
960960
hasMultiLocalhost,
961961
invalidArgTypeHelper,
962962
isAlive,
963-
isAsan,
963+
isASan,
964964
isDumbTerminal,
965965
isFreeBSD,
966966
isLinux,

‎test/parallel/test-crypto-dh-leak.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
const common = require('../common');
55
if (!common.hasCrypto)
66
common.skip('missing crypto');
7-
if (process.config.variables.asan)
8-
common.skip('ASAN messes with memory measurements');
7+
if (common.isASan)
8+
common.skip('ASan messes with memory measurements');
99

1010
const assert = require('assert');
1111
const crypto = require('crypto');

‎test/parallel/test-crypto-secure-heap.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ if (!common.hasCrypto)
77
if (common.isWindows)
88
common.skip('Not supported on Windows');
99

10-
if (process.config.variables.asan)
11-
common.skip('ASAN does not play well with secure heap allocations');
10+
if (common.isASan)
11+
common.skip('ASan does not play well with secure heap allocations');
1212

1313
const assert = require('assert');
1414
const { fork } = require('child_process');

‎test/parallel/test-strace-openat-openssl.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ if (!common.hasCrypto)
99
common.skip('missing crypto');
1010
if (!common.isLinux)
1111
common.skip('linux only');
12-
if (common.isAsan)
12+
if (common.isASan)
1313
common.skip('strace does not work well with address sanitizer builds');
1414
if (spawnSync('strace').error !== undefined) {
1515
common.skip('missing strace');

‎test/parallel/test-v8-serialize-leak.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ for (let i = 0; i < 1000000; i++) {
1818
async function main() {
1919
await common.gcUntil('RSS should go down', () => {
2020
const after = process.memoryUsage.rss();
21-
if (process.config.variables.asan) {
22-
console.log(`asan: before=${before} after=${after}`);
21+
if (common.isASan) {
22+
console.log(`ASan: before=${before} after=${after}`);
2323
return after < before * 10;
2424
} else if (process.config.variables.node_builtin_modules_path) {
2525
console.log(`node_builtin_modules_path: before=${before} after=${after}`);

‎test/pummel/test-vm-memleak.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424

2525
const common = require('../common');
2626

27-
if (process.config.variables.asan) {
28-
common.skip('ASAN messes with memory measurements');
27+
if (common.isASan) {
28+
common.skip('ASan messes with memory measurements');
2929
}
3030

3131
const assert = require('assert');

‎tools/test.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1588,8 +1588,9 @@ def get_env_type(vm, options_type, context):
15881588
return env_type
15891589

15901590

1591-
def get_asan_state():
1592-
return "on" if os.environ.get('ASAN') is not None else "off"
1591+
def get_asan_state(vm, context):
1592+
asan = Execute([vm, '-p', 'process.config.variables.asan'], context).stdout
1593+
return "on" if asan == "1" else "off"
15931594

15941595

15951596
def Main():
@@ -1684,7 +1685,7 @@ def Main():
16841685
'system': utils.GuessOS(),
16851686
'arch': vmArch,
16861687
'type': get_env_type(vm, options.type, context),
1687-
'asan': get_asan_state(),
1688+
'asan': get_asan_state(vm, context),
16881689
}
16891690
test_list = root.ListTests([], path, context, arch, mode)
16901691
unclassified_tests += test_list

0 commit comments

Comments
 (0)
Please sign in to comment.