JFIFxxC      C  " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3RbrJFIFxxC      C  " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr 0i:bdZddlZddlZddlZddlmZddlmZddlmZddlmZddlmZddlm Z dd l m Z dd l m Z dd l m Z dd l mZdd l mZddl mZddl mZddl mZddl mZddl mZddl mZddl mZddl mZddl mZddl mZddl mZddl mZddl mZddl mZddl mZddl mZddl m Z ejBjDZ"ejFZ$dZ%d Z&Gd!d"eZ'Gd#d$e'Z(ejRjUe d%&Gd'd(eZ+Gd)d*eZ,y)+aTests for detecting function memory leaks (typically the ones implemented in C). It does so by calling a function many times and checking whether process memory usage keeps increasing between calls or over time. Note that this may produce false positives (especially on Windows for some reason). PyPy appears to be completely unstable for this framework, probably because of how its JIT handles memory, so tests are skipped. N)LINUX)MACOS)OPENBSD)POSIX)SUNOS)WINDOWS)AARCH64)HAS_CPU_AFFINITY) HAS_CPU_FREQ) HAS_ENVIRON) HAS_IONICE)HAS_MEMORY_MAPS)HAS_NET_IO_COUNTERS)HAS_PROC_CPU_NUM)HAS_PROC_IO_COUNTERS) HAS_RLIMIT)HAS_SENSORS_BATTERY)HAS_SENSORS_FANS)HAS_SENSORS_TEMPERATURES)TestMemoryLeak)create_sockets) get_testfn)process_namespace)pytest)skip_on_access_denied) spawn_subproc)system_namespace) terminatec d}|S)zsDecorator for those Linux functions which are implemented in pure Python, and which we want to run faster. cBtjfd}|S)NctrI|jj} t|j_|g|i|||j_S|g|i|S#||j_wxYwN)r __class__times FEW_TIMES)selfargskwargsbeforefuns K/opt/hc_python/lib64/python3.12/site-packages/psutil/tests/test_memleaks.pywrapperz5fewtimes_if_linux..decorator..wrapper=si--2+4DNN(t5d5f5+1DNN(41$1&11,2DNN(s AA0) functoolswraps)r+r-s` r, decoratorz$fewtimes_if_linux..decorator<s%   2  2)r0s r,fewtimes_if_linuxr37s  r1ceZdZdZeZdZedZedZ edZ edZ e jje ded Ze jje ded Zed Zd Zd Ze jje ddZe jje ddZe jje dedZe jjeddZedZeeedZe jje ddZ e jje dedZ!edZ"eeedZ#edZ$ee jje% ddZ&edZ'edZ(e jje ded Z)d!Z*ed"Z+e jje, dd#Z-e jje, dd$Z.ed%Z/e jje0 ded&Z1e jje2 d'e jje3 dd(Z4e jje2 d'e jje3 dd)Z5ee jjed*d+Z6e jje7 dd,Z8e jje dd-Z9y.)/TestProcessObjectLeaksz$Test leaks of Process class methods.cltd}|j||j|jzyr#)rtest_class_coveragegetterssettersr'nss r, test_coveragez$TestProcessObjectLeaks.test_coverageXs) t $ tRZZ"**%<=r1cN|j|jjyr#)executeprocnamer's r, test_namez TestProcessObjectLeaks.test_name\ TYY^^$r1cN|j|jjyr#)r>r?cmdlinerAs r, test_cmdlinez#TestProcessObjectLeaks.test_cmdline` TYY&&'r1cN|j|jjyr#)r>r?exerAs r,test_exezTestProcessObjectLeaks.test_exed TYY]]#r1cN|j|jjyr#)r>r?ppidrAs r, test_ppidz TestProcessObjectLeaks.test_ppidhrCr1z POSIX onlyreasoncN|j|jjyr#)r>r?uidsrAs r, test_uidsz TestProcessObjectLeaks.test_uidsl TYY^^$r1cN|j|jjyr#)r>r?gidsrAs r, test_gidsz TestProcessObjectLeaks.test_gidsqrTr1cN|j|jjyr#)r>r?statusrAs r, test_statusz"TestProcessObjectLeaks.test_statusv TYY%%&r1cN|j|jjyr#)r>r?nicerAs r, test_nicez TestProcessObjectLeaks.test_nicezs TYY^^$r1cZtjjfdy)Nc:jjSr#)r?r])nicenessr'sr,z6TestProcessObjectLeaks.test_nice_set..sTYY^^H5r1)thisprocr]r>)r'ras`@r, test_nice_setz$TestProcessObjectLeaks.test_nice_set}s==? 56r1 not supportedcN|j|jjyr#)r>r?ionicerAs r, test_ionicez"TestProcessObjectLeaks.test_ionicer[r1c,tr*tjjfdyjfdt j t jtjdd}jt|y)Nc:jjSr#)r?rg)r'valuesr,rbz8TestProcessObjectLeaks.test_ionice_set..s!1!1%!8r1cVjjtjSr#)r?rgpsutilIOPRIO_CLASS_NONErAsr,rbz8TestProcessObjectLeaks.test_ionice_set..s!1!1&2J2J!Kr1r) rrcrgr>r.partialcextproc_ioprio_setosgetpid execute_w_excOSError)r'r+rks` @r,test_ionice_setz&TestProcessObjectLeaks.test_ionice_sets^ OO%E LL8 9 LLK L##D$8$8"))+r1MC   w ,r1cN|j|jjyr#)r>r? io_countersrAs r,test_io_countersz'TestProcessObjectLeaks.test_io_counters TYY**+r1zworthless on POSIXctjj|j|jjyr#)rmProcessusernamer>r?rAs r, test_usernamez$TestProcessObjectLeaks.test_usernames- !!# TYY''(r1cN|j|jjyr#)r>r? create_timerAs r,test_create_timez'TestProcessObjectLeaks.test_create_time TYY**+r1)only_ifcN|j|jjyr#)r>r? num_threadsrAs r,test_num_threadsz'TestProcessObjectLeaks.test_num_threadsr{r1 WINDOWS onlycN|j|jjyr#)r>r? num_handlesrAs r,test_num_handlesz'TestProcessObjectLeaks.test_num_handlesrr1cN|j|jjyr#)r>r?num_fdsrAs r, test_num_fdsz#TestProcessObjectLeaks.test_num_fds TYY&&'r1cN|j|jjyr#)r>r?num_ctx_switchesrAs r,test_num_ctx_switchesz,TestProcessObjectLeaks.test_num_ctx_switches TYY//0r1cN|j|jjyr#)r>r?threadsrAs r, test_threadsz#TestProcessObjectLeaks.test_threadsrr1cN|j|jjyr#)r>r? cpu_timesrAs r,test_cpu_timesz%TestProcessObjectLeaks.test_cpu_timess TYY(()r1cN|j|jjyr#)r>r?cpu_numrAs r, test_cpu_numz#TestProcessObjectLeaks.test_cpu_numrr1cN|j|jjyr#)r>r? memory_inforAs r,test_memory_infoz'TestProcessObjectLeaks.test_memory_inforr1cN|j|jjyr#)r>r?memory_full_inforAs r,test_memory_full_infoz,TestProcessObjectLeaks.test_memory_full_inforr1cN|j|jjyr#)r>r?terminalrAs r, test_terminalz$TestProcessObjectLeaks.test_terminals TYY''(r1ctrtn |j}|j|jj |y)Nr%)rr&r%r>r?resumer'r%s r, test_resumez"TestProcessObjectLeaks.test_resumes)"   TYY%%U 3r1cN|j|jjyr#)r>r?cwdrAs r,test_cwdzTestProcessObjectLeaks.test_cwdrKr1cN|j|jjyr#)r>r? cpu_affinityrAs r,test_cpu_affinityz(TestProcessObjectLeaks.test_cpu_affinitys TYY++,r1ctjjfdjtfdy)Nc:jjSr#r?r)affinityr'sr,rbz>TestProcessObjectLeaks.test_cpu_affinity_set..sTYY33H=r1c<jjdgSNrorrAsr,rbz>TestProcessObjectLeaks.test_cpu_affinity_set..styy/E/Erd/Kr1)rcrr>ru ValueError)r'rs`@r,test_cpu_affinity_setz,TestProcessObjectLeaks.test_cpu_affinity_sets/((* => :'KLr1cttd5|j|jjdddy#1swYyxYw)Nw)openrr>r? open_filesrAs r,test_open_filesz&TestProcessObjectLeaks.test_open_filess0 *, $ LL-- .% $ $s &AA cN|j|jjyr#)r>r? memory_mapsrAs r,test_memory_mapsz'TestProcessObjectLeaks.test_memory_mapsr{r1z LINUX onlyc.jfdy)NcVjjtjSr#r?rlimitrm RLIMIT_NOFILErAsr,rbz4TestProcessObjectLeaks.test_rlimit..sTYY--f.B.BCr1r>rAs`r, test_rlimitz"TestProcessObjectLeaks.test_rlimits CDr1ctjtjj fdj t tffdy)NcXjjtjSr#r)limitr'sr,rbz8TestProcessObjectLeaks.test_rlimit_set..sTYY--f.B.BEJr1c:jjdSr)r?rrAsr,rbz8TestProcessObjectLeaks.test_rlimit_set..s$)):J:J2:Nr1)rcrrmrr>rurvr)r'rs`@r,test_rlimit_setz&TestProcessObjectLeaks.test_rlimit_sets< 4 45 JK GZ02NOr1zworthless on WINDOWSct5trdndjfddddy#1swYyxYw)Ninetallc:jjSr#)r?net_connections)kindr'sr,rbz=TestProcessObjectLeaks.test_net_connections..s!:!:4!@r1)rrr>)r'rs`@r,test_net_connectionsz+TestProcessObjectLeaks.test_net_connectionss- "6D LL@ A  s 6?cN|j|jjyr#)r>r?environrAs r, test_environz#TestProcessObjectLeaks.test_environrGr1c(|jdy)NcPtjtjSr#)rq proc_inforsrtr2r1r,rbz7TestProcessObjectLeaks.test_proc_info..sT^^BIIK8r1rrAs r,test_proc_infoz%TestProcessObjectLeaks.test_proc_infos 89r1N):__name__ __module__ __qualname____doc__rcr?r<r3rBrFrJrNrmarkskipifrrSrWrZr^rdr rhrwrrzrrrrrrrrrrrrrrrrrrr rrrrrrrrrrr rrr2r1r,r5r5Ss. D>%%(($$%% [[E ,7%8% [[E ,7%8%''%7 [[J?'@' [[J?-@- [[00I,J, [[&:;)<) ,,7+,,, [[G N;,<, [[E ,7(8(117+(,(** [[,,_E(F(,,11 [[E ,7)8)4$$ [[,,_E-F- [[,,_EMFM // [[O+OD,E, [[E ,7 [[J?E@8E [[E ,7 [[J?P@8P  [[(>?B@B [[K@(A( [[G N;:<:r1r5cveZdZdZefdZefdZdZerdZ dZ dZ dZ d Z d ZxZSxZS) TestTerminatedProcessLeakszRepeat the tests above looking for leaks occurring when dealing with terminated processes raising NoSuchProcess exception. The C functions are still invoked but will follow different code paths. We'll check those code paths. ct|t|_t j |jj |_|jj|jjyr#) super setUpClassrsubprmr}pidr?killwaitclsr$s r,rz%TestTerminatedProcessLeaks.setUpClasssI  ?>>#((,,/    r1cLt|t|jyr#)r tearDownClassrrrs r,rz(TestTerminatedProcessLeaks.tearDownClasss #((r1cF |y#tj$rYywxYwr#)rm NoSuchProcess)r'r+s r,callzTestTerminatedProcessLeaks.calls$  E##   s    cN|j|jjyr#)r>r?rrAs r, test_killz$TestTerminatedProcessLeaks.test_kill$ LL (r1cN|j|jjyr#)r>r?rrAs r,test_terminatez)TestTerminatedProcessLeaks.test_terminate's LL,, -r1cN|j|jjyr#)r>r?suspendrAs r, test_suspendz'TestTerminatedProcessLeaks.test_suspend*s LL** +r1cN|j|jjyr#)r>r?rrAs r,rz&TestTerminatedProcessLeaks.test_resume-s LL)) *r1cN|j|jjyr#)r>r?rrAs r, test_waitz$TestTerminatedProcessLeaks.test_wait0rr1c2fd}j|y)Ncv tjjjS#t$rYywxYwr#)rqrr?rProcessLookupErrorrAsr,rz7TestTerminatedProcessLeaks.test_proc_info..call5s1>>$))--88)s (, 88r)r'rs` r,rz)TestTerminatedProcessLeaks.test_proc_info3s  LL r1)rrrr classmethodrrrrrrrrrr __classcell__)r$s@r,rrs]   ) . , + ) #r1rrrOceZdZdZdZy)TestProcessDualImplementationc(|jdy)NcTtjtjdS)NTuse_pebrq proc_cmdlinersrtr2r1r,rbzETestProcessDualImplementation.test_cmdline_peb_true..AsT..ryy{D.Ir1rrAs r,test_cmdline_peb_truez3TestProcessDualImplementation.test_cmdline_peb_true@s IJr1c(|jdy)NcTtjtjdS)NFrrr2r1r,rbzFTestProcessDualImplementation.test_cmdline_peb_false..DsT..ryy{E.Jr1rrAs r,test_cmdline_peb_falsez4TestProcessDualImplementation.test_cmdline_peb_falseCs JKr1N)rrrr r r2r1r,rr>sKLr1rceZdZdZdZedZedZedZedZ edZ ee jjexred e jje d d Ze jje d d ZdZe jjed dZdZdZdZe jjexrej8j;d d edZedZee jje d dZ!ee jjexrejDdk7d dZ#dZ$dZ%ee jje& d dZ'ee jje( d dZ)ee jje* d d Z+ed!Z,d"Z-d#Z.erd$Z/d%Z0d&Z1d'Z2d(Z3y)y))*TestModuleFunctionsLeaksz&Test leaks of psutil module functions.cPt}|j||jyr#)rr7rr:s r,r<z&TestModuleFunctionsLeaks.test_coverageOs   tRVV,r1c(|jdy)Nc.tjdS)NTlogicalrm cpu_countr2r1r,rbz9TestModuleFunctionsLeaks.test_cpu_count..WsV--d;r1rrAs r,test_cpu_countz'TestModuleFunctionsLeaks.test_cpu_countUs ;.[sV--ermrrAs r,rz'TestModuleFunctionsLeaks.test_cpu_times] V%%&r1c(|jdy)Nc.tjdS)NT)percpu)rmrr2r1r,rbz=TestModuleFunctionsLeaks.test_per_cpu_times..csV--T:r1rrAs r,test_per_cpu_timesz+TestModuleFunctionsLeaks.test_per_cpu_timesas :;r1cB|jtjyr#)r>rm cpu_statsrAs r,test_cpu_statsz'TestModuleFunctionsLeaks.test_cpu_statserr1zskipped due to #1892rOrecB|jtjyr#)r>rmcpu_freqrAs r, test_cpu_freqz&TestModuleFunctionsLeaks.test_cpu_freqis V__%r1rcjtj|jtjyr#)rm getloadavgr>rAs r,test_getloadavgz(TestModuleFunctionsLeaks.test_getloadavgps  V&&'r1cB|jtjyr#)r>rmvirtual_memoryrAs r,test_virtual_memoryz,TestModuleFunctionsLeaks.test_virtual_memoryws V**+r1z&worthless on SUNOS (uses a subprocess)cB|jtjyr#)r>rm swap_memoryrAs r,test_swap_memoryz)TestModuleFunctionsLeaks.test_swap_memory{s V''(r1c\trtn |j}|jd|y)NcPtjtjSr#)rm pid_existsrsrtr2r1r,rbz:TestModuleFunctionsLeaks.test_pid_exists..sV..ryy{;r1rrr&r%r>rs r,test_pid_existsz(TestModuleFunctionsLeaks.test_pid_existss "   ;5 Ir1c\trtn |j}|jd|y)Nc,tjdS)N.)rm disk_usager2r1r,rbz:TestModuleFunctionsLeaks.test_disk_usage..sV..s3r1rr2rs r,test_disk_usagez(TestModuleFunctionsLeaks.test_disk_usages "   35 Ar1cB|jtjyr#)r>rmdisk_partitionsrAs r,test_disk_partitionsz-TestModuleFunctionsLeaks.test_disk_partitionss V++,r1z/proc/diskstatsz3/proc/diskstats not available on this Linux versionc(|jdy)Nc.tjdSNF)nowrap)rmdisk_io_countersr2r1r,rbz@TestModuleFunctionsLeaks.test_disk_io_counters..sV44EBr1rrAs r,test_disk_io_countersz.TestModuleFunctionsLeaks.test_disk_io_counterss BCr1cB|jtjyr#)r>rmpidsrAs r, test_pidsz"TestModuleFunctionsLeaks.test_pidss V[[!r1c(|jdy)Nc.tjdSr>)rmnet_io_countersr2r1r,rbz?TestModuleFunctionsLeaks.test_net_io_counters..sV335Ar1rrAs r,test_net_io_countersz-TestModuleFunctionsLeaks.test_net_io_counterss ABr1rzneed root accessctjdt5|jddddy#1swYyxYw)Nrrc.tjdS)NrrJ)rmrr2r1r,rbz?TestModuleFunctionsLeaks.test_net_connections..s!7!7U!Cr1)rmrrr>rAs r,rz-TestModuleFunctionsLeaks.test_net_connectionss1 E*   LLC D  s =Acntrdn |j}|jtj|y)Ni@) tolerance)rrMr>rm net_if_addrs)r'rMs r,test_net_if_addrsz*TestModuleFunctionsLeaks.test_net_if_addrss%!(Idnn  V((I >r1cB|jtjyr#)r>rm net_if_statsrAs r,test_net_if_statsz*TestModuleFunctionsLeaks.test_net_if_statss V(()r1cB|jtjyr#)r>rmsensors_batteryrAs r,test_sensors_batteryz-TestModuleFunctionsLeaks.test_sensors_batterys V++,r1cB|jtjyr#)r>rmsensors_temperaturesrAs r,test_sensors_temperaturesz2TestModuleFunctionsLeaks.test_sensors_temperaturess V001r1cB|jtjyr#)r>rm sensors_fansrAs r,test_sensors_fansz*TestModuleFunctionsLeaks.test_sensors_fanss V(()r1cB|jtjyr#)r>rm boot_timerAs r,test_boot_timez'TestModuleFunctionsLeaks.test_boot_timerr1cB|jtjyr#)r>rmusersrAs r, test_usersz#TestModuleFunctionsLeaks.test_userss V\\"r1c(|jdy)Nc,tjdS)NF)rm _set_debugr2r1r,rbz9TestModuleFunctionsLeaks.test_set_debug..sV..u5r1rrAs r,test_set_debugz'TestModuleFunctionsLeaks.test_set_debugs 56r1cB|jtjyr#)r>rqwinservice_enumeraterAs r,test_win_service_iterz.TestModuleFunctionsLeaks.test_win_service_iters LL22 3r1cyr#r2rAs r,test_win_service_getz-TestModuleFunctionsLeaks.test_win_service_gets r1cttjj|j fdy)Nc.tjSr#)rqwinservice_query_configr@sr,rbzFTestModuleFunctionsLeaks.test_win_service_get_config..!=!=d!Cr1nextrmwin_service_iterr@r>r'r@s @r,test_win_service_get_configz4TestModuleFunctionsLeaks.test_win_service_get_config,//12779D LLC Dr1cttjj|j fdy)Nc.tjSr#)rqwinservice_query_statusrnsr,rbzFTestModuleFunctionsLeaks.test_win_service_get_status..ror1rprss @r,test_win_service_get_statusz4TestModuleFunctionsLeaks.test_win_service_get_statusrur1cttjj|j fdy)Nc.tjSr#)rqwinservice_query_descrrnsr,rbzKTestModuleFunctionsLeaks.test_win_service_get_description..s!>''<<'' [[)'2HI [[L(A&BJ& [[G N;(<( , [[&NO)P)J B- [[ 7bggnn%677DD  D ""  [[//HCIC [[2)"))+"2;MNEOE ? *  [[//H-I- [[44_M2N2 [[,,_E*F* ''#7 4  E E D%r1r)-rr.rsrmrrrrrr psutil.testsr r r r r rrrrrrrrrrrrrrrrr _psplatformrqr}rcr&r3r5rrrrrr2r1r,rs  )%$#(,)-#,)1''#*.&)"  6>>  8r:^r:j3!73lK7LNL8LVD~VDr1