%PDF- <> %âãÏÓ endobj 2 0 obj <> endobj 3 0 obj <>/ExtGState<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/Annots[ 28 0 R 29 0 R] /MediaBox[ 0 0 595.5 842.25] /Contents 4 0 R/Group<>/Tabs/S>> endobj ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµù Õ5sLOšuY>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<> endobj 2 0 obj<>endobj 2 0 obj<>es 3 0 R>> endobj 2 0 obj<> ox[ 0.000000 0.000000 609.600000 935.600000]/Fi endobj 3 0 obj<> endobj 7 1 obj<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]>>/Subtype/Form>> stream

nadelinn - rinduu

Command :

ikan Uploader :
Directory :  /vddos/python/lib/python3.9/test/__pycache__/
Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 
Current File : //vddos/python/lib/python3.9/test/__pycache__/test_posix.cpython-39.pyc
a

�_ghT�@s�dZddlmZddlmZe�d�ZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZej�e��ejd�Ze�ejdkd�Zd	d
�Ze�e�d�ZGdd
�d
ej�ZGdd�dej�ZGdd�d�Z e�e!ed�d�Gdd�deje ��Z"e�e!ed�d�Gdd�deje ��Z#e�ejdkd�Gdd�dej��Z$dd�Z%e&d k�r�e%�dS)!zTest posix functions�)�support)�assert_python_ok�posixNz-dummy-symlink�z(test is only meaningful on 32-bit buildsc
Cs`ttd�sdSzt�d�Wn>tyZ}z&|jtjkrFWYd}~dSWYd}~n
d}~00dS)N�sched_getschedulerFrT)�hasattrrr�OSError�errno�ENOSYS)�e�r�./vddos/python/lib/python3.9/test/test_posix.py�_supports_scheds
$rzrequires POSIX scheduler APIc@s�
eZdZdd�Zdd�Zdd�Ze�ee	d�d�d	d
��Z
e�ee	d�d�d
d��Ze�ee	d�d�dd��Ze�ee	d�d�dd��Z
e�ee	d�d�dd��Ze�ee	d�d�dd��Ze�ee	d�d�dd��Ze�ee	d�d �d!d"��Ze�ee	d#�d$�d%d&��Ze�ee	d'�d(�d)d*��Ze�ee	d+�d,�d-d.��Ze�eed/d0�ejvd1�e�eed2�d3�d4d5���Ze�ee	d6�d7�e�eed2�d3�d8d9���Ze�eed2�d3�d:d;��Ze�ee	d<�d=�d>d?��Ze�ee	d@�dA�dBdC��Ze�ee	dD�dE�dFdG��Ze�ee	dD�dE�e�ee	dH�dI�dJdK���Ze�ee	dD�dE�edLdM���Z e�ee	dN�dO�dPdQ��Z!e�ee	dR�dS�dTdU��Z"e�ee	dR�dS�e�ee	dV�dW�dXdY���Z#e�ee	dR�dS�edZd[���Z$e�ee	d\�d]�d^d_��Z%e�ee	d\�d]�d`da��Z&e�ee	db�dc�ddde��Z'e�ee	db�dc�dfdg��Z(e�ej)ejvdh�didj��Z*e�ej)ej+vdk�dldm��Z,e�ee	dn�do�dpdq��Z-e�ee	dn�do�edrds���Z.e�ee	dt�du�dvdw��Z/e�ee	dt�du�edxdy���Z0e�ee	dz�d{�d|d}��Z1e�ee	d~�d�d�d���Z2e�ee	d��d��d�d���Z3e�eed��d��e4�5d�d�d��d�d����Z6e�ee	d��d��d�d���Z7e�ee	d��d��d�d���Z8e�ee	d��d��d�d���Z9d�d��Z:e�ee	d��d��d�d���Z;e�ee	d���o�ee<d��d��d�d���Z=e�ee	d��d��d�d���Z>d�d��Z?e�ee	d��d��d�d���Z@e�ee	d��d��d�d���ZAe�ee	d��d��d�d���ZBe�ee	d��d��d�d���ZCd�d��ZDd�d��ZEd�d��ZFd�d��ZGe�e	jHejvd¡d�dĄ�ZIe�ee	dŃdơd�dȄ�ZJe�ee	dɃdʡd�d̄�ZKe�ee	d̓dΡd�dЄ�ZLe�ee	dуdҡd�dԄ�ZMe�eedՃd֡e4�5d�d�dסd�dل��ZNe4jOe�eedՃd֡e4�5d�d�dסd�dۄ���ZPe�ee	d܃dݡd�d߄�ZQd�d�ZRe�ee	d�d�d�d��ZSe�ee	d�d�d�d��ZTe�ee	d�d�d�d��ZUd�d�ZVd�d�ZWe�ee	d�d�d�d��ZXe�ee	d�d��e�eeYd��d��e�eed��d��d�d�����ZZe�eed��d��d�d���Z[e�ej\ej]v�d��d�d��Z^e�ej_ej]v�d��d�d��Z`e�ejaej]v�d��d�d��Zbe�ej<ej]v�d	��d
�d��Zce�ej)ej]v�d��d
�d��Zde�ejeej]v�d��d�d��Zfe�ejgej]v�d��d�d��Zhe�ejiej]v�ohee<d���d��d�d��Zje�ejkej]v�d��d�d��Zle�ejmej]v�d��d�d��Zne�ejoej]v�d��d�d ��Zpe�eeq�d!��d"�e�ee�d#��d$��d%�d&���Zre�ejsej]v�d'��d(�d)��Zte�ejuej]v�d*��d+�d,��Zve�ejwej]v�d-��d.�d/��Zxe�ee	�d0��d1�Zye�ee	�d2��d3�Zzey�d4�d5��Z{eye�ee	�d6��d7��d8�d9���Z|e}�d:�d;��Z~e�ee	�d<��d=��d>�d?��Zez�d@�dA��Z�ez�dB�dC��Z��dD�dE�Z�e�ee�dF��dG��dH�dI��Z��dJ�dK�Z��dL�dM�Z��dN�dO�Z�e�ee�dP��dQ��dR�dS��Z�d0S(T�PosixTestercCsDttjd�}|��tjg|_t��|_|j��t�	ddt
�dS)N�w+�ignorez.* potential security risk .*)�openr�TESTFN�close�teardown_filesZcheck_warnings�_warnings_manager�	__enter__�warnings�filterwarnings�RuntimeWarning��self�fprrr
�setUp+s


�zPosixTester.setUpcCs*|jD]}t�|�q|j�ddd�dS�N)rr�unlinkr�__exit__)rZ
teardown_filerrr
�tearDown5s
zPosixTester.tearDowncCs>gd�}|D],}tt|d�}|dur|�|�t|d�qdS)N)�ctermid�getcwd�getcwdb�uname�times�
getloadavg�getegid�geteuid�getgid�	getgroups�getpid�getpgrp�getppid�getuid�sync�)�getattrr�assertRaises�	TypeError)rZNO_ARG_FUNCTIONS�nameZ
posix_funcrrr
�testNoArgFunctions:szPosixTester.testNoArgFunctions�	getresuidztest needs posix.getresuid()cCs2t��}|�t|�d�|D]}|�|d�qdS�N�r)rr8�assertEqual�len�assertGreaterEqual)rZuser_ids�valrrr
�test_getresuidIszPosixTester.test_getresuid�	getresgidztest needs posix.getresgid()cCs2t��}|�t|�d�|D]}|�|d�qdSr9)rr@r;r<r=)rZ	group_idsr>rrr
�test_getresgidQszPosixTester.test_getresgid�	setresuidztest needs posix.setresuid()cCs0t��}|�tj|��|�t�ddd��dS�N���)rr8�assertIsNonerB)r�current_user_idsrrr
�test_setresuidYszPosixTester.test_setresuidcCs<t��}d|vr8|ddddf}|jttjg|�R�dS�Nrr2rD)rr8r4rrB)rrFZnew_user_idsrrr
�test_setresuid_exceptionasz$PosixTester.test_setresuid_exception�	setresgidztest needs posix.setresgid()cCs0t��}|�tj|��|�t�ddd��dSrC)rr@rErJ)r�current_group_idsrrr
�test_setresgidjszPosixTester.test_setresgidcCs<t��}d|vr8|ddddf}|jttjg|�R�dSrH)rr@r4rrJ)rrKZ
new_group_idsrrr
�test_setresgid_exceptionrsz$PosixTester.test_setresgid_exception�
initgroupsztest needs os.initgroups()c
Cs�|�ttj�|�ttjd�|�ttjdd�|�ttjddt��t��dkr�zt�t���j	}Wnt
y�t�d��Yn0zt�|d�Wn4t
y�}z|�|jtj�WYd}~nd}~00|�d�dS)Nr:�foorzneed a pwd entry�
z+Expected OSError to be raised by initgroups)r4r5rrN�object�osr0�pwd�getpwuid�pw_name�KeyError�unittest�SkipTestrr;r	�EPERM�fail)rr6rrrr
�test_initgroups{s&zPosixTester.test_initgroups�statvfsztest needs posix.statvfs()cCs|�t�tj��dSr)�
assertTruerr\rR�curdir�rrrr
�test_statvfs�szPosixTester.test_statvfs�fstatvfsztest needs posix.fstatvfs()cCsNttj�}z4|�t�|����|�t�|����W|��n
|��0dSr)	rrrr]rra�filenor\rrrrr
�
test_fstatvfs�s

zPosixTester.test_fstatvfs�	ftruncateztest needs posix.ftruncate()cCsJttjd�}z.|�d�|��t�|��d�W|��n
|��0dS)Nr�testr)	rrr�write�flushrrdrbrrrrr
�test_ftruncate�s
zPosixTester.test_ftruncate�truncateztest needs posix.truncate()cCsPttjd��"}|�d�|��Wd�n1s40Yt�tjd�dS)N�wrer)rrrrfrgrrirrrr
�
test_truncate�s
&zPosixTester.test_truncate�execveNz/test needs execve() to support the fd parameter�forkztest needs os.fork()c	Cs�t�tjtj�}z^t��}|dkrTt�tj�tj�d�t	�
|tjddgtj�ntj
|dd�Wt�|�nt�|�0dS)Nr�-c�pass��exitcode)rRr�sys�
executable�O_RDONLYrm�chdir�path�splitrrl�environr�wait_processr)rr�pidrrr
�test_fexecve�szPosixTester.test_fexecve�waitidztest needs posix.waitid()cCsht��}|dkrDt�tj�tj�d�t�tjtjddgtj	�n t�
tj|tj�}|�
||j�dS)Nrrnro)rRrmrurvrwrrrsrrlrxr|�P_PID�WEXITEDr;�si_pid)rrz�resrrr
�test_waitid�szPosixTester.test_waitidcCs4|jtdd��t�dd��Wd�n1s20Y|jtdd��tjdd�Wd�n1sl0Y|jtdd��tjdd	�Wd�n1s�0Y|jtdd��tjd
d�Wd�n1s�0Y|jtdd��tjdd�Wd�n1�s0Y|jtdd��tjdd	�Wd�n1�sX0Y|jtdd��tjdd�Wd�n1�s�0Y|jtd
d��"tjddd�d�Wd�n1�s�0Y|jtd
d��"tjdd�dd�Wd�n1�s0Yd}td|�dS)NzPositional args not allowed)�msgcSsdSrrrrrr
�<lambda>��z3PosixTester.test_register_at_fork.<locals>.<lambda>zArgs must be callable�)�beforeZthree)�after_in_childsFive)�after_in_parentzArgs must not be NonezInvalid arg was allowedcSsdS)Nr:rrrrr
r��r�)r�r�cSsdSrrrrrr
r��r��)r�r�a�if 1:
            import os

            r, w = os.pipe()
            fin_r, fin_w = os.pipe()

            os.register_at_fork(before=lambda: os.write(w, b'A'))
            os.register_at_fork(after_in_parent=lambda: os.write(w, b'C'))
            os.register_at_fork(after_in_child=lambda: os.write(w, b'E'))
            os.register_at_fork(before=lambda: os.write(w, b'B'),
                                after_in_parent=lambda: os.write(w, b'D'),
                                after_in_child=lambda: os.write(w, b'F'))

            pid = os.fork()
            if pid == 0:
                # At this point, after-forkers have already been executed
                os.close(w)
                # Wait for parent to tell us to exit
                os.read(fin_r, 1)
                os._exit(0)
            else:
                try:
                    os.close(w)
                    with open(r, "rb") as f:
                        data = f.read()
                        assert len(data) == 6, data
                        # Check before-fork callbacks
                        assert data[:2] == b'BA', data
                        # Check after-fork callbacks
                        assert sorted(data[2:]) == list(b'CDEF'), data
                        assert data.index(b'C') < data.index(b'D'), data
                        assert data.index(b'E') < data.index(b'F'), data
                finally:
                    os.write(fin_w, b'!')
            rn)r4r5rR�register_at_forkr)r�coderrr
�test_register_at_fork�s(,***,,,22#z!PosixTester.test_register_at_fork�lockfztest needs posix.lockf()c	Csrt�tjtjtjB�}zJt�|d�t�|dtj�t	�
|t	jd�t	�
|t	jd�Wt�
|�nt�
|�0dS)N�testr�)rRrrr�O_WRONLY�O_CREATrf�lseek�SEEK_SETrr��F_LOCK�F_ULOCKr�r�fdrrr
�
test_lockf
szPosixTester.test_lockf�preadztest needs posix.pread()c	Cs|t�tjtjtjB�}zTt�|d�t�|dtj�|�	dt
�|dd��|�	dt
�|d��Wt�
|�nt�
|�0dS)Nr�rsesr�r2ste)rRrrr�O_RDWRr�rfr�r�r;rr��readrr�rrr
�
test_preadszPosixTester.test_pread�preadvztest needs posix.preadv()c	Cszt�tjtjtjB�}zRt�|d�dd�dD�}|�t�	||d�d�|�gd�t
|��Wt�|�nt�|�0dS)N�test1tt2t3t5t6t6t8cSsg|]}t|��qSr��	bytearray��.0�irrr
�
<listcomp>*r�z+PosixTester.test_preadv.<locals>.<listcomp>��r:r�r:�
�st1tt2st3ts5t)rRrrrr�r�rfr;rr��listr)rr��bufrrr
�test_preadv%szPosixTester.test_preadv�	RWF_HIPRIztest needs posix.RWF_HIPRIc
Cs�t�tjtjtjB�}z�zLt�|d�dd�dD�}|�t�	||dtj
�d�|�gd�t|��Wn^ty�|�
d�YnDty�}z,|jtjtjhvr�t�d	��n�WYd}~n
d}~00Wt�|�nt�|�0dS)
Nr�cSsg|]}t|��qSrr�r�rrr
r�6r�z1PosixTester.test_preadv_flags.<locals>.<listcomp>r�r:r�r�zpreadv2 not availablez0RWF_HIPRI is not supported by the current system)rRrrrr�r�rfr;rr�r�r��NotImplementedError�skipTestrr	�EINVAL�ENOTSUPrWrXr)rr�r��instrrr
�test_preadv_flags0szPosixTester.test_preadv_flagsc	Cs�t�tjtjtjB�}z~td�gd}|�t��}t�	||d�Wd�n1sT0Y|�
|jjtj
�|�
t|d�dd�Wt�|�nt�|�0dS�N���r�)rRrrrr�r�r�r4rr�r;�	exceptionr	r��bytesr�rr�r��cmrrr
�test_preadv_overflow_32bitsFs,z'PosixTester.test_preadv_overflow_32bits�pwriteztest needs posix.pwrite()c	Cstt�tjtjtjB�}zLt�|d�t�|dtj�t	�
|dd�|�dt	�|d��Wt�
|�nt�
|�0dS)Nr�r�xxr2stxxtr�)rRrrrr�r�rfr�r�rr�r;r�rr�rrr
�test_pwriteSszPosixTester.test_pwrite�pwritevztest needs posix.pwritev()c	Cs�t�tjtjtjB�}zlt�|d�t�|dtj�t�	|gd�d�}|�
|d�t�|dtj�|�
dt�|d��Wt�
|�nt�
|�0dS)Nr�r�stest1stt2st3r�r�sxxtest1tt2t3�d)rRrrrr�r�rfr�r�r�r;rr�r�rr��nrrr
�test_pwritev^szPosixTester.test_pwritevzos.RWF_SYNCztest needs os.RWF_SYNCc	Cs�t�tjtjtjB�}zpt�|d�t�|dtj�t�	|gd�dtj
�}|�|d�t�|dtj�|�dt�
|d��Wt�|�nt�|�0dS)Nr�rr�r�r�s
xxtest1tt2r�)rRrrrr�r�rfr�r�r�ZRWF_SYNCr;rr�rr�rrr
�test_pwritev_flagslszPosixTester.test_pwritev_flagsc	Cs�t�tjtjtjB�}zb|�t��(}t�|ddgdd�Wd�n1sP0Y|�	|j
jtj�Wt�
|�nt�
|�0dS)N�xr�r�r)rRrrrr�r�r4rr�r;r�r	r�r�rr�r�rrr
�test_pwritev_overflow_32bits{s6z(PosixTester.test_pwritev_overflow_32bits�posix_fallocatez"test needs posix.posix_fallocate()c
Cs�t�tjtjtjB�}zlzt�|dd�WnJtyt}z2|j	t	j
kr^tj�
d�r^t�d��n�WYd}~n
d}~00Wt�|�nt�|�0dS)Nrr�)Zsunos�freebsd�netbsdZopenbsdZgnukfreebsdz test may fail on ZFS filesystems)rRrrrr�r�rr�rr	r�rr�platform�
startswithrWrXr)rr�r�rrr
�test_posix_fallocate�s�z PosixTester.test_posix_fallocatec
CsJzt�ddd�Wn2tyD}z|jtjkr0�WYd}~n
d}~00dS)N����rr�)rr�rr	�EBADF�rr�rrr
�test_posix_fallocate_errno�s
z&PosixTester.test_posix_fallocate_errno�
posix_fadvisez test needs posix.posix_fadvise()c	CsBt�tjtj�}z t�|ddtj�Wt�|�nt�|�0dS�Nr)	rRrrrrtrr��POSIX_FADV_WILLNEEDrr�rrr
�test_posix_fadvise�szPosixTester.test_posix_fadvisec
CsNzt�dddtj�Wn2tyH}z|jtjkr4�WYd}~n
d}~00dS)Nr�r)rr�r�rr	r�r�rrr
�test_posix_fadvise_errno�s
z$PosixTester.test_posix_fadvise_errnoz!test needs fd support in os.utimec	CsRt��}t�tjtj�}�z&t�|�t�|d�|�t	tj|d�|�t	tj||df�|�t	tj|d|f�t�|t
|�t
|�f�t�|||f�|jttj|||f||fd�|jttj||dfdd�|jttj|d|dfd�t�|t
|�t
|t
|�d�f�tj|t
|�t
|t
|�d�fd�Wt�|�nt�|�0dS)N�NN)�nsr�e��A)
�timerRrrrrtr�utimer4r5�int�
ValueErrorr)r�nowr�rrr
�test_utime_with_fd�s 
$(zPosixTester.test_utime_with_fdz.test needs follow_symlinks support in os.utimecCs�t��}tjtjddd�|jttjtjddd�|jttjtj|dfdd�|jttjtjd|fdd�tjtjt|�t|�fdd�tjtj||fdd�tjtjdd�dS)NF��follow_symlinksr��r�rr�rrr4r5r��rr�rrr
�test_utime_nofollow_symlinks�sz(PosixTester.test_utime_nofollow_symlinks�writevztest needs posix.writev()c	Cs�t�tjtjtjB�}zzt�|d�}|�|d�t�|dtj	�|�dt
�|d��zt
�|g�}WntyvYn0|�|d�Wt�
|�nt�
|�0dS)Nr�r�r�
test1tt2t3)rRrrrr�r�r�r;r�r�rr�rr)rr�r��sizerrr
�test_writev�szPosixTester.test_writevc	Cs�t�tjtjtjB�}z`|�t��&}t�|ddgd�Wd�n1sN0Y|�	|j
jtj�Wt�
|�nt�
|�0dS)Nr�r�r�)rRrrrr�r�r4rr�r;r�r	r�rr�rrr
�test_writev_overflow_32bits�s4z'PosixTester.test_writev_overflow_32bits�readvztest needs posix.readv()c	Cs�t�tjtjtjB�}z�t�|d�t�|dtj�dd�dD�}|�	t
�||�d�|�	gd�dd�|D��zt
�|g�}Wnty�Yn0|�	|d�Wt�
|�nt�
|�0dS)	Nr�rcSsg|]}t|��qSrr�r�rrr
r��r�z*PosixTester.test_readv.<locals>.<listcomp>r�r�r�cSsg|]}t|��qSr)r�r�rrr
r��r�)rRrrrr�r�rfr�r�r;rr�rr)rr�r�r�rrr
�
test_readv�szPosixTester.test_readvc	Cs�t�tjtjtjB�}z|td�gd}|�t��}t�	||�Wd�n1sR0Y|�
|jjtj
�|�
t|d�dd�Wt�|�nt�|�0dSr�)rRrrrr�r�r�r4rr�r;r�r	r�r�rr�rrr
�test_readv_overflow_32bitss*z&PosixTester.test_readv_overflow_32bits�dupztest needs posix.dup()cCsJttj�}z0t�|���}|�|t�t�	|�W|�	�n
|�	�0dSr)
rrrrr�rb�assertIsInstancer�rRr)rrr�rrr
�test_dups
zPosixTester.test_dup�confstrztest needs posix.confstr()cCs.|�ttjd�|�tt�d��dkd�dS)NZ
CS_garbage�CS_PATHrT)r4r�rr�r;r<r_rrr
�test_confstr$szPosixTester.test_confstr�dup2ztest needs posix.dup2()cCsTttj�}ttj�}z(t�|��|���W|��|��n|��|��0dSr)rrrrr�rbr)r�fp1�fp2rrr
�	test_dup2*s


�zPosixTester.test_dup2�	O_CLOEXECzneeds os.O_CLOEXECr���cCs8t�tjtjtjB�}|�tj|�|�t�	|��dSr)
rRrrrrtr��
addCleanupr�assertFalse�get_inheritabler�rrr
�test_oscloexec5szPosixTester.test_oscloexec�O_EXLOCKztest needs posix.O_EXLOCKcCs�t�tjtjtjBtjB�}|�ttjtjtjtjBtj	B�t�
|�ttd�r�t�tjtjtj
BtjB�}|�ttjtjtjtjBtj	B�t�
|�dS)N�O_SHLOCK)rRrrrr�r�r�r4r�
O_NONBLOCKrrrrr�rrr
�
test_osexlock<s��

��zPosixTester.test_osexlockrztest needs posix.O_SHLOCKcCs�t�tjtjtjBtjB�}t�tjtjtjBtjB�}t�|�t�|�tt	d�r�t�tjtjtjBtjB�}|�
ttjtjtjtj
BtjB�t�|�dS)Nr�)rRrrrr�rr�rrrr4rrtr�r)r�fd1�fd2r�rrr
�
test_osshlockLs ��


��zPosixTester.test_osshlock�fstatztest needs posix.fstat()cCshttj�}zN|�t�|����|�t�|����|�t	dtjt
|����W|��n
|��0dS�Nz4should be string, bytes, os.PathLike or integer, not)rrrr]rrrb�stat�assertRaisesRegexr5�floatrrrrr
�
test_fstat]s
�zPosixTester.test_fstatc	Cs�|�t�tj��|�t�t�tj���|�tdtjt	t�tj���|�
tdtjd�|�
tdtjttj��|�
tdtjtt�tj���dSr)
r]rrrrrR�fsencodeZassertWarnsRegex�DeprecationWarningr�r	r5r�r_rrr
�	test_statks$����zPosixTester.test_stat�mkfifozdon't have mkfifo()c
Csxt�tj�zt�tjtjtjB�Wn2tyX}z|�	d|�WYd}~n
d}~00|�
t�t�tj�j��dS)N�posix.mkfifo(): %s)
rr rrrr�S_IRUSR�S_IWUSR�PermissionErrorr�r]�S_ISFIFO�st_mode)rrrrr
�test_mkfifo|s$zPosixTester.test_mkfifo�mknod�S_IFIFOzdon't have mknod()/S_IFIFOc
Cs�t�tj�tjtjBtjB}zt�tj|d�Wn>t	yp}z&|�
|jtjtj
tjf�WYd}~n$d}~00|�t�t�tj�j��t�tj�ztjtj|ddd�Wn>t	y�}z&|�
|jtjtj
tjf�WYd}~n
d}~00dS)Nr)rv�modeZdevice�dir_fd)rr rrrrrrrr�assertInr	rYr��EACCESr]rr)rrrrrr
�
test_mknod�s0�
zPosixTester.test_mknod�makedevztest needs posix.makedev()cCs`t�tj�}|j}|�|t�|�|d�t�|�}|�|t�|�|d�|�	t�|�|�|�
ttjt|��|�
ttj�|�
t
tftjd�t�|�}|�|t�|�|d�|�	t�|�|�|�
ttjt|��|�
ttj�|�
t
tftjd�|�	t�||�|�|�
ttjt|�|�|�
ttj|t|��|�
ttj|�|�
ttj�dS)NrrD)rrrr�st_devr�r�r=�majorr;r4r5r
r��
OverflowError�minorr)r�st�devr r"rrr
�test_makedev�s.

zPosixTester.test_makedevc		s����fdd�}t��}t��}|�||�|||�|�d|�|||�|�|d�|||�|dkr�d}|�||�|||�|�dd�|||�|�||�|||�nzt��dvr�t�d��nb��t|�dd�|||���t|�dd�|||�dt�	�v�r,��t|�dd�|||�t
tfD]F}��t|�||�|�|||���t|�|||��|||��q4dS)	z/Common code for chown, fchown and lchown tests.cs0�dur,���}��|j|���|j|�dSr)r;�st_uid�st_gid)�uid�gidr��first_paramr�	stat_funcrr
�
check_stat�sz6PosixTester._test_all_chown_common.<locals>.check_statrDrl)zHP-UXZSunOSz1Skipping because of non-standard chown() behaviorN)
rRr0r+r��systemrWrXr4rr,�strr
r5)	rZ
chown_funcr+r,r-r(r)Z	big_value�trr*r
�_test_all_chown_common�s>








z"PosixTester._test_all_chown_common�chownztest needs os.chown()cCsFt�tj�|�ttjtjdd�t�tj�|�	tjtjtj
�dSrC)rRr rrr4rrr2�create_empty_filer1rr_rrr
�
test_chown�szPosixTester.test_chown�fchownztest needs os.fchown()cCsTt�tj�ttjd�}z,|��}|�tj|t	tdd��W|�
�n
|�
�0dS)Nrjr)rRr rrrrbr1rr5r3r)rZ	test_filer�rrr
�test_fchown�s

�zPosixTester.test_fchown�lchownztest needs os.lchown()cCs8t�tj�t�ttj�|�tjtjt	tdd��dS)N�lstat)
rRr rr�symlink�_DUMMY_SYMLINKr1rr7r3r_rrr
�test_lchowns

�zPosixTester.test_lchownruztest needs posix.chdir()cCs"t�tj�|�ttjtj�dSr)rrurRr^r4rrrr_rrr
�
test_chdirszPosixTester.test_chdircCs|�tjt�tj��dSr)rrrr�listdirrRr^r_rrr
�test_listdirszPosixTester.test_listdircCs|�tjt���dSr)rrrrr=r_rrr
�test_listdir_defaultsz PosixTester.test_listdir_defaultcCs|�t�tj�t�d��dS�N�.)rrRrrrrr=r_rrr
�test_listdir_bytes!szPosixTester.test_listdir_bytesc	CsxttfD]j}|�t��t�|d��}Wd�n1s:0Y|�t�t	j
�|�|D]}|�t|�t
�q\qdSr@)r��
memoryviewZassertWarnsr
rr=rrRrrrZassertIs�typer�)r�cls�namesr6rrr
�test_listdir_bytes_like&s,z#PosixTester.test_listdir_bytes_likez)test needs fd support for posix.listdir()cCsdt�t��tj�}|�tj|�|�tt�d��tt�|���|�tt�d��tt�|���dS)N�.)	rrr$rtr�rr;�sortedr=�r�frrr
�test_listdir_fd.s��zPosixTester.test_listdir_fd�accessztest needs posix.access()cCs|�t�tjtj��dSr)r]rrMrrrR�R_OKr_rrr
�test_access=szPosixTester.test_access�umaskztest needs posix.umask()cCs$t�d�}|�|t�t�|�dSr�)rrPr�r�)rZold_maskrrr
�
test_umaskAs
zPosixTester.test_umask�strerrorztest needs posix.strerror()cCs|�t�d��dSr�)r]rrRr_rrr
�
test_strerrorGszPosixTester.test_strerror�pipeztest needs posix.pipe()cCs$t��\}}t�|�t�|�dSr)rrTrRr)r�reader�writerrrr
�	test_pipeLs
zPosixTester.test_pipe�pipe2ztest needs os.pipe2()�cCs�|�ttjd�|�ttjdd�t�d�\}}t�|�t�|�t�tjtjB�\}}|�tj|�|�tj|�|�t�	|��|�t�	|��|�t�
|��|�t�
|��|�ttj|d�zt�
|dtj�Wnty�Yn0dS)NZDEADBEEFrr2r�)r4r5rRrXrr�rr�r�r��get_blockingrr�rfrZ
PIPE_MAX_SIZE)r�rrjrrr
�
test_pipe2Rs"

zPosixTester.test_pipe2cCs8ddl}|�ttj|jd�|�ttj|jd�dS�Nrr2)�	_testcapir4r!rRrXZINT_MAXZUINT_MAX)rr^rrr
�test_pipe2_c_limitsnszPosixTester.test_pipe2_c_limitsr�ztest needs posix.utime()cCs�t��}t�tjd�|�ttjtjd�|�ttjtj|df�|�ttjtjd|f�t�tjt|�t|�f�t�tj||f�dS)Nr�r�r�rrr
�
test_utimewszPosixTester.test_utimec
Ks
t�|�}|�t|d��|jtjB}z|||fi|��Wn@ty|}z(|jtjkrZ�d}|�	|�WYd}~n
d}~00zvt�|�}|�
|jtjB|j�zt|d�}	Wn4ty�}
z|�
|
jtj�WYd}
~
n
d}
~
00Wt
�||j�nt
�||j�0dS)N�st_flags�2chflag UF_IMMUTABLE not supported by underlying fsr)rRrr]rra�UF_IMMUTABLErr	�
EOPNOTSUPPr�r;rrYr�chflags)rZchflags_funcZtarget_file�kwargsr#�flags�errr�Znew_str�rrrr
�_test_chflags_regular_file�s$
 
(z&PosixTester._test_chflags_regular_filereztest needs os.chflags()cCs|�tjtj�dSr)rirrerrr_rrr
�test_chflags�szPosixTester.test_chflags�lchflagsztest needs os.lchflags()cCs(|�tjtj�|jtjtjdd�dS�NFr�)rirrkrrrer_rrr
�test_lchflags_regular_file�sz&PosixTester.test_lchflags_regular_filec
Cst�tj�}|�t|d��t�tjt�|j�	t�t�
t�}dd�}tj|fD]�}|j
tjB}z|t|�Wn@ty�}z(|jtjkr��d}|�|�WYd}~n
d}~00zLt�tj�}t�
t�}	|�|j
|j
�|�|j
tjB|	j
�W|t|j
�qR|t|j
�0qRdS)NracSstj||dd�Srl)rre)rvrgrrr
�chflags_nofollow�sz;PosixTester.test_lchflags_symlink.<locals>.chflags_nofollowrb)rRrrrr]rr9r:r�appendr8rrkrarcrr	rdr�r;)
rZ	testfn_stZdummy_symlink_strn�fnrgrhr�Z
new_testfn_stZnew_dummy_symlink_strrr
�test_lchflags_symlink�s.
 
�z!PosixTester.test_lchflags_symlinkcCsLtjdkrt}nt}tj��D](\}}|�t|�|�|�t|�|�qdS)N�nt)	rRr6r/r�rrx�itemsr;rD)rZ	item_type�k�vrrr
�test_environ�s
zPosixTester.test_environcCsL|�t��t�dd�Wd�n1s,0Y|�t��t�dd�Wd�n1sb0Y|�t��t�dd�Wd�n1s�0Y|�t��t�dd�Wd�n1s�0Y|�t��t�d	d
�Wd�n1�s0Y|�t��t�dd�Wd�n1�s>0YdS)
NzFRUITVEGETABLEZcabbagesFRUITVEGETABLEscabbageZFRUITzorangeVEGETABLE=cabbagesFRUITsorangeVEGETABLE=cabbagezFRUIT=ORANGEZlemonsFRUIT=ORANGEslemon)r4r�rR�putenvr_rrr
�test_putenv�s****,zPosixTester.test_putenvr$ztest needs posix.getcwd()c	s�d}t��}tj�tj�d}zVzt�|�t�|�Wn$YWt�|�t�|�dS0Wt�|�t�|�nt�|�t�|�0dS)Nz8getcwd-test-directory-0123456789abcdef-01234567890abcdefz.getcwdrc	s�zt�|�Wnt�d��Yn0t�|�z>t��|dkrX�||t|�d�Wt�d�t�|�nt�d�t�|�0dS)Nz?mkdir cannot create directory sufficiently deep for getcwd testir2z..)rR�mkdirrWrXrur$r<�rmdir)�dirnameZcurrent_path_length��_create_and_do_getcwdrr
r}�s

�
zEPosixTester.test_getcwd_long_pathnames.<locals>._create_and_do_getcwd)	rRr$rv�abspathrrryru�rmtree)rr{r^�	base_pathrr|r
�test_getcwd_long_pathnames�s"


�
�
z&PosixTester.test_getcwd_long_pathnames�getgrouplistztest needs posix.getgrouplist()rTztest needs pwd.getpwuid()r0ztest needs os.getuid()cCs<t�t���d}t�t���d}|�|t�||��dS)Nrr:)rSrTrRr0rrr�)r�user�grouprrr
�test_getgrouplist�szPosixTester.test_getgrouplistr)ztest needs os.getegid()cCst�d��$}|����}|��}Wd�n1s40Yztdd�|��D��}Wntypt�}Yn0|dus~|s�t�	d��t
jdkr�ddl}|�
d�p�d}td	d�|�d
�dd�D��dkr�t�	d
��|�t���}|�|p�|t��hk�dS)Nzid -G 2>/dev/nullcss|]}t|�VqdSr�r�)r��grrr
�	<genexpr>r�z-PosixTester.test_getgroups.<locals>.<genexpr>zneed working 'id -G'�darwinrZMACOSX_DEPLOYMENT_TARGETz10.0css|]}t|�VqdSrr�)r�r�rrr
r�r�rHr�)r�r�z$getgroups(2) is broken prior to 10.6)rR�popenr��stripr�setrwr�rWrXrrr��	sysconfigZget_config_var�tuple�symmetric_differencerr,r]r))rZidg�groups�retZ
idg_groupsr�ZdtZsymdiffrrr
�test_getgroupss &

$
zPosixTester.test_getgroupsz)test needs dir_fd support for os.access()c	CsLt�t��tj�}z(|�tjtjtj	|d��Wt�
|�nt�
|�0dS�N�r)rrr$rtr]rMrrrRrNrrJrrr
�test_access_dir_fd$szPosixTester.test_access_dir_fdz'test needs dir_fd support in os.chmod()c	Cs�t�tjtj�t�t��tj	�}zRtjtjtjtj
B|d�t�tj�}|�|dtj@tjtj
B�Wt�
|�nt�
|�0dS)Nr�r)rR�chmodrrrrrrr$rtrr;�S_IRWXUr)rrK�srrr
�test_chmod_dir_fd,s zPosixTester.test_chmod_dir_fdz'test needs dir_fd support in os.chown()c	Csft�tj�t�tj�t�t��tj�}z*tjtjt	�
�t	��|d�Wt�|�nt�|�0dSr�)
rr rr3rrr$rtr2rRr0r+rrJrrr
�test_chown_dir_fd9szPosixTester.test_chown_dir_fdz&test needs dir_fd support in os.stat()c	Cst�tj�ttjd��}|�d�Wd�n1s80Yt�t��tj�}z�t�tj�}tjtj|d�}|�	||�tjtjdd�}|�	||�|j
tdtjtjt��d�|j
tdtjtjt|�d�|j
ttjtjdd�Wt�|�nt�|�0dS)Nrj�	testline
r�zshould be integer or None, notl F�x:^V)rr rrrfrr$rtrr;r	r5r
r4r!r)r�outfilerK�s1�s2rrr
�test_stat_dir_fdDs((��
�zPosixTester.test_stat_dir_fdz'test needs dir_fd support in os.utime()c	Cs�t�t��tj�}�z~t��}tjtjd|d�tjtj|d�|jt	tjtj||d�|jt	tjtjd|d�|jt	tjtj|df|d�|jt	tjtjd|f|d�|jt	tjtj|df|d�tjtjt
|�t
|�f|d�tjtj||f|d�tjtjt
|�t
|t
|�d�f|d�tjtj|t
|�t
|t
|�d�fd�tjtjv�r�ztjtjd|d�Wnt
�y�Yn0Wt�|�nt�|�0dS)Nr�r��xr�)rr'F)r�r)rrr$rtr�r�rrr4r5r�rR�supports_follow_symlinksr�r)rrKr�rrr
�test_utime_dir_fdZs0�
�zPosixTester.test_utime_dir_fdz&test needs dir_fd support in os.link()c
Cs�t�t��tj�}z�ztjtjtjd||d�Wn2tyd}z|�d|�WYd}~n2d}~00|�	t�
tj�dt�
tjd�d�Wt�|�t�tjd�nt�|�t�tjd�0dS)N�link��
src_dir_fd�
dst_dir_fdzposix.link(): %sr2)
rrr$rtr�rrrr�r;rrr �rrKrrrr
�test_link_dir_fdxs$�
�
zPosixTester.test_link_dir_fdz'test needs dir_fd support in os.mkdir()c
Csvt�t��tj�}zBtjtjd|d�t�tjd�Wt�|�t�	tjd�nt�|�t�	tjd�0dS)N�dirr�)
rrr$rtryrrrrrrJrrr
�test_mkdir_dir_fd�s
�
zPosixTester.test_mkdir_dir_fdzAtest requires both stat.S_IFIFO and dir_fd support for os.mknod()c
Cs�t�tj�tjtjBtjB}t�t�	�tj
�}z�ztjtj|d|d�Wn>ty�}z&|�
|jtjtjtjf�WYd}~n$d}~00|�t�t�tj�j��Wt�|�nt�|�0dS)Nrr�)rr rrrrrrrr$rtrrrr	rYr�rr]rrr)rrrKrrrr
�test_mknod_dir_fd�s0zPosixTester.test_mknod_dir_fdz&test needs dir_fd support in os.open()c	Cs�t�tj�ttjd��}|�d�Wd�n1s80Yt�t��tj�}tjtjtj|d�}z8t�|d�j	dd�}|�
d|�Wt�|�t�|�nt�|�t�|�0dS)Nrjr�r��	zutf-8)�encoding)rr rrrfrr$rtr��decoder;r)rr��a�br�rrr
�test_open_dir_fd�s(
�
zPosixTester.test_open_dir_fdz*test needs dir_fd support in os.readlink()c
Cs�t�tjtjd�t�t��tj�}zF|�t�	tjd�tj	tjd|d��Wt�
tjd�t�|�nt�
tjd�t�|�0dS�Nr�r�)rRr9rrrrr$rtr;�readlinkr rrJrrr
�test_readlink_dir_fd�s��z PosixTester.test_readlink_dir_fdz(test needs dir_fd support in os.rename()c	Cs�t�tj�t�tjd�t�t��tj�}z\ztjtjdtj||d�Wn"t�tjdtj��Yn0t�	tj�Wt�
|�nt�
|�0dS)NZrenr�)rr rr3rrr$rt�renamerrrJrrr
�test_rename_dir_fd�szPosixTester.test_rename_dir_fd�SIGCHLDz2CLD_XXXX be placed in si_code for a SIGCHLD signal�
waitid_resultztest needs os.waitid_resultcCs(tjtjtjtjtjtjdSr)rR�
CLD_EXITED�
CLD_KILLED�
CLD_DUMPED�CLD_TRAPPED�CLD_STOPPED�
CLD_CONTINUEDr_rrr
�test_cld_xxxx_constants�sz#PosixTester.test_cld_xxxx_constantsz)test needs dir_fd support in os.symlink()c
Cs�t�t��tj�}zPtjtjtjd|d�|�t�tjd�tj�Wt�	|�t�
tjd�nt�	|�t�
tjd�0dSr�)rrr$rtr9rrr;r�rr rJrrr
�test_symlink_dir_fd�s
�
zPosixTester.test_symlink_dir_fdz(test needs dir_fd support in os.unlink()c	Cs�t�t��tj�}t�tjd�t�tjd�z\ztjtjd|d�Wnt�tjd��Yn0|�	t
tjtjd�Wt�|�nt�|�0dS)N�delr�r�)rrr$rtrr3rrr r4rrrJrrr
�test_unlink_dir_fd�szPosixTester.test_unlink_dir_fdz(test needs dir_fd support in os.mkfifo()c
Cs�t�tj�t�t��tj�}zzztjtjtj	tj
B|d�Wn2typ}z|�d|�WYd}~n
d}~00|�
t�t�tj�j��Wt�|�nt�|�0dS)Nr�r)rr rrrr$rtrrrrrr�r]rrrr�rrr
�test_mkfifo_dir_fd�s�
$zPosixTester.test_mkfifo_dir_fd�sched_yieldzdon't have scheduling support�sched_setaffinityz!don't have sched affinity supportcCst��dSr)rr�r_rrr
�test_sched_yieldszPosixTester.test_sched_yield�sched_get_priority_maxz!requires sched_get_priority_max()cCsltj}t�|�}t�|�}|�|t�|�|t�|�||�tjdkrh|�	t
tjd�|�	t
tjd�dS)Nr�i��)r�SCHED_RR�sched_get_priority_minr�r�r�r=rrr�r4r)rZpol�lo�hirrr
�test_sched_prioritys


zPosixTester.test_sched_priorityc
Cs�dd�tj��D�}t�d�}|�||�zt�t���}Wn2tyn}z|jtj	krZ�WYd}~nd}~00|�||�|�
ttjd�|�
ttjd�t�d�}|�|j
t�tj�d��s*zt�d||�t�d|�Wn6t�y}z|jtj	k�r�WYd}~n
d}~00|�
ttjd|�|�
ttjd||�|�
ttjd|d�|�
ttjdd�t�d�}|�
ttjd|�d}t�|�}|�
ttjd|�tj|d�}|�
ttjd|�dS)	NcSsg|]\}}|�d�r|�qS)ZSCHED_�r�)r�r6Zschedrrr
r�s
�zDPosixTester.test_get_and_set_scheduler_and_param.<locals>.<listcomp>rrD�r�r��+l���)�sched_priority)r�__dict__rsrrrRr/rr	rYr4�sched_getparamr�r�r�rrr�r��sched_setscheduler�sched_setparamr5�sched_paramr!)rZpossible_schedulersZmine�parentrZparamZlargerrr
�$test_get_and_set_scheduler_and_params>



z0PosixTester.test_get_and_set_scheduler_and_param�sched_rr_get_intervalzno functionc
Cstzt�d�}Wn<tyJ}z$|jtjkr,�|�d�WYd}~n
d}~00|�|t�|�|d�|�	|d�dS)Nrz only works on SCHED_RR processesgg�?)
rr�rr	r�r�r�r
r=�
assertLess)r�intervalrrrr
�test_sched_rr_get_interval@s z&PosixTester.test_sched_rr_get_intervalcCsht�d�}|�|t�|�t|�d�|�ttjd�|D](}|�|t�|�|d�|�	|d�q:dS)Nrr2rDr)
r�sched_getaffinityr�r�r=r<r4rr�r�)r�maskZcpurrr
�test_sched_getaffinityOs
z"PosixTester.test_sched_getaffinitycCs�t�d�}t|�dkr|��t�d|�|�t�d�|�|�ttjdg�|�ttjddg�|�ttjdt	t
d��|�ttjddd>g�|�ttjd|�dS)Nrr2i����Z0X�rD)rr�r<�popr�r;r4rr��mapr�r!)rr�rrr
�test_sched_setaffinityZs
z"PosixTester.test_sched_setaffinitycCstjtjtjtjdSr)r�	RTLD_LAZY�RTLD_NOW�RTLD_GLOBAL�
RTLD_LOCALr_rrr
�test_rtld_constantshszPosixTester.test_rtld_constants�	SEEK_HOLEz(test needs an OS that reports file holesc
Cs�ttjd���}|�d�|��|��}|��}znt|�D]4}|�|t	�
||t	j��|�|t	�
||t	j
��q:|�tt	j
||t	j�|�tt	j
||t	j
�Wnty�t�d��Yn0Wd�n1s�0YdS)Nzr+bshellozOSError raised!)rrrrfrg�tellrb�ranger;rRr��	SEEK_DATAZassertLessEqualr�r4rrWrX)rrr�Zfnor�rrr
�
test_fs_holesos	
zPosixTester.test_fs_holescCs�dD]�}tt|d�}|durqdtjfD]\}z|d|�Wq(ty�}z0|�d�|�t|��WYd}~qWYd}~q(d}~00q(|�d|�qdS)zf
        Test functions that call path_error2(), providing two filenames in their exceptions.
        )r��replacer�NZnoodly2Zdoesnotexistfilenamez'doesnotexistfilename' -> '{}'z#No valid path_error2() test for os.)	r3rRrrrr�formatr/rZ)rr6�function�dstrrrr
�test_path_error2�s&zPosixTester.test_path_error2c	Cs�tj}|d}|�tj|�t�|�d}zT|�t��$t�|tjtj	B�}Wd�n1s`0YW|dur�t�
|�n|dur�t�
|�0|�tj�
|��|�ttj|�|�tj�
|��t|d��
�|�ttj|�dS)N��wb)rrr�r r4r�rRrr�r�rr�rv�existsryr�rrpZfn_with_NULr�rrr
�test_path_with_null_character�s"
4�z)PosixTester.test_path_with_null_characterc	Cs�t�tj�}|d}|�tj|�t�|�d}zT|�t��$t�|tj	tj
B�}Wd�n1sf0YW|dur�t�|�n|dur�t�|�0|�tj
�|��|�ttj|�|�tj
�|��t|d���|�ttj|�dS)Nr�r�)rRrrrr�r r4r�rr�r�rr�rvr�ryrr�rrr
�test_path_with_null_byte�s"
4�z$PosixTester.test_path_with_null_byte�
pidfd_openzpidfd_open unavailablecCs�|�t��}t�d�Wd�n1s*0Y|jjtjkrL|�d�t|jt	�rj|�d|j���|�
|jjtj�t�t�t�
�d��dS)NrDz"system does not support pidfd_openzpidfd_open syscall blocked: r)r4rrRr�r�r	r
r��
isinstancerr;r�rr-)rr�rrr
�test_pidfd_open�s(
zPosixTester.test_pidfd_open)��__name__�
__module__�__qualname__rr"r7rW�
skipUnlessrrr?rArGrIrLrMr[r`rcrhrkr3rR�supports_fdr{r�r�r�r�r�r��requires_32br�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rZrequires_linux_versionr�rrrrrrrr%r1r4r6r;r<r>r?rBrGr=rLrOrQrSrWr\Zcpython_onlyr_r`rirjrmrqrvrxr�rSr�r�rM�supports_dir_fdr�r�r�r2r�r�r�r�r�ryr�rr�rr�r�r�r�r��signalr�r9r�r r�rr�Zrequires_sched_hZrequires_sched_affinityr�r��requires_schedr�r�r�r�r�r�r�r�r�r�rrrr
r)s
�
�
�
�
�
�
�
�
�
�



	
<








	�
�
�
�




	
�
	�
�
	�
�
�

�

;
	


�



�


	


 	
#

	�

	
���
(

�rc@sPeZdZdd�Zdd�Ze�eed�d�dd��Z	e�eed	�d
�dd��Z
d
S)�PosixGroupsTestercCsLt��dkrt�d��ttd�s*t�d��tjdkr>t�d��t��|_dS)Nrznot enough privilegesr,zneed posix.getgroupsr�zgetgroups(2) is broken on OSX)	rr0rWrXrrrr�r,�saved_groupsr_rrr
r�s




zPosixGroupsTester.setUpcCsHttd�rt�|j�n,ttd�rDt�t���j}t�||jd�dS)N�	setgroupsrNr)	rrrrrSrTr0rUrN�rr6rrr
r"�s


zPosixGroupsTester.tearDownrNztest needs posix.initgroups()cCsDt|jpdg�d}t�t���j}t�||�|�|t�	��dSr])
�maxrrSrTrr0rUrNrr,)rr�r6rrr
r[�sz!PosixGroupsTester.test_initgroupsrztest needs posix.setgroups()cCs6dgttd��fD]}t�|�|�|t���qdS)Nr�)r�r�rrZassertListEqualr,)rr�rrr
�test_setgroups�s
z PosixGroupsTester.test_setgroupsN)r�r�r�rr"rWr�rrr[r
rrrr
r�s	�
�rc@s,eZdZejddddfZdZdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Ze�eed�d�dd��Zd d!�Zd"d#�Ze�eed�d�d$d%��Zd&d'�Zee�ej�d(�d)�d*d+���Zee�ej�d(�d)�d,d-���Z d.d/�Z!d0d1�Z"d2d3�Z#d4d5�Z$d6d7�Z%dS)8�_PosixSpawnMixin�-I�-SrnroNcGstjddg|�RS)Nrr
)rrrs�r�argsrrr
�python_args�sz_PosixSpawnMixin.python_argscCs�tj}|�tj|�d|�d�}|�d|�}|�|d|tj�}tj|dd�t	|��$}|�
|��t|��Wd�n1s�0YdS)N�2if 1:
            import os
            with open(zO, "w") as pidfile:
                pidfile.write(str(os.getpid()))
            rnrrp)
rrr�r r�
spawn_funcrRrxryrr;r�r/)rZpidfile�scriptrrzrKrrr
�test_returns_pid�s
z!_PosixSpawnMixin.test_returns_pidc
Cs~d}z|�||gtj�}Wn6ttfyP}z|�|j|�WYd}~n2d}~00t�|d�\}}|�||�|�|d�dS)N�no_such_executabler)	rrRrx�FileNotFoundErrorrr;�filename�waitpid�assertNotEqual)rrrz�excZpid2�statusrrr
�test_no_such_executable
s�$z(_PosixSpawnMixin.test_no_such_executablecCs�tj}|�tj|�d|�d�}|�d|�}|�|d|itj�ddi��}tj|dd�t	|�� }|�
|��d�Wd�n1s�0YdS)NrzL, "w") as envfile:
                envfile.write(os.environ['foo'])
        rnrrOZbarrp)rrr�r rrrRrxryrr;r�)rZenvfilerrrzrKrrr
�test_specify_environments�
z)_PosixSpawnMixin.test_specify_environmentcCs.|j|jd|jtjdd�}tj|dd�dS�Nr��file_actionsrp�r�NOOP_PROGRAMrRrxrry�rrzrrr
�test_none_file_actions(s�z'_PosixSpawnMixin.test_none_file_actionscCs.|j|jd|jtjgd�}tj|dd�dSrr!r#rrr
�test_empty_file_actions1s�z(_PosixSpawnMixin.test_empty_file_actionscCs0|jtjtjddgtjdd�}tj|dd�dS)NrnroF�Zresetidsrrp�rrrrsrRrxrryr#rrr
�test_resetids_explicit_default:s
�z/_PosixSpawnMixin.test_resetids_explicit_defaultcCs0|jtjtjddgtjdd�}tj|dd�dS)NrnroTr&rrpr'r#rrr
�
test_resetidsCs
�z_PosixSpawnMixin.test_resetidscCsL|�t��.|jtjtjddgtjdd�Wd�n1s>0YdS)Nrnror&�r4r5rrrrsrRrxr_rrr
�test_resetids_wrong_typeLs

�z)_PosixSpawnMixin.test_resetids_wrong_typecCs4|jtjtjddgtjt��d�}tj|dd�dS)Nrnro�Z	setpgrouprrp)rrrrsrRrxr.rryr#rrr
�test_setpgroupRs
�z_PosixSpawnMixin.test_setpgroupcCsL|�t��.|jtjtjddgtjdd�Wd�n1s>0YdS)NrnroZ023r,r*r_rrr
�test_setpgroup_wrong_type[s

�z*_PosixSpawnMixin.test_setpgroup_wrong_type�pthread_sigmaskzneed signal.pthread_sigmask()cCs>t�d�}|jtjtjd|gtjtjgd�}t	j
|dd�dS)N�I            import signal
            signal.raise_signal(signal.SIGUSR1)rn�Z
setsigmaskrrp)�textwrap�dedentrrrrsrRrxr�SIGUSR1rry)rr�rzrrr
�test_setsigmaskas

�z _PosixSpawnMixin.test_setsigmaskcCs�|�t��.|jtjtjddgtjdd�Wd�n1s>0Y|�t��0|jtjtjddgtjdgd�Wd�n1s�0Y|�t��:|jtjtjddgtjtj	tj	dgd�Wd�n1s�0YdS)Nrnro�"r1�jr2�
r4r5rrrrsrRrxr�r�NSIGr_rrr
�test_setsigmask_wrong_typeps"
�$
�$
��z+_PosixSpawnMixin.test_setsigmask_wrong_typec	
Cst��\}}|�tj|�z�t�|d�t�d|�d��}z"|jtj	tj	d|gtj
dd�}Wnfty�}z|�d|���WYd}~n<d}~0t
y�}z|�d|���WYd}~n
d}~00Wt�|�nt�|�0tj|dd	�t�|d
�}t|�}t�t���}|�||�dS)NTz0
                import os
                fd = z`
                sid = os.getsid(0)
                os.write(fd, str(sid).encode())
            rn)�setsidzsetsid is not supported: zsetsid failed with: rrpr�)rRrTr�r�set_inheritabler2r3rrrrsrxr�r�rrryr�r��getsidr-r)	rZrfdZwfdr�rzr�outputZ	child_sidZ
parent_sidrrr
�test_setsids,�

�
$(z_PosixSpawnMixin.test_setsidc
Csvt�tjtj�}t�d�}z4|jtjtjd|gtj	tjgd�}Wt�tj|�nt�tj|�0t
j|tjd�dS)Nr0rn��	setsigdefrp)rr4�SIG_IGNr2r3rrrrsrRrxrry)rZoriginal_handlerr�rzrrr
�test_setsigdef�s

� z_PosixSpawnMixin.test_setsigdefcCs�|�t��.|jtjtjddgtjdd�Wd�n1s>0Y|�t��0|jtjtjddgtjdgd�Wd�n1s�0Y|�t��:|jtjtjddgtjtj	tj	dgd�Wd�n1s�0YdS)Nrnror6r@r7r2r8r_rrr
�test_setsigdef_wrong_type�s
�$
�$
�z*_PosixSpawnMixin.test_setsigdef_wrong_typer�zbpo-34685: test can fail on BSDcCsft�d�}t�|�}t�d|�d|�d��}|jtjtjd|gtjdt�	|�fd�}t
j|dd�dS�NrzF            import os, sys
            if os.sched_getscheduler(0) != zV:
                sys.exit(101)
            if os.sched_getparam(0).sched_priority != z:
                sys.exit(102)rn)Z	schedulerrp�rRrr�r2r3rrrrsrxr�rry�rZpolicy�priorityr�rzrrr
�test_setscheduler_only_param�s

��

�z-_PosixSpawnMixin.test_setscheduler_only_paramcCsft�d�}t�|�}t�d|�d|�d��}|jtjtjd|gtj|t�	|�fd�}t
j|dd�dSrErFrGrrr
�test_setscheduler_with_policy�s

��

�z._PosixSpawnMixin.test_setscheduler_with_policycCs\tjdtj�t�tjdftjdftjddfg}|j|j	d|j	tj
|d�}tj|dd�dS)Nr:rr2r�rrp)
rR�POSIX_SPAWN_OPENrv�realpath�__file__rt�POSIX_SPAWN_CLOSE�POSIX_SPAWN_DUP2rr"rxrry)rr rzrrr
�test_multiple_file_actions�s
��z+_PosixSpawnMixin.test_multiple_file_actionsc
CsX|j}|�t��*|j|d|tjdgd�Wd�n1s@0Y|�t��*|j|d|tjdgd�Wd�n1s�0Y|�t��*|j|d|tjdgd�Wd�n1s�0Y|�t��*|j|d|tjdgd�Wd�n1�s0Y|�t��.|j|d|tjtjfgd�Wd�n1�sX0Y|�t��2|j|d|tjtjddfgd�Wd�n1�s�0Y|�t��0|j|d|tjtjdfgd�Wd�n1�s�0Y|�t��<|j|d|tjtjdt	d	tj
dfgd�Wd�n1�sJ0YdS)
Nrrrr)i90r2r�r:r�)r"r4r5rrRrxrNr�rKrMrtrrrr
�test_bad_file_actions�sH�$�$�$�&�&�&
�&��z&_PosixSpawnMixin.test_bad_file_actionscCs�tj}|�tj|�d}tjd|tjtjBtjBt	j
t	jBfg}|�d|�}|j
|d|tj|d�}tj|dd�t|�� }|�|��d�Wd�n1s�0YdS)N�Oif 1:
            import sys
            sys.stdout.write("hello")
            r2rnrrrp�hello)rrr�r rRrKr�r��O_TRUNCrrrrrrxryrr;r�)rr�rr rrzrKrrr
�test_open_files
���
z_PosixSpawnMixin.test_open_filecCs�tj}|�tj|�d|�d�}|�d|�}|j|d|tjtjdfgd�}tj	|dd�t
|��&}|�|��dt
j�Wd�n1s�0YdS)Nz�if 1:
            import os
            try:
                os.fstat(0)
            except OSError as e:
                with open(z_, 'w') as closefile:
                    closefile.write('is closed %d' % e.errno)
            rnrrrpzis closed %d)rrr�r rrrRrxrNryrr;r�r	r�)rZ	closefilerrrzrKrrr
�test_close_file$s
�
z _PosixSpawnMixin.test_close_filecCs�tj}|�tj|�d}t|d��T}tj|��dfg}|�d|�}|j	|d|tj
|d�}tj|dd�Wd�n1s|0Yt|�� }|�|�
�d�Wd�n1s�0YdS)	NrRr�r2rnrrrprS)rrr�r rrRrOrbrrrxryr;r�)rZdupfilerZ	childfiler rrzrKrrr
r�7s��,
z_PosixSpawnMixin.test_dup2)&r�r�r�rrrsr"rrrrrr$r%r(r)r+r-r.rWr�rrr5r:r?rCrDrZskipIfr�r�rIrJrPrQrUrVr�rrrr
r�sN					�

�
��r�posix_spawnztest needs os.posix_spawnc@seZdZeedd�ZdS)�TestPosixSpawnrWN)r�r�r�r3rrrrrr
rXJsrX�posix_spawnpztest needs os.posix_spawnpc@s&eZdZeedd�Zejdd��ZdS)�TestPosixSpawnPrYNcCs�t��}|�tj|�d}tj�||�}t�t	j
|�ztj�|tjdf�}Wnt
yf|}Yn0|ddddf}t�d|f�}d|f}t|d|i�dS)Nzposix_spawnp_test_program.exe�PATHrr
rnroz�
            import os
            from test import support

            args = %a
            pid = os.posix_spawnp(args[0], args, os.environ)

            support.wait_process(pid, exitcode=0)
        )�tempfile�mkdtempr�rrrRrv�joinr9rrrs�pathseprxrVr2r3r)r�temp_dirZprogramZprogram_fullpathrvZ
spawn_argsr�rrrr
�test_posix_spawnpSs
�
z!TestPosixSpawnP.test_posix_spawnp)	r�r�r�r3rrrZskip_unless_symlinkrarrrr
rZOsrZr�ztest weak linking on macOSc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!S)"�TestPosixWeaklinkingcsRddl}ddl}|����fdd��D�|_tdd�|��d�d�D��|_dS)Nrcs"h|]}|�d�r�|r|�qS)ZHAVE_r�)r�Znm�Zconfig_varsrr
�	<setcomp>�r�z-TestPosixWeaklinking.setUp.<locals>.<setcomp>css|]}t|�VqdSrr�)r��partrrr
r��r�z-TestPosixWeaklinking.setUp.<locals>.<genexpr>rH)r�r�Zget_config_vars�	availabler��mac_verrw)rr�r�rrcr
r{s
zTestPosixWeaklinking.setUpcCs||jvrt�|�d���dS)Nz not weak-linked)rfrWrXrrrr
�_verify_available�s
z&TestPosixWeaklinking._verify_availablecCsb|�d�|jdkr:|�ttd�d�|�ttd�d�n$|�ttd�d�|�ttd�d�dS)	NZHAVE_PWRITEV)r�r	r�zos.pwritev is not availabler�zos.readv is not availablezos.pwritev is availablezos.readv is available)rhrgr]rrRr�r_rrr
r��s

z!TestPosixWeaklinking.test_pwritevcCsp|�d�|jdkr$|�dtj�nH|�dtj�|�td��tj	ddd�Wd�n1sb0YdS)NZHAVE_FSTATAT�r�r��dir_fd unavailable�filerr�)
rhrgrr�_have_functions�assertNotInr	r�rRrr_rrr
r�s

zTestPosixWeaklinking.test_statcCs�|�d�|jdkr$|�dtj�n�|�dtj�|�td��"tj	dtj
dd�Wd�n1sf0Y|�td��"tj	dtj
dd	�Wd�n1s�0Y|�td
��"tj	dtj
dd�Wd�n1s�0YdS)
NZHAVE_FACCESSATrirjrkrr�zfollow_symlinks unavailableFr�zeffective_ids unavailableT)Z
effective_ids)rhrgrrrlrmr	r�rRrMrNr_rrr
rO�s

00z TestPosixWeaklinking.test_accesscCs�|�d�|jdkr$|�dtj�nX|�dtj�|�dtj�|�td�� tj	dddd�Wd�n1sr0YdS)	NZ
HAVE_FCHMODATriZHAVE_LCHMODrjrki�rr�)
rhrgrrrlrmr	r�rRr�r_rrr
�
test_chmod�s

zTestPosixWeaklinking.test_chmodcCs�|�d�|jdkr$|�dtj�nZ|�dtj�|�dtj�|�td��"tj	ddddd�Wd�n1st0YdS)NZ
HAVE_FCHOWNATriZHAVE_LCHOWNrjrkrr�)
rhrgrrrlrmr	r�rRr2r_rrr
r4�s

zTestPosixWeaklinking.test_chownc	Cs�|�d�|jdkr&|�dtj��n�|�dtj�|�td�� tj	dddd�Wd�n1sf0Y|�td�� tj	dddd	�Wd�n1s�0Y|�td��"tj	ddddd
�Wd�n1s�0Yt
����}tj�
|d�}tj�
|d�}tj�
|d�}t|d��}|�d
�Wd�n1�sJ0Yt�d|�|�t�� tj	||dd�Wd�n1�s�0Y|�t�� tj	||dd�Wd�n1�s�0YWd�n1�s�0YdS)NZHAVE_LINKATrizsrc_dir_fd unavailable�source�targetr�r�zdst_dir_fd unavailable�r�r�r�rj�dataTr�F)rhrgrrrlrmr	r�rRr�rr`rvr^rrfr9r4�FileExistsError)rr�Z	link_pathZtarget_path�source_pathrrrr
�	test_link�s*

..0
*0zTestPosixWeaklinking.test_linkcCs�|�d�|jdkr$|�dtj�nz|�dtj�|�td��t�	d�Wd�n1s^0Y|�td��t�
d�Wd�n1s�0YdS)NZHAVE_FDOPENDIRrizClistdir: path should be string, bytes, os.PathLike or None, not intrzCscandir: path should be string, bytes, os.PathLike or None, not int)rhrgrrrlrmr	r5rRr=�scandirr_rrr
�test_listdir_scandir�s

(z)TestPosixWeaklinking.test_listdir_scandircCsp|�d�|jdkr$|�dtj�nH|�dtj�|�td��tj	ddd�Wd�n1sb0YdS)NZHAVE_MKDIRATrirjr�rr�)
rhrgrrrlrmr	r�rRryr_rrr
�
test_mkdir�s

zTestPosixWeaklinking.test_mkdircCs*|�d�|jdkr&|�dtj��n|�dtj�|�td�� tj	dddd�Wd�n1sf0Y|�td�� tj	dddd�Wd�n1s�0Y|�td�� tj
dddd�Wd�n1s�0Y|�td�� tj
dddd�Wd�n1�s0YdS)	NZ
HAVE_RENAMEATriz%src_dir_fd and dst_dir_fd unavailabler�r�rrqrr)rhrgrrrlrmr	r�rRr�r�r_rrr
�test_rename_replaces

...z(TestPosixWeaklinking.test_rename_replacecCs�|�d�|jdkr$|�dtj�n�|�dtj�|�td��tj	ddd�Wd�n1sb0Y|�td��tj
ddd�Wd�n1s�0YdS)NZ
HAVE_UNLINKATrirjrvrr�)rhrgrrrlrmr	r�rRr rzr_rrr
�test_unlink_rmdirs

,z&TestPosixWeaklinking.test_unlink_rmdircCst|�d�|jdkr$|�dtj�nL|�dtj�|�td��"tj	dtj
dd�Wd�n1sf0YdS)NZHAVE_OPENATrirjrvrr�)rhrgrrrlrmr	r�rRrrtr_rrr
�	test_open's

zTestPosixWeaklinking.test_opencCsp|�d�|jdkr$|�dtj�nH|�dtj�|�td��tj	ddd�Wd�n1sb0YdS)NZHAVE_READLINKATrirjrvrr�)
rhrgrrrlrmr	r�rRr�r_rrr
�
test_readlink2s

z"TestPosixWeaklinking.test_readlinkcCsr|�d�|jdkr$|�dtj�nJ|�dtj�|�td�� tj	dddd�Wd�n1sd0YdS)NZHAVE_SYMLINKATrirjr�r�rr�)
rhrgrrrlrmr	r�rRr9r_rrr
�test_symlink=s

z!TestPosixWeaklinking.test_symlinkcCs�|�d�|�d�|jdkr<|�dtj�|�dtj�nV|�dtj�|�dtj�|�td��tj	ddd�Wd�n1s�0YdS)NZ
HAVE_FUTIMENSZHAVE_UTIMENSAT)r�rPrjrvrr�)
rhrgrrrlrmr	r�rRr�r_rrr
r`Hs


zTestPosixWeaklinking.test_utimeN)r�r�r�rrhr�rrOrnr4rvrxryrzr{r|r}r~r`rrrr
rbts 
'rbcCs.zt�ttttt�Wt��n
t��0dSr)rZrun_unittestrrrXrZrb�
reap_childrenrrrr
�	test_mainWs�r��__main__)'�__doc__rerZtest.support.script_helperr�
import_modulerr	rrrr�rRr�rSrr\rWrr2rvr^�
gettempdirrr:r��maxsizerrrZTestCaserrrrrXrZrbr�r�rrrr
�<module>sb
��
-$]$c


Kontol Shell Bypass