��Qc@s�dZddlZddlZddlZddlmZmZmZmZm Z yddl
Z
Wnek
runXe
jdddde
�dejfd ��YZd
�Zedkr�ejdd
�ndS(sfTestCases for checking that it does not segfault when a DBEnv object
is closed before its DB objects.
i�N(tdbttest_supporttverbosetget_new_environment_pathtget_new_database_pathtignoretmessagesDB could not be closed intcategorytDBEnvClosedEarlyCrashcBsYeZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z
RS( cCst�|_d|_dS(Nttest(RthomeDirtfilename(tself((s1/sys/lib/python2.7/bsddb/test/test_early_close.pytsetUpscCstj|j�dS(N(RtrmtreeR
(R((s1/sys/lib/python2.7/bsddb/test/test_early_close.pyttearDownscCstj�}|j|jtjtjBtjBtjBd�tj|�}tj|�}|j|j tj
tjtjBd�|jtj|j|j dtj
tjd�|j
dd�|j|jd�dd�|j�|jtj|jd�dS(Ni�t2R sthis is a testsput!=get(RtDBEnvtopenR
tDB_INIT_CDBt DB_CREATEt DB_THREADt
DB_INIT_MPOOLtDBRtDB_BTREEtassertRaisestDBNoSuchFileErrortputtassertEqualtgettclosetDBError(Rtdbenvtdtd2((s1/sys/lib/python2.7/bsddb/test/test_early_close.pyttest01_close_dbenv_before_db s&
cCsttj�}|j|jtjtjBtjBtjBd�tj|�}|j|j tj
tjtjBd�|jdd�|jdd�|jdd�|j|j
d�dd�|j�}|j�|j�|j�|jtj|j�tj|�}|j|j tj
tjtjBd�|j�}|j�|j�|j�|jtj|j�dS( Ni�R sthis is a testttest2sanother testttest3sanother onesput!=get(RRRR
RRRRRRRRRRtcursortfirsttnextRRR(RR R!tc((s1/sys/lib/python2.7/bsddb/test/test_early_close.pyt"test02_close_dbenv_before_dbcursor2s,&
&
cCs�ddl}|jj|j|j�}tj�}|j|tjtj tj
Bd�|jdd�|jdd�|jdd�|j|j
d�dd �|j�}|j�|j�|j�|jtj|j�dS(
Ni�i�R sthis is a testR$sanother testR%sanother onesput!=get(tos.pathtpathtjoinR
RRRRRRRRRRR&R'R(RRR(RtosR,R!R)((s1/sys/lib/python2.7/bsddb/test/test_early_close.pyt+test03_close_db_before_dbcursor_without_envOs#
cCstj�}|j|jtjtjBtjBtjBd�gtd�D]}tj |�^qG}g}x4|D],}|j|j
tjtjtjBd�qoW|djdd�|djdd�|djdd �|j
|d
jd�dd�x:|D]2}|jgtd�D]}|j�^q�qWx%|ddd
�D]}|j�qLWx%|ddd
�D]}|j�qtW|jtj|djd�|jtj|dj�|dj�|dj�|j�|jtj|dj�dS(Ni�ii
R sthis is a testR$sanother testR%sanother oneisput!=geti ii ieiP(RRRR
RRRRtxrangeRRRRRRtextendR&RRRR'R((RR titdbstcursorstj((s1/sys/lib/python2.7/bsddb/test/test_early_close.pyttest04_close_massive`s0(
*
0
cCs�tj�}|j|jtjtjBtjBtjBd�tj|�}|j|j tj
tjtjBd�|j�~yddl}Wnt
k
r�d}nX|r�|j�ndS(Ni�i�(RRRR
RRRRRRRRtgctImportErrortNonetcollect(RR R!R7((s1/sys/lib/python2.7/bsddb/test/test_early_close.pyt$test05_close_dbenv_delete_db_success�s&
cCsotj�}|j|jtjtjBtjBtjB�tj|�}|j �}|j|j
dtjdtjd|�|jddd|�|j
�|j �}|j|�}|j�}|jd
|j��ddl}tjdkr|jd �|j
�|j�n?|j�}|j�z|jd �|j
�Wd|j�X|jtj|j�dS(NtdbtypetflagsttxntXXXtyyyi�iiR(R?R@(ii(RRRR
tDB_INIT_TXNRtDB_INIT_LOGRRt txn_beginRtDB_HASHRtcommitR&tdupRR'twarningstsystversion_infotsimplefiltert
resetwarningstcatch_warningst __enter__t__exit__RtDBCursorClosedError(RR R!R>tc1tc2RGtw((s1/sys/lib/python2.7/bsddb/test/test_early_close.pyt"test06_close_txn_before_dup_cursor�s2!
cCs}ddl}|jj|j|j�}tj�}|j|tjtj tj
Bd�tj|�}|j�|j�dS(Ni�i�(
R+R,R-R
RRRRRRRt
DBSequenceR(RR.R,R!R3((s1/sys/lib/python2.7/bsddb/test/test_early_close.pyttest07_close_db_before_sequence�s#
(t__name__t
__module__R
RR#R*R/R6R;RSRU(((s1/sys/lib/python2.7/bsddb/test/test_early_close.pyRs $ -cCs&tj�}|jtjt��|S(N(tunittestt TestSuitetaddTestt makeSuiteR(tsuite((s1/sys/lib/python2.7/bsddb/test/test_early_close.pyt
test_suite�st__main__tdefaultTestR](t__doc__R.RHRXttest_allRRRRRRGR8tfilterwarningstRuntimeWarningtTestCaseRR]RVtmain(((s1/sys/lib/python2.7/bsddb/test/test_early_close.pyt<module>s(
�
|