8000 gh-127146: Emscripten: Skip segfaults in test suite (#127151) · python/cpython@43634fc · GitHub
[go: up one dir, main page]

Skip to content

Commit 43634fc

Browse files
authored
gh-127146: Emscripten: Skip segfaults in test suite (#127151)
Added skips for tests known to cause problems when running on Emscripten. These mostly relate to the limited stack depth on Emscripten.
1 parent 2f1cee8 commit 43634fc

File tree

21 files changed

+46
-8
lines changed
  • test_pathlib
  • 21 files changed

    +46
    -8
    lines changed

    Lib/test/list_tests.py

    Lines changed: 2 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -6,7 +6,7 @@
    66
    from functools import cmp_to_key
    77

    88
    from test import seq_tests
    9-
    from test.support import ALWAYS_EQ, NEVER_EQ, get_c_recursion_limit
    9+
    from test.support import ALWAYS_EQ, NEVER_EQ, get_c_recursion_limit, skip_emscripten_stack_overflow
    1010

    1111

    1212
    class CommonTest(seq_tests.CommonTest):
    @@ -59,6 +59,7 @@ def test_repr(self):
    5959
    self.assertEqual(str(a2), "[0, 1, 2, [...], 3]")
    6060
    self.assertEqual(repr(a2), "[0, 1, 2, [...], 3]")
    6161

    62+
    @skip_emscripten_stack_overflow()
    6263
    def test_repr_deep(self):
    6364
    a = self.type2test([])
    6465
    for i in range(get_c_recursion_limit() + 1):

    Lib/test/mapping_tests.py

    Lines changed: 2 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -1,7 +1,7 @@
    11
    # tests common to dict and UserDict
    22
    import unittest
    33
    import collections
    4-
    from test.support import get_c_recursion_limit
    4+
    from test.support import get_c_recursion_limit, skip_emscripten_stack_overflow
    55

    66

    77
    class BasicTestMappingProtocol(unittest.TestCase):
    @@ -622,6 +622,7 @@ def __repr__(self):
    622622
    d = self._full_mapping({1: BadRepr()})
    623623
    self.assertRaises(Exc, repr, d)
    624624

    625+
    @skip_emscripten_stack_overflow()
    625626
    def test_repr_deep(self):
    626627
    d = self._empty_mapping()
    627628
    for i in range(get_c_recursion_limit() + 1):

    Lib/test/support/__init__.py

    Lines changed: 3 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -535,6 +535,9 @@ def skip_android_selinux(name):
    535535
    is_emscripten = sys.platform == "emscripten"
    536536
    is_wasi = sys.platform == "wasi"
    537537

    538+
    def skip_emscripten_stack_overflow():
    539+
    return unittest.skipIf(is_emscripten, "Exhausts limited stack on Emscripten")
    540+
    538541
    is_apple_mobile = sys.platform in {"ios", "tvos", "watchos"}
    539542
    is_apple = is_apple_mobile or sys.platform == "darwin"
    540543

    Lib/test/test_ast/test_ast.py

    Lines changed: 4 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -18,7 +18,7 @@
    1818
    _testinternalcapi = None
    1919

    2020
    from test import support
    21-
    from test.support import os_helper, script_helper
    21+
    from test.support import os_helper, script_helper, skip_emscripten_stack_overflow
    2222
    from test.support.ast_helper import ASTTestMixin
    2323
    from test.test_ast.utils import to_tuple
    2424
    from test.test_ast.snippets import (
    @@ -745,6 +745,7 @@ def next(self):
    745745
    enum._test_simple_enum(_Precedence, ast._Precedence)
    746746

    747747
    @support.cpython_only
    748+
    @skip_emscripten_stack_overflow()
    748749
    def test_ast_recursion_limit(self):
    749750
    fail_depth = support.exceeds_recursion_limit()
    750751
    crash_depth = 100_000
    @@ -1661,13 +1662,15 @@ def test_level_as_none(self):
    16611662
    exec(code, ns)
    16621663
    self.assertIn('sleep', ns)
    16631664

    1665+
    @skip_emscripten_stack_overflow()
    16641666
    def test_recursion_direct(self):
    16651667
    e = ast.UnaryOp(op=ast.Not(), lineno=0, col_offset=0, operand=ast.Constant(1))
    16661668
    e.operand = e
    16671669
    with self.assertRaises(RecursionError):
    16681670
    with support.infinite_recursion():
    16691671
    compile(ast.Expression(e), "<test>", "eval")
    16701672

    1673+
    @skip_emscripten_stack_overflow()
    16711674
    def test_recursion_indirect(self):
    16721675
    e = ast.UnaryOp(op=ast.Not(), lineno=0, col_offset=0, operand=ast.Constant(1))
    16731676
    f = ast.UnaryOp(op=ast.Not(), lineno=0, col_offset=0, operand=ast.Constant(1))

    Lib/test/test_call.py

    Lines changed: 2 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -1,6 +1,6 @@
    11
    import unittest
    22
    from test.support import (cpython_only, is_wasi, requires_limited_api, Py_DEBUG,
    3-
    set_recursion_limit, skip_on_s390x)
    3+
    set_recursion_limit, skip_on_s390x, skip_emscripten_stack_overflow)
    44
    try:
    55
    import _testcapi
    66
    except ImportError:
    @@ -1038,6 +1038,7 @@ class TestRecursion(unittest.TestCase):
    10381038
    @skip_on_s390x
    10391039
    @unittest.skipIf(is_wasi and Py_DEBUG, "requires deep stack")
    10401040
    @unittest.skipIf(_testcapi is None, "requires _testcapi")
    1041+
    @skip_emscripten_stack_overflow()
    10411042
    def test_super_deep(self):
    10421043

    10431044
    def recurse(n):

    Lib/test/test_capi/test_misc.py

    Lines changed: 1 addition & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -2137,6 +2137,7 @@ def test_py_config_isoloated_per_interpreter(self):
    21372137
    # test fails, assume that the environment in this process may
    21382138
    # be altered and suspect.
    21392139

    2140+
    @requires_subinterpreters
    21402141
    @unittest.skipUnless(hasattr(os, "pipe"), "requires os.pipe()")
    21412142
    def test_configured_settings(self):
    21422143
    """

    Lib/test/test_class.py

    Lines changed: 2 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -1,7 +1,7 @@
    11
    "Test the functionality of Python classes implementing operators."
    22

    33
    import unittest
    4-
    from test.support import cpython_only, import_helper, script_helper
    4+
    from test.support import cpython_only, import_helper, script_helper, skip_emscripten_stack_overflow
    55

    66
    testmeths = [
    77

    @@ -554,6 +554,7 @@ class Custom:
    554554
    self.assertFalse(hasattr(o, "__call__"))
    555555
    self.assertFalse(hasattr(c, "__call__"))
    556556

    557+
    @skip_emscripten_stack_overflow()
    557558
    def testSFBug532646(self):
    558559
    # Test for SF bug 532646
    559560

    Lib/test/test_compile.py

    Lines changed: 2 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -121,6 +121,7 @@ def __getitem__(self, key):
    121121
    self.assertEqual(d['z'], 12)
    122122

    123123
    @unittest.skipIf(support.is_wasi, "exhausts limited stack on WASI")
    124+
    @support.skip_emscripten_stack_overflow()
    124125
    def test_extended_arg(self):
    125126
    repeat = int(get_c_recursion_limit() * 0.9)
    126127
    longexpr = 'x = x or ' + '-x' * repeat
    @@ -709,6 +710,7 @@ def test_yet_more_evil_still_undecodable(self):
    709710

    710711
    @support.cpython_only
    711712
    @unittest.skipIf(support.is_wasi, "exhausts limited stack on WASI")
    713+
    @support.skip_emscripten_stack_overflow()
    712714
    def test_compiler_recursion_limit(self):
    713715
    # Expected limit is Py_C_RECURSION_LIMIT
    714716
    limit = get_c_recursion_limit()

    Lib/test/test_copy.py

    Lines changed: 3 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -371,6 +371,7 @@ def test_deepcopy_list(self):
    371371
    self.assertIsNot(x, y)
    372372
    self.assertIsNot(x[0], y[0])
    373373

    374+
    @support.skip_emscripten_stack_overflow()
    374375
    def test_deepcopy_reflexive_list(self):
    375376
    x = []
    376377
    x.append(x)
    @@ -398,6 +399,7 @@ def test_deepcopy_tuple_of_immutables(self):
    398399
    y = copy.deepcopy(x)
    399400
    self.assertIs(x, y)
    400401

    402+
    @support.skip_emscripten_stack_overflow()
    401403
    def test_deepcopy_reflexive_tuple(self):
    402404
    x = ([],)
    403405
    x[0].append(x)
    @@ -415,6 +417,7 @@ def test_deepcopy_dict(self):
    415417
    self.assertIsNot(x, y)
    416418
    self.assertIsNot(x["foo"], y["foo"])
    417419

    420+
    @support.skip_emscripten_stack_overflow()
    418421
    def test_deepcopy_reflexive_dict(self):
    419422
    x = {}
    420423
    x['foo'] = x

    Lib/test/test_descr.py

    Lines changed: 3 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -3663,6 +3663,7 @@ def f(a): return a
    36633663
    encoding='latin1', errors='replace')
    36643664
    self.assertEqual(ba, b'abc\xbd?')
    36653665

    3666+
    @support.skip_emscripten_stack_overflow()
    36663667
    def test_recursive_call(self):
    36673668
    # Testing recursive __call__() by setting to instance of class...
    36683669
    class A(object):
    @@ -3942,6 +3943,7 @@ def __del__(self):
    39423943
    # it as a leak.
    39433944
    del C.__del__
    39443945

    3946+
    @unittest.skipIf(support.is_emscripten, "Seems to works in Pyodide?")
    39453947
    def test_slots_trash(self):
    39463948
    # Testing slot trash...
    39473949
    # Deallocating deeply nested slotted trash caused stack overflows
    @@ -4864,6 +4866,7 @@ class Thing:
    48644866
    # CALL_METHOD_DESCRIPTOR_O
    48654867
    deque.append(thing, thing)
    48664868

    4869+
    @support.skip_emscripten_stack_overflow()
    48674870
    def test_repr_as_str(self):
    48684871
    # Issue #11603: crash or infinite loop when rebinding __str__ as
    48694872
    # __repr__.

    Lib/test/test_dict.py

    Lines changed: 1 addition & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -594,6 +594,7 @@ def __repr__(self):
    594594
    d = {1: BadRepr()}
    595595
    self.assertRaises(Exc, repr, d)
    596596

    597+
    @support.skip_emscripten_stack_overflow()
    597598
    def test_repr_deep(self):
    598599
    d = {}
    599600
    for i in range(get_c_recursion_limit() + 1):

    Lib/test/test_dictviews.py

    Lines changed: 2 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -2,7 +2,7 @@
    22
    import copy
    33
    import pickle
    44
    import unittest
    5-
    from test.support import get_c_recursion_limit
    5+
    from test.support import get_c_recursion_limit, skip_emscripten_stack_overflow
    66

    77
    class DictSetTest(unittest.TestCase):
    88

    @@ -277,6 +277,7 @@ def test_recursive_repr(self):
    277277
    # Again.
    278278
    self.assertIsInstance(r, str)
    279279

    280+
    @skip_emscripten_stack_overflow()
    280281
    def test_deeply_nested_repr(self):
    281282
    d = {}
    282283
    for i in range(get_c_recursion_limit()//2 + 100):

    Lib/test/test_exception_group.py

    Lines changed: 3 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -1,7 +1,7 @@
    11
    import collections.abc
    22
    import types
    33
    import unittest
    4-
    from test.support import get_c_recursion_limit
    4+
    from test.support import get_c_recursion_limit, skip_emscripten_stack_overflow
    55

    66
    class TestExceptionGroupTypeHierarchy(unittest.TestCase):
    77
    def test_exception_group_types(self):
    @@ -464,11 +464,13 @@ def make_deep_eg(self):
    464464
    e = ExceptionGroup('eg', [e])
    465465
    return e
    466466

    467+
    @skip_emscripten_stack_overflow()
    467468
    def test_deep_split(self):
    468469
    e = self.make_deep_eg()
    469470
    with self.assertRaises(RecursionError):
    470471
    e.split(TypeError)
    471472

    473+
    @skip_emscripten_stack_overflow()
    472474
    def test_deep_subgroup(self):
    473475
    e = self.make_deep_eg()
    474476
    with self.assertRaises(RecursionError):

    Lib/test/test_functools.py

    Lines changed: 2 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -404,6 +404,7 @@ def test_setstate_subclasses(self):
    404404
    self.assertEqual(r, ((1, 2), {}))
    405405
    self.assertIs(type(r[0]), tuple)
    406406

    407+
    @support.skip_emscripten_stack_overflow()
    407408
    def test_recursive_pickle(self):
    408409
    with replaced_module('functools', self.module):
    409410
    f = self.partial(capture)
    @@ -2054,6 +2055,7 @@ def orig(a, /, b, c=True): ...
    20542055

    20552056
    @support.skip_on_s390x
    20562057
    @unittest.skipIf(support.is_wasi, "WASI has limited C stack")
    2058+
    @support.skip_emscripten_stack_overflow()
    20572059
    def test_lru_recursion(self):
    20582060

    20592061
    @self.module.lru_cache

    Lib/test/test_isinstance.py

    Lines changed: 3 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -263,12 +263,14 @@ def test_subclass_tuple(self):
    263263
    self.assertEqual(True, issubclass(int, (int, (float, int))))
    264264
    self.assertEqual(True, issubclass(str, (str, (Child, str))))
    265265

    266+
    @support.skip_emscripten_stack_overflow()
    266267
    def test_subclass_recursion_limit(self):
    267268
    # make sure that issubclass raises RecursionError before the C stack is
    268269
    # blown
    269270
    with support.infinite_recursion():
    270271
    self.assertRaises(RecursionError, blowstack, issubclass, str, str)
    271272

    273+
    @support.skip_emscripten_stack_overflow()
    272274
    def test_isinstance_recursion_limit(self):
    273275
    # make sure that issubclass raises RecursionError before the C stack is
    274276
    # blown
    @@ -315,6 +317,7 @@ def __bases__(self):
    315317
    self.assertRaises(RecursionError, issubclass, int, X())
    316318
    self.assertRaises(RecursionError, isinstance, 1, X())
    317319

    320+
    @support.skip_emscripten_stack_overflow()
    318321
    def test_infinite_recursion_via_bases_tuple(self):
    319322
    """Regression test for bpo-30570."""
    320323
    class Failure(object):

    Lib/test/test_json/test_recursion.py

    Lines changed: 3 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -68,6 +68,7 @@ def default(self, o):
    6868
    self.fail("didn't raise ValueError on default recursion")
    6969

    7070

    71+
    @support.skip_emscripten_stack_overflow()
    7172
    def test_highly_nested_objects_decoding(self):
    7273
    # test that loading highly-nested objects doesn't segfault when C
    7374
    # accelerations are used. See #12017
    @@ -81,6 +82,7 @@ def test_highly_nested_objects_decoding(self):
    8182
    with support.infinite_recursion():
    8283
    self.loads('[' * 100000 + '1' + ']' * 100000)
    8384

    85+
    @support.skip_emscripten_stack_overflow()
    8486
    def test_highly_nested_objects_encoding(self):
    8587
    # See #12051
    8688
    l, d = [], {}
    @@ -93,6 +95,7 @@ def test_highly_nested_objects_encoding(self):
    9395
    with support.infinite_recursion(5000):
    9496
    self.dumps(d)
    9597

    98+
    @support.skip_emscripten_stack_overflow()
    9699
    def test_endless_recursion(self):
    97100
    # See #12051
    98101
    class EndlessJSONEncoder(self.json.JSONEncoder):

    Lib/test/test_pathlib/test_pathlib_abc.py

    Lines changed: 3 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -9,7 +9,7 @@
    99
    from pathlib._abc import UnsupportedOperation, ParserBase, PurePathBase, PathBase
    1010
    import posixpath
    1111

    12-
    from test.support import is_wasi
    12+
    from test.support import is_wasi, is_emscripten
    1313
    from test.support.os_helper import TESTFN
    1414

    1515

    @@ -2298,6 +2298,7 @@ def _check(path, pattern, case_sensitive, expected):
    22982298
    _check(path, "dirb/file*", False, ["dirB/fileB"])
    22992299

    23002300
    @needs_symlinks
    2301+
    @unittest.skipIf(is_emscripten, "Hangs")
    23012302
    def test_glob_recurse_symlinks_common(self):
    23022303
    def _check(path, glob, expected):
    23032304
    actual = {path for path in path.glob(glob, recurse_symlinks=True)
    @@ -2393,6 +2394,7 @@ def test_rglob_windows(self):
    23932394
    self.assertEqual(set(p.rglob("*\\")), { P(self.base, "dirC/dirD/") })
    23942395

    23952396
    @needs_symlinks
    2397+
    @unittest.skipIf(is_emscripten, "Hangs")
    23962398
    def test_rglob_recurse_symlinks_common(self):
    23972399
    def _check(path, glob, expected):
    23982400
    actual = {path for path in path.rglob(glob, recurse_symlinks=True)

    Lib/test/test_traceback.py

    Lines changed: 2 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -2097,6 +2097,7 @@ def deep_eg(self):
    20972097
    return e
    20982098

    20992099
    @cpython_only
    2100+
    @support.skip_emscripten_stack_overflow()
    21002101
    def test_exception_group_deep_recursion_capi(self):
    21012102
    from _testcapi import exception_print
    21022103
    LIMIT = 75
    @@ -2108,6 +2109,7 @@ def test_exception_group_deep_recursion_capi(self):
    21082109
    self.assertIn('ExceptionGroup', output)
    21092110
    self.assertLessEqual(output.count('ExceptionGroup'), LIMIT)
    21102111

    2112+
    @support.skip_emscripten_stack_overflow()
    21112113
    def test_exception_group_deep_recursion_traceback(self):
    21122114
    LIMIT = 75
    21132115
    eg = self.deep_eg()

    Lib/test/test_xml_etree_c.py

    Lines changed: 1 addition & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -57,6 +57,7 @@ def test_del_attribute(self):
    5757
    del element.attrib
    5858
    self.assertEqual(element.attrib, {'A': 'B', 'C': 'D'})
    5959

    60+
    @unittest.skipIf(support.is_emscripten, "segfaults")
    6061
    def test_trashcan(self):
    6162
    # If this test fails, it will most likely die via segfault.
    6263
    e = root = cET.Element('root')

    configure

    Lines changed: 1 addition & 0 deletions
    Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

    configure.ac

    Lines changed: 1 addition & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -2334,6 +2334,7 @@ AS_CASE([$ac_sys_system],
    23342334
    AS_VAR_APPEND([LDFLAGS_NODIST], [" -sFORCE_FILESYSTEM -lidbfs.js -lnodefs.js -lproxyfs.js -lworkerfs.js"])
    23352335
    AS_VAR_APPEND([LDFLAGS_NODIST], [" -sEXPORTED_RUNTIME_METHODS=FS,callMain"])
    23362336
    AS_VAR_APPEND([LDFLAGS_NODIST], [" -sEXPORTED_FUNCTIONS=_main,_Py_Version"])
    2337+
    AS_VAR_APPEND([LDFLAGS_NODIST], [" -sSTACK_SIZE=5MB"])
    23372338
    23382339
    AS_VAR_IF([enable_wasm_dynamic_linking], [yes], [
    23392340
    AS_VAR_APPEND([LINKFORSHARED], [" -sMAIN_MODULE"])

    0 commit comments

    Comments
     (0)
    0