selftests: respect ASAN_OPTIONS

Ensure that this environment variable is respected, as ASAN errors
(e.g. memory leaks) can cause the selftests to fail since they expect
no errors in their output.

Fix an incorrect function name in a comment, while we're at it.

Fixes: QTBUG-118041
Pick-to: 6.5
Change-Id: I07502101aabd8743df898ae8fe4a693c4733c4af
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
(cherry picked from commit 3f2b54f0a1749eb8a52e99dbba6af4839e36cb90)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Mitch Curtis 2023-10-12 16:05:28 +08:00 committed by Qt Cherry-pick Bot
parent 9f49af182f
commit 8f87e3f67b
2 changed files with 3 additions and 2 deletions

View File

@ -201,9 +201,9 @@ class Scanner (object):
del re
# Keep in sync with tst_selftests.cpp's processEnvironment():
# Keep in sync with tst_selftests.cpp's testEnvironment():
def baseEnv(platname=None,
keep=('PATH', 'QT_QPA_PLATFORM'),
keep=('PATH', 'QT_QPA_PLATFORM', 'ASAN_OPTIONS'),
posix=('HOME', 'USER', 'QEMU_SET_ENV', 'QEMU_LD_PREFIX'),
nonapple=('DISPLAY', 'XAUTHORITY', 'XAUTHLOCALHOSTNAME'), # and XDG_*
# Don't actually know how to test for QNX, so this is ignored:

View File

@ -929,6 +929,7 @@ static QProcessEnvironment testEnvironment()
const bool preserveLibPath = qEnvironmentVariableIsSet("QT_PRESERVE_TESTLIB_PATH");
foreach (const QString &key, systemEnvironment.keys()) {
const bool useVariable = key == "PATH" || key == "QT_QPA_PLATFORM"
|| key == "ASAN_OPTIONS"
#if defined(Q_OS_QNX)
|| key == "GRAPHICS_ROOT" || key == "TZ"
#elif defined(Q_OS_UNIX)