Skip to content

Commit 35fd4ba

Browse files
committed
added test and test_hashlib to list of tsan tests
1 parent 01f498e commit 35fd4ba

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

Lib/test/libregrtest/tsan.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
'test_code',
99
'test_enum',
1010
'test_functools',
11+
'test_hashlib',
1112
'test_httpservers',
1213
'test_imaplib',
1314
'test_importlib',

Lib/test/test_hashlib.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,6 +1196,29 @@ def test_file_digest(self):
11961196
with open(os_helper.TESTFN, "wb") as f:
11971197
hashlib.file_digest(f, "sha256")
11981198

1199+
@unittest.skipUnless(support.check_sanitizer(thread=True), "only meaningful on free-threading")
1200+
def test_gh_128657(self):
1201+
def test_hashlib_sha256():
1202+
hash_obj = hashlib.sha256()
1203+
1204+
def closure(barrier):
1205+
barrier.wait()
1206+
test_hashlib_sha256()
1207+
1208+
num_workers = 40
1209+
num_runs = 20
1210+
1211+
for i in range(num_runs):
1212+
barrier = threading.Barrier(num_workers)
1213+
thrds = []
1214+
1215+
for i in range(num_workers):
1216+
thrds.append(thrd := threading.Thread(target=closure, args=(barrier,)))
1217+
thrd.start()
1218+
1219+
for thrd in thrds:
1220+
thrd.join()
1221+
11991222

12001223
if __name__ == "__main__":
12011224
unittest.main()

0 commit comments

Comments
 (0)