gf7.dZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlmZddlmZddlmZddlmZddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lmZddlmZddlmZddlmZddlmZddl m!Z!ddl m"Z"ddl m#Z#ddl m$Z$ddl m%Z%ddl m&Z&ddl m'Z'ddl m(Z(ddl m)Z)ddl m*Z*ddl m+Z+ddl m,Z,ddl m-Z-ddl m.Z.dd l m/Z/dd!l m0Z0dd"l m1Z1dd#l m2Z2dd$l m3Z3dd%l m4Z4dd&l m5Z5dd'l m6Z6dd(l m7Z7dd)l m8Z8dd*l m9Z9dd+l m:Z:dd,l m;Z;dd-l mdkrGd0d1e=Z?Gd2d3e2Z@eAd4krdd5lBmCZCeCeDdSdS)6Tests for psutil.Process class.N)AIX)BSD)LINUX)MACOS)NETBSD)OPENBSD)OSX)POSIX)SUNOS)WINDOWS) open_text)FileNotFoundError)long)PY3)super)APPVEYOR) call_until) CI_TESTING)copyload_shared_lib) create_exe)GITHUB_ACTIONS)GLOBAL_TIMEOUT)HAS_CPU_AFFINITY) HAS_ENVIRON) HAS_IONICE)HAS_MEMORY_MAPS)HAS_PROC_CPU_NUM)HAS_PROC_IO_COUNTERS) HAS_RLIMIT) HAS_THREADS)mock)process_namespace)PsutilTestCase)PYPY) PYTHON_EXE reap_children)retry_on_failure)sh)skip_on_access_denied)skip_on_not_implemented) ThreadTask)unittest) wait_for_pidc" eZdZdZdZdZdZdZdZe j e ddZ d Z d Zd Zd Zd ZdZdZdZdZe j e ddZdZe j e ddZe j e deedZe j e de j e ddZe j e de j e ddZ!e j e" ddZ#e j e" ddZ$e j e" ddZ%e j e" dd Z&e j e" dd!Z'd"Z(e j e d#d$Z)e j e* dd%Z+e,e-e.e j e* dd&Z/e,d'Z0d(Z1e j e2 dd)Z3e j e2 dd*Z4d+Z5d,Z6d-Z7d.Z8e j e9d/d0Z:d1Z;e j e9d2d3Z<e j e=d4e j e>d5e j e9d/d6Z?e j e dd7Z@e j e dd8ZAd9ZBd:ZCd;ZDd<ZEd=ZFe j eG dd>ZHe j eG dd?ZIe j eG dd@ZJe j eKdAe j eLdBdCZMe j eKdAe j eLdBdDZNe j e ddEZOeee j ePpeQdFdGZRdHZSdIZTdJZUdKZVe,dLZWdMZXdNZYdOZZdPZ[dQZ\dRZ]dSZ^dTZ_dUZ`dVZadWZbe j e ddXZce j e ddYZde j e ddZZed[Zfe j eg dd\Zhe j eg de j e dd]Zid^S)_ TestProcessrcN|j|i|}tj|jSN)spawn_testprocpsutilProcesspid)selfargskwargssprocs {/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib64/python3.11/site-packages/psutil/tests/test_process.py spawn_psproczTestProcess.spawn_psprocNs+##T4V44~ei(((ctj}||jt j|t5d|_ddddS#1swxYwYdS)N!)r5r6 assertEqualr7osgetpid assertRaisesAttributeErrorr8ps r<test_pidzTestProcess.test_pidTs N    ,,,   ~ . .  AE                  sA//A36A3c:|}||}tr!||t jn!||t j ||dSr3) r=killwaitr rAsignalSIGTERMSIGKILLassertProcessGoner8rGcodes r< test_killzTestProcess.test_killZs      vvxx  4   T6> 2 2 2 2   TFN? 3 3 3 q!!!!!r>c:|}||}tr!||t jn!||t j ||dSr3)r= terminaterKr rArLrMrOrPs r<test_terminatezTestProcess.test_terminateds      vvxx  4   T6> 2 2 2 2   TFN? 3 3 3 q!!!!!r>cRtr tjn tj}|}|||}tr|||n||| | |dSr3) r rLrNrMr= send_signalrKr rArO)r8sigrGrQs r<test_send_signalzTestProcess.test_send_signalns %9fnn6>      cvvxx  )   T3 ' ' ' '   TC4 ( ( ( q!!!!!r>z not POSIXc tj}|}tjdt t jd5|tj |j |dddn #1swxYwY|}tjdt t j d5|tj |j |ddddS#1swxYwYdS)Nzpsutil.os.kill side_effect)rLrMr=r"patchOSErrorerrnoESRCHrDr5 NoSuchProcessrWEPERM AccessDenied)r8rXrGs r<test_send_signal_mockedz#TestProcess.test_send_signal_mockedysn      Z($+EK$<$<>>> H H   f2AM3 G G G H H H H H H H H H H H H H H H      Z($+EK$<$<>>> G G   f11=# F F F G G G G G G G G G G G G G G G G G Gs$'BB B'DD Dctddg}||}|}||d||tddg}||t j}|}||d||tddg}||}|}||d||tdd g}||}|}||d||dS) N-cpassrz1 / 0)stderrzimport sys; sys.exit(5);zimport os; os._exit(5);)r&r=rKrArO subprocessPIPE)r8cmdrGrQs r<test_wait_exitedzTestProcess.test_wait_exitedsk4(   c " "vvxx q!!! q!!!4)   c*/  : :vvxx q!!! q!!!4!;<   c " "vvxx q!!! q!!!4!:;   c " "vvxx q!!! q!!!!!r>c@|}tr|tj|t j|jd|tj |t j|jd|tj | |tj | |tj dS| |t j|jd| |t j|jd|| |tj | |tj dS)NMbP?)timeout)r=r rWrLSIGSTOPrDr5TimeoutExpiredrKSIGCONTrMrAsuspendresumerTrFs r<test_wait_stoppedzTestProcess.test_wait_stoppeds       7 MM&. ) ) )   f3QVU  K K K MM&. ) ) )   f3QVU  K K K MM&. ) ) )   QVVXX 7 7 7   QVVXX 7 7 7 7 7 IIKKK   f3QVU  K K K HHJJJ   f3QVU  K K K KKMMM   QVVXXv~ 6 6 6   QVVXXv~ 6 6 6 6 6r>cl|\}}|tj|jd|tj|jd|||}|}t r9||tj ||ddS||tj ||tj dS)N{Gz?) spawn_children_pairrDr5rtrKrTr rArLrM)r8child grandchild child_retgrandchild_rets r<test_wait_non_childrenz"TestProcess.test_wait_non_childrens !4466z &/TBBB &/$GGG JJLL #**  8   Y 8 8 8   ^T 2 2 2 2 2   Y 7 7 7   Y 7 7 7 7 7r>c0|}||tj|jd|tj|jd|t |jddS)Nrzr)r=namerDr5rtrK ValueErrorrFs r<test_wait_timeoutzTestProcess.test_wait_timeoutsz       &/>>> &/;;; *afb11111r>cr|}|tj|jd|t jtz}t j|krC |d}nA#tj$rYnwxYwt j|kC|dtr"| |tj n | |tj ||dS)Nrrr)r=rDr5rtrKrJtimerfailr rArLrNrMrO)r8rGstop_atrQs r<test_wait_timeout_nonblockingz)TestProcess.test_wait_timeout_nonblockings      &/;;; )++.ikkG## vvayy(     ikkG##))I&& &  3   TFN? 3 3 3 3   T6> 2 2 2 q!!!!!sBB*)B*ctj}|d|dtdD]I}|d}||t ||dJ|t5|dddddS#1swxYwYdS)Nrq)intervaldr) r5r6 cpu_percentrangeassertIsInstancefloatassertGreaterEqualrDr)r8rGxpercents r<test_cpu_percentzTestProcess.test_cpu_percents N   u %%% u %%%s 2 2AmmTm22G  ! !'5 1 1 1  # #GS 1 1 1 1   z * * ' ' MM2M & & & ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' 's3CCCctjdd5}tj|jsJ ddddS#1swxYwYdS)Nzpsutil.cpu_count) return_value)r"r^r5r6rcalled)r8ms r<test_cpu_percent_numcpus_nonez)TestProcess.test_cpu_percent_numcpus_nones Z* > > > ! N   ( ( * * *8OO8O                  s/AAAc tj}|jdks|jdks J||jdks J||jdks J|tr|jdks J||j D]7}tj dtj t||8dS)Nrz%H:%M:%S)r5r6 cpu_timesusersystem children_userchildren_systemriowait_fieldsrstrftime localtimegetattr)r8timesrs r<test_cpu_timeszTestProcess.test_cpu_timess  **,, S  elS&8&8&85&8&89#s***U***%,,,u,,,  .<3&&&&&&M L LD M*dnWUD5I5I&J&J K K K K L Lr>ctjdd\}}tjdd\}}t ||gt ||gz dkr|d|d|t ||gt ||gz dkr|d|d|dSdS)N皙? expected: , found: )r5r6rrBrmaxminr)r8 user_time kernel_timeutimektimes r<test_cpu_times_2zTestProcess.test_cpu_times_2s!'!1!1!;!;!=!=bqb!A ;xzz"1"~ u E" # #c9e*<&=&= = D D III555))D E E E e$ % %[%,@(A(A AS H H III555++F G G G G G I Hr>z not supportedcftj}|}||dtjdkr||d||ttjdSNrrj)r5r6cpu_numr cpu_countrAassertInr)r8rGnums r< test_cpu_numzTestProcess.test_cpu_nums N  iikk Q'''     " "   S! $ $ $ aiikk5)9););#<#<=====r>cZ|}tj}|}t||z }|dkr|d|d|d|tjdtj|dS)Nrrrz, difference: z%Y %m %d %H:%M:%S)r=r create_timeabsrrr)r8rGnowr differences r<test_create_timezTestProcess.test_create_times     ikkmmoo s*++ >> IIIkkk::7 8 8 8 )4>!--//+J+JKKKKKr>z POSIX onlyctj}|Dtjt d}|||dSdS)Ntty)r5r6terminalrBpathrealpathr*rA)r8rrs r< test_terminalzTestProcess.test_terminal's`>##,,..  '""2e99--C   Xs + + + + + r>)only_ifcRtj}|}ttd5}|dddn #1swxYwY|}t sts||j |j | |j |j tr@||j |j | |j|jn@||j|j||j|j|}t|d5}t&r'|t+ddzdn|ddzdddn #1swxYwY|}||j |j ||j|j||j |j ||j|jtr@||j|j||j |j t-t/|D]H}t r|dkr|||d|||dIdS)Nrbwbri@Basciirr)r5r6 io_countersopenr&readrr assertGreater read_countrA write_countr read_chars write_charsr read_bytes write_bytes get_testfnrwritebytesrlen)r8rGio1fio2is r<test_io_counterszTestProcess.test_io_counters.s2 N  mmoo *d # # q FFHHH               mmoo F3 F   s~s~ > > >   S_co > > > C""3>3>BBB  #/BBB  # #CNCN C C C  # #COS_ E E Emmoo $//##T * * 'a 'cGmW556666g &&&  ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' mmoo AAA AAA ??? ???  D   s @ @ @  # #CNCN C C Cs3xx / /A qAvv  # #CFA . . .  # #CFA . . . .  / /s$AA"%A" AGG #G z linux onlyctj}ts8||dtj|tjd|tjd|tjd|tjd|} |tj|t|tjdf| t5|tjddddn #1swxYwY|tj|t|tjdf|tjd|t|tjdf| t5|tjddddn #1swxYwY |tjdn#tj $rYnwxYw| td|jtjd| td|jtjd| td |jd|\}}|tjkrd}|||dS#|\}}|tjkrd}|||wxYw) Nrrjrvaluezioclass accepts no valuez$'ioclass' argument must be specified)r5r6rrAioniceIOPRIO_CLASS_NONEIOPRIO_CLASS_RTIOPRIO_CLASS_BEIOPRIO_CLASS_IDLEtuplerDrrdassertRaisesRegex)r8rGinitioclassrs r<test_ionice_linuxzTestProcess.test_ionice_linuxYs N   F   QXXZZ]F,D E E E 11555 /333 /333 11555xxzz % HHV- . . .   U188::..1I10M N N N"":.. < <1;;; < < < < < < < < < < < < < < < HHV+ , , ,   U188::..1G0K L L L HHV+1H 5 5 5   U188::..1G0K L L L"":.. : :/q999 : : : : : : : : : : : : : : : /q9999&      " "6&2A 7 7 7  " "6&2A 7 7 7  " "B # # # #"NGU&222 HHWe $ $ $ $ $"NGU&222 HHWe $ $ $ $s{(A:N""F NFNFCN7"J% N%J))N,J)-N1!KNK%"N$K%%BN/Oz!not supported on this win versionctj}ts2||tj|} |tj||tj|tj||tj |tj||tjn#tj $rYnwxYw| td|jtjd| td|jtjdz||dS#||wxYw)Nz&value argument not accepted on Windowsrjrzis not a valid priority) r5r6rrAr IOPRIO_NORMALIOPRIO_VERYLOW IOPRIO_LOW IOPRIO_HIGHrdr TypeErrorr)r8rGrs r<test_ionice_winzTestProcess.test_ionice_wins N   ?   QXXZZ)= > > >xxzz  HHV* + + +   QXXZZ)> ? ? ? HHV& ' ' '   QXXZZ): ; ; ; A+,,,  V-?@@@@&      " "C&.a # 9 9 9  " "5&,q0 2 2 2 HHTNNNNNAHHTNNNNs2"B"G E$3G E)&G (E))A G G7cddl}tjtj}dt tD}|s J||D]}t t|}||d|t |vri||t ||trk|| || || |}|t|d||dd||dddS)Nrc<g|]}|d|S)RLIMIT startswith.0rs r< z/TestProcess.test_rlimit_get..s)BBBq1<<+A+ABBBBr>rrrj) resourcer5r6rBrCdirrrrAr%rlimit getrlimitr)r8rrGnamesrrrets r<test_rlimit_getzTestProcess.test_rlimit_gets[ N29;; ' 'BBCKKBBBeu 4 4DFD))E  # #E1 - - -s8}}$$  $(?(?@@@  %(2D2DU2K2KLLLLhhuoo  S1---''A333''A3333 4 4r>cR|}|tjd||tjdt re|td5tj dddddn #1swxYwY| t5|tjdddddS#1swxYwYdS)N)rkrkzcan't use prlimitr)rkrkrk) r=rr5 RLIMIT_NOFILErArrr _psplatformr6rDrFs r<test_rlimit_setzTestProc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XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXr)r5r6rr RLIMIT_FSIZErrrDIOErrorrAr exceptionr`EFBIG)r8rGtestfnsofthardrexcs r< test_rlimitzTestProcess.test_rlimitsw N  ""XXf122 d J HHV(4, 7 7 7fd## %q $$$ % % % % % % % % % % % % % % %""7++ )s&$'')1GGK((())))))))))))))) ) ) ) ) ) ) ) ) ) ) ) ) ) ) )   CMS]00S]1=M"[ * * * HHV(4, 7 7 7   QXXf&9::T4L I I I I I HHV(4, 7 7 7   QXXf&9::T4L I I I Isz 2F0=B F0B##F0&B#'F0DC7+ D7C; ;D>C; ?D F0DF0DAF00AH ctj}|tj\}} |tjd|f|tjtj|ft |d5}|ddddn #1swxYwY|tj||f||tj||fdS#|tj||f||tj||fwxYw)Nr rsXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX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XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX) r5r6rr  RLIM_INFINITYrrrrA)r8rGrrrs r<test_rlimit_infinityz TestProcess.test_rlimit_infinitys N  XXf122 d J HHV(4, 7 7 7 HHV(6+?*F G G Gdoo''.. %! $$$ % % % % % % % % % % % % % % % HHV(4, 7 7 7   QXXf&9::T4L I I I I I HHV(4, 7 7 7   QXXf&9::T4L I I I Is1A0D-'C = D- C  D-C D--AFctj}|tj\}}|tj||tj||fdSr3)r5r6rr rAr)r8rGrrs r<test_rlimit_infinity_valuez&TestProcess.test_rlimit_infinity_valuesc N  XXf122 d -t444 $tTl33333r>ctj}tr= |}n;#tj$rt jdwxYw|}t5|}|||dzddddS#1swxYwYdS)N$on OpenBSD this requires root accessrj) r5r6r num_threadsrdr.SkipTestr-rA)r8rGstep1step2s r<test_num_threadszTestProcess.test_num_threadss N    $ P & P P P'(NOOO PMMOOE \\ / /MMOOE   UEAI . . . / / / / / / / / / / / / / / / / / /s1$A:.B55B9<B9z WINDOWS onlyc|tj}||ddSNr)r5r6r num_handlesrFs r<test_num_handleszTestProcess.test_num_handless5 N   1==??A.....r>ctj}tr= |}n;#tj$rt jdwxYw|}t5|}|t|t|dz|d}||j |d||j |d||j |dddddS#1swxYwYdS)Nrrjrr) r5r6r threadsrdr.rr-rAridr system_time)r8rGrrathreads r< test_threadszTestProcess.test_threads so N     P & P P P'(NOOO PIIKKE \\ > >IIKKE   SZZUa 8 8 8AhG   WZ 4 4 4   W. ; ; ;   W0'!* = = = > > > > > > > > > > > > > > > > > >s1$A:B3D::D>D>c|}tr= |n'#tj$rt jdwxYw||j td|Dd||j td|DddS)Nrcg|] }|j S)rrs r<rz.TestProcess.test_threads_2..-s222222r>r)deltacg|] }|j Sr-)r(rs r<rz.TestProcess.test_threads_2..0s4441444r>) r=r r&r5rdr.rassertAlmostEqualrrsumrrFs r<test_threads_2zTestProcess.test_threads_2 s       < < & < < <':<<< <  KKMM  22aiikk222 3 33  @ @ @  KKMM 44 444 5 5S  B B B B Bs 2$Actj}|dd\}}|}||d||ddgdz}|dd\}}|}|||||||||~t rT|} || j| j || j | j |} | j D]&} |t| | d'dS)Nrri`)r5r6 memory_infomemory_percentrrr rArsswsetvmspagefilerr) r8rGrss1vms1percent1memarrrss2vms2percent2memrs r<test_memory_infozTestProcess.test_memory_info2s| N  ]]__RaR( d##%% 4### 4###'!]]__RaR( d##%% 4&&& d+++ 8X...   4--//C   SWch / / /   SWcl 3 3 3mmooK ; ;D  # #GC$6$6 : : : : ; ;r>c*tj}tjj}|}|jD]\}t ||}||d||f|dkrtstrA| |||||f]tststr||j dtr8||jd||jddSdS)Nr)msgr8)r5r6virtual_memorytotalmemory_full_inforrrr rassertLessEqualr russpssswap)r8rGrFrArrs r<test_memory_full_infoz!TestProcess.test_memory_full_infoQs! N  %''-  ""K I IDC&&E  # #E14- # @ @ @u}}}}  D%3G H H H H  0G 0u 0  # #CGQ / / /  1  # #CGQ / / /  # #CHa 0 0 0 0 0 1 1r>ctj}|}d|D}|t |t t ||d}|D]}|jdsotj |jsJ|jtr tj |js3tj |jsJ|j#t$rTtstd5}|}dddn #1swxYwYd|jz|vrYwxYwdtj|jvrU tj|j}t%j|jsJ|j|#t*$rYwxYw|D]f}|jD]\} t/|| } | dkr| d vr | s J| *|| t2t4f| d ks J| ]gdS) Ncg|]}|Sr-r-rs r<rz0TestProcess.test_memory_maps..es!!!q!!!r>F)grouped[z/proc/self/smapsz %s (deleted)64r)addrpermsr)r5r6 memory_mapsrArsetrrrBisabsr existsislinkAssertionErrorrrrbasenamestatS_ISREGst_moderrrrintr) r8rGmapspathsext_mapsntrdatastfnamers r<test_memory_mapszTestProcess.test_memory_mapsas N  }}!!D!!! USU__555===// E EB7%%c** Ew}}RW--66rw66-E &!w~~bg66=GNN2733==57W== 4)&&&$&!"++=!>!>0!'(vvxx000000000000000-7tCC % DC&27#3#3BG#<#<<<E!#!1!1B$(< #;#;DDRWDD#;D 1!!! D! - -B - -E**F??/// ''%''5'))%#t=== A:::u:::: - - -sI"AD::!FE<0 F<F FF FFH HHctj}t5}dfd|D}|||ddddS#1swxYwYdS)Ncztjtj|Sr3)rBrrnormcase)rGs r<normpathz8TestProcess.test_memory_maps_lists_lib..normpaths(w''(8(8(;(;<<c0g|]}|jSr-)r)rrrjs r<rz:TestProcess.test_memory_maps_lists_lib..s5222!((222r>)r5r6rrTr)r8rGrlibpathsrjs @r<test_memory_maps_lists_libz&TestProcess.test_memory_maps_lists_libs N   " " 4d = = =2222!"222H MM((4..( 3 3 3  4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4sAA33A7:A7ctj}||t|jdt st str|ddSdS)Nz?!?)memtyperI)r5r6r5rDrrrr rFs r<test_memory_percentzTestProcess.test_memory_percents| N    *a&6FFF  ,E ,W ,  U  + + + + + , ,r>c.|}|sJ|sJ|||rJ|rJdSr3)r= is_runningrJrKrFs r<test_is_runningzTestProcess.test_is_runnings     ||~~~||~~~  <<>>!!!<<>>!!!!!r>c|}|} ||tn#t$rt rdt |t tkr?tjj }||||tnvtj ddtj d} || |dtj |dn#t$rYnwxYwYnwxYwt|ddg}||ddS)Nr.rjr[rgzimport os; print('hey')hey)r=exerAr&rYr rrBrrisys version_inforeplacer*)r8rGrwriverouts r<test_exezTestProcess.test_exesl     eegg    S* - - - -    3s88s:667+  #0D0DEEEE"%!1!!4!4!4c6Fq6I6IJ$$S[[b%9%9%/%7R%@%@BBBB%D! (#t6788 e$$$$$s6ABD4#=D! D4! D.+D4-D..D43D4cttddg}||}tststr5||dtdS|d|d|dS)Nrgzimport time; time.sleep(60)r )r&r=rr rrAcmdlinejoin)r8rrGs r< test_cmdlinezTestProcess.test_cmdlinest%BC   g & &  GW G G   QYY[[^Z 8 8 8 8 8   SXXaiikk22CHHW4E4E F F F F Fr>zbroken on PYPYc|}t||gdgdzz}||}|||dS)N 0123456789)rrr=rAr)r8rrrGs r<test_long_cmdlinezTestProcess.test_long_cmdlinesi""6(|nr12   g & & g.....r>cx|t}|}tjtjtj }| |s J||fdSr3) r=r&rlowerrBrrZrrx executabler)r8rGrpyexes r< test_namezTestProcess.test_names   j ) )vvxx~~  !1!1#.!A!ABBHHJJ%%44t}44%44r>zunreliable on PYPYc|d}t|||}||t j|dS)N01234567890123456789suffix)rrr=rArrBrrZ)r8rrGs r<test_long_namezTestProcess.test_long_namesk(8996   f % % 27#3#3F#;#;<<<<zbroken on SUNOSz broken on AIXc*|d}t||ddddddg}||}|||||t j||t j | t j |dS)Nz foo bar )rrgz9import time; [time.sleep(0.01) for x in range(3000)];arg1arg2r[arg3) rrr=rArrrBrrZrirw)r8 funky_pathrrGs r<test_prog_w_funky_namez"TestProcess.test_prog_w_funky_names__K_88 :t!2vr3   g & & g... 27#3#3J#?#?@@@ ))!%%''22))*55 7 7 7 7 7r>ctj}|\}}}||t j||t jttdr;|t j|dSdSN getresuid) r5r6uidsrArBgetuidgeteuidhasattrrr8rGreal effectivesaveds r< test_uidszTestProcess.test_uids N  !"i ry{{+++ BJLL111 2{ # # 7   R\^^QVVXX 6 6 6 6 6 7 7r>ctj}|\}}}||t j||t jttdr;|t j|dSdSr) r5r6gidsrArBgetgidgetegidr getresgidrs r< test_gidszTestProcess.test_gids rr>ctj}|t|jd|} t rtjtjtjtj tj tj fD]}| |5 ||| ||n#tj$rYnwxYwdddn #1swxYwYnn tt drV| t!jt jt!j||d| |dtt drV| t!jt jt!j|t(s=|d| |dn#tj$rYnwxYw ||dS#tj$rYdSwxYw# ||w#tj$rYwwxYwxYw)Nstr)prio getpriorityrjr)r5r6rDrnicer NORMAL_PRIORITY_CLASSIDLE_PRIORITY_CLASSBELOW_NORMAL_PRIORITY_CLASSREALTIME_PRIORITY_CLASSHIGH_PRIORITY_CLASSABOVE_NORMAL_PRIORITY_CLASSsubTestrArdrrBr PRIO_PROCESSrCr)r8rGrrs r< test_nicezTestProcess.test_nices N   )QVU333vvxx&  #9#7#?#;#7#? A = =D 400===FF4LLL!,,QVVXXt<<<< &2!!! D!=============== =r=11&((N2?BIKKHHFFHH&&&FF1III$$QVVXXq111r=11&((N2?BIKKHHFFHH&&& !6q ((1555*D t &     t &    s A#J8-D/C-)D-C?<D>C??D J8D J8D J8EI54J85JJ8JJ8 J""J54J58K%:KK%K"K%!K""K%ctj}||tjdSr3)r5r6rAstatusSTATUS_RUNNINGrFs r< test_statuszTestProcess.test_statusCs6 N   V%:;;;;;r>c|}|}trw|d\}}||t jdtjvr(||tjddSdS||t jdS)N\ USERDOMAIN) r=usernamer splitrAgetpassgetuserrBenviron)r8rGrdomains r< test_usernamezTestProcess.test_usernameGs     ::<<  :'~~d33 FH   Xw'8'8 9 9 9rz))  L)ABBBBB*)   Xw'8'8 9 9 9 9 9r>c|}||tjdSr3)r=rAcwdrBgetcwdrFs r<test_cwdzTestProcess.test_cwdRs=      ")++.....r>cntddg}||}t|jddS)Nrgz/import os, time; os.chdir('..'); time.sleep(60)z#ret == os.path.dirname(os.getcwd()))r&r=rr)r8rnrGs r< test_cwd_2zTestProcess.test_cwd_2Vs>4@B   c " "15?@@@@@r>c tj}|}|s J|||j|t t dr:||tt j|j |t|tt|ttttj d}|D]}||g|||gt t drL||tt j|j t |dr@||d||gtr@|||jn(|||t t drL||tt j|j |t&|jd|||t||t)|dS)Nsched_getaffinityTpercpunum_cpurrj)r5r6 cpu_affinity addCleanuprrBrAlistrr7rrUrrrr_proc_get_eligible_cpusrDrr)r8rGinitialall_cpusns r<test_cpu_affinityzTestProcess.test_cpu_affinity\s N  ..""w 000 2* + + I   Wd2+?+F+F&G&G H H H Ws3w<<'8'8999c&"4D"A"A"ABBCCDD C CA NNA3      Q^^--s 3 3 3r.// D  !1!1!%b&:15&A&A!B!BDDDq)$$ C  !1!1!!4aiikkBBB r  9   Q^^--qw/I/I/K/K L L L L   Q^^--x 8 8 8 2* + + @   Q^^--!""6qu"="=>> @ @ @ )Q^Q777 w s8}}%%% uX'''''r>c|}ttjddzg}|t |j||t |jtdd|t|jddg|t |jddgdS) NTr i'i*r1r) r=rr5rrDrrrr)r8rG invalid_cpus r<test_cpu_affinity_errsz"TestProcess.test_cpu_affinity_errss     6+488899B>?  *ankBBB *aneE56I6IJJJ )Q^aX>>> *anq"g>>>>>r>cVtj}|}|s J|||j|t |dkr |dd}g}t dt |dzD]>}t j||D]&}|r"|t|'?|D]Y}||| t|t|ZdS)N rrj) r5r6rrrr itertools combinationsappendrrAsorted)r8rGrcombosrsubsetcombos r<"test_cpu_affinity_all_combinationsz.TestProcess.test_cpu_affinity_all_combinationss4 N  ..""w 000 w<<"  crclGq#g,,*++ 0 0A#0!<< 0 00MM$v,,/// 0 F FE NN5 ! ! !   VANN$4$455ve}} E E E E F Fr>z broken on BSDzunreliable on APPVEYORcvtj}|}|}|||t |d5}|d|t|jdt|z}d|D}| tj ||tr+|D](}|j |kr||jd)dddn #1swxYwY|D]0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xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxzlen(ret) != %icVg|]&}tj|j'Sr-rBrrirs r<rz/TestProcess.test_open_files..s*AAAa))!&11AAAr>r z2import time; f = open(r'%s', 'r'); time.sleep(60);rgrcVg|]&}tj|j'Sr-rrs r<rz/TestProcess.test_open_files..s*JJJa))!&11JJJr>rz)r5r6r open_files assertNotInrrflushrrrrBrrirrApositionisfiler=r&rrsleep) r8rGrfilesr filenamesfilerrs r<test_open_fileszTestProcess.test_open_filesse N  ""  ''' &$   >1 GGK GGIIIq|-=E -JKKEAA5AAAI MM"'**622I > > > >!>>DyF**((=== > > > > > > > > > > > > > > > 3 3D7>>$),, 2 2d 2 2, 2GO   z49 : :s ? ?AJJ1<<>>JJJI"" JsOOOO MM"'**622I > > > . .D7>>$'' - - - -' - . .s"CD..D25D2ctj}tjj}|}t |d5}|D]C}||j||jks|j | krn8D| dt|z| ||j||jtr| |j dn-| |j | |d}| |d|j| |d|j ||j|ddddS#1swxYwYdS)Nwzno file found; files=%srrrj)r5r6rBrrirrrrfdfilenorreprrAr r)r8rGrirfileobjrntuples r<test_open_files_2zTestProcess.test_open_files_2s N  7#"" &#   ;'  L L8DI&&((7<*@*@@@7>>#3#333E4 3d1<<>>6J6JJKKK   XXdi00((7<2H2H I I I <  "----  '..*:*:;;;\\^^A&F   VAY 4 4 4   VAY 2 2 2   W\1<<>> : : :# ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;s FG11G58G5cvtj}|}|}t |d}||j|||dztj}||j|||dz|||||dS)Nrrjr) r5r6rnum_fdsrrcloserAsocket)r8rGrstartrsocks r< test_num_fdszTestProcess.test_num_fdss N  "" FC    ### eai000}  ### eai000   e,,,,,r>z not reliable on OPENBSD & NETBSDctj}t|}t dD],}t|}||krdS-|ddS)Ni z7num ctx switches still the same after 50.000 iterations)r5r6r1num_ctx_switchesrr)r8rGbeforerafters r<test_num_ctx_switchesz!TestProcess.test_num_ctx_switchess N  Q''))**v  A**,,--Ev~~ KLLLLLr>cttj}ttdr9||tj|}||tjtrdSdS)Ngetppid) r5r6rrBrAppidr r=rCrrFs r< test_ppidzTestProcess.test_ppids N   2y ! ! 5   QVVXXrz|| 4 4 4      29;;///   F   r>cN|}||jt jt jd}|t j |dSr") r=rAparentr7rBrCr5pids assertIsNoner6)r8rG lowest_pids r< test_parentzTestProcess.test_parentsy      555[]]1%  &.44;;==>>>>>r>ctj}|\}}||||||dSr3)r5r6r{rArr8rr|r}s r<test_parent_multizTestProcess.test_parent_multisk!! 4466z **,,e444 00000r>c|}tjdtjdd5||ddddS#1swxYwYdS)Npsutil.Processrfoor\)r=r"r^r5rbrrrFs r<test_parent_disappearedz#TestProcess.test_parent_disappeareds      Z($*$8E$B$BDDD * *   ahhjj ) ) ) * * * * * * * * * * * * * * * * * *s(A33A7:A7ctj}|sJ|\}}||d|||d|||d|dSr)r5r6parentsr{rArs r< test_parentszTestProcess.test_parentss!!~~ 4466z +V444 ++--a0%888 ++--a0&99999r>cVtj}||g||dg|d}|}|d}||fD]~}|t |d||dj|j||d|jdS)NT recursiver) creationflagsrj)r5r6rAchildrenr=rr7r )r8rr| children1 children2r"s r< test_childrenzTestProcess.test_children%s!! **B/// 488"===!!!22OO%% OOdO33 "I. = =H   S]]A . . .   Xa[_ei 8 8 8   Xa[--// < < < < = =r>ctj}|\}}|||g||d||g||||dgdS)NTr)r5r6r{rAr"rTrKrs r<test_children_recursivez#TestProcess.test_children_recursive4s!! 4466z **UG444 4885*:MNNN   488"=====r>cttjt}tjD]:} ||xxdz cc<&#tj$rY7wxYwt|ddd}tr|dkr| dtj |} | d}| t|tt|dS#tj$rYdSwxYw) Nrjc|dS)Nrjr-)rs r<z6TestProcess.test_children_duplicates..Js !A$r>)keyrrzPID 0Tr) collections defaultdictr^r5 process_iterr ErrorritemsrskipTestr6r"rArrUrd)r8tablerGr7cs r<test_children_duplicatesz$TestProcess.test_children_duplicatesAs9',,$&&  A affhh1$<    U[[]]777;A>  )SAXX--(( ( N3   2 T **A   SVVSQ[[ 1 1 1 1 1"    DD s#"AA%$A%D$$D76D7ctj}|\}}|d}|t |d||d|||d||}||d|||d|dS)NTrrrrj)r5r6r{r"rArr)r8rr|r}r"rs r<test_parents_and_childrenz%TestProcess.test_parents_and_childrenUs!! 4466z??T?22 X*** !e,,, !j111$$&& U+++ V,,,,,r>cv|}|tdD]:}|tjkrnt jd;|| |tjdS)Nrrz) r=rvrrr5STATUS_STOPPEDrrrwassertNotEqual)r8rGrs r<test_suspend_resumezTestProcess.test_suspend_resumebs      s  AxxzzV222 Jt       AHHJJ(=>>>>>r>c|ttjd|ttjddS)Nrr)rDrr5r6rr8s r<test_invalid_pidzTestProcess.test_invalid_pidls< )V^S999 *fnb99999r>ctj}|ddg}|t |ddgtjt tj}|dgd}t|dts||ddtj ddtj 5||d gd d d idddn #1swxYwYtj ddtj |jd 5|tj |jd gdddn #1swxYwYtj ddtj|jd 5||d gdd didddn #1swxYwYtj ddt" 5|}|d t||t"5|d gdddn #1swxYwYdddn #1swxYwY|t&5|ddddn #1swxYwY|t(5|dgdddn #1swxYwY|t(5|dd gddddS#1swxYwYdS) Nrwr)attrs connectionsr)r?ad_valuezpsutil.Process.niceT)creater]rrjbar)r5r6as_dictrArkeysrr isinstancerr"r^rdrbr7rD ZombieProcessNotImplementedErrorrrr)r8rGds r< test_as_dictzTestProcess.test_as_dictps N   IIUFOI , , ))E6?;;; N3v{}}-- . . II]OeI < <!M*D11 6   Q}-u 5 5 5Z-d$*$7999 D D    1 55{ D D D D D D D D D D D D D D D D D D Z-d$*$8$G$GIII A A   $aix  A A A A A A A A A A A A A A A A A A Z-d$*$8$G$GIII L L    5 99FE? L L L L L L L L L L L L L L L L L LZ-d$7999 * * A   VT!&&((^^ 4 4 4""#677 * *  ))) * * * * * * * * * * * * * * *  * * * * * * * * * * * * * * *  y ) )   IIf                     z * *   IIug                     z * * & & IIuen % % % & & & & & & & & & & & & & & & & & &s/EEE:)F//F36F3)/H$$H(+H( A$K*/K K*K K*K K**K.1K.L11L58L5M99M=M=OO Oc@tj}tjd5}|5||dddn #1swxYwY||jddddn #1swxYwYtjd5}||dddn #1swxYwY||jddS)N$psutil._psplatform.Process.cpu_timesrjrr5r6r"r^oneshotrrA call_countr8rGrs r< test_oneshotzTestProcess.test_oneshots N   Z> ? ? .1                      Q\1 - - -  . . . . . . . . . . . . . . . Z> ? ? 1 KKMMM KKMMM                q)))))sFB$)A2& B$2A6 6B$9A6 :B$$B(+B()C88C<?C<c vtj}tjd5}tjd5}|5|||5||dddn #1swxYwYdddn #1swxYwY||jd||jddddn #1swxYwYdddn #1swxYwYtjd5}||dddn #1swxYwY||jddS)NrLz(psutil._psplatform.Process.oneshot_enterrjrrM)r8rGm1m2rs r<test_oneshot_twicezTestProcess.test_oneshot_twices N   Z> ? ? 32FGG 32YY[[&&KKMMMKKMMM&&  &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&   222  222 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3Z> ? ? 1 KKMMM KKMMM                q)))))sD?D(=C)C 8 CC C C C D(C D("C #9D( D?(D, ,D?/D, 0D??EE)FFFc|\}}|}|}||||5||||||dddn #1swxYwY|5||||||ddddS#1swxYwYdSr3)r{r r9rNrA)r8p1p2p1_ppidp2_ppids r<test_oneshot_cachezTestProcess.test_oneshot_caches))++B''))'')) GW--- ZZ\\ 1 1   RWWYY 0 0 0   RWWYY 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1ZZ\\ 1 1   RWWYY 0 0 0   RWWYY 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1s&*ACC C &AEE Ec@fd}}||tr"t t jd|jz|t|}| |j D]\}}|||trYtsTtjj}|||t$dSdSdS)Nc |}tr|dvrdS|d|d#tj$rtj$rYdStj$rt r|dvrYdSwxYw)N)rwrz didn't raise NSP and returned z instead)r&r)r rr5rGrbrdr )funfun_namerr8s r<assert_raises_nspzFTestProcess.test_halfway_terminated_process..assert_raises_nsps 8ceex?::Fii-0SS###!7888'   '   &   x+EEEFF s 5A4A42A4z %s not in ret)r=rTrKr rr5rr7rOr#iterallrrBrrirArwr&)r8r`rGnsr^rris` r<test_halfway_terminated_processz+TestProcess.test_halfway_terminated_processs- 8 8 8 8 8$         = v{Oae$; < < < q!!! q ! ! ) )IC  c4 ( ( ( (  F> Fw'H   XXaeegg..0D0D E E E E E F F F Fr>cd}|\}}tj|j}||tj|sJ|t|}| |j D]\}}||tj |jsJ| |jtj| |jdtjDit_| |jdtjDdS)Nc\ |S#tjtjf$rYdSwxYwr3)r5rGrd)r^s r<succeed_or_zombie_p_excz@TestProcess.test_zombie_process..succeed_or_zombie_p_excs? suu (&*=>    s ++cg|] }|j Sr-r7rs r<rz3TestProcess.test_zombie_process..!G!G!GA!%!G!G!Gr>cg|] }|j Sr-rirs r<rz3TestProcess.test_zombie_process..rjr>) spawn_zombier5r6r7rAr STATUS_ZOMBIErrrDr#rarb pid_existsrrr._pmap)r8rgrzombiezprocrcr^rs r<test_zombie_processzTestProcess.test_zombie_processs_    **,,vz** )=>>>!!!!! u % % ) )IC # #C ( ( ( ( +++++ ei/// ei!G!G1D1F1F!G!G!GHHH  ei!G!G1D1F1F!G!G!GHHHHHr>ctj}tjdtjd5}|sJ|jsJ ddddS#1swxYwYdS)Nrrr\)r5r6r"r^rGrrrrPs r<$test_zombie_process_is_running_w_excz0TestProcess.test_zombie_process_is_running_w_excs N   Z($*$8$;$;=== @A<<>> ! !>8OO8O                  s A**A.1A.c&tj}tjdtjd5}||tj|jsJ ddddS#1swxYwYdS)Nz!psutil._psplatform.Process.statusrr\) r5r6r"r^rGrArrmrrPs r< test_zombie_process_status_w_excz,TestProcess.test_zombie_process_status_w_exc's N   Z;$*$8$;$;=== @A   QXXZZ)= > > >8OO8O                  s.clean_dict..dsp(((Q))D"%%--dB77))D"%%--dB779(((r>)poprdictr0)rIs r< clean_dictz,TestProcess.test_environ..clean_dictZs EE"D ) ) ) EE&$    EE&$    8/6666===0$777((WWYY((()) )r>) maxDiffr5r6rrBcopyr rrA)r8rrGd1d2s r< test_environzTestProcess.test_environXs ) ) ) N   Z $ $ Z )) * * %~ %   R $ $ $ $ $ % % % %r>ctjd}|}t||||gt jt j}tj|j }t|j | sJ| |j dtr3t r, |}n*#tj$rYdSwxYw|}| |ddd|| |jddS) Na #include #include char * const argv[] = {"cat", 0}; char * const envp[] = {"A=1", "X", "C=3", 0}; int main(void) { /* Close stderr on exec so parent can wait for the execve to * finish. */ if (fcntl(2, F_SETFD, FD_CLOEXEC) != 0) return 0; return execve("/bin/cat", argv, envp); } )c_code)stdinrir>r3)ACr)textwrapdedentrrr4rlrmr5r6r7r/rrrArirrrrrd communicate returncode)r8rQrr;rGenvs r<test_weird_environzTestProcess.test_weird_environosg     4%%%%## F*/*/$CC N59 % %QU||~~~ **,,c222  Z  iikk&     ))++C Cc22333  )1-----s&C;;D DN)j__name__ __module__ __qualname____doc__r=rHrRrUrYr.skipIfr rerorxrrrrrrrrrrrrr,rrrrr rr rr rrrr r$r!r*r)r+rr2rBrLrrfrmrprsr}rr%rrrr rrrrrrrrrrrrrrrrrrr rr r rrrrr%r'r4r6r:r=rJrQrUr[rdrrrtrvr{rrrr-r>r<r1r1Ks )))))  """""" " " "X_Y ,, G G-, G"""6777*888*222"""& ' ' ' L L L H H HX_))?;;>><;>LLL X_Y --,,.-, X_--??U+++'/'/,+@?'/RX_^_55X_Y --(%(%.-65(%TX_^_55X_["EFFGF656X_^_5544654,X_^_55 6 665 6X_^_55JJ65J&X_^_55 J J65 JX_^_55 4 465 4///"X_[.11//21/ X__o66>>76>&5)))X__o66 B B76*) B;;;<111 X_(/::+-+-;:+-ZX_(/::44;:4,,,"""%%%8 G G GX_T+,,//-,/555 X_T/00==10=X_U-..X_S/**X_T+,, 7 7-,+*/. 7X_Y -- 7 7.- 7X_Y -- 7 7.- 7***X<<< : : :///AAA X_))?;;%(%(<;%(NX_))?;;??<;?X_))?;;FF<;F(X_S/**X_X788..98+*.DX_S/**X_X788;;98+*;0X_Y -- - -.- -U+++X_W&(JKKMMLK,+M   ???111 ***::: = = = > > >222( - - -???:::,&,&,&\ * * ****( 1 1 1(F(F(FTX_Y --"I"I.-"IHX_Y --.-X_Y --.-%(%(%(NX__o66%%76%,X__o66X_Y --#.#..-76#.#.#.r>r1ceZdZdZeedrejZejZ fdZ fdZ fdZ dZ ejddd ZxZS) LimitedUserTestCasezRepeat the previous tests by using a limited user. Executed only on UNIX and only if the user who run the test script is root. rc tj|i|dt|DD];}t||fd}t ||t j||.s)FFFqf1E1EFFFFr>cJ dS#tj$rYdSwxYwr3)r5rd)r8meths r<test_z+LimitedUserTestCase.__init__..test_s<!.s "")r__init__rrsetattrtypes MethodType)r8r9r:attrrr __class__s @r<rzLimitedUserTestCase.__init__s EGG d -f - - -GFCIIFFF C CtT** dE$4UD$A$ABBBB C Cr>cttjdtjddS)Ni)rsetUprBsetegidseteuidr8rs r<rzLimitedUserTestCase.setUps: GGMMOOO Jt    Jt     r>ctj|jtj|jt dSr3)rBr PROCESS_UIDr PROCESS_GIDrtearDownrs r<rzLimitedUserTestCase.tearDownsE Jt' ( ( ( Jt' ( ( ( GG       r>c tjd|ddS#tj$rYdSwxYw)Nrzexception not raised)r5r6rrrdr<s r<rzLimitedUserTestCase.test_nicese 2  %%b))) 011111&    s&?AArjzcauses problem as rootcdSr3r-r<s r<rrz'LimitedUserTestCase.test_zombie_processs Dr>)rrrrrrBrrrrrrrrr.rrr __classcell__)rs@r<rrs  72x  &#")++K#")++K C C C C C             2 2 2 4 5 5   6 5     r>rc:eZdZdZedZdZdZdZdS) TestPopenzTests for psutil.Popen class.c"tdSr3r')clss r< tearDownClasszTestPopen.tearDownClasssr>ctddg}tj|tjtj5}|||j|t|| tt|d| dddn #1swxYwYtr6||dt"j dS||dt"jdS)Nrgimport time; time.sleep(60);stdoutrirrk)r&r5Popenrlrmrrr assertTruerrDrErrTr rArKrLrMr8rnprocs r< test_misczTestPopen.test_miscsH4!?@ \#jo!+222 59 IIKKK NN    JJ OOCII & & &   ngtU C C C NN                    ;   TYYq\\FN? ; ; ; ; ;   TYYq\\6> : : : : :sBC  CCcbtjtdgtjtjtj5}|dddn #1swxYwY|jjsJ|jjsJ|j jsJ| |j ddS)Nz-V)rrirr) r5rr&rlrmrrclosedrirrAr)r8rs r<test_ctx_managerzTestPopen.test_ctx_managers \:t,!+!+ *111 59                       {!!!!{!!!!z     !,,,,,sAA#&A#ctddg}tj|tjtj5}|||tj|j|tj|j |tj|j tj trptjdkr`|tj|j tj|tj|j tjddddS#1swxYwYdS)Nrgrr)rr)r&r5rrlrmrTrKrDrbrJrWrLrMr rxry CTRL_C_EVENTCTRL_BREAK_EVENTrs r<test_kill_terminatezTestPopen.test_kill_terminatest4!?@ \#jo!+222 ;59 NN    IIKKK   f2DN C C C   f2DI > > >   f2D4D$n . . . ;3+v55!!&"68H"("5777!!&"68H"("9;;; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;sDEE!$E!N) rrrr classmethodrrrrr-r>r<rrs`''[;;;$ - - -;;;;;r>r__main__) run_from_name)Err,r`rrrBrLrr[rlrxrrrr5rrrrrr r r r r psutil._commonrpsutil._compatrrrr psutil.testsrrrrrrrrrrrrrr r!r"r#r$r%r&r(r)r*r+r,r-r.r/r1rrrrpsutil.tests.runnerr__file__r-r>r<rs|&%    $$$$$$,,,,,, !!!!!!############,,,,,,######''''''''''''))))))$$$$$$######(((((())))))------######$$$$$$******''''''######&&&&&&))))))......000000######!!!!!!%%%%%%I.I.I.I.I..I.I.I.b* .YRY[[A  ,,,,,k,,,h5;5;5;5;5;5;5;5;p z111111M(r>