Tests: Set MallocNanoZone=0 on macOS when using asan

This commit is contained in:
Geza Lore 2026-03-22 16:49:52 +00:00
parent ee7ec08cf5
commit 06263ec724
1 changed files with 12 additions and 0 deletions

View File

@ -696,6 +696,7 @@ class VlTest:
self._scenario_off = False # scenarios() didn't match running scenario
self._skips = None
self._start_time = time.time()
self._uses_asan = False
self._wall_time = 0
match = re.match(r'^(.*/)?([^/]*)\.py', self.py_filename)
@ -1127,6 +1128,9 @@ class VlTest:
else:
self.trace_format = 'vcd-c' # pylint: disable=attribute-defined-outside-init
if re.search(r'-runtime-debug', checkflags):
self._uses_asan = True
verilator_flags = [*param.get('verilator_flags', "")]
if Args.gdb:
verilator_flags += ["--gdb"]
@ -1853,6 +1857,10 @@ class VlTest:
if entering:
print("driver: Entering directory '" + os.path.abspath(entering) + "'")
if self._uses_asan and platform.system() == "Darwin":
# Otherwise asan prints warning that causes mismatch with expected output
os.environ['MallocNanoZone'] = '0'
# Execute command redirecting output, keeping order between stderr and stdout.
# Must do low-level IO so GCC interaction works (can't be line-based)
status = None
@ -3165,4 +3173,8 @@ if __name__ == '__main__':
# Speed up single-test makes
Args.driver_build_jobs_n = calc_jobs()
if Capabilities.have_dev_asan and platform.system() == "Darwin":
# Otherwise asan prints warning that causes mismatch with expected output
os.environ['MallocNanoZone'] = '0'
run_them()