Skip to content

Commit 555dc50

Browse files
authored
gh-129694: Add --parallel-threads TSAN job to CI (gh-129696)
For now, this just adds a single test suite to the TSAN CI to be run with `--parallel-threads`.
1 parent 55f17b7 commit 555dc50

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed

.github/workflows/reusable-tsan.yml

+3
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ jobs:
7474
run: make pythoninfo
7575
- name: Tests
7676
run: ./python -m test --tsan -j4
77+
- name: Parallel tests
78+
if: fromJSON(inputs.free-threading)
79+
run: ./python -m test --tsan-parallel --parallel-threads=4 -j4
7780
- name: Display TSAN logs
7881
if: always()
7982
run: find "${GITHUB_WORKSPACE}" -name 'tsan_log.*' | xargs head -n 1000

Lib/test/libregrtest/cmdline.py

+4
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ def __init__(self, **kwargs) -> None:
168168
self.pgo = False
169169
self.pgo_extended = False
170170
self.tsan = False
171+
self.tsan_parallel = False
171172
self.worker_json = None
172173
self.start = None
173174
self.timeout = None
@@ -351,6 +352,9 @@ def _create_parser():
351352
help='enable extended PGO training (slower training)')
352353
group.add_argument('--tsan', dest='tsan', action='store_true',
353354
help='run a subset of test cases that are proper for the TSAN test')
355+
group.add_argument('--tsan-parallel', action='store_true',
356+
help='run a subset of test cases that are appropriate '
357+
'for TSAN with `--parallel-threads=N`')
354358
group.add_argument('--fail-env-changed', action='store_true',
355359
help='if a test file alters the environment, mark '
356360
'the test as failed')

Lib/test/libregrtest/main.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from .runtests import RunTests, HuntRefleak
2121
from .setup import setup_process, setup_test_dir
2222
from .single import run_single_test, PROGRESS_MIN_TIME
23-
from .tsan import setup_tsan_tests
23+
from .tsan import setup_tsan_tests, setup_tsan_parallel_tests
2424
from .utils import (
2525
StrPath, StrJSON, TestName, TestList, TestTuple, TestFilter,
2626
strip_py_suffix, count, format_duration,
@@ -60,6 +60,7 @@ def __init__(self, ns: Namespace, _add_python_opts: bool = False):
6060
self.pgo: bool = ns.pgo
6161
self.pgo_extended: bool = ns.pgo_extended
6262
self.tsan: bool = ns.tsan
63+
self.tsan_parallel: bool = ns.tsan_parallel
6364

6465
# Test results
6566
self.results: TestResults = TestResults()
@@ -195,6 +196,9 @@ def find_tests(self, tests: TestList | None = None) -> tuple[TestTuple, TestList
195196
if self.tsan:
196197
setup_tsan_tests(self.cmdline_args)
197198

199+
if self.tsan_parallel:
200+
setup_tsan_parallel_tests(self.cmdline_args)
201+
198202
exclude_tests = set()
199203
if self.exclude:
200204
for arg in self.cmdline_args:

Lib/test/libregrtest/tsan.py

+11
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,18 @@
2828
'test_free_threading.test_slots',
2929
]
3030

31+
# Tests that should be run with `--parallel-threads=N` under TSAN. These tests
32+
# typically do not use threads, but are run multiple times in parallel by
33+
# the regression test runner with the `--parallel-threads` option enabled.
34+
TSAN_PARALLEL_TESTS = [
35+
'test_abc',
36+
]
37+
3138

3239
def setup_tsan_tests(cmdline_args) -> None:
3340
if not cmdline_args:
3441
cmdline_args[:] = TSAN_TESTS[:]
42+
43+
def setup_tsan_parallel_tests(cmdline_args) -> None:
44+
if not cmdline_args:
45+
cmdline_args[:] = TSAN_PARALLEL_TESTS[:]

0 commit comments

Comments
 (0)