Skip to content

Commit ebf29b3

Browse files
authoredMar 15, 2024··
gh-112536: Add --tsan test for reasonable TSAN execution times. (gh-116601)
1 parent 1634986 commit ebf29b3

File tree

5 files changed

+39
-0
lines changed

5 files changed

+39
-0
lines changed
 

‎Lib/test/libregrtest/cmdline.py

+3
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ def __init__(self, **kwargs) -> None:
164164
self.match_tests: TestFilter = []
165165
self.pgo = False
166166
self.pgo_extended = False
167+
self.tsan = False
167168
self.worker_json = None
168169
self.start = None
169170
self.timeout = None
@@ -333,6 +334,8 @@ def _create_parser():
333334
help='enable Profile Guided Optimization (PGO) training')
334335
group.add_argument('--pgo-extended', action='store_true',
335336
help='enable extended PGO training (slower training)')
337+
group.add_argument('--tsan', dest='tsan', action='store_true',
338+
help='run a subset of test cases that are proper for the TSAN test')
336339
group.add_argument('--fail-env-changed', action='store_true',
337340
help='if a test file alters the environment, mark '
338341
'the test as failed')

‎Lib/test/libregrtest/main.py

+5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from .runtests import RunTests, HuntRefleak
1919
from .setup import setup_process, setup_test_dir
2020
from .single import run_single_test, PROGRESS_MIN_TIME
21+
from .tsan import setup_tsan_tests
2122
from .utils import (
2223
StrPath, StrJSON, TestName, TestList, TestTuple, TestFilter,
2324
strip_py_suffix, count, format_duration,
@@ -56,6 +57,7 @@ def __init__(self, ns: Namespace, _add_python_opts: bool = False):
5657
self.quiet: bool = ns.quiet
5758
self.pgo: bool = ns.pgo
5859
self.pgo_extended: bool = ns.pgo_extended
60+
self.tsan: bool = ns.tsan
5961

6062
# Test results
6163
self.results: TestResults = TestResults()
@@ -183,6 +185,9 @@ def find_tests(self, tests: TestList | None = None) -> tuple[TestTuple, TestList
183185
# add default PGO tests if no tests are specified
184186
setup_pgo_tests(self.cmdline_args, self.pgo_extended)
185187

188+
if self.tsan:
189+
setup_tsan_tests(self.cmdline_args)
190+
186191
exclude_tests = set()
187192
if self.exclude:
188193
for arg in self.cmdline_args:

‎Lib/test/libregrtest/tsan.py

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Set of tests run by default if --tsan is specified. The tests below were
2+
# chosen because they use threads and run in a reasonable amount of time.
3+
4+
TSAN_TESTS = [
5+
'test_code',
6+
'test_enum',
7+
'test_functools',
8+
'test_httpservers',
9+
'test_imaplib',
10+
'test_importlib',
11+
'test_io',
12+
'test_logging',
13+
'test_ssl',
14+
'test_syslog',
15+
'test_thread',
16+
'test_threadedtempfile',
17+
'test_threading_local',
18+
'test_threadsignals',
19+
]
20+
21+
22+
def setup_tsan_tests(cmdline_args):
23+
if not cmdline_args:
24+
cmdline_args[:] = TSAN_TESTS[:]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Add --tsan to test.regrtest for running TSAN tests in reasonable execution
2+
times. Patch by Donghee Na.

‎Tools/tsan/supressions.txt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## reference: https://github.com/google/sanitizers/wiki/ThreadSanitizerSuppressions
2+
race:get_allocator_unlocked
3+
race:set_allocator_unlocked
4+
race:mi_heap_visit_pages
5+
race:_mi_heap_delayed_free_partial

0 commit comments

Comments
 (0)
Please sign in to comment.