diff --git a/ci/_utils.sh b/ci/_utils.sh index d09776b93a..8f634d4655 100644 --- a/ci/_utils.sh +++ b/ci/_utils.sh @@ -303,11 +303,13 @@ get_ctest_junitxml() { check_test_filter() { test -z "$TEST_FILTER" && return 0 + set -f # disable globbing so patterns in masks are used as-is for _tf in $TEST_FILTER; do case "$1" in - $_tf) return 0 + $_tf) set +f; return 0 esac done + set +f return 1 } diff --git a/tests/pytorch/triton_kernels/conftest.py b/tests/pytorch/triton_kernels/conftest.py index 9cbf0bffdd..78e354478c 100644 --- a/tests/pytorch/triton_kernels/conftest.py +++ b/tests/pytorch/triton_kernels/conftest.py @@ -35,14 +35,27 @@ import torch +_force_exit = False +_exitstatus = 0 + @pytest.hookimpl(trylast=True) def pytest_sessionfinish(session, exitstatus): + global _force_exit, _exitstatus + # Only ROCm hits the hsa_shut_down teardown segfault; leave CUDA/CPU exit # semantics (and their normal atexit cleanup) untouched. - if getattr(torch.version, "hip", None) is None: - return - # trylast ensures the junitxml plugin and te_ci_result_sink have already - # written their reports in this same hook before we hard-exit. - sys.stdout.flush() - sys.stderr.flush() - os._exit(0 if exitstatus == 0 else int(exitstatus)) + if getattr(torch.version, "hip", None) is not None: + _force_exit = True + _exitstatus = int(exitstatus) + +# trylast ensures the junitxml plugin and te_ci_result_sink have already +# written their reports in this same hook before we hard-exit. +# unconfigure is the last hook called before pytest exits +@pytest.hookimpl(trylast=True) +def pytest_unconfigure(config): + global _force_exit, _exitstatus + + if _force_exit: + sys.stdout.flush() + sys.stderr.flush() + os._exit(_exitstatus)