o =?h@sddlZddlZddlZddlZddlZddlZddlmZddlm Z m Z zddl Z Wn e y7dZ Ynwddl mZmZdZddZdd Zd d ZdS) N)support)TESTFN_UNDECODABLE FS_NONASCII)setup_unraisable_hooksetup_threading_excepthookZPYTHONREGRTEST_UNICODE_GUARDc Csjztj}Wn ttfyd}Yn-wtjd|dg}ttdr)| tj ttdr4| tj |D] }tj |d|dq6t tttj|jr\tjdtj|jtjD](}t|dr{t|jD] \}}tj||j|<qmt|ddrtj|j|_qa|jrd tj_ t!|j"durt#|j"|j$durt%&|j$t'|j(o|j(d k|j)t_)ttd rd d }t*|t+t,|j-durt.tj/|j-dt_/t.tj0|j-dt_0t1tj2|j-t_2t1tj3|j-t_3t1tj/|j-t_/t1tj0|j-t_0|j4rddl5m6}d|_7t8r'tj9r'tj:;t<=t8dSt>r3tj?;tdSdS)NT)Z all_threadsfileSIGALRMSIGUSR1)chainrr__path____file__F addaudithookcSsdSN)nameargsrr=/opt/alt/python310/lib64/python3.10/test/libregrtest/setup.py_test_audit_hookUsz%setup_tests.._test_audit_hook()RegressionTestResult)@sys __stderr__fileno ValueErrorAttributeError faulthandlerZenablehasattrsignalappendrr register_adjust_resource_limitsreplace_stdoutrZrecord_original_stdoutstdoutZtestdirpathinsertosabspathmodulesvalues enumerater getattrr Z huntrleaksunittestZ BaseTestSuiteZ_cleanup_deactivate_opcacheZmemlimitZ set_memlimitZ thresholdgcZ set_thresholdZsuppress_msvcrt_assertsverboseZ use_resourcesrrrZtimeoutmaxZ SHORT_TIMEOUTZ LONG_TIMEOUTminZLOOPBACK_TIMEOUTZINTERNET_TIMEOUTZxmlpathZtest.support.testresultrZUSE_XMLrsupports_bytes_environenvironb setdefaultUNICODE_GUARD_ENVencoderenviron) nsZ stderr_fdZsignalsZsignummoduleindexr%rrrrr setup_testssl               r<csZtjz}Wn tyYdSwt|djddddt_fdd}t|dS) zSet stdout encoder error handler to backslashreplace (as stderr error handler) to avoid UnicodeEncodeError when printing a tracebackNwbackslashreplaceF )encodingerrorsclosefdnewlinecstjt_dSr)rr$closerr$rrrestore_stdouts  z&replace_stdout..restore_stdout)rr$rropenr@atexitr!)fdrFrrErr#ss   r#c Cszddl}ddlm}m}Wn tyYdSw||\}}d}||krh||krjt||}z||||ftd|d|WdStt fyg}ztd|d|d |d WYd}~dSd}~wwdSdS) z5Adjust the system resource limits (ulimit) if needed.rN) RLIMIT_NOFILE RLIM_INFINITYizRaised RLIMIT_NOFILE: z -> z#Unable to raise RLIMIT_NOFILE from z to z: .) resourcerJrK ImportErrorZ getrlimitr2Z setrlimitprintrOSError)rMrJrKZfd_limitZmax_fdsZ desired_fdsZ new_fd_limiterrrrrr"s,   r")rHrr'rrr-testrZtest.support.os_helperrrr/rNZtest.libregrtest.utilsrrr6r<r#r"rrrrs$   ^