a zeS@sdZddlmZddlmZedZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlZddlZe jeejdZeejdkdZd d Zeed ZGd d d ejZGdddejZGdddZ ee!e ddGdddeje Z"ee!e ddGdddeje Z#eej dkdGdddejZ$ddZ%e&d kre'dS)!zTest posix functions)support)assert_python_okposixNz-dummy-symlinkz(test is only meaningful on 32-bit buildsc Cs`ttdsdSztdWn>tyZ}z&|jtjkrFWYd}~dSWYd}~n d}~00dS)Nsched_getschedulerFrT)hasattrrrOSErrorerrnoENOSYS)er C/opt/bitninja-python-dojo/embedded/lib/python3.9/test/test_posix.py_supports_scheds  $rzrequires POSIX scheduler APIc@s eZdZddZddZddZeee ddd d Z eee d d d dZ eee ddddZ eee ddddZ eee ddddZeee ddddZeee ddddZeee dd d!d"Zeee d#d$d%d&Zeee d'd(d)d*Zeee d+d,d-d.Zeeed/d0ejvd1eeed2d3d4d5Zeee d6d7eeed2d3d8d9Zeeed2d3d:d;Zeee d<d=d>d?Zeee d@dAdBdCZeee dDdEdFdGZeee dDdEeee dHdIdJdKZeee dDdEedLdMZ eee dNdOdPdQZ!eee dRdSdTdUZ"eee dRdSeee dVdWdXdYZ#eee dRdSedZd[Z$eee d\d]d^d_Z%eee d\d]d`daZ&eee dbdcdddeZ'eee dbdcdfdgZ(eej)ejvdhdidjZ*eej)ej+vdkdldmZ,eee dndodpdqZ-eee dndoedrdsZ.eee dtdudvdwZ/eee dtduedxdyZ0eee dzd{d|d}Z1eee d~dddZ2eee ddddZ3eeedde45dddddZ6eee ddddZ7eee ddddZ8eee ddddZ9ddZ:eee ddddZ;eee doeeddZ?eee ddddZ@eee ddddZAeee ddddZBeee ddddZCddZDddZEddZFddZGee jHejvd¡ddĄZIeee dŃdơddȄZJeee dɃdʡdd̄ZKeee d̓dΡddЄZLeee dуdҡddԄZMeeedՃd֡e45dddסddلZNe4jOeeedՃd֡e45dddסddۄZPeee d܃dݡdd߄ZQddZReee ddddZSeee ddddZTeee ddddZUddZVddZWeee ddddZXeee ddeeeYddeeeddddZZeeeddddZ[eej\ej]vdddZ^eej_ej]vdddZ`eejaej]vdddZbeejd?Zezd@dAZezdBdCZdDdEZeeedFdGdHdIZdJdKZdLdMZdNdOZeeedPdQdRdSZd0S(T PosixTestercCsDttjd}|tjg|_t|_|jt ddt dS)Nw+ignorez.* potential security risk .*) openrTESTFNcloseteardown_filesZcheck_warnings_warnings_manager __enter__warningsfilterwarningsRuntimeWarningselffpr r r setUp+s    zPosixTester.setUpcCs*|jD]}t|q|jddddSN)rrunlinkr__exit__)rZ teardown_filer r r tearDown5s  zPosixTester.tearDowncCs>gd}|D],}tt|d}|dur ||t|dq dS)N)ctermidgetcwdgetcwdbunametimes getloadavggetegidgeteuidgetgid getgroupsgetpidgetpgrpgetppidgetuidsync)getattrr assertRaises TypeError)rZNO_ARG_FUNCTIONSnameZ posix_funcr r r testNoArgFunctions:s  zPosixTester.testNoArgFunctions getresuidztest needs posix.getresuid()cCs2t}|t|d|D]}||dqdSNr)rr8 assertEquallenassertGreaterEqual)rZuser_idsvalr r r test_getresuidIszPosixTester.test_getresuid getresgidztest needs posix.getresgid()cCs2t}|t|d|D]}||dqdSr9)rr@r;r<r=)rZ group_idsr>r r r test_getresgidQszPosixTester.test_getresgid setresuidztest needs posix.setresuid()cCs0t}|tj||tddddSN)rr8 assertIsNonerB)rcurrent_user_idsr r r test_setresuidYszPosixTester.test_setresuidcCs<t}d|vr8|ddddf}|jttjg|RdSNrr2rD)rr8r4rrB)rrFZ new_user_idsr r r test_setresuid_exceptionasz$PosixTester.test_setresuid_exception setresgidztest needs posix.setresgid()cCs0t}|tj||tddddSrC)rr@rErJ)rcurrent_group_idsr r r test_setresgidjszPosixTester.test_setresgidcCs<t}d|vr8|ddddf}|jttjg|RdSrH)rr@r4rrJ)rrKZ new_group_idsr r r test_setresgid_exceptionrsz$PosixTester.test_setresgid_exception initgroupsztest needs os.initgroups()c Cs|ttj|ttjd|ttjdd|ttjddttdkrzttj }Wnt yt dYn0zt|dWn4t y}z||jtjWYd}~nd}~00|ddS)Nr:foorzneed a pwd entry z+Expected OSError to be raised by initgroups)r4r5rrNobjectosr0pwdgetpwuidpw_nameKeyErrorunittestSkipTestrr;r EPERMfail)rr6r r r r test_initgroups{s  &zPosixTester.test_initgroupsstatvfsztest needs posix.statvfs()cCs|ttjdSr) assertTruerr\rRcurdirrr r r test_statvfsszPosixTester.test_statvfsfstatvfsztest needs posix.fstatvfs()cCsNttj}z4|t||t|W|n |0dSr) rrrr]rrafilenor\rrr r r test_fstatvfss  zPosixTester.test_fstatvfs ftruncateztest needs posix.ftruncate()cCsJttjd}z.|d|t|dW|n |0dS)Nrtestr) rrrwriteflushrrdrbrrr r r test_ftruncates   zPosixTester.test_ftruncatetruncateztest needs posix.truncate()cCsPttjd"}|d|Wdn1s40YttjddS)Nwrer)rrrrfrgrrirr r r test_truncates &zPosixTester.test_truncateexecveNz/test needs execve() to support the fd parameterforkztest needs os.fork()c Csttjtj}z^t}|dkrTttjtjdt |tjddgtj nt j |ddWt|n t|0dS)Nr-cpassexitcode)rRrsys executableO_RDONLYrmchdirpathsplitrrlenvironr wait_processr)rrpidr r r test_fexecveszPosixTester.test_fexecvewaitidztest needs posix.waitid()cCsht}|dkrDttjtjdttjtjddgtj n t tj |tj }| ||jdS)Nrrnro)rRrmrurvrwrrrsrrlrxr|P_PIDWEXITEDr;si_pid)rrzresr r r test_waitids zPosixTester.test_waitidcCs4|jtddtddWdn1s20Y|jtddtjddWdn1sl0Y|jtddtjdd Wdn1s0Y|jtddtjd d Wdn1s0Y|jtd dtjddWdn1s0Y|jtd dtjdd Wdn1sX0Y|jtd dtjdd Wdn1s0Y|jtd d"tjddddWdn1s0Y|jtd d"tjddddWdn1s0Yd}td|dS)NzPositional args not allowed)msgcSsdSrr r r r r z3PosixTester.test_register_at_fork..zArgs must be callable)beforeZthree)after_in_childsFive)after_in_parentzArgs must not be NonezInvalid arg was allowedcSsdS)Nr:r r r r r rr)rrcSsdSrr r r r r rr)rraif 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)r4r5rRregister_at_forkr)rcoder r r test_register_at_forks(,***,,,22#z!PosixTester.test_register_at_forklockfztest needs posix.lockf()c CsrttjtjtjB}zJt|dt|dtjt |t j dt |t j dWt |n t |0dS)Ntestr)rRrrrO_WRONLYO_CREATrflseekSEEK_SETrrF_LOCKF_ULOCKrrfdr r r test_lockf s zPosixTester.test_lockfpreadztest needs posix.pread()c Cs|ttjtjtjB}zTt|dt|dtj| dt |dd| dt |dWt |n t |0dS)Nrrsesrr2ste)rRrrrO_RDWRrrfrrr;rrreadrrr r r test_preads zPosixTester.test_preadpreadvztest needs posix.preadv()c CszttjtjtjB}zRt|ddddD}|t ||dd|gdt |Wt |n t |0dS)Ntest1tt2t3t5t6t6t8cSsg|] }t|qSr  bytearray.0ir r r *rz+PosixTester.test_preadv..r:rr: st1tt2st3ts5t) rRrrrrrrfr;rrlistr)rrbufr r r test_preadv%s zPosixTester.test_preadv RWF_HIPRIztest needs posix.RWF_HIPRIc CsttjtjtjB}zzLt|ddddD}|t ||dtj d|gdt |Wn^t y| dYnDty}z,|jtjtjhvrtd nWYd}~n d}~00Wt|n t|0dS) NrcSsg|] }t|qSr rrr r r r6rz1PosixTester.test_preadv_flags..rr:rrzpreadv2 not availablez0RWF_HIPRI is not supported by the current system)rRrrrrrrfr;rrrrNotImplementedErrorskipTestrr EINVALENOTSUPrWrXr)rrrinstr r r test_preadv_flags0s   zPosixTester.test_preadv_flagsc CsttjtjtjB}z~tdgd}|t}t ||dWdn1sT0Y| |j j t j | t|dddWt|n t|0dSNr)rRrrrrrrr4rrr; exceptionr rbytesrrrrcmr r r test_preadv_overflow_32bitsFs ,z'PosixTester.test_preadv_overflow_32bitspwriteztest needs posix.pwrite()c CstttjtjtjB}zLt|dt|dtjt |dd| dt |dWt |n t |0dS)Nrrxxr2stxxtr)rRrrrrrrfrrrrr;rrrr r r test_pwriteSs zPosixTester.test_pwritepwritevztest needs posix.pwritev()c CsttjtjtjB}zlt|dt|dtjt |gdd}| |dt|dtj| dt |dWt |n t |0dS)Nrrstest1stt2st3rrs xxtest1tt2t3d)rRrrrrrrfrrrr;rrrrrnr r r test_pwritev^s  zPosixTester.test_pwritevz os.RWF_SYNCztest needs os.RWF_SYNCc CsttjtjtjB}zpt|dt|dtjt |gddtj }| |dt|dtj| dt |dWt|n t|0dS)Nrrrrrs xxtest1tt2r)rRrrrrrrfrrrZRWF_SYNCr;rrrrr r r test_pwritev_flagsls  zPosixTester.test_pwritev_flagsc CsttjtjtjB}zb|t(}t|ddgddWdn1sP0Y| |j j t j Wt |n t |0dS)Nxrrr)rRrrrrrr4rrr;rr rrrrrr r r test_pwritev_overflow_32bits{s  6z(PosixTester.test_pwritev_overflow_32bitsposix_fallocatez"test needs posix.posix_fallocate()c CsttjtjtjB}zlzt|ddWnJtyt}z2|j t j kr^t j dr^tdnWYd}~n d}~00Wt|n t|0dS)Nrr)ZsunosfreebsdnetbsdZopenbsdZ gnukfreebsdz test may fail on ZFS filesystems)rRrrrrrrrrr rrrplatform startswithrWrXr)rrrr r r test_posix_fallocates z PosixTester.test_posix_fallocatec CsJztdddWn2tyD}z|jtjkr0WYd}~n d}~00dS)Nrr)rrrr EBADFrrr r r test_posix_fallocate_errnos  z&PosixTester.test_posix_fallocate_errno posix_fadvisez test needs posix.posix_fadvise()c CsBttjtj}z t|ddtjWt|n t|0dSNr) rRrrrrtrrPOSIX_FADV_WILLNEEDrrr r r test_posix_fadviseszPosixTester.test_posix_fadvisec CsNztdddtjWn2tyH}z|jtjkr4WYd}~n d}~00dS)Nrr)rrrrr rrr r r test_posix_fadvise_errnos  z$PosixTester.test_posix_fadvise_errnoz!test needs fd support in os.utimec CsRt}ttjtj}z&t|t|d|t tj|d|t tj||df|t tj|d|ft|t |t |ft|||f|jt tj|||f||fd|jt tj||dfdd|jt tj|d|dfdt|t |t |t |dftj|t |t |t |dfdWt |n t |0dS)NNN)nsreA) timerRrrrrtrutimer4r5int ValueErrorr)rnowrr r r test_utime_with_fds   $(zPosixTester.test_utime_with_fdz.test needs follow_symlinks support in os.utimecCst}tjtjddd|jttjtjddd|jttjtj|dfdd|jttjtjd|fddtjtjt|t|fddtjtj||fddtjtjdddS)NFfollow_symlinksrrrrrrr4r5rrrr r r test_utime_nofollow_symlinkssz(PosixTester.test_utime_nofollow_symlinkswritevztest needs posix.writev()c CsttjtjtjB}zzt|d}||dt|dtj |dt |dzt |g}Wnt yvYn0||dWt |n t |0dS)Nrrr test1tt2t3)rRrrrrrrr;rrrrrr)rrrsizer r r test_writevs   zPosixTester.test_writevc CsttjtjtjB}z`|t&}t|ddgdWdn1sN0Y| |j j t j Wt |n t |0dS)Nrrr)rRrrrrrr4rrr;rr rrrr r r test_writev_overflow_32bitss  4z'PosixTester.test_writev_overflow_32bitsreadvztest needs posix.readv()c CsttjtjtjB}zt|dt|dtjdddD}| t ||d| gddd|Dzt |g}Wnt yYn0| |dWt |n t |0dS) NrrcSsg|] }t|qSr rrr r r rrz*PosixTester.test_readv..rrrcSsg|] }t|qSr )rrr r r rr)rRrrrrrrfrrr;rrrr)rrrrr r r test_readvs  zPosixTester.test_readvc CsttjtjtjB}z|tdgd}|t}t ||Wdn1sR0Y| |j j t j | t|dddWt|n t|0dSr)rRrrrrrrr4rrr;rr rrrrr r r test_readv_overflow_32bits s *z&PosixTester.test_readv_overflow_32bitsdupztest needs posix.dup()cCsJttj}z0t|}||tt |W| n | 0dSr) rrrrrrbassertIsInstancerrRr)rrrr r r test_dups    zPosixTester.test_dupconfstrztest needs posix.confstr()cCs.|ttjd|ttddkddS)NZ CS_garbageCS_PATHrT)r4rrrr;r<r_r r r test_confstr$szPosixTester.test_confstrdup2ztest needs posix.dup2()cCsTttj}ttj}z(t||W||n||0dSr)rrrrrrbr)rfp1fp2r r r test_dup2*s   zPosixTester.test_dup2 O_CLOEXECzneeds os.O_CLOEXECrcCs8ttjtjtjB}|tj||t |dSr) rRrrrrtr addCleanupr assertFalseget_inheritablerr r r test_oscloexec5szPosixTester.test_oscloexecO_EXLOCKztest needs posix.O_EXLOCKcCsttjtjtjBtjB}|ttjtjtjtjBtj Bt |t t drttjtjtj BtjB}|ttjtjtjtjBtj Bt |dS)NO_SHLOCK)rRrrrrrrr4r O_NONBLOCKrrrrrr r r test_osexlock<s  zPosixTester.test_osexlockrztest needs posix.O_SHLOCKcCsttjtjtjBtjB}ttjtjtjBtjB}t|t|tt drttjtjtjBtjB}| t tjtjtj tj BtjBt|dS)Nr)rRrrrrrrrrrr4rrtrr)rfd1fd2rr r r test_osshlockLs    zPosixTester.test_osshlockfstatztest needs posix.fstat()cCshttj}zN|t||t||t dtjt |W| n | 0dSNz4should be string, bytes, os.PathLike or integer, not) rrrr]rrrbstatassertRaisesRegexr5floatrrr r r test_fstat]s zPosixTester.test_fstatc Cs|ttj|tttj|tdtjt ttj| t dtjd| t dtjt tj| t dtjt ttjdSr) r]rrrrrRfsencodeZassertWarnsRegexDeprecationWarningrr r5rr_r r r test_statks$ zPosixTester.test_statmkfifozdon't have mkfifo()c CsxttjzttjtjtjBWn2tyX}z| d|WYd}~n d}~00| t ttjj dS)Nposix.mkfifo(): %s) rr rrrrS_IRUSRS_IWUSRPermissionErrorrr]S_ISFIFOst_mode)rr r r r test_mkfifo|s  $zPosixTester.test_mkfifomknodS_IFIFOzdon't have mknod()/S_IFIFOc CsttjtjtjBtjB}zttj|dWn>t yp}z&| |j t j t j t jfWYd}~n$d}~00|tttjjttjztjtj|dddWn>t y}z&| |j t j t j t jfWYd}~n d}~00dS)Nr)rvmodeZdevicedir_fd)rr rrrrrrrrassertInr rYrEACCESr]rr)rrr r r r test_mknods 0   zPosixTester.test_mknodmakedevztest needs posix.makedev()cCs`ttj}|j}||t||dt|}||t||d| t||| t tjt || t tj| t tftjdt|}||t||d| t||| t tjt || t tj| t tftjd| t|||| t tjt ||| t tj|t || t tj|| t tjdS)NrrD)rrrrst_devrrr=majorr;r4r5r r OverflowErrorminorr)rstdevr r"r r r test_makedevs.         zPosixTester.test_makedevc sfdd}t}t}|||||||d||||||d||||dkrd}|||||||dd|||||||||nztdvrtdnbt|dd|||t|dd|||dt vr,t|dd|||t t fD]F}t |||||||t |||||||q4dS) z/Common code for chown, fchown and lchown tests.cs0dur,}|j||j|dSr)r;st_uidst_gid)uidgidr first_paramr stat_funcr r check_statsz6PosixTester._test_all_chown_common..check_statrDrl)zHP-UXZSunOSz1Skipping because of non-standard chown() behaviorN) rRr0r+rsystemrWrXr4rr,strr r5) rZ chown_funcr+r,r-r(r)Z big_valuetr r*r _test_all_chown_commons>                   z"PosixTester._test_all_chown_commonchownztest needs os.chown()cCsFttj|ttjtjddttj| tjtjtj dSrC) rRr rrr4rrr2create_empty_filer1rr_r r r test_chowns  zPosixTester.test_chownfchownztest needs os.fchown()cCsTttjttjd}z,|}|tj|t tddW| n | 0dS)Nrjr) rRr rrrrbr1rr5r3r)rZ test_filerr r r test_fchowns    zPosixTester.test_fchownlchownztest needs os.lchown()cCs8ttjtttj|tjtjt tdddS)Nlstat) rRr rrsymlink_DUMMY_SYMLINKr1rr7r3r_r r r test_lchown s    zPosixTester.test_lchownruztest needs posix.chdir()cCs"ttj|ttjtjdSr)rrurRr^r4rrrr_r r r test_chdirs zPosixTester.test_chdircCs|tjttjdSr)rrrrlistdirrRr^r_r r r test_listdirszPosixTester.test_listdircCs|tjtdSr)rrrrr=r_r r r test_listdir_defaultsz PosixTester.test_listdir_defaultcCs|ttjtddSN.)rrRr rrrr=r_r r r test_listdir_bytes!szPosixTester.test_listdir_bytesc CsxttfD]j}|tt|d}Wdn1s:0Y|tt j ||D]}| t |t q\qdSr@)r memoryviewZ assertWarnsr rr=rrRr rrZassertIstyper)rclsnamesr6r r r test_listdir_bytes_like&s   ,z#PosixTester.test_listdir_bytes_likez)test needs fd support for posix.listdir()cCsdtttj}|tj||ttdtt||ttdtt|dS)N.) rrr$rtrrr;sortedr=rfr r r test_listdir_fd.s    zPosixTester.test_listdir_fdaccessztest needs posix.access()cCs|ttjtjdSr)r]rrMrrrRR_OKr_r r r test_access=szPosixTester.test_accessumaskztest needs posix.umask()cCs$td}||tt|dSr)rrPrr)rZold_maskr r r test_umaskAs  zPosixTester.test_umaskstrerrorztest needs posix.strerror()cCs|tddSr)r]rrRr_r r r test_strerrorGszPosixTester.test_strerrorpipeztest needs posix.pipe()cCs$t\}}t|t|dSr)rrTrRr)rreaderwriterr r r test_pipeLs  zPosixTester.test_pipepipe2ztest needs os.pipe2()cCs|ttjd|ttjddtd\}}t|t|ttjtjB\}}|tj||tj||t ||t ||t ||t ||t tj |dzt |dtjWnt yYn0dS)NZDEADBEEFrr2r)r4r5rRrXrrrrrr get_blockingrrrfrZ PIPE_MAX_SIZE)rrrjr r r test_pipe2Rs"   zPosixTester.test_pipe2cCs8ddl}|ttj|jd|ttj|jddSNrr2) _testcapir4r!rRrXZINT_MAXZUINT_MAX)rr^r r r test_pipe2_c_limitsnszPosixTester.test_pipe2_c_limitsrztest needs posix.utime()cCst}ttjd|ttjtjd|ttjtj|df|ttjtjd|fttjt|t|fttj||fdS)Nrrrr r r test_utimewszPosixTester.test_utimec Ks t|}|t|d|jtjB}z|||fi|Wn@ty|}z(|jtjkrZd}| |WYd}~n d}~00zvt|}| |jtjB|jzt |d} Wn4ty} z| | jtj WYd} ~ n d} ~ 00Wt ||jnt ||j0dS)Nst_flags2chflag UF_IMMUTABLE not supported by underlying fsr)rRrr]rra UF_IMMUTABLErr EOPNOTSUPPrr;rrYrchflags) rZ chflags_funcZ target_filekwargsr#flagserrrZnew_strr r r r _test_chflags_regular_files$     (z&PosixTester._test_chflags_regular_filereztest needs os.chflags()cCs|tjtjdSr)rirrerrr_r r r test_chflagsszPosixTester.test_chflagslchflagsztest needs os.lchflags()cCs(|tjtj|jtjtjdddSNFr)rirrkrrrer_r r r test_lchflags_regular_filesz&PosixTester.test_lchflags_regular_filec Csttj}|t|dttjt|j tt t}dd}t j |fD]}|j tjB}z|t|Wn@ty}z(|jtjkrd}||WYd}~n d}~00zLttj}t t} ||j |j ||j tjB| j W|t|j qR|t|j 0qRdS)NracSstj||ddSrl)rre)rvrgr r r chflags_nofollowsz;PosixTester.test_lchflags_symlink..chflags_nofollowrb)rRrrrr]rr9r:rappendr8rrkrarcrr rdrr;) rZ testfn_stZdummy_symlink_strnfnrgrhrZ new_testfn_stZnew_dummy_symlink_str r r test_lchflags_symlinks.        z!PosixTester.test_lchflags_symlinkcCsLtjdkrt}nt}tjD](\}}|t|||t||qdS)Nnt) rRr6r/rrrxitemsr;rD)rZ item_typekvr r r test_environs  zPosixTester.test_environcCsL|ttddWdn1s,0Y|ttddWdn1sb0Y|ttddWdn1s0Y|ttddWdn1s0Y|ttd d Wdn1s0Y|ttd d Wdn1s>0YdS) NzFRUITVEGETABLEZcabbagesFRUITVEGETABLEscabbageZFRUITzorangeVEGETABLE=cabbagesFRUITsorangeVEGETABLE=cabbagez FRUIT=ORANGEZlemons FRUIT=ORANGEslemon)r4rrRputenvr_r r r test_putenvs * * * * , zPosixTester.test_putenvr$ztest needs posix.getcwd()c sd}t}tjtjd}zVzt|t|Wn$YWt|t|dS0Wt|t|nt|t|0dS)Nz8getcwd-test-directory-0123456789abcdef-01234567890abcdefz.getcwdrc szt|WntdYn0t|z>t|dkrX||t|dWtdt|ntdt|0dS)Nz?mkdir cannot create directory sufficiently deep for getcwd testir2z..)rRmkdirrWrXrur$r<rmdir)dirnameZcurrent_path_length_create_and_do_getcwdr r r}s   zEPosixTester.test_getcwd_long_pathnames.._create_and_do_getcwd) rRr$rvabspathrrryrurmtree)rr{r^ base_pathr r|r test_getcwd_long_pathnamess"     z&PosixTester.test_getcwd_long_pathnames getgrouplistztest needs posix.getgrouplist()rTztest needs pwd.getpwuid()r0ztest needs os.getuid()cCs<ttd}ttd}||t||dS)Nrr:)rSrTrRr0rrr)rusergroupr r r test_getgrouplistszPosixTester.test_getgrouplistr)ztest needs os.getegid()cCstd$}|}|}Wdn1s40Yztdd|D}Wntypt}Yn0|dus~|st dt j dkrddl }| dpd}td d|d dd Dd krt d |t}|| p|thkdS)Nzid -G 2>/dev/nullcss|]}t|VqdSrr)rgr r r rz-PosixTester.test_getgroups..zneed working 'id -G'darwinrZMACOSX_DEPLOYMENT_TARGETz10.0css|]}t|VqdSrr)rrr r r rrrHr)rrz$getgroups(2) is broken prior to 10.6)rRpopenrstriprsetrwrrWrXrrr sysconfigZget_config_vartuplesymmetric_differencerr,r]r))rZidggroupsretZ idg_groupsrZdtZsymdiffr r r test_getgroupss   &     $ zPosixTester.test_getgroupsz)test needs dir_fd support for os.access()c CsLtttj}z(|tjtjtj |dWt |n t |0dSNr) rrr$rtr]rMrrrRrNrrJr r r test_access_dir_fd$szPosixTester.test_access_dir_fdz'test needs dir_fd support in os.chmod()c Csttjtjtttj }zRtjtjtjtj B|dttj}| |dtj @tjtj BWt |n t |0dS)Nrr)rRchmodrrrrrrr$rtrr;S_IRWXUr)rrKsr r r test_chmod_dir_fd,s  zPosixTester.test_chmod_dir_fdz'test needs dir_fd support in os.chown()c Csfttjttjtttj}z*tjtjt t |dWt |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 Csttjttjd}|dWdn1s80Ytttj}zttj}tjtj|d}| ||tjtjdd}| |||j t dtjtjtd|j t dtjtjt |d|j ttjtjddWt|n t|0dS)Nrj testline rzshould be integer or None, notl Fx:^V)rr rrrfrr$rtrr;r r5r r4r!r)routfilerKs1s2r r r test_stat_dir_fdDs( (    zPosixTester.test_stat_dir_fdz'test needs dir_fd support in os.utime()c Cstttj}z~t}tjtjd|dtjtj|d|jt tjtj||d|jt tjtjd|d|jt tjtj|df|d|jt tjtjd|f|d|jt tjtj|df|dtjtjt |t |f|dtjtj||f|dtjtjt |t |t |df|dtjtj|t |t |t |dfdt jt j vrztjtjd|dWnt yYn0Wt|n t|0dS)Nrrxr)rr'F)rr)rrr$rtrrrrr4r5rrRsupports_follow_symlinksrr)rrKrr r r test_utime_dir_fdZs0 zPosixTester.test_utime_dir_fdz&test needs dir_fd support in os.link()c Cstttj}zztjtjtjd||dWn2tyd}z|d|WYd}~n2d}~00| t tjdt tjddWt |t tjdnt |t tjd0dS)Nlink src_dir_fd dst_dir_fdzposix.link(): %sr2) rrr$rtrrrrrr;rrr rrKr r r r test_link_dir_fdxs$  zPosixTester.test_link_dir_fdz'test needs dir_fd support in os.mkdir()c Csvtttj}zBtjtjd|dttjdWt|t tjdnt|t tjd0dS)Ndirr) rrr$rtryrrrrrrJr r r test_mkdir_dir_fds  zPosixTester.test_mkdir_dir_fdzAtest requires both stat.S_IFIFO and dir_fd support for os.mknod()c CsttjtjtjBtjB}tt tj }zztj tj|d|dWn>t y}z&| |jtjtjtjfWYd}~n$d}~00|tttjjWt|n t|0dS)Nrr)rr rrrrrrrr$rtrrrr rYrrr]rrr)rrrKr r r r test_mknod_dir_fds 0zPosixTester.test_mknod_dir_fdz&test needs dir_fd support in os.open()c Csttjttjd}|dWdn1s80Ytttj}tjtjtj|d}z8t|dj dd}| d|Wt |t |nt |t |0dS)Nrjrr zutf-8)encoding) rr rrrfrr$rtrdecoder;r)rrabrr r r test_open_dir_fds (  zPosixTester.test_open_dir_fdz*test needs dir_fd support in os.readlink()c Csttjtjdtttj}zF|t tjdtj tjd|dWt tjdt |nt tjdt |0dSNrr) rRr9rrrrr$rtr;readlinkr rrJr r r test_readlink_dir_fds z PosixTester.test_readlink_dir_fdz(test needs dir_fd support in os.rename()c Csttjttjdtttj}z\ztjtjdtj||dWn"ttjdtjYn0t tjWt |n t |0dS)NZrenr) rr rr3rrr$rtrenamerrrJr r r test_rename_dir_fds zPosixTester.test_rename_dir_fdSIGCHLDz2CLD_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_constantss z#PosixTester.test_cld_xxxx_constantsz)test needs dir_fd support in os.symlink()c Cstttj}zPtjtjtjd|d|ttjdtjWt |t tjdnt |t tjd0dSr) rrr$rtr9rrr;rrr rJr r r test_symlink_dir_fds  zPosixTester.test_symlink_dir_fdz(test needs dir_fd support in os.unlink()c Cstttj}ttjdttjdz\ztjtjd|dWnttjdYn0| t tjtjdWt |n t |0dS)Ndelrr) rrr$rtrr3rrr r4rrrJr r r test_unlink_dir_fdszPosixTester.test_unlink_dir_fdz(test needs dir_fd support in os.mkfifo()c Csttjtttj}zzztjtjtj tj B|dWn2t yp}z| d|WYd}~n d}~00| tttjjWt|n t|0dS)Nrr)rr rrrr$rtrrrrrrr]rrrrr r r test_mkfifo_dir_fds  $zPosixTester.test_mkfifo_dir_fd sched_yieldzdon't have scheduling supportsched_setaffinityz!don't have sched affinity supportcCs tdSr)rrr_r r r test_sched_yieldszPosixTester.test_sched_yieldsched_get_priority_maxz!requires sched_get_priority_max()cCsltj}t|}t|}||t||t|||tjdkrh| t tjd| t tjddS)Nri) rSCHED_RRsched_get_priority_minrrrr=rrrr4r)rZpollohir r r test_sched_prioritys      zPosixTester.test_sched_priorityc CsddtjD}td}|||ztt}Wn2tyn}z|jtj krZWYd}~nd}~00|||| ttjd| ttj dt d}| |j ttjds*ztd||td|Wn6ty}z|jtj krWYd}~n d}~00| ttjd|| ttjd||| ttjd|d| ttjddtd}| ttjd|d}t|}| ttjd|tj| d}| ttjd|dS) NcSsg|]\}}|dr|qS)ZSCHED_r)rr6Zschedr r r rs  zDPosixTester.test_get_and_set_scheduler_and_param..rrDrr+l)sched_priority)r__dict__rsrrrRr/rr rYr4sched_getparamrrrrrrrsched_setschedulersched_setparamr5 sched_paramr!)rZpossible_schedulersZmineparentr ZparamZlarger r r $test_get_and_set_scheduler_and_params>       z0PosixTester.test_get_and_set_scheduler_and_paramsched_rr_get_intervalz no functionc Cstztd}Wn<tyJ}z$|jtjkr,|dWYd}~n d}~00||t||d| |ddS)Nrz only works on SCHED_RR processesgg?) rrrr rrrr r= assertLess)rintervalr r r r test_sched_rr_get_interval@s    z&PosixTester.test_sched_rr_get_intervalcCshtd}||t|t|d|ttjd|D](}||t||d| |dq:dS)Nrr2rDr) rsched_getaffinityrrr=r<r4rrr)rmaskZcpur r r test_sched_getaffinityOs    z"PosixTester.test_sched_getaffinitycCstd}t|dkr|td||td||ttjdg|ttjddg|ttjdt t d|t tjddd>g|ttjd|dS)Nrr2iZ0XrD) rrr<poprr;r4rrmaprr!)rrr r r test_sched_setaffinityZs   z"PosixTester.test_sched_setaffinitycCstjtjtjtjdSr)r RTLD_LAZYRTLD_NOW RTLD_GLOBAL RTLD_LOCALr_r r r test_rtld_constantshszPosixTester.test_rtld_constants SEEK_HOLEz(test needs an OS that reports file holesc Csttjd}|d||}|}znt|D]4}||t ||t j | |t ||t j q:|tt j ||t j |tt j ||t j WntytdYn0Wdn1s0YdS)Nzr+bshellozOSError raised!)rrrrfrgtellrbranger;rRr SEEK_DATAZassertLessEqualrr4rrWrX)rrrZfnorr r r test_fs_holesos    zPosixTester.test_fs_holesc CsdD]}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. )rreplacerNZnoodly2Zdoesnotexistfilenamez'doesnotexistfilename' -> '{}'z#No valid path_error2() test for os.) r3rRrrrrformatr/rZ)rr6functiondstr r r r test_path_error2s &zPosixTester.test_path_error2c Cstj}|d}|tj|t|d}zT|t$t|tjtj B}Wdn1s`0YW|durt |n|durt |0| tj ||ttj|| tj |t|d |ttj|dS)Nwb)rrrr r4rrRrrrrrrvexistsryrrrpZ fn_with_NULrr r r test_path_with_null_characters"  4  z)PosixTester.test_path_with_null_characterc Csttj}|d}|tj|t|d}zT|t$t|tj tj B}Wdn1sf0YW|durt |n|durt |0| tj ||ttj|| tj |t|d |ttj|dS)Nrr)rRr rrrr r4rrrrrrrvrryrrr r r test_path_with_null_bytes"   4  z$PosixTester.test_path_with_null_byte pidfd_openzpidfd_open unavailablecCs|t}tdWdn1s*0Y|jjtjkrL|dt|jt rj|d|j| |jjtj t tt ddS)NrDz"system does not support pidfd_openzpidfd_open syscall blocked: r)r4rrRrrr r r isinstancerr;rrr-)rrr r r test_pidfd_opens (  zPosixTester.test_pidfd_open)__name__ __module__ __qualname__rr"r7rW skipUnlessrrr?rArGrIrLrMr[r`rcrhrkr3rR supports_fdr{rrrrrr requires_32brrrrrrrrrrrrrrrrrrrrrZrequires_linux_versionrrrr rrrrr%r1r4r6r;r<r>r?rBrGr=rLrOrQrSrWr\Z cpython_onlyr_r`rirjrmrqrvrxrrSrrrMsupports_dir_fdrrrr2rrrrrryrrrrrrrrrsignalrr9rr rrrZrequires_sched_hZrequires_sched_affinityrrrequires_schedrrrrrrrrrrr r r r r)s                         <                                     ;                   #         (     rc@sPeZdZddZddZeeeddddZ eeed d d d Z d S)PosixGroupsTestercCsLtdkrtdttds*tdtjdkr>tdt|_dS)Nrznot enough privilegesr,zneed posix.getgroupsrzgetgroups(2) is broken on OSX) rr0rWrXrrrrr, saved_groupsr_r r r rs      zPosixGroupsTester.setUpcCsHttdrt|jn,ttdrDttj}t||jddS)N setgroupsrNr) rrrrrSrTr0rUrNrr6r r r r"s   zPosixGroupsTester.tearDownrNztest needs posix.initgroups()cCsDt|jp dgd}ttj}t||||t dSr]) maxrrSrTrr0rUrNrr,)rrr6r r r r[s z!PosixGroupsTester.test_initgroupsrztest needs posix.setgroups()cCs6dgttdfD]}t|||tqdS)Nr)rrrrZassertListEqualr,)rrr r r test_setgroupss z PosixGroupsTester.test_setgroupsN) rrrrr"rWrrrr[r r r r r rs    rc@s,eZdZejddddfZdZddZdd Zd d Z d d Z ddZ ddZ ddZ ddZddZddZddZeeeddddZd d!Zd"d#Zeeeddd$d%Zd&d'Zeeejd(d)d*d+Zeeejd(d)d,d-Z d.d/Z!d0d1Z"d2d3Z#d4d5Z$d6d7Z%dS)8_PosixSpawnMixin-I-SrnroNcGstjddg|RS)Nr r )rrrsrargsr r r python_argssz_PosixSpawnMixin.python_argscCstj}|tj|d|d}|d|}||d|tj}tj|ddt |$}| | t |Wdn1s0YdS)N2if 1: import os with open(zO, "w") as pidfile: pidfile.write(str(os.getpid())) rnrrp) rrrr r spawn_funcrRrxryrr;rr/)rZpidfilescriptrrzrKr r r test_returns_pids  z!_PosixSpawnMixin.test_returns_pidc Cs~d}z|||gtj}Wn6ttfyP}z||j|WYd}~n2d}~00t|d\}}|||||ddS)Nno_such_executabler) rrRrxFileNotFoundErrorrr;filenamewaitpidassertNotEqual)rrrzexcZpid2statusr r r test_no_such_executable s$ z(_PosixSpawnMixin.test_no_such_executablecCstj}|tj|d|d}|d|}||d|itjddi}tj|ddt | }| | dWdn1s0YdS)NrzL, "w") as envfile: envfile.write(os.environ['foo']) rnrrOZbarrp) rrrr rrrRrxryrr;r)rZenvfilerrrzrKr r r test_specify_environments   z)_PosixSpawnMixin.test_specify_environmentcCs.|j|jd|jtjdd}tj|dddSNr file_actionsrpr NOOP_PROGRAMrRrxrryrrzr r r test_none_file_actions(sz'_PosixSpawnMixin.test_none_file_actionscCs.|j|jd|jtjgd}tj|dddSrr!r#r r r test_empty_file_actions1sz(_PosixSpawnMixin.test_empty_file_actionscCs0|jtjtjddgtjdd}tj|dddS)NrnroFZresetidsrrprrrrsrRrxrryr#r r r test_resetids_explicit_default:s z/_PosixSpawnMixin.test_resetids_explicit_defaultcCs0|jtjtjddgtjdd}tj|dddS)NrnroTr&rrpr'r#r r r test_resetidsCs z_PosixSpawnMixin.test_resetidscCsL|t.|jtjtjddgtjddWdn1s>0YdS)Nrnror&r4r5rrrrsrRrxr_r r r test_resetids_wrong_typeLs   z)_PosixSpawnMixin.test_resetids_wrong_typecCs4|jtjtjddgtjtd}tj|dddS)NrnroZ setpgrouprrp)rrrrsrRrxr.rryr#r r r test_setpgroupRs z_PosixSpawnMixin.test_setpgroupcCsL|t.|jtjtjddgtjddWdn1s>0YdS)NrnroZ023r,r*r_r r r test_setpgroup_wrong_type[s   z*_PosixSpawnMixin.test_setpgroup_wrong_typepthread_sigmaskzneed signal.pthread_sigmask()cCs>td}|jtjtjd|gtjtjgd}t j |dddS)NI import signal signal.raise_signal(signal.SIGUSR1)rnZ setsigmaskrrp) textwrapdedentrrrrsrRrxrSIGUSR1rry)rrrzr r r test_setsigmaskas  z _PosixSpawnMixin.test_setsigmaskcCs|t.|jtjtjddgtjddWdn1s>0Y|t0|jtjtjddgtjdgdWdn1s0Y|t:|jtjtjddgtjtj tj dgdWdn1s0YdS)Nrnro"r1jr2 r4r5rrrrsrRrxrrNSIGr_r r r test_setsigmask_wrong_typeps"  $  $  z+_PosixSpawnMixin.test_setsigmask_wrong_typec Cst\}}|tj|zt|dtd|d}z"|jtj tj d|gtj dd}Wnft y}z| d|WYd}~n0Y|t0|jtjtjddgtjdgdWdn1s0Y|t:|jtjtjddgtjtj tj dgdWdn1s0YdS)Nrnror6r@r7r2r8r_r r r test_setsigdef_wrong_types  $  $  z*_PosixSpawnMixin.test_setsigdef_wrong_typerzbpo-34685: test can fail on BSDcCsftd}t|}td|d|d}|jtjtjd|gtjdt |fd}t j |dddSNrzF 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 rRrrr2r3rrrrsrxrrryrZpolicypriorityrrzr r r test_setscheduler_only_params     z-_PosixSpawnMixin.test_setscheduler_only_paramcCsftd}t|}td|d|d}|jtjtjd|gtj|t |fd}t j |dddSrErFrGr r r test_setscheduler_with_policys     z._PosixSpawnMixin.test_setscheduler_with_policycCs\tjdtjttjdftjdftjddfg}|j|j d|j tj |d}t j |dddS)Nr:rr2rrrp) rRPOSIX_SPAWN_OPENrvrealpath__file__rtPOSIX_SPAWN_CLOSEPOSIX_SPAWN_DUP2rr"rxrry)rr rzr r r test_multiple_file_actionss  z+_PosixSpawnMixin.test_multiple_file_actionsc CsX|j}|t*|j|d|tjdgdWdn1s@0Y|t*|j|d|tjdgdWdn1s0Y|t*|j|d|tjdgdWdn1s0Y|t*|j|d|tjdgdWdn1s0Y|t.|j|d|tjtjfgdWdn1sX0Y|t2|j|d|tjtjddfgdWdn1s0Y|t0|j|d|tjtjdfgdWdn1s0Y|t<|j|d|tjtjdt d tj dfgdWdn1sJ0YdS) Nrrr r)i90r2rr:r) r"r4r5rrRrxrNrrKrMrtrr r r test_bad_file_actionssH $ $ $ & &  &  & z&_PosixSpawnMixin.test_bad_file_actionscCstj}|tj|d}tjd|tjtjBtjBt j t j Bfg}| d|}|j |d|tj|d}tj|ddt| }||dWdn1s0YdS)NOif 1: import sys sys.stdout.write("hello") r2rnrrrphello)rrrr rRrKrrO_TRUNCrrrrrrxryrr;r)rrrr rrzrKr r r test_open_files   z_PosixSpawnMixin.test_open_filecCstj}|tj|d|d}|d|}|j|d|tjtjdfgd}tj |ddt |&}| | dt jWdn1s0YdS)Nzif 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)rrrr rrrRrxrNryrr;rr r)rZ closefilerrrzrKr r r test_close_file$s   z _PosixSpawnMixin.test_close_filecCstj}|tj|d}t|dT}tj|dfg}|d|}|j |d|tj |d}tj |ddWdn1s|0Yt| }| | dWdn1s0YdS) NrRrr2rnrrrprS)rrrr rrRrOrbrrrxryr;r)rZdupfilerZ childfiler rrzrKr r r r7s  , z_PosixSpawnMixin.test_dup2)&rrrrrrsr"rrrrrr$r%r(r)r+r-r.rWrrrr5r:r?rCrDrZskipIfrrrIrJrPrQrUrVrr r r r r sN            r  posix_spawnztest needs os.posix_spawnc@seZdZeeddZdS)TestPosixSpawnrWN)rrrr3rrr r r r rXJsrX posix_spawnpztest needs os.posix_spawnpc@s&eZdZeeddZejddZdS)TestPosixSpawnPrYNcCst}|tj|d}tj||}tt j |ztj |tj df}Wnt yf|}Yn0|ddddf}td|f}d|f}t|d|idS)Nzposix_spawnp_test_program.exePATHr 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) )tempfilemkdtemprrrrRrvjoinr9rrrspathseprxrVr2r3r)rtemp_dirZprogramZprogram_fullpathrvZ spawn_argsrrr r r test_posix_spawnpSs   z!TestPosixSpawnP.test_posix_spawnp) rrrr3rrrZskip_unless_symlinkrar r r r rZOs rZrztest weak linking on macOSc@seZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!S)"TestPosixWeaklinkingcsRddl}ddl}|fddD|_tdd|ddD|_dS)Nrcs"h|]}|dr|r|qS)ZHAVE_r)rZnmZ config_varsr r rz-TestPosixWeaklinking.setUp..css|]}t|VqdSrr)rpartr r r rrz-TestPosixWeaklinking.setUp..rH)rrZget_config_vars availablermac_verrw)rrrr rcr r{s zTestPosixWeaklinking.setUpcCs||jvrt|ddS)Nz not weak-linked)rfrWrXrr r r _verify_availables z&TestPosixWeaklinking._verify_availablecCsb|d|jdkr:|ttdd|ttddn$|ttdd|ttdddS) NZ HAVE_PWRITEV)rr rzos.pwritev is not availablerzos.readv is not availablezos.pwritev is availablezos.readv is available)rhrgr]rrRrr_r r r rs   z!TestPosixWeaklinking.test_pwritevcCsp|d|jdkr$|dtjnH|dtj|tdtj dddWdn1sb0YdS)NZ HAVE_FSTATATrrdir_fd unavailablefilerr) rhrgrr_have_functions assertNotInr rrRrr_r r r rs   zTestPosixWeaklinking.test_statcCs|d|jdkr$|dtjn|dtj|td"tj dtj ddWdn1sf0Y|td"tj dtj dd Wdn1s0Y|td "tj dtj d d Wdn1s0YdS) NZHAVE_FACCESSATrirjrkrrzfollow_symlinks unavailableFrzeffective_ids unavailableT)Z effective_ids) rhrgrrrlrmr rrRrMrNr_r r r rOs  00z TestPosixWeaklinking.test_accesscCs|d|jdkr$|dtjnX|dtj|dtj|td tj ddddWdn1sr0YdS) NZ HAVE_FCHMODATriZ HAVE_LCHMODrjrkirr) rhrgrrrlrmr rrRrr_r r r test_chmods  zTestPosixWeaklinking.test_chmodcCs|d|jdkr$|dtjnZ|dtj|dtj|td"tj dddddWdn1st0YdS)NZ HAVE_FCHOWNATriZ HAVE_LCHOWNrjrkrr) rhrgrrrlrmr rrRr2r_r r r r4s  zTestPosixWeaklinking.test_chownc Cs|d|jdkr&|dtjn|dtj|td tj ddddWdn1sf0Y|td tj dddd Wdn1s0Y|td"tj ddddd Wdn1s0Yt }tj |d }tj |d}tj |d}t|d }|d Wdn1sJ0Ytd||t tj ||ddWdn1s0Y|t tj ||ddWdn1s0YWdn1s0YdS)NZ HAVE_LINKATrizsrc_dir_fd unavailablesourcetargetrrzdst_dir_fd unavailablerrrrjdataTrF)rhrgrrrlrmr rrRrrr`rvr^rrfr9r4FileExistsError)rrZ link_pathZ target_path source_pathrr r r test_links*  ..0  *  0 zTestPosixWeaklinking.test_linkcCs|d|jdkr$|dtjnz|dtj|tdt dWdn1s^0Y|tdt dWdn1s0YdS)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_scandirs  (z)TestPosixWeaklinking.test_listdir_scandircCsp|d|jdkr$|dtjnH|dtj|tdtj dddWdn1sb0YdS)NZ HAVE_MKDIRATrirjrrr) rhrgrrrlrmr rrRryr_r r r test_mkdirs   zTestPosixWeaklinking.test_mkdircCs*|d|jdkr&|dtjn|dtj|td tj ddddWdn1sf0Y|td tj ddddWdn1s0Y|td tj ddddWdn1s0Y|td tj ddddWdn1s0YdS) NZ HAVE_RENAMEATriz%src_dir_fd and dst_dir_fd unavailablerrrrqrr) rhrgrrrlrmr rrRrrr_r r r test_rename_replaces  ...z(TestPosixWeaklinking.test_rename_replacecCs|d|jdkr$|dtjn|dtj|tdtj dddWdn1sb0Y|tdtj dddWdn1s0YdS)NZ HAVE_UNLINKATrirjrvrr) rhrgrrrlrmr rrRr rzr_r r r test_unlink_rmdirs  ,z&TestPosixWeaklinking.test_unlink_rmdircCst|d|jdkr$|dtjnL|dtj|td"tj dtj ddWdn1sf0YdS)NZ HAVE_OPENATrirjrvrr) rhrgrrrlrmr rrRrrtr_r r r test_open's   zTestPosixWeaklinking.test_opencCsp|d|jdkr$|dtjnH|dtj|tdtj dddWdn1sb0YdS)NZHAVE_READLINKATrirjrvrr) rhrgrrrlrmr rrRrr_r r r test_readlink2s   z"TestPosixWeaklinking.test_readlinkcCsr|d|jdkr$|dtjnJ|dtj|td tj ddddWdn1sd0YdS)NZHAVE_SYMLINKATrirjrrrr) rhrgrrrlrmr rrRr9r_r r r test_symlink=s   z!TestPosixWeaklinking.test_symlinkcCs|d|d|jdkr<|dtj|dtjnV|dtj|dtj|tdtj dddWdn1s0YdS)NZ HAVE_FUTIMENSZHAVE_UTIMENSAT)rrPrjrvrr) rhrgrrrlrmr rrRrr_r r r r`Hs   zTestPosixWeaklinking.test_utimeN)rrrrrhrrrOrnr4rvrxryrzr{r|r}r~r`r r r r rbts     '    rbcCs tdSr)r reap_childrenr r r r tearDownModuleWsr__main__)(__doc__rerZtest.support.script_helperr import_modulerr rrrrrRrrSrr\rWrr2rvr^ gettempdirrr:rmaxsizerrrZTestCaserrr rrXrZrbrrmainr r r r sb      -$]$c