Plan 9 from Bell Labs’s /usr/web/sources/contrib/jas/root/sys/lib/python2.7/bsddb/test/test_lock.pyo

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


��Qc@s�dZddlZddlZddlmZmZmZmZmZm	Z	er�ddl
mZddlZej
ddkr�ddl
mZq�ddl
mZnd	ejfd
��YZd�Zedkr�jd
d�ndS(s/
TestCases for testing the locking sub-system.
i�N(tdbttest_supporttverbosethave_threadstget_new_environment_pathtget_new_database_path(tThreadii(t
currentThread(tcurrent_threadtLockingTestCasecBs>eZd�Zd�Zd�Zd�Zd�Zd�ZRS(cCsMt�|_tj�|_|jj|jtjtjBtjBtj	B�dS(N(
RthomeDirRtDBEnvtenvtopent	DB_THREADt
DB_INIT_MPOOLtDB_INIT_LOCKt	DB_CREATE(tself((s*/sys/lib/python2.7/bsddb/test/test_lock.pytsetUpscCs!|jj�tj|j�dS(N(RtcloseRtrmtreeR
(R((s*/sys/lib/python2.7/bsddb/test/test_lock.pyttearDowns
cCs�tr%dGddGHd|jjGHn|jj�}trFd|GHn|jj|dtj�}trsd|GHn|jj|�tr�d|GHn|jj	|�dS(	Ns
s-=isRunning %s.test01_simple...s
locker ID: %sssome locked thingsAquired lock: %ssReleased lock: %s(
Rt	__class__t__name__Rtlock_idtlock_getRt
DB_LOCK_WRITEtlock_puttlock_id_free(RtanIDtlock((s*/sys/lib/python2.7/bsddb/test/test_lock.pyt
test01_simple"s
cCs�tr%dGddGHd|jjGHng}|jtd|jdtjf��|jtd|jdtjf��|jtd|jdtjf��|jtd|jdtjf��|jtd|jdtjf��|jtd|jdtjf��|jtd|jdtjf��|jtd|jdtjf��|jtd|jdtjf��xP|D]H}ddl	}|j
dd	kr�|jt�n	t|_
|j�qWx|D]}|j�q�Wd
�}dS(Ns
s-=isRunning %s.test02_threaded...ttargettargsi�iicSs�|jjdtj�|j|jjtj�d�|jjdtj�|j|jjtj�d�|jjdtj�|j|jjtj�d�|jjdtj�|j|jjtj�d�dS(Nii@�i�x(Rtset_timeoutRtDB_SET_LOCK_TIMEOUTtassertEqualtget_timeouttDB_SET_TXN_TIMEOUT(R((s*/sys/lib/python2.7/bsddb/test/test_lock.pyttest03_lock_timeoutVs(RRRtappendRt	theThreadRRtDB_LOCK_READtsystversion_infot	setDaemontTruetdaemontstarttjoin(RtthreadsttR,R(((s*/sys/lib/python2.7/bsddb/test/test_lock.pyttest02_threaded3s>

	
cs��jjdtj��jjdtj��jjdtj��jjdtj���fd��t�_d�_td��}ddl	}|j
ddkr�|jt�n	t|_
|j��jjdtj��jj�}�jj�}�j||��jj|d	tj�}tj�}�jtj�jj|d	tj�tj�}t�_�j||d
k��jj|�|j��jj|��jj|�tj�d
kr�j�jdk�ndS(Nii@�i�xcsVxO�jsQ�jjtj��_�jrAx
�js<q0WPntjd�qWdS(Ngz��?(tendRtlock_detectRtDB_LOCK_EXPIREtcountttimetsleep((tdeadlock_detectionR(s*/sys/lib/python2.7/bsddb/test/test_lock.pyR<fs	R!i�ii�sshared lockg���?ii(ii(RR#RR$R'tFalseR6R9RR,R-R.R/R0R1RtassertNotEqualRRR:tassertRaisestDBLockNotGrantedErrorR+t
assertTrueRR2Rtversion(RR4R,RtanID2Rt
start_timetend_time((R<Rs*/sys/lib/python2.7/bsddb/test/test_lock.pyttest04_lock_timeout2`s<
			
	
cCsddl}|jddkr1t�j�}nt�j}|tjkrUd}nd}|jj�}t	r�d||fGHnxrt
d�D]d}|jj|d|�}t	r�d	|||fGHn|jj|�t	r�d
|||fGHq�q�W|jj
|�dS(Ni�iitwritetreads%s: locker ID: %si�ssome locked things%s: Aquired %s lock: %ss%s: Released %s lock: %s(R,R-RtgetNametnameRRRRRtxrangeRRR(RtlockTypeR,RJtltRtiR((s*/sys/lib/python2.7/bsddb/test/test_lock.pyR*�s$	(Rt
__module__RRR R5RFR*(((s*/sys/lib/python2.7/bsddb/test/test_lock.pyR	s				-	.cCsHtj�}tr+|jtjt��n|jtjtd��|S(Nttest01(tunittestt	TestSuiteRtaddTestt	makeSuiteR	(tsuite((s*/sys/lib/python2.7/bsddb/test/test_lock.pyt
test_suite�s
t__main__tdefaultTestRV(t__doc__R:RQttest_allRRRRRRt	threadingRR,R-RRtTestCaseR	RVRtmain(((s*/sys/lib/python2.7/bsddb/test/test_lock.pyt<module>s.�

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.