asda?‰PNG  IHDR ? f ??C1 sRGB ??é gAMA ±? üa pHYs ? ??o¨d GIDATx^íüL”÷e÷Y?a?("Bh?_ò???¢§?q5k?*:t0A-o??¥]VkJ¢M??f?±8\k2íll£1]q?ù???T a bYhW@sdZddlmZddlmZedZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlZddlZddlmZe jeejdZeejdkd Zd d Zeed ZGd ddejZ GdddejZ!GdddejZ"GdddZ#ee$e ddGdddeje#Z%ee$e ddGdddeje#Z&eej dkdGdd d ejZ'd!d"Z(e)d#kre*dS)$zTest posix functions)support)assert_python_okposixN)contextmanagerz-dummy-symlinkz(test is only meaningful on 32-bit buildsc Cs`ttdsdSztdWn>tyZ}z&|jtjkrFWYd}~dSWYd}~n d}~00dS)Nsched_getschedulerFrT)hasattrrrOSErrorerrnoENOSYS)er +/usr/local/lib/python3.9/test/test_posix.py_supports_scheds  $rzrequires POSIX scheduler APIc@seZdZddZddZddZeee 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[eee\ddeeeddddZ]eee ddZ^eee dd Z_e^d d Z`e^eee d d ddZaebddZceee ddddZde_ddZee_ddZfddZgeeeddddZhd d!Zid"d#Zjd$d%Zkeeed&d'd(d)Zld0S(* PosixTestercCsDttjd}|tjg|_t|_|jt ddt dS)Nw+ignorez.* potential security risk .*) openrTESTFNcloseteardown_filesZcheck_warnings_warnings_manager __enter__warningsfilterwarningsRuntimeWarningselffpr r rsetUp,s    zPosixTester.setUpcCs*|jD]}t|q|jddddSN)rrunlinkr__exit__)rZ teardown_filer r rtearDown6s  zPosixTester.tearDowncCs>gd}|D],}tt|d}|dur ||t|dq dS)N)ctermidgetcwdgetcwdbunametimes getloadavggetegidgeteuidgetgid getgroupsgetpidgetpgrpgetppidgetuidsync)getattrr assertRaises TypeError)rZNO_ARG_FUNCTIONSnameZ posix_funcr r rtestNoArgFunctions;s  zPosixTester.testNoArgFunctions getresuidztest needs posix.getresuid()cCs2t}|t|d|D]}||dqdSNr)rr9 assertEquallenassertGreaterEqual)rZuser_idsvalr r rtest_getresuidJszPosixTester.test_getresuid getresgidztest needs posix.getresgid()cCs2t}|t|d|D]}||dqdSr:)rrAr<r=r>)rZ group_idsr?r r rtest_getresgidRszPosixTester.test_getresgid setresuidztest needs posix.setresuid()cCs0t}|tj||tddddSN)rr9 assertIsNonerC)rcurrent_user_idsr r rtest_setresuidZszPosixTester.test_setresuidcCs<t}d|vr8|ddddf}|jttjg|RdSNrr3rE)rr9r5r rC)rrGZ new_user_idsr r rtest_setresuid_exceptionbsz$PosixTester.test_setresuid_exception setresgidztest needs posix.setresgid()cCs0t}|tj||tddddSrD)rrArFrK)rcurrent_group_idsr r rtest_setresgidkszPosixTester.test_setresgidcCs<t}d|vr8|ddddf}|jttjg|RdSrI)rrAr5r rK)rrLZ new_group_idsr r rtest_setresgid_exceptionssz$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)r5r6rrOobjectosr1pwdgetpwuidpw_nameKeyErrorunittestSkipTestr r<r EPERMfail)rr7r r r rtest_initgroups|s  &zPosixTester.test_initgroupsstatvfsztest needs posix.statvfs()cCs|ttjdSr ) assertTruerr]rScurdirrr r r test_statvfsszPosixTester.test_statvfsfstatvfsztest needs posix.fstatvfs()cCsNttj}z4|t||t|W|n |0dSr ) rrrr^rrbfilenor]rrr r r test_fstatvfss  zPosixTester.test_fstatvfs ftruncateztest needs posix.ftruncate()cCsJttjd}z.|d|t|dW|n |0dS)Nrtestr) rrrwriteflushrrercrrr r rtest_ftruncates   zPosixTester.test_ftruncatetruncateztest needs posix.truncate()cCsPttjd"}|d|Wdn1s40YttjddS)Nwrfr)rrrrgrhrrjrr 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)rSrsys executableO_RDONLYrnchdirpathsplitrrmenvironr wait_processr)rrpidr r r test_fexecveszPosixTester.test_fexecvewaitidztest needs posix.waitid()cCsht}|dkrDttjtjdttjtjddgtj n t tj |tj }| ||jdS)Nrrorp)rSrnrvrwrxrsrtrrmryr}P_PIDWEXITEDr<si_pid)rr{resr 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)msgcSsdSr r r r r rz3PosixTester.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 rrr)rrcSsdSr r r r r rrr)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'!') ro)r5r6rSregister_at_forkr)rcoder r rtest_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)rSrrrO_WRONLYO_CREATrglseekSEEK_SETrrF_LOCKF_ULOCKrrfdr r r test_lockfs zPosixTester.test_lockfpreadztest needs posix.pread()c Cs|ttjtjtjB}zTt|dt|dtj| dt |dd| dt |dWt |n t |0dS)Nrrsesrr3ste)rSrrrO_RDWRrrgrrr<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) rSrrrrrrgr<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 rr7rz1PosixTester.test_preadv_flags..rr;rrzpreadv2 not availablez0RWF_HIPRI is not supported by the current system)rSrrrrrrgr<rrrrNotImplementedErrorskipTestr r EINVALENOTSUPrXrYr)rrrinstr r rtest_preadv_flags1s   zPosixTester.test_preadv_flagsc CsttjtjtjB}z~tdgd}|t}t ||dWdn1sT0Y| |j j t j | t|dddWt|n t|0dSNr)rSrrrrrrr5r rr< exceptionr rbytesrrrrcmr r rtest_preadv_overflow_32bitsGs ,z'PosixTester.test_preadv_overflow_32bitspwriteztest needs posix.pwrite()c CstttjtjtjB}zLt|dt|dtjt |dd| dt |dWt |n t |0dS)Nrrxxr3stxxtr)rSrrrrrrgrrrrr<rrrr r r test_pwriteTs zPosixTester.test_pwritepwritevztest needs posix.pwritev()c CsttjtjtjB}zlt|dt|dtjt |gdd}| |dt|dtj| dt |dWt |n t |0dS)Nrrstest1stt2st3rrs xxtest1tt2t3d)rSrrrrrrgrrrr<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)rSrrrrrrgrrrRWF_SYNCr<rrrrr r rtest_pwritev_flagsms  zPosixTester.test_pwritev_flagsc CsttjtjtjB}zb|t(}t|ddgddWdn1sP0Y| |j j t j Wt |n t |0dS)Nxrrr)rSrrrrrr5r rr<rr rrrrrr r rtest_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)rSrrrrrrrr r rrsplatform startswithrXrYr)rrrr r rtest_posix_fallocates z PosixTester.test_posix_fallocatec CsJztdddWn2tyD}z|jtjkr0WYd}~n d}~00dS)Nrr)rrr r EBADFrrr r rtest_posix_fallocate_errnos  z&PosixTester.test_posix_fallocate_errno posix_fadvisez test needs posix.posix_fadvise()c CsBttjtj}z t|ddtjWt|n t|0dSNr) rSrrrrurrPOSIX_FADV_WILLNEEDrrr r rtest_posix_fadviseszPosixTester.test_posix_fadvisec CsNztdddtjWn2tyH}z|jtjkr4WYd}~n d}~00dS)Nrr)rrrr r rrr r rtest_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) timerSrrrrurutimer5r6int ValueErrorr)rnowrr r rtest_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_symlinksrrrrrrr5r6rrrr r rtest_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)rSrrrrrrr<rrrrr r)rrrsizer r r test_writevs   zPosixTester.test_writevc CsttjtjtjB}z`|t&}t|ddgdWdn1sN0Y| |j j t j Wt |n t |0dS)Nrrr)rSrrrrrr5r rr<rr rrrr r rtest_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 rrrz*PosixTester.test_readv..rrrcSsg|] }t|qSr )rrr r rrr)rSrrrrrrgrrr<rrr r)rrrrr r r test_readvs  zPosixTester.test_readvc CsttjtjtjB}z|tdgd}|t}t ||Wdn1sR0Y| |j j t j | t|dddWt|n t|0dSr)rSrrrrrrr5r rr<rr rrrrr r rtest_readv_overflow_32bits s *z&PosixTester.test_readv_overflow_32bitsdupztest needs posix.dup()cCsJttj}z0t|}||tt |W| n | 0dSr ) rrrrrrcassertIsInstancerrSr)rrrr r rtest_dups    zPosixTester.test_dupconfstrztest needs posix.confstr()cCs.|ttjd|ttddkddS)NZ CS_garbageCS_PATHrT)r5rrrr<r=r`r r r test_confstr%szPosixTester.test_confstrdup2ztest needs posix.dup2()cCsTttj}ttj}z(t||W||n||0dSr )rrrrrrcr)rfp1fp2r r r test_dup2+s   zPosixTester.test_dup2 O_CLOEXECzneeds os.O_CLOEXECrcCs8ttjtjtjB}|tj||t |dSr ) rSrrrrur addCleanupr assertFalseget_inheritablerr r rtest_oscloexec6szPosixTester.test_oscloexecO_EXLOCKztest needs posix.O_EXLOCKcCsttjtjtjBtjB}|ttjtjtjtjBtj Bt |t t drttjtjtj BtjB}|ttjtjtjtjBtj Bt |dS)NO_SHLOCK)rSrrrrrrr5r 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)rSrrrrrrrrrr5r rurr)rfd1fd2rr r r test_osshlockMs    zPosixTester.test_osshlockfstatztest needs posix.fstat()cCshttj}zN|t||t||t dtjt |W| n | 0dSNz4should be string, bytes, os.PathLike or integer, not) rrrr^rrrcstatassertRaisesRegexr6floatrrr r r test_fstat^s zPosixTester.test_fstatc Cs|ttj|tttj|tdtjt ttj| t dtjd| t dtjt tj| t dtjt ttjdSr ) r^rr rrrSfsencodeZassertWarnsRegexDeprecationWarningrr r6rr`r r r test_statls$ zPosixTester.test_statmkfifozdon't have mkfifo()c CsxttjzttjtjtjBWn2tyX}z| d|WYd}~n d}~00| t ttjj dS)Nposix.mkfifo(): %s) rr!rrrr S_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)rwmodeZdevicedir_fd)rr!rr rrrrrr assertInr rZrEACCESr^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)NrrE)rr rrst_devrrr>majorr<r5r6r 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_statrErl)zHP-UXZSunOSz1Skipping because of non-standard chown() behaviorN) rSr1r,rsystemrXrYr5r r-strr r6) 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 dSrD) rSr!rrr5r rr4create_empty_filer3r r`r r r test_chowns  zPosixTester.test_chownfchownztest needs os.fchown()cCsTttjttjd}z,|}|tj|t tddW| n | 0dS)Nrkr) rSr!rrrrcr3rr7r4r)rZ test_filerr r r test_fchowns    zPosixTester.test_fchownlchownztest needs os.lchown()cCs8ttjtttj|tjtjt tdddS)Nlstat) rSr!rrsymlink_DUMMY_SYMLINKr3rr9r4r`r r r test_lchown s    zPosixTester.test_lchownrvztest needs posix.chdir()cCs"ttj|ttjtjdSr )rrvrSr_r5r rrr`r r r test_chdirs zPosixTester.test_chdircCs|tjttjdSr )rrrrlistdirrSr_r`r r r test_listdirszPosixTester.test_listdircCs|tjtdSr )rrrrr?r`r r rtest_listdir_defaultsz PosixTester.test_listdir_defaultcCs|ttjtddSN.)rrSrrrrr?r`r r rtest_listdir_bytes"szPosixTester.test_listdir_bytesc CsxttfD]j}|tt|d}Wdn1s:0Y|tt j ||D]}| t |t q\qdSrB)r memoryviewZ assertWarnsrrr?rrSrrrZassertIstyper)rclsnamesr7r r rtest_listdir_bytes_like's   ,z#PosixTester.test_listdir_bytes_likez)test needs fd support for posix.listdir()cCsdtttj}|tj||ttdtt||ttdtt|dS)N.) rrr%rurrr<sortedr?)rfr r rtest_listdir_fd/s    zPosixTester.test_listdir_fdaccessztest needs posix.access()cCs|ttjtjdSr )r^rrNrrrSR_OKr`r r r test_access>szPosixTester.test_accessumaskztest needs posix.umask()cCs$td}||tt|dSr)rrQrr)rZold_maskr r r test_umaskBs  zPosixTester.test_umaskstrerrorztest needs posix.strerror()cCs|tddSr)r^rrSr`r r r test_strerrorHszPosixTester.test_strerrorpipeztest needs posix.pipe()cCs$t\}}t|t|dSr )rrUrSr)rreaderwriterr r r test_pipeMs  zPosixTester.test_pipepipe2ztest needs os.pipe2()cCs|ttjd|ttjddtd\}}t|t|ttjtjB\}}|tj||tj||t ||t ||t ||t ||t tj |dzt |dtjWnt yYn0dS)NZDEADBEEFrr3r)r5r6rSrYrrrrrr get_blockingr rrgrZ PIPE_MAX_SIZE)rrrkr r r test_pipe2Ss"   zPosixTester.test_pipe2cCs8ddl}|ttj|jd|ttj|jddSNrr3) _testcapir5r#rSrYZINT_MAXZUINT_MAX)rr_r r rtest_pipe2_c_limitsoszPosixTester.test_pipe2_c_limitsrztest needs posix.utime()cCst}ttjd|ttjtjd|ttjtj|df|ttjtjd|fttjt|t|fttj||fdS)Nrrrr r r test_utimexszPosixTester.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)rSr r^rrb UF_IMMUTABLEr r EOPNOTSUPPrr<rrZrchflags) rZ chflags_funcZ target_filekwargsr%flagserrrZnew_strr r r r_test_chflags_regular_files$     (z&PosixTester._test_chflags_regular_filerfztest needs os.chflags()cCs|tjtjdSr )rjrrfrrr`r r r test_chflagsszPosixTester.test_chflagslchflagsztest needs os.lchflags()cCs(|tjtj|jtjtjdddSNFr)rjrrlrrrfr`r r rtest_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)NrbcSstj||ddSrm)rrf)rwrhr r rchflags_nofollowsz;PosixTester.test_lchflags_symlink..chflags_nofollowrc)rSr rrr^rr;r<rappendr:rrlrbrdr r rerr<) rZ testfn_stZdummy_symlink_strofnrhrirZ new_testfn_stZnew_dummy_symlink_str r rtest_lchflags_symlinks.        z!PosixTester.test_lchflags_symlinkcCsLtjdkrt}nt}tjD](\}}|t|||t||qdS)Nnt) rSr7r1rrryitemsr<rF)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)r5rrSputenvr`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 testir3z..)rSmkdirrXrYrvr%r=rmdir)dirnameZcurrent_path_length_create_and_do_getcwdr rr~s   zEPosixTester.test_getcwd_long_pathnames.._create_and_do_getcwd) rSr%rwabspathrrrzrvrmtree)rr|r_ base_pathr r}rtest_getcwd_long_pathnamess"     z&PosixTester.test_getcwd_long_pathnames getgrouplistztest needs posix.getgrouplist()rUztest needs pwd.getpwuid()r1ztest needs os.getuid()cCs<ttd}ttd}||t||dS)Nrr;)rTrUrSr1rrr)rusergroupr r rtest_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|VqdSr r)rgr r r rz-PosixTester.test_getgroups..zneed working 'id -G'darwinrZMACOSX_DEPLOYMENT_TARGETz10.0css|]}t|VqdSr r)rrr r rrrrJr)rrz$getgroups(2) is broken prior to 10.6)rSpopenrstriprsetrxrrXrYrsr sysconfigZget_config_vartuplesymmetric_differencerr-r^r*)rZidggroupsretZ idg_groupsrZdtZsymdiffr r rtest_getgroupss   &     $ zPosixTester.test_getgroupsSIGCHLDz2CLD_XXXX be placed in si_code for a SIGCHLD signal waitid_resultztest needs os.waitid_resultcCs(tjtjtjtjtjtjdSr )rS CLD_EXITED CLD_KILLED CLD_DUMPED CLD_TRAPPED CLD_STOPPED CLD_CONTINUEDr`r r rtest_cld_xxxx_constants#s z#PosixTester.test_cld_xxxx_constants sched_yieldzdon't have scheduling supportsched_setaffinityz!don't have sched affinity supportcCs tdSr )rrr`r r rtest_sched_yield2szPosixTester.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>rsrr5r )rZpollohir r rtest_sched_priority7s      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)rr7Zschedr r rrIs  zDPosixTester.test_get_and_set_scheduler_and_param..rrErr+l)sched_priority)r__dict__rtrrrSr0r r rZr5sched_getparamrrrrsrrsched_setschedulersched_setparamr6 sched_paramr#)rZpossible_schedulersZmineparentr ZparamZlarger r r$test_get_and_set_scheduler_and_paramGs>       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?) rrr r rrrr r> assertLess)rintervalr r r rtest_sched_rr_get_intervalps    z&PosixTester.test_sched_rr_get_intervalcCsttd}||t|t|dtjdsB| t tjd|D](}||t ||d| |dqFdS)Nrr3rrEr) rsched_getaffinityrrr>r=rsrrr5r rr)rmaskZcpur r rtest_sched_getaffinitys     z"PosixTester.test_sched_getaffinitycCstd}t|dkr|td||td||ttjdg|ttjddg|ttjdt t d|t tjddd>gt j ds|ttjd|dS)Nrr3iZ0XrrE)rrr=poprr<r5r rmaprr#rsrr)rrr r rtest_sched_setaffinitys    z"PosixTester.test_sched_setaffinitycCstjtjtjtjdSr )r RTLD_LAZYRTLD_NOW RTLD_GLOBAL RTLD_LOCALr`r r rtest_rtld_constantsszPosixTester.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!)rrrrgrhtellrcranger<rSr SEEK_DATAZassertLessEqualrr5r rXrY)rrrZfnorr r r test_fs_holess    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. )renamereplacelinkNZnoodly2Zdoesnotexistfilenamez'doesnotexistfilename' -> '{}'z#No valid path_error2() test for os.) r4rSrrr rformatr1r[)rr7functiondstr r r rtest_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!r5rrSrrrrrrwexistsrzr rrqZ fn_with_NULrr r rtest_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)rSrrrrr!r5rrrrrrrwrrzr rr r rtest_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)NrEz"system does not support pidfd_openzpidfd_open syscall blocked: r)r5r rSrrr r r isinstancerr<rrr.)rrr r rtest_pidfd_opens (  zPosixTester.test_pidfd_open)m__name__ __module__ __qualname__rr#r8rX skipUnlessrrr@rBrHrJrMrNr\rardrirlr4rS supports_fdr|rrrrrr requires_32brrrrrrrrrrrsupports_follow_symlinksrrrrrrrrrZrequires_linux_versionrrrr rrr rr'r3r6r8r=r>r@rArDrIr?rMrPrRrTrXr]Z cpython_onlyr`rarjrkrnrrrwryrrTrrsignalrZrequires_sched_hZrequires_sched_affinityrrrequires_schedrrrrrrrrrrr r r rr*s                         <                                     ;                   #  (     rc@seZdZdZeddZeddZee j e j vdddZ ee j e j vd d d Zeee d ote je j vd ddZee je j vdddZee je j vdddZee je j vdddZee je j vdddZeee doe je j voeedddd Zee je j vd!d"d#Zeee d$o\e je j vd%d&d'Zee j e j vd(d)d*Z!ee j"e j vd+d,d-Z#ee j$e j vd.d/d0Z%ee j&e j vd1d2d3Z'd4S)5TestPosixDirFdrccstjd7_tjd|j}tjd|jd}t||tj|tj ||}tj |rjJt |}|||fVWdn1s0YdS)Nr3_base) rcountrrrrzrr{rSrwjoinrZ open_dir_fd)rr7base_dirfullnamerr r rprepares  zTestPosixDirFd.prepareccsV|:\}}}t||tj||||fVWdn1sH0YdSr )rrr5rrr!rrr7rr r r prepare_files zTestPosixDirFd.prepare_filez)test needs dir_fd support for os.access()cCsJ|.\}}}|tj|tj|dWdn1s<0YdSNr)rr^rrNrSrOrr r rtest_access_dir_fdsz!TestPosixDirFd.test_access_dir_fdz'test needs dir_fd support in os.chmod()cCs~|b\}}}t|tjtj|tjtjB|dt|}||jtj@tjtjBWdn1sp0YdSr) rrchmodr rrr<rS_IRWXU)rrr7rsr r rtest_chmod_dir_fds  z TestPosixDirFd.test_chmod_dir_fdr4z'test needs dir_fd support in os.chown()cCsL|0\}}}tj|tt|dWdn1s>0YdSr)rrr4rSr1r,rr r rtest_chown_dir_fd%sz TestPosixDirFd.test_chown_dir_fdz&test needs dir_fd support in os.stat()c Cs|\}}}t|d}|dWdn1s:0Y|tj|t|}tj||d}|||tj|dd}||||jt dtj|t d|jt dtj|t |d|j t tj|ddWdn1s0YdS)Nrkz testline rzshould be integer or None, notl Fx:^V)rrrgrrr!r r<r r6r%r r5r#)rrr7routfiles1s2r r rtest_stat_dir_fd+s$ (     zTestPosixDirFd.test_stat_dir_fdz'test needs dir_fd support in os.utime()c Cs|n\}}}t}tj|d|dtj||d|jttj|||d|jttj|d|d|jttj||df|d|jttj|d|f|d|jttj||df|dtj|t|t|f|dtj|||f|dtj|t|t|t|df|dtj||t|t|t|dfdtjtjvrjztj|d|dWnt yhYn0Wdn1s0YdS)Nrrxr)rr(F)rr) rrrrr5r6rrSrr)rrr7rrr r rtest_utime_dir_fd?s@     z TestPosixDirFd.test_utime_dir_fdz&test needs dir_fd support in os.link()c Cs|\}}}|\}}}ztj||||dWn2tyh}z|d|WYd}~n d}~00|tj||t |dt |dWdn1s0YWdn1s0YdS)N src_dir_fd dst_dir_fdzposix.link(): %sr3) rrrrrrrr!r<r )rrr7rdir_fd2ZlinknameZ fulllinknamer r r rtest_link_dir_fd^s$ zTestPosixDirFd.test_link_dir_fdz'test needs dir_fd support in os.mkdir()cCsX|<\}}}tj||d|tj|t|Wdn1sJ0YdSr)rrrzrr{r rr r rtest_mkdir_dir_fdksz TestPosixDirFd.test_mkdir_dir_fdrrzAtest requires both stat.S_IFIFO and dir_fd support for os.mknod()c Cs|\}}}tjtjBtjB}ztj||d|dWn>tyv}z&||j t j t j t j fWYd}~n0d}~00| tj||tt|jWdn1s0YdS)Nrr)rr rrrrrr rr rZrrrr!r^rr)rrr7rrr r r rtest_mknod_dir_fdrs0z TestPosixDirFd.test_mknod_dir_fdz&test needs dir_fd support in os.open()c Cs|\}}}t|d}|dWdn1s:0Y|tj|tj|tj|d}z&t|d}|d|Wt |n t |0Wdn1s0YdS)Nrs testline r ) rrrgrrr!rurr<r)rrr7rrrrr r rtest_open_dir_fds ( zTestPosixDirFd.test_open_dir_fdreadlinkz*test needs dir_fd support in os.readlink()cCsb|F\}}}td||tj||tj||ddWdn1sT0YdSNr;r)rrSr;rrr!r<rrr r rtest_readlink_dir_fds z#TestPosixDirFd.test_readlink_dir_fdz(test needs dir_fd support in os.rename()c Cs|l\}}}|>\}}}tj||||dt|t||Wdn1s\0YWdn1sz0YdS)Nr)rrrrr )rrr7rrZname2Z fullname2r r rtest_rename_dir_fds z!TestPosixDirFd.test_rename_dir_fdz)test needs dir_fd support in os.symlink()cCsb|F\}}}tjd||d|tj||t|dWdn1sT0YdSr)rrr;rr!r<rrr r rtest_symlink_dir_fdsz"TestPosixDirFd.test_symlink_dir_fdz(test needs dir_fd support in os.unlink()cCs|j\}}}t|t|z"tj||d|ttj|Wn|tj|Yn0Wdn1sx0YdSr) rrr5rr r!r5r rrr r rtest_unlink_dir_fds  z!TestPosixDirFd.test_unlink_dir_fdz(test needs dir_fd support in os.mkfifo()c Cs|\}}}ztj|tjtjB|dWn2ty^}z|d|WYd}~n d}~00|tj || t t|j Wdn1s0YdS)Nrr) rrrr rrrrrr!r^rr)rrr7rr r r rtest_mkfifo_dir_fds$z!TestPosixDirFd.test_mkfifo_dir_fdN)(rrrrrrrrXrrSrNsupports_dir_fdrrrrr4rr rrrrrrzrrrrrrrrrr;rr!rrrr r r rrsT                rc@sPeZdZddZddZeeeddddZ eeed d d d Z d S)PosixGroupsTestercCsLtdkrtdttds*tdtjdkr>tdt|_dS)Nrznot enough privilegesr-zneed posix.getgroupsrzgetgroups(2) is broken on OSX) rr1rXrYrrsrr- saved_groupsr`r r rrs      zPosixGroupsTester.setUpcCsHttdrt|jn,ttdrDttj}t||jddS)N setgroupsrOr) rrr r rTrUr1rVrOrr7r r rr#s   zPosixGroupsTester.tearDownrOztest needs posix.initgroups()cCsDt|jp dgd}ttj}t||||t dSr^) maxr rTrUrr1rVrOrr-)rrr7r r rr\s z!PosixGroupsTester.test_initgroupsr ztest needs posix.setgroups()cCs6dgttdfD]}t|||tqdS)Nr)rrrr ZassertListEqualr-)rrr r rtest_setgroupss z PosixGroupsTester.test_setgroupsN) rrrrr#rXrrrr\rr r r rrs    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-SrorpNcGstjddg|RS)Nrr)rsrtrargsr 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())) rorrq) rrrr!r spawn_funcrSryrzrr<rr1)rZpidfilescriptrr{rLr r rtest_returns_pids  z!_PosixSpawnMixin.test_returns_pidc Cs~d}z|||gtj}Wn6ttfyP}z||j|WYd}~n2d}~00t|d\}}|||||ddS)Nno_such_executabler) rrSryFileNotFoundErrorrr<filenamewaitpidassertNotEqual)rrr{excZpid2statusr r rtest_no_such_executables$ z(_PosixSpawnMixin.test_no_such_executablecCstj}|tj|d|d}|d|}||d|itjddi}tj|ddt | }| | dWdn1s0YdS)NrzL, "w") as envfile: envfile.write(os.environ['foo']) rorrPZbarrq) rrrr!rrrSryrzrr<r)rZenvfilerrr{rLr r rtest_specify_environments   z)_PosixSpawnMixin.test_specify_environmentcCs.|j|jd|jtjdd}tj|dddSNr file_actionsrqr NOOP_PROGRAMrSryrrzrr{r r rtest_none_file_actionssz'_PosixSpawnMixin.test_none_file_actionscCs.|j|jd|jtjgd}tj|dddSr"r%r'r r rtest_empty_file_actions'sz(_PosixSpawnMixin.test_empty_file_actionscCs0|jtjtjddgtjdd}tj|dddS)NrorpFZresetidsrrqrrsrtrSryrrzr'r r rtest_resetids_explicit_default0s z/_PosixSpawnMixin.test_resetids_explicit_defaultcCs0|jtjtjddgtjdd}tj|dddS)NrorpTr*rrqr+r'r r r test_resetids9s z_PosixSpawnMixin.test_resetidscCsL|t.|jtjtjddgtjddWdn1s>0YdS)Nrorpr*r5r6rrsrtrSryr`r r rtest_resetids_wrong_typeBs   z)_PosixSpawnMixin.test_resetids_wrong_typecCs4|jtjtjddgtjtd}tj|dddS)NrorpZ setpgrouprrq)rrsrtrSryr/rrzr'r r rtest_setpgroupHs z_PosixSpawnMixin.test_setpgroupcCsL|t.|jtjtjddgtjddWdn1s>0YdS)NrorpZ023r0r.r`r r rtest_setpgroup_wrong_typeQs   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)roZ setsigmaskrrq) textwrapdedentrrsrtrSryrSIGUSR1rrz)rrr{r r rtest_setsigmaskWs  z _PosixSpawnMixin.test_setsigmaskcCs|t.|jtjtjddgtjddWdn1s>0Y|t0|jtjtjddgtjdgdWdn1s0Y|t:|jtjtjddgtjtj tj dgdWdn1s0YdS)Nrorp"r5jr3 r5r6rrsrtrSryrrNSIGr`r r rtest_setsigmask_wrong_typefs"  $  $  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)Nrorpr:rDr;r3r<r`r r rtest_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)ro)Z schedulerrq rSrrr6r7rrsrtryrrrzrZpolicypriorityrr{r r rtest_setscheduler_only_params     z-_PosixSpawnMixin.test_setscheduler_only_paramcCsftd}t|}td|d|d}|jtjtjd|gtj|t |fd}t j |dddSrIrJrKr r rtest_setscheduler_with_policys     z._PosixSpawnMixin.test_setscheduler_with_policycCs\tjdtjttjdftjdftjddfg}|j|j d|j tj |d}t j |dddS)Nr;rr3rr#rq) rSPOSIX_SPAWN_OPENrwrealpath__file__ruPOSIX_SPAWN_CLOSEPOSIX_SPAWN_DUP2rr&ryrrz)rr$r{r r rtest_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) Nrr#r r )i90r3rr;r) r&r5r6rrSryrRrrOrQrurr r rtest_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") r3rorr#rqhello)rrrr!rSrOrrO_TRUNCr rrrrryrzrr<r)rrrr$rr{rLr r rtest_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) rorr#rqz is closed %d)rrrr!rrrSryrRrzrr<rr r)rZ closefilerrr{rLr r rtest_close_files   z _PosixSpawnMixin.test_close_filecCstj}|tj|d}t|dT}tj|dfg}|d|}|j |d|tj |d}tj |ddWdn1s|0Yt| }| | dWdn1s0YdS) NrVrr3rorr#rqrW)rrrr!rrSrSrcrrryrzr<r)rZdupfilerZ childfiler$rr{rLr r rr-s  , z_PosixSpawnMixin.test_dup2)&rrrrsrtr&rrrr r!r(r)r,r-r/r1r2rXrrrr9r>rCrGrHrZskipIfrrrMrNrTrUrYrZrr r r rrsN            r posix_spawnztest needs os.posix_spawnc@seZdZeeddZdS)TestPosixSpawnr[N)rrrr4rrr r r rr\@sr\ posix_spawnpztest needs os.posix_spawnpc@s&eZdZeeddZejddZdS)TestPosixSpawnPr]NcCst}|tj|d}tj||}tt j |ztj |tj df}Wnt yf|}Yn0|ddddf}td|f}d|f}t|d|idS)Nzposix_spawnp_test_program.exePATHrrrorpz import os from test import support args = %a pid = os.posix_spawnp(args[0], args, os.environ) support.wait_process(pid, exitcode=0) )tempfilemkdtemprrrrSrwrr;rsrtpathsepryrWr6r7r)rtemp_dirZprogramZprogram_fullpathrwZ spawn_argsrrr r rtest_posix_spawnpIs   z!TestPosixSpawnP.test_posix_spawnp) rrrr4rrrZskip_unless_symlinkrdr r r rr^Es r^rztest weak linking on macOSc@seZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zd#d$Zd%S)&TestPosixWeaklinkingcsRddl}ddl}|fddD|_tdd|ddD|_dS)Nrcs"h|]}|dr|r|qS)ZHAVE_r)rZnmZ config_varsr r vrz-TestPosixWeaklinking.setUp..css|]}t|VqdSr r)rpartr r rrwrz-TestPosixWeaklinking.setUp..rJ)rrZget_config_vars availablermac_verrx)rrrr rfrrqs zTestPosixWeaklinking.setUpcCs||jvrt|ddS)Nz not weak-linked)rirXrYr r r r_verify_availableys 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)rkrjr^rrSrr`r r rr}s   z!TestPosixWeaklinking.test_pwritevcCsp|d|jdkr$|dtjnH|dtj|tdtj dddWdn1sb0YdS)NZ HAVE_FSTATATrrdir_fd unavailablefilerr) rkrjrr_have_functions assertNotInr rrSr r`r r rrs   zTestPosixWeaklinking.test_statcCs|d|jdkr$|dtjn|dtj|td"tj dtj ddWdn1sf0Y|td"tj dtj dd Wdn1s0Y|td "tj dtj d d Wdn1s0YdS) NZHAVE_FACCESSATrlrmrnrrzfollow_symlinks unavailableFrzeffective_ids unavailableT)Z effective_ids) rkrjrrrorpr rrSrNrOr`r r rrPs  00z TestPosixWeaklinking.test_accesscCs|d|jdkr$|dtjnX|dtj|dtj|td tj ddddWdn1sr0YdS) NZ HAVE_FCHMODATrlZ HAVE_LCHMODrmrnirr) rkrjrrrorpr rrSrr`r r r test_chmods  zTestPosixWeaklinking.test_chmodcCs|d|jdkr$|dtjnZ|dtj|dtj|td"tj dddddWdn1st0YdS)NZ HAVE_FCHOWNATrlZ HAVE_LCHOWNrmrnrr) rkrjrrrorpr rrSr4r`r r rr6s  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_LINKATrlzsrc_dir_fd unavailablesourcetargetrrzdst_dir_fd unavailablerrrrkdataTrF)rkrjrrrorpr rrSrrrcrwrrrgr;r5FileExistsError)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_FDOPENDIRrlzClistdir: path should be string, bytes, os.PathLike or None, not intrzCscandir: path should be string, bytes, os.PathLike or None, not int) rkrjrrrorpr r6rSr?scandirr`r r rtest_listdir_scandirs  (z)TestPosixWeaklinking.test_listdir_scandircCsp|d|jdkr$|dtjnH|dtj|tdtj dddWdn1sb0YdS)NZ HAVE_MKDIRATrlrmdirrr) rkrjrrrorpr rrSrzr`r r r test_mkdirs   zTestPosixWeaklinking.test_mkdircCsp|d|jdkr$|dtjnH|dtj|tdtj dddWdn1sb0YdS)NZ HAVE_MKFIFOATrQrrmrwrr) rkrjrrrorpr rrSrr`r r rrs   z TestPosixWeaklinking.test_mkfifocCsp|d|jdkr$|dtjnH|dtj|tdtj dddWdn1sb0YdS)NZ HAVE_MKNODATr~rmrwrr) rkrjrrrorpr rrSrr`r r rrs   zTestPosixWeaklinking.test_mknodcCs*|d|jdkr&|dtjn|dtj|td tj ddddWdn1sf0Y|td tj ddddWdn1s0Y|td tj ddddWdn1s0Y|td tj ddddWdn1s0YdS) NZ HAVE_RENAMEATrlz%src_dir_fd and dst_dir_fd unavailableabrrtru) rkrjrrrorpr rrSrrr`r r rtest_rename_replaces  ...z(TestPosixWeaklinking.test_rename_replacecCs|d|jdkr$|dtjn|dtj|tdtj dddWdn1sb0Y|tdtj dddWdn1s0YdS)NZ HAVE_UNLINKATrlrmrwrr) rkrjrrrorpr rrSr!r{r`r r rtest_unlink_rmdir%s  ,z&TestPosixWeaklinking.test_unlink_rmdircCst|d|jdkr$|dtjnL|dtj|td"tj dtj ddWdn1sf0YdS)NZ HAVE_OPENATrlrmrwrr) rkrjrrrorpr rrSrrur`r r r test_open3s   zTestPosixWeaklinking.test_opencCsp|d|jdkr$|dtjnH|dtj|tdtj dddWdn1sb0YdS)NZHAVE_READLINKATrlrmrwrr) rkrjrrrorpr rrSrr`r r r test_readlink>s   z"TestPosixWeaklinking.test_readlinkcCsr|d|jdkr$|dtjnJ|dtj|td tj ddddWdn1sd0YdS)NZHAVE_SYMLINKATrlrmrrrr) rkrjrrrorpr rrSr;r`r r r test_symlinkIs   z!TestPosixWeaklinking.test_symlinkcCs|d|d|jdkr<|dtj|dtjnV|dtj|dtj|tdtj dddWdn1s0YdS)NZ HAVE_FUTIMENSZHAVE_UTIMENSAT)rrQrmrwrr) rkrjrrrorpr rrSrr`r r rraTs   zTestPosixWeaklinking.test_utimeN)rrrrrkrrrPrqr6ryr{r}rrrrrrrrar r r rrejs$    '      recCs tdSr )r reap_childrenr r r rtearDownModulecsr__main__)+__doc__rfrZtest.support.script_helperr import_modulerr rsrrrSrrTr r`rXrr6 contextlibrrwr gettempdirrr<rmaxsizerrrZTestCaserrrrrr\r^rerrmainr r r rsd       `A$]$y