1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

pytest:segfault: prevent @no_gdb_backtrace smearing on exception

It is OK for one of these tests to raise an exception -- that is often
the only reasonable thing to do when you'd otherwise crash -- but the
@no_gdb_backtrace decorator would not clean up in that case, leading to
no gdb backtraces for all subsequent tests.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Douglas Bagnall 2024-03-07 11:05:55 +13:00 committed by Andrew Bartlett
parent 682a87fd0a
commit 5ceecd3f73

View File

@ -58,9 +58,11 @@ def segfault_detector(f):
def no_gdb_backtrace(f):
from os import environ
def w(*args, **kwargs):
environ['PLEASE_NO_GDB_BACKTRACE'] = '1'
f(*args, **kwargs)
del environ['PLEASE_NO_GDB_BACKTRACE']
environ['PLEASE_NO_GDB_BACKTRACE'] = '1'
try:
f(*args, **kwargs)
finally:
del environ['PLEASE_NO_GDB_BACKTRACE']
return w