Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lldb/packages/Python/lldbsuite/test/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,7 @@ def swiftTest(func):
"""Decorate the item as a Swift test (Darwin/Linux only, no i386)."""

func.__swift_test__ = True
func.__pdb_variant_enrolled__ = True

# The OS check is static and can be evaluated at decoration time.
# Using unittest.skip (which sets __unittest_skip__ on the method) causes
Expand Down
65 changes: 60 additions & 5 deletions lldb/packages/Python/lldbsuite/test/lldbtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import signal
from subprocess import *
import sys
import threading
import time
import traceback

Expand Down Expand Up @@ -2070,10 +2071,12 @@ def no_reason(*args, **kwargs):
if enabled
]

# PDB is off by default, because it has a lot of failures right now.
# See llvm.org/pr149498
if original_testcase.TEST_WITH_PDB_DEBUG_INFO:
dbginfo_categories.append("pdb")
if (
original_testcase.TEST_WITH_PDB_DEBUG_INFO
or getattr(attrvalue, "__pdb_variant_enrolled__", False)
):
if "pdb" not in dbginfo_categories:
dbginfo_categories.append("pdb")

xfail_fns = getattr(attrvalue, "__variant_xfail__", {})
skip_fns = getattr(attrvalue, "__variant_skip__", {})
Expand All @@ -2083,7 +2086,59 @@ def no_reason(*args, **kwargs):

@decorators.add_test_categories([cat])
@wraps(attrvalue)
def test_method(self, attrvalue=attrvalue):
def test_method(self, attrvalue=attrvalue, cat=cat):
# Non-fatal variants (e.g. pdb) run in a daemon
# thread with a wall-clock timeout. This way a
# hang or crash in lldb's per-method work
# doesn't take down the whole dotest process
# via lit's per-file timeout. Any exception,
# including a timeout, is reported as a
# tolerated skipTest. The thread is left as
# daemon — we make no attempt to kill the
# hung lldb call, since doing so safely from
# Python is not possible. The thread (and any
# inferior process it owns) will be torn down
# when the dotest process exits.
if (
cat
in test_categories.non_fatal_debug_info_categories
):
result = {"exc": None}

def _runner():
try:
attrvalue(self)
except Exception as e:
result["exc"] = e

# Per-method wall-clock budget for a
# non-fatal variant. Generous enough for
# a Swift build + run on the bridge, but
# tight enough that several hangs in the
# same .py file still finish under lit's
# 900s per-file timeout.
timeout_s = 90
t = threading.Thread(
target=_runner, daemon=True
)
t.start()
t.join(timeout=timeout_s)

if t.is_alive():
self.skipTest(
f"tolerated under debug_info={cat}: "
f"timed out after {timeout_s}s"
)
if result["exc"] is not None:
if isinstance(
result["exc"], unittest.SkipTest
):
raise result["exc"]
self.skipTest(
f"tolerated under debug_info={cat}: "
f"{result['exc']!r}"
)
return None
return attrvalue(self)

method_name = attrname + "_" + cat
Expand Down
2 changes: 2 additions & 0 deletions lldb/packages/Python/lldbsuite/test/test_categories.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
"gmodules": False,
}

non_fatal_debug_info_categories = {"pdb"}

swift_module_importer_categories = {
"clang": True,
"noclang": True,
Expand Down