Skip to content

Commit 6e8ae40

Browse files
gh-133454: Mark tests with many threads that use much memory as bigmem
1 parent 0c5151b commit 6e8ae40

File tree

7 files changed

+38
-22
lines changed

7 files changed

+38
-22
lines changed

Lib/test/test_asyncio/test_ssl.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,10 @@ async def wait_closed(self, obj):
195195
except (BrokenPipeError, ConnectionError):
196196
pass
197197

198-
def test_create_server_ssl_1(self):
198+
@support.bigmemtest(size=25, memuse=90*2**20, dry_run=False)
199+
def test_create_server_ssl_1(self, size):
199200
CNT = 0 # number of clients that were successful
200-
TOTAL_CNT = 25 # total number of clients that test will create
201+
TOTAL_CNT = size # total number of clients that test will create
201202
TIMEOUT = support.LONG_TIMEOUT # timeout for this test
202203

203204
A_DATA = b'A' * 1024 * BUF_MULTIPLIER
@@ -1038,9 +1039,10 @@ async def run_main():
10381039

10391040
self.loop.run_until_complete(run_main())
10401041

1041-
def test_create_server_ssl_over_ssl(self):
1042+
@support.bigmemtest(size=25, memuse=90*2**20, dry_run=False)
1043+
def test_create_server_ssl_over_ssl(self, size):
10421044
CNT = 0 # number of clients that were successful
1043-
TOTAL_CNT = 25 # total number of clients that test will create
1045+
TOTAL_CNT = size # total number of clients that test will create
10441046
TIMEOUT = support.LONG_TIMEOUT # timeout for this test
10451047

10461048
A_DATA = b'A' * 1024 * BUF_MULTIPLIER

Lib/test/test_capi/test_misc.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1173,7 +1173,9 @@ def pendingcalls_wait(self, l, numadded, context = None):
11731173
def test_main_pendingcalls_threaded(self):
11741174

11751175
#do every callback on a separate thread
1176-
n = 32 #total callbacks
1176+
# Limit the number of threads, since every thread consumes
1177+
# over 70MB of memory.
1178+
n = 20 #total callbacks
11771179
threads = []
11781180
class foo(object):pass
11791181
context = foo()

Lib/test/test_compile.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,7 @@ def test_yet_more_evil_still_undecodable(self):
710710
@support.cpython_only
711711
@unittest.skipIf(support.is_wasi, "exhausts limited stack on WASI")
712712
@support.skip_emscripten_stack_overflow()
713+
@support.requires_resource('cpu')
713714
def test_compiler_recursion_limit(self):
714715
# Compiler frames are small
715716
limit = 100

Lib/test/test_importlib/test_threaded_import.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,12 @@ def check_parallel_module_init(self, mock_os):
135135
if verbose:
136136
print("OK.")
137137

138-
def test_parallel_module_init(self):
138+
@support.bigmemtest(size=50, memuse=76*2**20, dry_run=False)
139+
def test_parallel_module_init(self, size):
139140
self.check_parallel_module_init()
140141

141-
def test_parallel_meta_path(self):
142+
@support.bigmemtest(size=50, memuse=76*2**20, dry_run=False)
143+
def test_parallel_meta_path(self, size):
142144
finder = Finder()
143145
sys.meta_path.insert(0, finder)
144146
try:
@@ -148,7 +150,8 @@ def test_parallel_meta_path(self):
148150
finally:
149151
sys.meta_path.remove(finder)
150152

151-
def test_parallel_path_hooks(self):
153+
@support.bigmemtest(size=50, memuse=76*2**20, dry_run=False)
154+
def test_parallel_path_hooks(self, size):
152155
# Here the Finder instance is only used to check concurrent calls
153156
# to path_hook().
154157
finder = Finder()
@@ -242,13 +245,15 @@ def target():
242245
__import__(TESTFN)
243246
del sys.modules[TESTFN]
244247

245-
def test_concurrent_futures_circular_import(self):
248+
@support.bigmemtest(size=1, memuse=1.8*2**30, dry_run=False)
249+
def test_concurrent_futures_circular_import(self, size):
246250
# Regression test for bpo-43515
247251
fn = os.path.join(os.path.dirname(__file__),
248252
'partial', 'cfimport.py')
249253
script_helper.assert_python_ok(fn)
250254

251-
def test_multiprocessing_pool_circular_import(self):
255+
@support.bigmemtest(size=1, memuse=1.8*2**30, dry_run=False)
256+
def test_multiprocessing_pool_circular_import(self, size):
252257
# Regression test for bpo-41567
253258
fn = os.path.join(os.path.dirname(__file__),
254259
'partial', 'pool_in_threads.py')

Lib/test/test_memoryview.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -743,19 +743,21 @@ def test_racing_getbuf_and_releasebuf(self):
743743
from multiprocessing.managers import SharedMemoryManager
744744
except ImportError:
745745
self.skipTest("Test requires multiprocessing")
746-
from threading import Thread
746+
from threading import Thread, Event
747747

748-
n = 100
748+
start = Event()
749749
with SharedMemoryManager() as smm:
750750
obj = smm.ShareableList(range(100))
751-
threads = []
752-
for _ in range(n):
753-
# Issue gh-127085, the `ShareableList.count` is just a convenient way to mess the `exports`
754-
# counter of `memoryview`, this issue has no direct relation with `ShareableList`.
755-
threads.append(Thread(target=obj.count, args=(1,)))
756-
751+
def test():
752+
# Issue gh-127085, the `ShareableList.count` is just a
753+
# convenient way to mess the `exports` counter of `memoryview`,
754+
# this issue has no direct relation with `ShareableList`.
755+
start.wait(support.SHORT_TIMEOUT)
756+
for i in range(10):
757+
obj.count(1)
758+
threads = [Thread(target=test) for _ in range(10)]
757759
with threading_helper.start_threads(threads):
758-
pass
760+
start.set()
759761

760762
del obj
761763

Lib/test/test_threadedtempfile.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import tempfile
1717

18+
from test import support
1819
from test.support import threading_helper
1920
import unittest
2021
import io
@@ -49,7 +50,8 @@ def run(self):
4950

5051

5152
class ThreadedTempFileTest(unittest.TestCase):
52-
def test_main(self):
53+
@support.bigmemtest(size=NUM_THREADS, memuse=60*2**20, dry_run=False)
54+
def test_main(self, size):
5355
threads = [TempFileGreedy() for i in range(NUM_THREADS)]
5456
with threading_helper.start_threads(threads, startEvent.set):
5557
pass

Lib/test/test_threading.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,8 @@ def test_enumerate_after_join(self):
526526
finally:
527527
sys.setswitchinterval(old_interval)
528528

529-
def test_join_from_multiple_threads(self):
529+
@support.bigmemtest(size=20, memuse=72*2**20, dry_run=False)
530+
def test_join_from_multiple_threads(self, size):
530531
# Thread.join() should be thread-safe
531532
errors = []
532533

@@ -1427,7 +1428,8 @@ def worker():
14271428
self._run_and_join(script)
14281429

14291430
@unittest.skipIf(sys.platform in platforms_to_skip, "due to known OS bug")
1430-
def test_4_daemon_threads(self):
1431+
@support.bigmemtest(size=40, memuse=70*2**20, dry_run=False)
1432+
def test_4_daemon_threads(self, size):
14311433
# Check that a daemon thread cannot crash the interpreter on shutdown
14321434
# by manipulating internal structures that are being disposed of in
14331435
# the main thread.

0 commit comments

Comments
 (0)