diff options
author | Dimitrios Apostolou <jimis@qt.io> | 2022-06-02 14:54:37 +0200 |
---|---|---|
committer | Dimitrios Apostolou <jimis@qt.io> | 2022-06-15 23:58:16 +0200 |
commit | fe0e87c9a6bb43c71e3af2083b5b0800c7dbca44 (patch) | |
tree | 8217be02087596f11f9a755ec1eb30fb13aa9ab3 /util | |
parent | 96001cb81234c11e35b06ed5d96fa923d170ddd7 (diff) |
Add ASAN build for qtbase
The test run is wrapped with a special TESTRUNNER script that ignores
failing tests (there are several tests failing when built with ASAN) and
also ignores LSAN errors (memory leaks - but still visible in the
output).
The test run only fails if a test reports ASAN errors or if it
crashes (or times out, which is like a crash caused by qtestlib's
watchdog timer).
Fixes: QTQAINFRA-5025
Change-Id: I861756ab49388ac4a52409d3a780684244e469b1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'util')
-rwxr-xr-x | util/testrunner/sanitizer-testrunner.py | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/util/testrunner/sanitizer-testrunner.py b/util/testrunner/sanitizer-testrunner.py new file mode 100755 index 0000000000..d1f0310d16 --- /dev/null +++ b/util/testrunner/sanitizer-testrunner.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python3 +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +import os +import re +import sys +import logging as L +from subprocess import Popen, PIPE + + +# Thin testrunner that ignores failures in tests and only catches +# crashes or ASAN errors. +# +# It executes its arguments as a command line, and parses the stderr for the +# following regex: +detect_ASAN = re.compile(r"^==[0-9]+==ERROR: AddressSanitizer") + + +my_name = os.path.basename(sys.argv[0]) +logging_format = my_name + " %(levelname)8s: %(message)s" +L.basicConfig(format=logging_format, level=L.DEBUG) + +proc = None +if sys.argv[1] == "-f": # hidden option to parse pre-existing files + f = open(sys.argv[2], "r", errors="ignore") +else: + proc = Popen(sys.argv[1:], stderr=PIPE, universal_newlines=True, errors="ignore") + f = proc.stderr + +issues_detected = False +for line in f: + if proc: + # We don't want the stderr of the subprocess to disappear, so print it. + print(line, file=sys.stderr, end="") + if detect_ASAN.match(line): + issues_detected = True +f.close() +if proc: + proc.wait() + rc = proc.returncode + L.info("Test exit code was: %d", rc) + if not ( 0 <= rc <= 127 ): + L.error("Crash detected") + exit(1) + +if issues_detected: + L.error("ASAN issues detected") + exit(1) |