GeezerVison is showing github.com — gh-112536: Add --tsan test for reasonable TSAN execution times. (gh-1… · vstinner/cpython@66f349d
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: Lib/test/libregrtest/cmdline.py +3Lines changed: 3 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -164,6 +164,7 @@ def __init__(self, **kwargs) -> None: | 164 | 164 | self.match_tests: TestFilter = [] | 165 | 165 | self.pgo = False | 166 | 166 | self.pgo_extended = False | | 167 | + self.tsan = False | 167 | 168 | self.worker_json = None | 168 | 169 | self.start = None | 169 | 170 | self.timeout = None | @@ -333,6 +334,8 @@ def _create_parser(): | 333 | 334 | help='enable Profile Guided Optimization (PGO) training') | 334 | 335 | group.add_argument('--pgo-extended', action='store_true', | 335 | 336 | 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') | 336 | 339 | group.add_argument('--fail-env-changed', action='store_true', | 337 | 340 | help='if a test file alters the environment, mark ' | 338 | 341 | 'the test as failed') | |
Collapse file Copy file name to clipboardExpand all lines: Lib/test/libregrtest/main.py +5Lines changed: 5 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 18 | 18 | from .runtests import RunTests, HuntRefleak | 19 | 19 | from .setup import setup_process, setup_test_dir | 20 | 20 | from .single import run_single_test, PROGRESS_MIN_TIME | | 21 | +from .tsan import setup_tsan_tests | 21 | 22 | from .utils import ( | 22 | 23 | StrPath, StrJSON, TestName, TestList, TestTuple, TestFilter, | 23 | 24 | strip_py_suffix, count, format_duration, | @@ -56,6 +57,7 @@ def __init__(self, ns: Namespace, _add_python_opts: bool = False): | 56 | 57 | self.quiet: bool = ns.quiet | 57 | 58 | self.pgo: bool = ns.pgo | 58 | 59 | self.pgo_extended: bool = ns.pgo_extended | | 60 | + self.tsan: bool = ns.tsan | 59 | 61 |
| 60 | 62 | # Test results | 61 | 63 | self.results: TestResults = TestResults() | @@ -183,6 +185,9 @@ def find_tests(self, tests: TestList | None = None) -> tuple[TestTuple, TestList | 183 | 185 | # add default PGO tests if no tests are specified | 184 | 186 | setup_pgo_tests(self.cmdline_args, self.pgo_extended) | 185 | 187 |
| | 188 | + if self.tsan: | | 189 | + setup_tsan_tests(self.cmdline_args) | | 190 | + | 186 | 191 | exclude_tests = set() | 187 | 192 | if self.exclude: | 188 | 193 | for arg in self.cmdline_args: | |
Collapse file Copy file name to clipboard +24Lines changed: 24 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 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[:] |
Collapse file Copy file name to clipboard +2Lines changed: 2 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +Add --tsan to test.regrtest for running TSAN tests in reasonable execution | | 2 | +times. Patch by Donghee Na. |
Collapse file Copy file name to clipboard +5Lines changed: 5 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 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 |
|