From 8f87e3f67bba89cc4816b6fa8f51d6ecd2a772c8 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Thu, 12 Oct 2023 16:05:28 +0800 Subject: [PATCH] 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 (cherry picked from commit 3f2b54f0a1749eb8a52e99dbba6af4839e36cb90) Reviewed-by: Qt Cherry-pick Bot --- tests/auto/testlib/selftests/generate_expected_output.py | 4 ++-- tests/auto/testlib/selftests/tst_selftests.cpp | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/auto/testlib/selftests/generate_expected_output.py b/tests/auto/testlib/selftests/generate_expected_output.py index be3633db74f..f48c8297205 100755 --- a/tests/auto/testlib/selftests/generate_expected_output.py +++ b/tests/auto/testlib/selftests/generate_expected_output.py @@ -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: diff --git a/tests/auto/testlib/selftests/tst_selftests.cpp b/tests/auto/testlib/selftests/tst_selftests.cpp index b3ecb24470e..3ea7e95a375 100644 --- a/tests/auto/testlib/selftests/tst_selftests.cpp +++ b/tests/auto/testlib/selftests/tst_selftests.cpp @@ -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)