Skip to content

Commit ff2278e

Browse files
cmaloneymgorny
andauthored
gh-127076: Disable strace tests under LD_PRELOAD (#127086)
Distribution tooling (ex. sandbox on Gentoo and fakeroot on Debian) uses LD_PRELOAD to intercept system calls and potentially modify them when building. These tools can change the set of system calls, so disable system call testing under these cases. Co-authored-by: Michał Górny <[email protected]>
1 parent 1629d2c commit ff2278e

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

Lib/test/support/strace_helper.py

+8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import re
22
import sys
33
import textwrap
4+
import os
45
import unittest
56
from dataclasses import dataclass
67
from functools import cache
@@ -163,6 +164,13 @@ def requires_strace():
163164
if sys.platform != "linux":
164165
return unittest.skip("Linux only, requires strace.")
165166

167+
if "LD_PRELOAD" in os.environ:
168+
# Distribution packaging (ex. Debian `fakeroot` and Gentoo `sandbox`)
169+
# use LD_PRELOAD to intercept system calls, which changes the overall
170+
# set of system calls which breaks tests expecting a specific set of
171+
# system calls).
172+
return unittest.skip("Not supported when LD_PRELOAD is intercepting system calls.")
173+
166174
if support.check_sanitizer(address=True, memory=True):
167175
return unittest.skip("LeakSanitizer does not work under ptrace (strace, gdb, etc)")
168176

Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Disable strace based system call tests when LD_PRELOAD is set.

0 commit comments

Comments
 (0)