Current File : //opt/imh-python/lib/python2.7/test/test_posix.pyc
�
��Wc@s?dZddlmZejd�ZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddlZddl
Z
ddlZddlZejje
j�ejd�Zejdde�dejfd	��YZd
ejfd��YZd�Zed
kr;e�ndS(sTest posix functionsi����(ttest_supporttposixNs-dummy-symlinktignores.* potential security risk .*tPosixTestercBs�eZd�Zd�Zd�Zejeed�d�d��Z	ejeed�d�d��Z
ejeed	�d
�d��Zejeed	�d
�d��Zejeed
�d�d��Z
ejeed
�d�d��Zejeed�d�d��Zejeed�d�d��Zejeed�d�d��Zejeed�d�d��Zejeed�d�d��Zejeed �d!�d"��Zejeed#�d$�d%��Zd&�Zejeed'�d(�d)��Zejeed'�d(�d*��Zejeed'�okejjd+�d(�d,��Zejeed-�d.�d/��Zejeed0�d1�d2��Zejeed3�d4�d5��Zejeed6�d7�d8��Z ejeed6�d7�ejeed9�d:�d;���Z!d<�Z"ejeed=�d>�d?��Z#ejeed@�dA�dB��Z$ejeedC�dD�dE��Z%ejeedF�dG�dH��Z&ejeedI�dJ�dK��Z'ejeedL�dM�dN��Z(ejeedO�dP�dQ��Z)ejeedR�dS�dT��Z*ejeedU�dV�dW��Z+ejeedX�dY�dZ��Z,ejeed[�d\�d]��Z-ejeed^�d_�d`��Z.da�Z/ejeedb�dc�dd��Z0ejeede�df�dg��Z1ejeede�df�dh��Z2ejeedi�dj�dk��Z3ejee4dl�dm�dn��Z5RS(ocCs/ttjd�}|j�tjg|_dS(Nsw+(topenRtTESTFNtclosetteardown_files(tselftfp((sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pytsetUps
cCs%x|jD]}tj|�q
WdS(N(Rtostunlink(Rt
teardown_file((sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyttearDown#scCs�ddddddddd	d
ddd
ddg}tj��dtjddt�xI|D]A}tt|d�}|dk	rZ|�|jt|d�qZqZWWdQXdS(Ntctermidtgetcwdtgetcwdutunamettimest
getloadavgttmpnamtgetegidtgeteuidtgetgidt	getgroupstgetpidtgetpgrptgetppidtgetuidRti(	twarningstcatch_warningstfilterwarningstDeprecationWarningtgetattrRtNonetassertRaisest	TypeError(RtNO_ARG_FUNCTIONStnamet
posix_func((sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyttestNoArgFunctions's	

t	getresuidstest needs posix.getresuid()cCsGtj�}|jt|�d�x|D]}|j|d�q)WdS(Nii(RR+tassertEqualtlentassertGreaterEqual(Rtuser_idstval((sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyttest_getresuid8s
t	getresgidstest needs posix.getresgid()cCsGtj�}|jt|�d�x|D]}|j|d�q)WdS(Nii(RR2R,R-R.(Rt	group_idsR0((sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyttest_getresgid@s
t	setresuidstest needs posix.setresuid()cCsBtj�}|jtj|��|jtjddd��dS(Ni����(RR+tassertIsNoneR5(Rtcurrent_user_ids((sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyttest_setresuidHscCsLtj�}d|krH|ddddf}|jttj|�ndS(Niii����(RR+R%tOSErrorR5(RR7tnew_user_ids((sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyttest_setresuid_exceptionPst	setresgidstest needs posix.setresgid()cCsBtj�}|jtj|��|jtjddd��dS(Ni����(RR2R6R<(Rtcurrent_group_ids((sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyttest_setresgidYscCsLtj�}d|krH|ddddf}|jttj|�ndS(Niii����(RR2R%R9R<(RR=t
new_group_ids((sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyttest_setresgid_exceptionast
initgroupsstest needs os.initgroups()cCs|jttj�|jttjd�|jttjdd�|jttjddt��tj�dkrytj	tj��j
}Wn tk
r�tj
d��nXytj|d�Wn)tk
r�}|j|jtj�qX|jd�ndS(Nitfooisneed a pwd entryi
s+Expected OSError to be raised by initgroups(R%R&RRAR$tobjectRRtpwdtgetpwuidtpw_nametKeyErrortunittesttSkipTestR9R,terrnotEPERMtfail(RR(te((sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyttest_initgroupsjs
tstatvfsstest needs posix.statvfs()cCs|jtjtj��dS(N(t
assertTrueRRORtcurdir(R((sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyttest_statvfs�stfstatvfsstest needs posix.fstatvfs()cCsAttj�}z |jtj|j���Wd|j�XdS(N(RRRRPRRStfilenoR(RR	((sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyt
test_fstatvfs�s t	ftruncatestest needs posix.ftruncate()cCsUttjd�}z1|jd�|j�tj|j�d�Wd|j�XdS(Nsw+ttesti(	RRRtwritetflushRRVRTR(RR	((sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyttest_ftruncate�s

tdupstest needs posix.dup()cCsWttj�}z6tj|j��}|j|t�tj	|�Wd|j	�XdS(N(
RRRRR[RTtassertIsInstancetintRR(RR	tfd((sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyttest_dup�stconfstrstest needs posix.confstr()cCs?|jttjd�|jttjd��dkt�dS(Nt
CS_garbagetCS_PATHi(R%t
ValueErrorRR`R,R-tTrue(R((sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyttest_confstr�stdup2stest needs posix.dup2()cCsZttj�}ttj�}z tj|j�|j��Wd|j�|j�XdS(N(RRRRRfRTR(Rtfp1tfp2((sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyt	test_dup2�s 
cGs8tjtjtj�}tj||�}|j�dS(N(RRRRtO_RDONLYRtfdopenR(RtargsR^Rh((sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyt
fdopen_helper�sRkstest needs posix.fdopen()cCs+|j�|jd�|jdd�dS(Ntrid(Rm(R((sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyttest_fdopen�s

cCs�ytjdtj�}Wn6tk
rQ}|j|jtj�|jd�nX|jt	��}tj
|d�WdQX|j|jjtj�dS(Nt.ssystem cannot open directoriesRn(
RRRjR9R,RJtEACCEStskipTestR%tIOErrorRkt	exceptiontEISDIR(RR^RMtcm((sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyttest_fdopen_directory�stsunoscCsBtjtjtj�}|jttj|d�tj	|�dS(Ntw(
RRRRRjR%R9RRkR(RR^((sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyt#test_fdopen_keeps_fd_open_on_errors�stO_EXLOCKstest needs posix.O_EXLOCKcCs�tjtjtjtjBtjB�}|jttjtjtjtjBtj	B�tj
|�ttd�r�tjtjtjtj
BtjB�}|jttjtjtjtjBtj	B�tj
|�ndS(NtO_SHLOCK(RRRRtO_WRONLYR{tO_CREATR%R9t
O_NONBLOCKRthasattrRR|(RR^((sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyt
test_osexlock�s
R|stest needs posix.O_SHLOCKcCs�tjtjtjtjBtjB�}tjtjtjtjBtjB�}tj|�tj|�tt	d�r�tjtjtjtjBtjB�}|j
ttjtjtjtj
BtjB�tj|�ndS(NR{(RRRRR}R|R~RR�RR%R9RjR{R(Rtfd1tfd2R^((sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyt
test_osshlock�s

tfstatstest needs posix.fstat()cCsAttj�}z |jtj|j���Wd|j�XdS(N(RRRRPRR�RTR(RR	((sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyt
test_fstat�s tstatstest needs posix.stat()cCs|jtjtj��dS(N(RPRR�RR(R((sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyt	test_statstmakedevstest needs posix.makedev()cCs�tjtj�}|j}|j|ttf�|j|d�tj	|�}|j|ttf�|j|d�|j
tj	t|��|�|j
tj	t|��|�|jttj	t
|��|jttj	�|jttftj	d�tj|�}|j|ttf�|j|d�|j
tjt|��|�|j
tjt|��|�|jttjt
|��|jttj�|jttftjd�|j
tj||�|�|j
tjt|�t|��|�|j
tjt|�t|��|�|jttjt
|�|�|jttj|t
|��|jttj|�|jttj�dS(Nii����(RR�RRtst_devR\R]tlongR.tmajorR,R%R&tfloatRct
OverflowErrortminorR�(RtsttdevR�R�((sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyttest_makedevs6	((c	s���fd�}tj�}tj�}|�||�|||�|�d|�|||�|�|d�|||�|dkr�d
}|�||�|||�|�dd�|||�|�||�|||�n�tj�dkrtjd��n��jt|�dd�|||��jt|�dd�|||�dtj	�kr��jt|�dd�|||�nxlt
tfD]^}�jt|�||�|�|||��jt|�|||��|||�q�Wd	S(s/Common code for chown, fchown and lchown tests.csE�dk	rA���}�j|j|��j|j|�ndS(N(R$R,tst_uidtst_gid(tuidtgidR�(tfirst_paramRt	stat_func(sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyt
check_stat,si����iiisHP-UXtSunOSs1Skipping because of non-standard chown() behaviorNI�(sHP-UXR�(
RRRtplatformtsystemRHRIR%R9RtstrR�R&(	Rt
chown_funcR�R�R�R�R�t	big_valuett((R�RR�sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyt_test_all_chown_common*s>







tchownstest needs os.chown()cCsntjtj�|jttjtjdd�ttjd�j	�|j
tjtjttdd��dS(Ni����RyR�(
RRRRR%R9RR�RRR�R#R$(R((sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyt
test_chownes
tfchownstest needs os.fchown()cCsftjtj�ttjd�}z2|j�}|jtj|t	tdd��Wd|j�XdS(NRyR�(RRRRRRTR�RR�R#R$R(Rt	test_fileR^((sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyttest_fchownpstlchownstest needs os.lchown()cCsLtjtj�tjttj�|jtjtjt	tdd��dS(Ntlstat(RRRRtsymlinkt_DUMMY_SYMLINKR�RR�R#R$(R((sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyttest_lchown}stchdirstest needs posix.chdir()cCs-tjtj�|jttjtj�dS(N(RR�RRQR%R9RR(R((sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyt
test_chdir�stlsdirstest needs posix.lsdir()cCs#|jtjtjtj��dS(N(tassertInRRRR�RRQ(R((sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyt
test_lsdir�staccessstest needs posix.access()cCs#|jtjtjtj��dS(N(RPRR�RRRtR_OK(R((sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyttest_access�stumaskstest needs posix.umask()cCs0tjd�}|j|t�tj|�dS(Ni(RR�R\R](Rtold_mask((sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyt
test_umask�ststrerrorstest needs posix.strerror()cCs|jtjd��dS(Ni(RPRR�(R((sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyt
test_strerror�stpipestest needs posix.pipe()cCs0tj�\}}tj|�tj|�dS(N(RR�RR(Rtreadertwriter((sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyt	test_pipe�s
ttempnamstest needs posix.tempnam()cCsrtj��`tjddt�|jtj��|jtjtj��|jtjtjd��WdQXdS(NRR�tblah(	RR R!R"RPRR�RRQ(R((sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyttest_tempnam�s

ttmpfilestest needs posix.tmpfile()cCs@tj��.tjddt�tj�}|j�WdQXdS(NRR�(RR R!R"RR�R(RR	((sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyttest_tmpfile�s
tutimestest needs posix.utime()cCs�tj�}tjtjd�|jttjtjd�|jttjtj|df�|jttjtjd|f�tjtjt|�t|�f�tjtj||f�dS(N(NN(	ttimeRR�RRR$R%R&R](Rtnow((sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyt
test_utime�s""%c	Cstj|�}|jt|d��y|||jtjB�Wn>tk
r�}|jtjkrj�nd}|j	|�nXzotj|�}|j
|jtjB|j�yt|d�}Wn)tk
r�}|j
|jtj
�nXWdtj||j�XdS(Ntst_flagss2chflag UF_IMMUTABLE not supported by underlying fssw+(RR�RPR�R�tUF_IMMUTABLER9RJt
EOPNOTSUPPRrR,RRsRKRtchflags(	Rtchflags_functtarget_fileR�terrtmsgtnew_stR^RM((sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyt_test_chflags_regular_file�s"R�stest needs os.chflags()cCs|jtjtj�dS(N(R�RR�RR(R((sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyttest_chflags�stlchflagsstest needs os.lchflags()cCs|jtjtj�dS(N(R�RR�RR(R((sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyttest_lchflags_regular_file�scCs,tjtj�}|jt|d��tjtjt�|jj	t�tj
t�}ytjt|j
tjB�Wn>tk
r�}|jtjkr��nd}|j|�nXzXtjtj�}tj
t�}|j|j
|j
�|j|j
tjB|j
�Wdtjt|j
�XdS(NR�s2chflag UF_IMMUTABLE not supported by underlying fs(RR�RRRPR�R�R�RtappendR�RR�R�R�R9RJR�RrR,(Rt	testfn_sttdummy_symlink_stR�R�t
new_testfn_sttnew_dummy_symlink_st((sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyttest_lchflags_symlink�s(	Rstest needs posix.getcwd()cs�d}tj�}tjjtj�d}ytj|�tj|�Wn�jd�nXz#d��fd���|�Wdtj|�t	j
|�XdS(Ns8getcwd-test-directory-0123456789abcdef-01234567890abcdefs.getcwds#cannot create directory for testingicsytj|�Wn�jd�nXtj|�z�y8tj�|dkro�||t|�d�nWnntk
r�}tj}dt	j
kp�dt	j
kp�dt	j
k}|r�tj}n�j|j|�nXWdtjd�tj
|�XdS(Ns?mkdir cannot create directory sufficiently deep for getcwd testiiRxtnetbsdtopenbsds..(RtmkdirRrR�RR-R9RJtENAMETOOLONGtsysR�tERANGER,trmdir(tdirnametcurrent_path_lengthRMtexpected_errnotquirky_platform(t_create_and_do_getcwdR(sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyR�	s(

"	
(RRtpathtabspathRRR�R�Rrtshutiltrmtree(RR�RQt	base_path((R�Rsh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyttest_getcwd_long_pathnames�s

Rstest needs os.getegid()cCstjd��%}|j�j�}|j�}WdQX|dksI|r[tjd��ntj	dkr�ddl
}|jd�p�d}td�|j
d�d	d
!D��dkr�tjd
��q�n|jtg|j
�D]}t|�^q��ttj�tj�g��dS(Nsid -G 2>/dev/nullsneed working 'id -G'tdarwini����tMACOSX_DEPLOYMENT_TARGETs10.0css|]}t|�VqdS(N(R](t.0tn((sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pys	<genexpr>9sRpiii
is$getgroups(2) is broken prior to 10.6(i
i(RtpopentreadtstripRR$RHRIR�R�t	sysconfigtget_config_varttupletsplitR,tsetR]RRR(RtidgtgroupstretR�tdttx((sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyttest_getgroups,s,((6t__name__t
__module__R
RR*RHt
skipUnlessR�RR1R4R8R;R>R@RNRRRURZR_ReRiRmRoRwR�R�t
startswithRzR�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�RR�(((sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyRs�			

	'!	;$$
$$$$$$$
	$$$0tPosixGroupsTestercBsbeZd�Zd�Zejeed�d�d��Zejeed�d�d��Z	RS(cCsytj�dkr$tjd��nttd�sEtjd��ntjdkrftjd��ntj�|_dS(Nisnot enough privilegesRsneed posix.getgroupsR�sgetgroups(2) is broken on OSX(	RRRHRIR�R�R�Rtsaved_groups(R((sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyR
FscCsgttd�r"tj|j�nAttd�rctjtj��j}tj||jd�ndS(Nt	setgroupsRAi(	R�RRRRDRERRFRA(RR(((sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyROs
RAstest needs posix.initgroups()cCs^t|jpdg�d}tjtj��j}tj||�|j|tj	��dS(Nii(
tmaxRRDRERRRFRAR�R(RtgR(((sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyRNVsRstest needs posix.setgroups()cCsGx@dgtd�gD])}tj|�|j|tj��qWdS(Nii(trangeRRtassertListEqualR(RR�((sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyttest_setgroups`s
(
R�R�R
RRHR�R�RRNR(((sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyRDs				cCstjtt�dS(N(Rtrun_unittestRR(((sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyt	test_mainhst__main__(t__doc__RWRt
import_moduleRRJR�R�RR�RDR�R�ttempfileRHRR�tjoint
gettempdirRR�R!tRuntimeWarningtTestCaseRRR
R�(((sh/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_posix.pyt<module>s2��+$