Your IP : 216.73.216.85


Current Path : /opt/alt/python35/lib64/python3.5/test/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/test/__pycache__/test_posix.cpython-35.opt-2.pyc



$�Yf���@sddlmZejd�ZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZejjej�ejd�ZGdd�de
j�ZGdd�de
j�Zd	d
�Zedkre�dS)�)�support�posixNz-dummy-symlinkc@s*
eZdZdd�Zdd�Zdd�Zejee	d�d�d	d
��Z
ejee	d�d�d
d��Zejee	d�d�dd��Zejee	d�d�dd��Z
ejee	d�d�dd��Zejee	d�d�dd��Zejee	d�d�dd��Zejee	d�d �d!d"��Zejee	d#�d$�d%d&��Zejee	d'�d(�d)d*��Zejee	d+�d,�d-d.��Zejeed/d0�ejkd1�ejeed2�d3�ejeed4�d5�d6d7����Zejee	d8�d9�ejeed2�d3�d:d;���Zejee	d<�d=�d>d?��Zejee	d@�dA�dBdC��Zejee	dD�dE�dFdG��Zejee	dH�dI�dJdK��Zejee	dL�dM�dNdO��ZejejejkdP�dQdR��Z ejejej!kdS�dTdU��Z"ejee	dV�dW�dXdY��Z#ejee	dZ�d[�d\d]��Z$ejee	d^�d_�d`da��Z%ejee	db�dc�ddde��Z&ejee	df�dg�dhdi��Z'ejeedj�dk�e(j)dldmdn�dodp���Z*ejee	dq�dr�dsdt��Z+ejee	du�dv�dwdx��Z,ejee	dy�dz�d{d|��Z-ejee	d}�d~�dd���Z.ejee	d��d��d�d���Z/ejee	d��o�ee0d��d��d�d���Z1ejee	d}�d~�ejee	d��d��d�d����Z2d�d��Z3ejee	d��d��d�d���Z4ejee	d��d��d�d���Z5ejee	d��d��d�d���Z6ejee	d��d��d�d���Z7d�d��Z8d�d��Z9d�d��Z:d�d��Z;eje	j<ejkd��d�d���Z=ejee	d��d��d�d���Z>ejee	d��d��d�d���Z?ejee	d��d��d�d���Z@ejee	d��d��d�d���ZAejeed��d��e(j)dldmd��d�d����ZBe(jCejeed��d��e(j)dldmd��d�d�����ZDejee	d��d��d�d���ZEd�d��ZFejee	d��d��d�d���ZGejee	d��d��d�d���ZHejee	d��d��d�d���ZId�d��ZJejeed��d��d�d���ZKejee	d��d��d�d���ZLejee	d��d��ejeeMd��d��ejeed��d��d�d�����ZNejeed��d��d�d���ZOejejPejQkd��d�d���ZRejejSejQkd��d�d���ZTejejUejQkd��d�d���ZVejej0ejQkd��d�d���ZWejejejQkd��d�d���ZXejejYejQkd��d�d���ZZejej[ejQkd��d�d���Z\ejej]ejQko�
ee0d��d��d�d���Z^ejej_ejQkd�dd��Z`ejejaejQkd�dd��ZbejejcejQkd�dd��ZdejejeejQkd	�d
d��ZfejejgejQkd�d
d��ZhejejiejQkd�dd��Zjejee	d�d�Zkejee	d�d�Zlekdd��Zmekejee	d�d�dd���Znejee	d�d�dd��Zoejee	d �d!�d"d#��Zpeld$d%��Zqeld&d'��Zrd(d)�Zsejtd*�ejeed+�d,�d-d.���Zud/d0�Zvd1d2�Zwd3d4�Zxd0S(5�PosixTestercCs^ttjd�}|j�tjg|_tj�|_|jj�tj	ddt
�dS)Nzw+�ignorez.* potential security risk .*)�openr�TESTFN�close�teardown_filesZcheck_warnings�_warnings_manager�	__enter__�warnings�filterwarnings�RuntimeWarning)�self�fp�r�//opt/alt/python35/lib64/python3.5/test_posix.py�setUps

zPosixTester.setUpcCs;x|jD]}tj|�q
W|jjddd�dS)N)r	r�unlinkr
�__exit__)rZ
teardown_filerrr�tearDown#szPosixTester.tearDowncCs�ddddddddd	d
ddd
ddg}xF|D]>}tt|d�}|dk	r:|�|jt|d�q:WdS)N�ctermid�getcwd�getcwdb�uname�times�
getloadavg�getegid�geteuid�getgid�	getgroups�getpid�getpgrp�getppid�getuid�sync�)�getattrr�assertRaises�	TypeError)rZNO_ARG_FUNCTIONS�nameZ
posix_funcrrr�testNoArgFunctions(s
zPosixTester.testNoArgFunctions�	getresuidztest needs posix.getresuid()cCsGtj�}|jt|�d�x|D]}|j|d�q)WdS)N�r)rr,�assertEqual�len�assertGreaterEqual)rZuser_ids�valrrr�test_getresuid7s
zPosixTester.test_getresuid�	getresgidztest needs posix.getresgid()cCsGtj�}|jt|�d�x|D]}|j|d�q)WdS)Nr-r)rr3r.r/r0)rZ	group_idsr1rrr�test_getresgid?s
zPosixTester.test_getresgid�	setresuidztest needs posix.setresuid()cCsBtj�}|jtj|��|jtjddd��dS)Nr&���r6r6)rr,�assertIsNoner5)r�current_user_idsrrr�test_setresuidGszPosixTester.test_setresuidcCsItj�}d|krE|ddddf}|jttj|�dS)Nrr&r6r6)rr,r(�OSErrorr5)rr8Znew_user_idsrrr�test_setresuid_exceptionOsz$PosixTester.test_setresuid_exception�	setresgidztest needs posix.setresgid()cCsBtj�}|jtj|��|jtjddd��dS)Nr&r6r6r6)rr3r7r<)r�current_group_idsrrr�test_setresgidXszPosixTester.test_setresgidcCsItj�}d|krE|ddddf}|jttj|�dS)Nrr&r6r6)rr3r(r:r<)rr=Z
new_group_idsrrr�test_setresgid_exception`sz$PosixTester.test_setresgid_exception�
initgroupsztest needs os.initgroups()cCs|jttj�|jttjd�|jttjdd�|jttjddt��tj�dkrytjtj��j	}Wn!t
k
r�tjd��YnXytj|d�Wn;t
k
r}z|j|jtj�WYdd}~XnX|jd�dS)Nr-Zfoorzneed a pwd entry�
z+Expected OSError to be raised by initgroups)r(r)rr@�object�osr$�pwd�getpwuid�pw_name�KeyError�unittest�SkipTestr:r.�errno�EPERM�fail)rr*�errr�test_initgroupsis
)zPosixTester.test_initgroups�statvfsztest needs posix.statvfs()cCs|jtjtj��dS)N)�
assertTruerrOrC�curdir)rrrr�test_statvfs�szPosixTester.test_statvfs�fstatvfsztest needs posix.fstatvfs()c
Cs]ttj�}z<|jtj|j���|jtj|j���Wd|j�XdS)N)	rrrrPrrS�filenorOr)rrrrr�
test_fstatvfs�s
 zPosixTester.test_fstatvfs�	ftruncateztest needs posix.ftruncate()c
CsUttjd�}z1|jd�|j�tj|j�d�Wd|j�XdS)Nzw+�testr)	rrr�write�flushrrVrTr)rrrrr�test_ftruncate�s

zPosixTester.test_ftruncate�truncateztest needs posix.truncate()c
CsJttjd��}|jd�|j�WdQRXtjtjd�dS)N�wrWr)rrrrXrYrr[)rrrrr�
test_truncate�s
zPosixTester.test_truncate�execveNz/test needs execve() to support the fd parameter�forkztest needs os.fork()�waitpidztest needs os.waitpid()cCs�tjtjtj�}z�tj�}|dkrxtjtjjtj�d�t	j
|tjddgtj�n"|jtj
|d�|df�Wdtj|�XdS)Nrz-c�pass)rCr�sys�
executable�O_RDONLYr_�chdir�path�splitrr^�environr.r`r)rr�pidrrr�test_fexecve�s %&zPosixTester.test_fexecve�waitidztest needs posix.waitid()cCs�tj�}|dkr`tjtjjtj�d�tjtjtjddgtj	�n.tj
tj|tj�}|j
||j�dS)Nrz-cra)rCr_rerfrgrbrcrr^rhrk�P_PID�WEXITEDr.�si_pid)rri�resrrr�test_waitid�s (zPosixTester.test_waitid�lockfztest needs posix.lockf()cCs�tjtjtjtjB�}zVtj|d�tj|dtj�t	j
|t	jd�t	j
|t	jd�Wdtj
|�XdS)Nstestr�)rCrrr�O_WRONLY�O_CREATrX�lseek�SEEK_SETrrq�F_LOCK�F_ULOCKr)r�fdrrr�
test_lockf�szPosixTester.test_lockf�preadztest needs posix.pread()cCs�tjtjtjtjB�}zetj|d�tj|dtj�|j	dt
j|dd��|j	dt
j|d��Wdtj
|�XdS)Nstestrses�r&ste)rCrrr�O_RDWRrtrXrurvr.rr{�readr)rryrrr�
test_pread�s zPosixTester.test_pread�pwriteztest needs posix.pwrite()cCs�tjtjtjtjB�}zYtj|d�tj|dtj�t	j
|dd�|jdt	j|d��Wdtj
|�XdS)Nstestrsxxr&stxxtrr)rCrrrr}rtrXrurvrr�r.r~r)rryrrr�test_pwrite�s zPosixTester.test_pwrite�posix_fallocatez"test needs posix.posix_fallocate()cCs�tjtjtjtjB�}zkytj|dd�WnMtk
r�}z-|j	t	j
ksstjj
d�rv�WYdd}~XnXWdtj|�XdS)Nr�
�sunos)rCrrrrsrtrr�r:rJ�EINVALrb�platform�
startswithr)rry�instrrr�test_posix_fallocate�s%z PosixTester.test_posix_fallocate�
posix_fadvisez test needs posix.posix_fadvise()cCsJtjtjtj�}ztj|ddtj�Wdtj|�XdS)Nr)	rCrrrrdrr��POSIX_FADV_WILLNEEDr)rryrrr�test_posix_fadvise�szPosixTester.test_posix_fadvisez!test needs fd support in os.utimecCs�tj�}tjtjtj�}z�tj|�tj|d�|jt	tj|d�|jt	tj||df�|jt	tj|d|f�tj|t
|�t
|�f�tj|||f�|jttj|||fd||f�|jttj||dfdd�|jttj|dd|df�tj|t
|�t
|t
|�d�f�tj|dt
|�t
|t
|�d�f�Wdtj|�XdS)N�nsrge��A)NN)NN)NN)
�timerCrrrrdr�utimer(r)�int�
ValueErrorr)r�nowryrrr�test_utime_with_fd�s 
"+%%07zPosixTester.test_utime_with_fdz.test needs follow_symlinks support in os.utimecCs�tj�}tjtjddd�|jttjtjddd�|jttjtj|dfdd�|jttjtjd|fdd�tjtjt|�t|�fdd�tjtj||fdd�tjtjdd�dS)N�follow_symlinksF)NN)r�rr�rrr(r)r�)rr�rrr�test_utime_nofollow_symlinks
s"((+z(PosixTester.test_utime_nofollow_symlinks�writevztest needs posix.writev()cCs�tjtjtjtjB�}z�tj|d�}|j|d�tj|dtj	�|jdt
j|d��yt
j|g�}Wntk
r�YnX|j|d�Wdtj
|�XdS)N�test1�tt2�t3r�rs
test1tt2t3)r�r�r�)rCrrrr}rtr�r.rurvrr~r:r)rry�n�sizerrr�test_writevs
zPosixTester.test_writev�readvztest needs posix.readv()cCs�tjtjtjtjB�}z�tj|d�tj|dtj�dd�dddgD�}|j	t
j||�d�|j	d	d
dgdd�|D��yt
j|g�}Wntk
r�YnX|j	|d�Wdtj
|�XdS)
Ns
test1tt2t3rcSsg|]}t|��qSr)�	bytearray)�.0�irrr�
<listcomp>4s	z*PosixTester.test_readv.<locals>.<listcomp>�r-r|r�stest1stt2st3cSsg|]}t|��qSr)�bytes)r�r�rrrr�6s	)rCrrrr}rtrXrurvr.rr�r:r)rry�bufr�rrr�
test_readv.s&
zPosixTester.test_readv�dupztest needs posix.dup()c
CsWttj�}z6tj|j��}|j|t�tj	|�Wd|j	�XdS)N)
rrrrr�rT�assertIsInstancer�rCr)rrryrrr�test_dupDszPosixTester.test_dup�confstrztest needs posix.confstr()cCs?|jttjd�|jttjd��dkd�dS)NZ
CS_garbage�CS_PATHrT)r(r�rr�r.r/)rrrr�test_confstrOszPosixTester.test_confstr�dup2ztest needs posix.dup2()c
CsZttj�}ttj�}z tj|j�|j��Wd|j�|j�XdS)N)rrrrr�rTr)r�fp1�fp2rrr�	test_dup2Us 
zPosixTester.test_dup2�	O_CLOEXECzneeds os.O_CLOEXECr|��cCsLtjtjtjtjB�}|jtj|�|jtj	|��dS)N)
rCrrrrdr��
addCleanupr�assertFalse�get_inheritable)rryrrr�test_oscloexec`szPosixTester.test_oscloexec�O_EXLOCKztest needs posix.O_EXLOCKcCs�tjtjtjtjBtjB�}|jttjtjtjtjBtj	B�tj
|�ttd�r�tjtjtjtj
BtjB�}|jttjtjtjtjBtj	B�tj
|�dS)N�O_SHLOCK)rCrrrrsr�rtr(r:�
O_NONBLOCKr�hasattrrr�)rryrrr�
test_osexlockgs
zPosixTester.test_osexlockr�ztest needs posix.O_SHLOCKcCs�tjtjtjtjBtjB�}tjtjtjtjBtjB�}tj|�tj|�tt	d�r�tjtjtjtjBtjB�}|j
ttjtjtjtj
BtjB�tj|�dS)Nr�)rCrrrrsr�rtrr�rr(r:rdr�r�)r�fd1�fd2ryrrr�
test_osshlockws

zPosixTester.test_osshlock�fstatztest needs posix.fstat()cCs�ttj�}za|jtj|j���|jtj|j���|jt	dtjt
|j���Wd|j�XdS)Nz'should be string, bytes or integer, not)rrrrPrr�rT�stat�assertRaisesRegexr)�floatr)rrrrr�
test_fstat�s	zPosixTester.test_fstatr�ztest needs posix.stat()cCs�|jtjtj��|jtjtjtj���|jtjttjtj����|jt	dtjd�|jt	dtjt
tj��|jt	dtjt
tjtj���dS)Nz$can't specify None for path argumentz'should be string, bytes or integer, not)rPrr�rrrC�fsencoder�r�r)�list)rrrr�	test_stat�s"(	
		zPosixTester.test_stat�mkfifozdon't have mkfifo()cCsVtjtj�tjtjtjtjB�|jtj	tjtj�j
��dS)N)rrrrr�r��S_IRUSR�S_IWUSRrP�S_ISFIFO�st_mode)rrrr�test_mkfifo�szPosixTester.test_mkfifo�mknod�S_IFIFOzdon't have mknod()/S_IFIFOcCs1tjtj�tjtjBtjB}ytjtj|d�WnDt	k
r�}z$|j
|jtjtj
f�WYdd}~Xn&X|jtjtjtj�j��tjtj�y)tjdtjd|dddd�WnDt	k
r,}z$|j
|jtjtj
f�WYdd}~XnXdS)Nrrf�modeZdevice�dir_fd)rrrr�r�r�r�rr�r:�assertInrJrKr�rPr�r�)rr�rMrrr�
test_mknod�s2%zPosixTester.test_mknod�makedevztest needs posix.makedev()cCs�tjtj�}|j}|j|t�|j|d�tj|�}|j|t�|j|d�|j	tj|�|�|j
ttjt|��|j
ttj�|j
t
tftjd�tj|�}|j|t�|j|d�|j	tj|�|�|j
ttjt|��|j
ttj�|j
t
tftjd�|j	tj||�|�|j
ttjt|�|�|j
ttj|t|��|j
ttj|�|j
ttj�dS)Nrr&r6r6)rr�rr�st_devr�r�r0�majorr.r(r)r�r��
OverflowError�minorr�)r�stZdevr�r�rrr�test_makedev�s.	zPosixTester.test_makedevc	s���fdd�}tj�}tj�}|�||�|||�|�d
|�|||�|�|d�|||�|dkr�d}|�||�|||�|�d
d�|||�|�||�|||�n�tj�dkrtjd	��n��jt|�dd�|||��jt|�dd�|||�dtj	�kr��jt|�dd�|||�xlt
tfD]^}�jt|�||�|�|||��jt|�|||��|||�q�WdS)NcsB�dk	r>���}�j|j|��j|j|�dS)N)r.�st_uid�st_gid)�uid�gidr�)�first_paramr�	stat_funcrr�
check_stat�sz6PosixTester._test_all_chown_common.<locals>.check_statr&rr|��HP-UX�SunOSz1Skipping because of non-standard chown() behaviorr6r6lr6r6)r�r�r6r6)
rCr$rr��systemrHrIr(r:r �strr�r))	rZ
chown_funcr�r�r�r�r�Z	big_value�tr)r�rr�r�_test_all_chown_common�s>








z"PosixTester._test_all_chown_common�chownztest needs os.chown()cCshtjtj�|jttjtjdd�tjtj�|j	tjtjt
tdd��dS)Nr&r�r6r6)rCrrrr(r:rr��create_empty_filer�r')rrrr�
test_chowns
zPosixTester.test_chown�fchownztest needs os.fchown()c
Csftjtj�ttjd�}z2|j�}|jtj|t	tdd��Wd|j
�XdS)Nr\r�)rCrrrrrTr�rr�r'r)rZ	test_fileryrrr�test_fchown)szPosixTester.test_fchown�lchownztest needs os.lchown()cCsLtjtj�tjttj�|jtjtjt	tdd��dS)N�lstat)
rCrrr�symlink�_DUMMY_SYMLINKr�rr�r')rrrr�test_lchown6szPosixTester.test_lchownreztest needs posix.chdir()cCs-tjtj�|jttjtj�dS)N)rrerCrQr(r:rr)rrrr�
test_chdir>szPosixTester.test_chdircCs#|jtjtjtj��dS)N)r�rrr�listdirrCrQ)rrrr�test_listdirCszPosixTester.test_listdircCs|jtjtj��dS)N)r�rrrr�)rrrr�test_listdir_defaultFsz PosixTester.test_listdir_defaultcCs)|jtjtj�tjd��dS)N�.)r�rCr�rrrr�)rrrr�test_listdir_bytesKszPosixTester.test_listdir_bytescCssxlttfD]^}tj|d��}|jtjtj�|�x$|D]}|j	t
|�t�qKWq
WdS)Nr�)r��
memoryviewrr�r�rCr�rrZassertIs�typer�)r�cls�namesr*rrr�test_listdir_bytes_likePs

z#PosixTester.test_listdir_bytes_likez)test needs fd support for posix.listdir()cCs�tjtj�tj�}|jtj|�|jttjd��ttj|���|jttjd��ttj|���dS)N�.)	rrrrdr�rr.�sortedr�)r�frrr�test_listdir_fdXszPosixTester.test_listdir_fd�accessztest needs posix.access()cCs#|jtjtjtj��dS)N)rPrrrrrC�R_OK)rrrr�test_accessgszPosixTester.test_access�umaskztest needs posix.umask()cCs0tjd�}|j|t�tj|�dS)Nr)rrr�r�)rZold_maskrrr�
test_umaskkszPosixTester.test_umask�strerrorztest needs posix.strerror()cCs|jtjd��dS)Nr)rPrr)rrrr�
test_strerrorqszPosixTester.test_strerror�pipeztest needs posix.pipe()cCs0tj�\}}tj|�tj|�dS)N)rrrCr)r�reader�writerrrr�	test_pipevs
zPosixTester.test_pipe�pipe2ztest needs os.pipe2()�cCsH|jttjd�|jttjdd�tjd�\}}tj|�tj|�tjtjtjB�\}}|jtj|�|jtj|�|jtj	|��|jtj	|��|jtj
|��|jtj
|��|jttj|d�ytj
|dtj�Wntk
rCYnXdS)NZDEADBEEFrr&�x)r(r)rCrrr�r�r�r�r��get_blockingr:r~rXrZ
PIPE_MAX_SIZE)r�rr\rrr�
test_pipe2|s"


zPosixTester.test_pipe2cCsJddl}|jttj|jd�|jttj|jd�dS)Nrr&)�	_testcapir(r�rCrZINT_MAXZUINT_MAX)rrrrr�test_pipe2_c_limits�szPosixTester.test_pipe2_c_limitsr�ztest needs posix.utime()cCs�tj�}tjtjd�|jttjtjd�|jttjtj|df�|jttjtjd|f�tjtjt|�t|�f�tjtj||f�dS)N)NN)r�rr�rrr(r)r�)rr�rrr�
test_utime�s""%zPosixTester.test_utimec&Ks5tj|�}|jt|d��|jtjB}y||||�WnMtk
r�}z-|jtjkrs�d}|j	|�WYdd}~XnXz�tj|�}|j
|jtjB|j�yt|d�}	Wn;tk
r}
z|j
|
jtj�WYdd}
~
XnXWdt
j||j�XdS)N�st_flagsz2chflag UF_IMMUTABLE not supported by underlying fszw+)rCr�rPr�r�UF_IMMUTABLEr:rJ�
EOPNOTSUPP�skipTestr.rrKr�chflags)rZchflags_funcZtarget_file�kwargsr��flags�err�msgZnew_stryrMrrr�_test_chflags_regular_file�s$ -z&PosixTester._test_chflags_regular_filerztest needs os.chflags()cCs|jtjtj�dS)N)rrrrr)rrrr�test_chflags�szPosixTester.test_chflags�lchflagsztest needs os.lchflags()cCs6|jtjtj�|jtjtjdd�dS)Nr�F)rrr rrr)rrrr�test_lchflags_regular_file�sz&PosixTester.test_lchflags_regular_filec
Csatjtj�}|jt|d��tjtjt�|jj	t�tj
t�}dd�}x�tj|fD]�}|j
tjB}y|t|�WnMtk
r�}z-|jtjkr��d}|j|�WYdd}~XnXzXtjtj�}tj
t�}	|j|j
|j
�|j|j
tjB|	j
�Wd|t|j
�XqvWdS)NrcSstj||dd�S)Nr�F)rr)rfrrrr�chflags_nofollow�sz;PosixTester.test_lchflags_symlink.<locals>.chflags_nofollowz2chflag UF_IMMUTABLE not supported by underlying fs)rCr�rrrPr�r�r�r	�appendr�rr rrr:rJrrr.)
rZ	testfn_stZdummy_symlink_str"�fnrrrZ
new_testfn_stZnew_dummy_symlink_strrr�test_lchflags_symlink�s, z!PosixTester.test_lchflags_symlinkcCsntjdkrt}nt}xItjj�D]8\}}|jt|�|�|jt|�|�q.WdS)N�nt)	rCr*r�r�rrh�itemsr.r�)rZ	item_type�k�vrrr�test_environ�s	zPosixTester.test_environ�putenvzrequires os.putenv()c-Cs�|jt��tjdd�WdQRX|jt��tjdd�WdQRX|jt��tjdd�WdQRX|jt��tjdd�WdQRX|jt��tjd	d
�WdQRX|jt��tjdd�WdQRXdS)
NzFRUITVEGETABLEZcabbagesFRUITVEGETABLEscabbageZFRUITzorangeVEGETABLE=cabbagesFRUITsorangeVEGETABLE=cabbagezFRUIT=ORANGEZlemonsFRUIT=ORANGEslemon)r(r�rCr+)rrrr�test_putenv�szPosixTester.test_putenvrztest needs posix.getcwd()cs�d}tj�}tjjtj�d}zPytj|�tj|�Wn+dSd�fdd���|�YnXWdtj|�tj|�XdS)Nz8getcwd-test-directory-0123456789abcdef-01234567890abcdefz.getcwdrcs�ytj|�Wntjd��YnXtj|�z5tj�|dkrl�||t|�d�Wdtjd�tj|�XdS)Nz?mkdir cannot create directory sufficiently deep for getcwd testir&z..)rC�mkdirrHrIrerr/�rmdir)�dirnameZcurrent_path_length)�_create_and_do_getcwdrrr0s


zEPosixTester.test_getcwd_long_pathnames.<locals>._create_and_do_getcwd)	rCrrf�abspathrrr-re�rmtree)rr/rQ�	base_pathr)r0r�test_getcwd_long_pathnamess

z&PosixTester.test_getcwd_long_pathnames�getgrouplistztest needs posix.getgrouplist()rEztest needs pwd.getpwuid()r$ztest needs os.getuid()cCsRtjtj��d}tjtj��d}|j|tj||��dS)Nrr-)rDrErCr$r�rr5)r�user�grouprrr�test_getgrouplist)szPosixTester.test_getgrouplistrztest needs os.getegid()cCstjd��%}|j�j�}|j�}WdQRX|dk	sJ|rYtjd��tjdkr�ddl	}|j
d�p�d}tdd�|jd	�dd
�D��dkr�tjd
��|j
tdd�|j�D��ttj�tj�g��dS)Nzid -G 2>/dev/nullzneed working 'id -G'�darwinr�MACOSX_DEPLOYMENT_TARGETz10.0css|]}t|�VqdS)N)r�)r�r�rrr�	<genexpr>?sz-PosixTester.test_getgroups.<locals>.<genexpr>r�r|r�r�z$getgroups(2) is broken prior to 10.6cSsg|]}t|��qSr)r�)r��xrrrr�Gs	z.PosixTester.test_getgroups.<locals>.<listcomp>)r�r�)rC�popenr~�striprrHrIrbr��	sysconfig�get_config_var�tuplergr.�setrr r)rZidg�groups�retr?Zdtrrr�test_getgroups2s2zPosixTester.test_getgroupsz)test needs dir_fd support for os.access()cCsYtjtj�tj�}z)|jtjtjtj	d|��Wdtj
|�XdS)Nr�)rrrrdrPrrrrCrr)rr�rrr�test_access_dir_fdLs)zPosixTester.test_access_dir_fdz'test needs dir_fd support in os.chmod()cCs�tjtjtj�tjtj�tj	�}z^tjtjtjtj
Bd|�tjtj�}|j|dtj@tjtj
B�Wdtj
|�XdS)Nr�r)rC�chmodrrr�r�rrrrdr�r.�S_IRWXUr)rr��srrr�test_chmod_dir_fdTs#)zPosixTester.test_chmod_dir_fdz'test needs dir_fd support in os.chown()cCs|tjtj�tjtj�tjtj�tj�}z,tjtjt	j
�t	j�d|�Wdtj|�XdS)Nr�)
rrrr�rrrrdr�rCr$rr)rr�rrr�test_chown_dir_fdas,zPosixTester.test_chown_dir_fdz&test needs dir_fd support in os.stat()cCs>tjtj�ttjd��}|jd�WdQRXtjtj�tj�}z�tjtj�}tjtjd|�}|j	||�tjtjdd�}|j	||�|j
tdtjtjdtj��|j
tdtjtjdt|��|j
ttjtjdd�Wdtj|�XdS)Nr\z	testline
r�zshould be integer, notr��l F�x:^V)rrrrrXrrrdr�r.r�r)r�r(r�r)r�outfiler��s1�s2rrr�test_stat_dir_fdls"	zPosixTester.test_stat_dir_fdz'test needs dir_fd support in os.utime()cCs1tjtj�tj�}ztj�}tjtjdd|�tjtjd|�|jt	tjtj|d|�|jt	tjtjdd|�|jt	tjtj|dfd|�|jt	tjtjd|fd|�|jt	tjtj|dfd|�tjtjt
|�t
|�fd|�tjtj||fd|�tjtjt
|�t
|t
|�d�fd|�tjtjd|dt
|�t
|t
|�d�f�tjtjkry tjtjddd|�Wnt
k
rYnXWdtj|�XdS)Nr�r<ge��Arr�F)NN)rrrrdr�r�rrr(r)r�rC�supports_follow_symlinksr�r)rr�r�rrr�test_utime_dir_fd�s,""(((+-' 
	zPosixTester.test_utime_dir_fdz&test needs dir_fd support in os.link()c
Cs�tjtj�tj�}z^tjtjtjdd|d|�|jtjtj�dtjtjd�d�Wdtj	|�tj
tjd�XdS)N�link�
src_dir_fd�
dst_dir_fdr&)rrrrdrSrrr.r�rr)rr�rrr�test_link_dir_fd�s&
zPosixTester.test_link_dir_fdz'test needs dir_fd support in os.mkdir()cCsvtjtj�tj�}z2tjtjdd|�tjtjd�Wdtj|�tj	tjd�XdS)N�dirr�)
rrrrdr-rrr�rr2)rr�rrr�test_mkdir_dir_fd�s
zPosixTester.test_mkdir_dir_fdzAtest requires both stat.S_IFIFO and dir_fd support for os.mknod()cCs�tjtj�tjtjBtjB}tjtj	�tj
�}z�y tjtj|dd|�WnDtk
r�}z$|j
|jtjtjf�WYdd}~Xn&X|jtjtjtj�j��Wdtj|�XdS)Nrr�)rrrr�r�r�r�rrrrdr�r:r�rJrKr�rPr�r�r)rr�r�rMrrr�test_mknod_dir_fd�s 2)zPosixTester.test_mknod_dir_fdz&test needs dir_fd support in os.open()cCs�tjtj�ttjd��}|jd�WdQRXtjtj�tj�}tjtjtjd|�}z2tj|d�j	dd�}|j
d|�Wdtj|�tj|�XdS)Nr\z	testline
r��	�encodingzutf-8)rrrrrXrrrdr~�decoder.r)rrM�a�brorrr�test_open_dir_fd�s
zPosixTester.test_open_dir_fdz*test needs dir_fd support in os.readlink()cCs�tjtjtjd�tjtj�tj�}z:|jtj	tjd�tj	tjdd|��Wdtj
tjd�tj|�XdS)NrSr�)rCr�rrrrrrdr.�readlinkrr)rr�rrr�test_readlink_dir_fd�s!z PosixTester.test_readlink_dir_fdz(test needs dir_fd support in os.rename()cCs�tjtj�tjtjd�tjtj�tj�}zfy*tjtjdtjd|d|�Wn%tjtjdtj��YnXtj	tj�Wdtj
|�XdS)NZrenrTrU)rrrr�rrrrd�renamer�r)rr�rrr�test_rename_dir_fd�s*zPosixTester.test_rename_dir_fdz)test needs dir_fd support in os.symlink()cCs�tjtj�tj�}zGtjtjtjdd|�|jtjtjd�tj�Wdtj	|�tj
tjd�XdS)NrSr�)rrrrdr�rrr.r`rr)rr�rrr�test_symlink_dir_fd�s '
zPosixTester.test_symlink_dir_fdz(test needs dir_fd support in os.unlink()cCs�tjtj�tj�}tjtjd�tjtjd�zaytjtjdd|�Wntjtjd��YnX|j	t
tjtjd�Wdtj|�XdS)N�delr�rS)rrrrdrr�rr�rr(r:r)rr�rrr�test_unlink_dir_fd�s!zPosixTester.test_unlink_dir_fdz(test needs dir_fd support in os.mkfifo()cCs�tjtj�tjtj�tj�}zLtjtjtj	tj
Bd|�|jtjtjtj�j
��Wdtj|�XdS)Nr�)rrrrrrrdr�r�r�r�rPr�r�r)rr�rrr�test_mkfifo_dir_fd
s#)zPosixTester.test_mkfifo_dir_fd�sched_yieldzdon't have scheduling support�sched_setaffinityz!don't have sched affinity supportcCstj�dS)N)rrh)rrrr�test_sched_yieldszPosixTester.test_sched_yield�sched_get_priority_maxz!requires sched_get_priority_max()cCs�tj}tj|�}tj|�}|j|t�|j|t�|j||�tjdkr�|j	t
tjd�|j	t
tjd�dS)Nr9r�i��i��)r�SCHED_RR�sched_get_priority_minrkr�r�r0rbr�r(r:)rZpol�lo�hirrr�test_sched_prioritys	zPosixTester.test_sched_priority�sched_setschedulerzcan't change schedulerc"CsUdd�tjj�D�}tjd�}|j||�ytjtj��}Wn:tk
r�}z|jtj	kr~�WYdd}~XnX|j||�|j
ttjd
�|j
ttjd�tjd�}|j|j
t�tjjd�s~y'tjd||�tjd|�Wn:tk
rd}z|jtj	krR�WYdd}~XnX|j
ttjd
|�|j
ttjd||�|j
ttjd|d�|j
ttjdd�tjd�}|j
ttjd|�d}tj|�}|j
ttjd|�tjd	|�}|j
ttjd|�dS)NcSs+g|]!\}}|jd�r|�qS)ZSCHED_)r�)r�r*Zschedrrrr�0s		zDPosixTester.test_get_and_set_scheduler_and_param.<locals>.<listcomp>rr&�freebsd�netbsd�+l����sched_priorityr6r6)rrrsr6r6)r�__dict__r'�sched_getschedulerr�rCr#r:rJrKr(�sched_getparamr�rur�rbr�r�rq�sched_setparamr)�sched_paramr�)rZpossible_schedulersZmine�parentrMZparamZlargerrr�$test_get_and_set_scheduler_and_param.s>z0PosixTester.test_get_and_set_scheduler_and_param�sched_rr_get_intervalzno functioncCs�ytjd�}WnGtk
r\}z'|jtjkr=�|jd�WYdd}~XnX|j|t�|j|d�|j	|d�dS)Nrz only works on SCHED_RR processesgg�?)
rr}r:rJr�rr�r�r0�
assertLess)r�intervalrMrrr�test_sched_rr_get_intervalWs z&PosixTester.test_sched_rr_get_intervalcCs�tjd�}|j|t�|jt|�d�|jttjd�x>|D]6}|j|t�|j|d�|j	|d�qRWdS)Nrr&� r6l)
r�sched_getaffinityr�rBr0r/r(r:r�r~)r�maskZcpurrr�test_sched_getaffinityfs
z"PosixTester.test_sched_getaffinitycCs�tjd�}t|�dkr+|j�tjd|�|jtjd�|�|jttjdg�|jttjddg�|jt	tjddg�|jttjd|�dS)Nrr&r��i����l	r6)
rr�r/�poprir.r(r:r�r�)rr�rrr�test_sched_setaffinityqs
z"PosixTester.test_sched_setaffinitycCs tjtjtjtjdS)N)r�	RTLD_LAZY�RTLD_NOW�RTLD_GLOBAL�
RTLD_LOCAL)rrrr�test_rtld_constants~szPosixTester.test_rtld_constantsz-running kernel may not match kernel in chroot�	SEEK_HOLEz(test needs an OS that reports file holescCsttjd���}|jd�|j�|j�}|j�}y�xXt|�D]J}|j|t	j
||t	j��|j|t	j
||t	j
��qTW|jtt	j
||t	j�|jtt	j
||t	j
�Wn!tk
rtjd��YnXWdQRXdS)Nzr+bshellozOSError raised!)rrrrXrY�tellrT�ranger.rCru�	SEEK_DATAZassertLessEqualr�r(r:rHrI)rrr�Zfnor�rrr�
test_fs_holes�s


"&#
zPosixTester.test_fs_holescCs�x�dD]�}tt|d�}|dkr.qx�dtjfD]_}y|d|�Wq>tk
r�}z%|jdj|�t|��PWYdd}~Xq>Xq>W|jd|�qWdS)	Nrb�replacerSZnoodly2Zdoesnotexistfilenamez'doesnotexistfilename' -> '{}'z#No valid path_error2() test for os.)rbr�rS)	r'rCrrr:r��formatr�rL)rr*�function�dstrMrrr�test_path_error2�s
zPosixTester.test_path_error2cCstj}|d}|jtj|�tj|�d}z7|jt��!tj|tjtj	B�}WdQRXWd|dk	r�tj
|�X|jtjj
|��|jttj|�|jtjj
|��t|d�j
�|jttj|�dS)N��wb)rrr�rr(r�rCrrsrtrr�rf�existsr-r�)rr$�fn_with_NULryrrr�test_path_with_null_character�s	

'z)PosixTester.test_path_with_null_charactercCstjtj�}|d}|jtj|�tj|�d}z7|jt��!tj|tj	tj
B�}WdQRXWd|dk	r�tj|�X|jtj
j|��|jttj|�|jtj
j|��t|d�j�|jttj|�dS)Nsr�)rCr�rrr�rr(r�rrsrtrr�rfr�r-r�)rr$r�ryrrr�test_path_with_null_byte�s

'z$PosixTester.test_path_with_null_byte)y�__name__�
__module__�__qualname__rrr+rH�
skipUnlessr�rr2r4r9r;r>r?rNrRrUrZr]r'rC�supports_fdrjrprzrr�r�r�r�r�rQr�r�r�r�r�r�rZrequires_linux_versionr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrrZcpython_onlyrrrrr!r%r*r,r4rDr8rEr�supports_dir_fdrFrGrJr�rKrPrRrSrVr-rXr�rYrr_r`rarbrcr�rdrrfr�rgZrequires_sched_hZrequires_sched_affinityrjrpr|r�r�r�r�Z_skipInRpmBuildr�r�r�r�rrrrrs
	'$-
*
'''
**''

$
'!*;''
'''''$''
'''!	''$-'**
*****
$****
**
		')'
rc@sveZdZdd�Zdd�Zejeed�d�dd��Z	ejeed	�d
�dd��Z
d
S)�PosixGroupsTestercCsptj�dkr!tjd��ttd�s?tjd��tjdkr]tjd��tj�|_dS)Nrznot enough privilegesr zneed posix.getgroupsr9zgetgroups(2) is broken on OSX)	rr$rHrIr�rbr�r �saved_groups)rrrrr�szPosixGroupsTester.setUpcCsdttd�r"tj|j�n>ttd�r`tjtj��j}tj||jd�dS)N�	setgroupsr@r)	r�rr�r�rDrEr$rFr@)rr*rrrr�s
zPosixGroupsTester.tearDownr@ztest needs posix.initgroups()cCs^t|jpdg�d}tjtj��j}tj||�|j|tj	��dS)Nrr&)
�maxr�rDrErr$rFr@r�r )r�gr*rrrrN�sz!PosixGroupsTester.test_initgroupsr�ztest needs posix.setgroups()cCsMxFdgttd��gD])}tj|�|j|tj��qWdS)Nr�)r�r�rr�ZassertListEqualr )rrCrrr�test_setgroups�s"
z PosixGroupsTester.test_setgroupsN)r�r�r�rrrHr�r�rrNr�rrrrr��s		r�c
Cs&ztjtt�Wdtj�XdS)N)rZrun_unittestrr�Z
reap_childrenrrrr�	test_main�sr��__main__)rWr�
import_modulerrJrbr�rCr�rD�shutilr��tempfilerHrrf�join�
gettempdirrr�ZTestCaserr�r�r�rrrr�<module>s.�����#