gf~vdZddlZddlZddlZddlmZddlmZddlmZddlmZddlm Z ddlm Z dd lm Z dd lm Z dd lm Z dd lmZd ZdZdZeje dGddeZeje dGddeZedkrddlmZeedSdS)zmacOS specific tests.N)MACOS) HAS_BATTERY)PsutilTestCase)retry_on_failure)sh)spawn_testproc) terminate)TOLERANCE_DISK_USAGE)TOLERANCE_SYS_MEM)unittestct|}|d} t|S#t$r|cYSwxYw)zmExpects a sysctl command with an argument and parse the result returning only the value of interest. )rsplitint ValueError)cmdlineoutresults w/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib64/python3.11/site-packages/psutil/tests/test_osx.pysysctlrsU W++C YY[[^F6{{  s: A A cddlm}td}|dD]}||vrn t dt t jd|d|zS)z)Wrapper around 'vm_stat' cmdline utility.r) getpagesizevm_stat zline not foundz\d+) psutil._psutil_posixrrrrrresearchgroup)fieldrrlines rrr%s000000 Y--C $++ D== E )*** ry&&,,Q// 0 0;;== @@cvddi}|}d}|r|dds|dddkrA||dz }|dd}|r|dd3|dddkAt|}|}|D] \}}||vrn6 |dkr|d}|}nt d|z|ddi}t |ddD]\}}d|dzd zz||<t|||zS) N customary) BKMGTPEZYrr.kzcan't interpret %r )isdigitfloatstripitemsupperr enumerater) sSYMBOLSinitnumletternamessetprefixis r human2bytesr@3sxBG D C !A#  AacFcMM qt  abbE !A#  AacFcMM **C WWYYFmmoo:: d T>> E  S==;'D\\^^FF1D899 91gq\F$qrr(##&&1!a%2%q sVF^# $ $$r!z MACOS onlyc@eZdZedZedZdZdS) TestProcessc6tj|_dSN)rpidclss r setUpClasszTestProcess.setUpClassPs ""&r!c.t|jdSrD)r rErFs r tearDownClasszTestProcess.tearDownClassTs#'r!c 2td|jz}|dd}|dd}|dd}t j|j}||tj dtj |||tj dtj |dS) Nzps -o lstart -p %sSTARTEDr- z%H:%M:%Sz%Y) rrEreplacer3rpsutilProcess create_time assertEqualtimestrftime localtime)selfoutputstart_pshhmmssyear start_psutils rtest_process_create_timez$TestProcess.test_process_create_timeXs(48344>>)R006688$$R(~~c""2&~dh//;;==    M*dn\&B&B C C E E E   M$| < < = = ? ? ? ? ?r!N)__name__ __module__ __qualname__ classmethodrHrJr^r!rrBrBMsY''['[ ? ? ? ? ?r!rBcleZdZedZdZdZdZdZedZ edZ edZ ed Z ed Z ed Zd Zeje d dZdS)TestSystemAPIscd}tjdD]}tj|j}||j\}}}}||j|||j|||j|t||j |tdS)Nctd|z}|d}|d|d}|dd\}}}}|dkrd}t |dz}t |dz}t |dz}||||fS)Nz df -k "%s"rrnoner-i)rr3rpopr)pathrlinesr devtotalusedfrees rdfz%TestSystemAPIs.test_disks..dfos\D())//11CIIdOOE IIaLLL99Q<>>>>r!c@tj}||jdzdzt d||jdzdzt d||jdzdzt ddS)Nizsysctl hw.cpufrequencyzsysctl hw.cpufrequency_minzsysctl hw.cpufrequency_max)rQcpu_freqrTcurrentrminmax)rXfreqs r test_cpu_freqzTestSystemAPIs.test_cpu_freqs    L4 $ &/G(H(H J J J  HtOd "F+G$H$H J J J  HtOd "F+G$H$H J J J J Jr!c|td}||tjjdS)Nzsysctl hw.memsize)rrTrQvirtual_memoryrn)rXsysctl_hwphymems rtest_vmem_totalzTestSystemAPIs.test_vmem_totals8 !455 &*?*A*A*GHHHHHr!ctd}tjj}|||t dS)Nrprs)rrQrrpryr rX vmstat_val psutil_vals rtest_vmem_freezTestSystemAPIs.test_vmem_frees@V__ *,,1  z:=NOOOOOr!ctd}tjj}|||t dS)Nactivers)rrQrrryr rs rtest_vmem_activezTestSystemAPIs.test_vmem_activesBX&& *,,3  z:=NOOOOOr!ctd}tjj}|||t dS)Ninactivers)rrQrrryr rs rtest_vmem_inactivez!TestSystemAPIs.test_vmem_inactivesBZ(( *,,5  z:=NOOOOOr!ctd}tjj}|||t dS)Nwiredrs)rrQrrryr rs rtest_vmem_wiredzTestSystemAPIs.test_vmem_wiredsBW%% *,,2  z:=NOOOOOr!ctd}tjj}|||dS)NPageins)rrQ swap_memorysinrTrs rtest_swapmem_sinzTestSystemAPIs.test_swapmem_sins<Y'' '))-  Z00000r!ctd}tjj}|||dS)NPageout)rrQrsoutrTrs rtest_swapmem_soutz TestSystemAPIs.test_swapmem_souts<Y'' ')).  Z00000r!c btjD]\}} td|z}||jd|v|||jttj d|dy#t$rYwxYwdS)Nz ifconfig %sRUNNING)msgz mtu (\d+)r) rQ net_if_statsr4rrTisupmturrfindall RuntimeError)rXr<statsrs rtest_net_if_statsz TestSystemAPIs.test_net_if_statss!.006688 H HKD% H-..  Y#-=3 GGG  !$RZ c%B%B1%E!F!FHHHH       H HsB B,+B,z no batteryc|td}tjd|d}tjd|d}|dk}t j}||j|||jt|dS)Nz pmset -g battz(\d+)%rzNow drawing from '([^']+)'zAC Power) rrrrrQsensors_batteryrT power_pluggedpercentr)rXrr drawing_fromr psutil_results rtest_sensors_batteryz#TestSystemAPIs.test_sensors_batterys!!)Is++11!44y!=sCCII!LL $ 2 .00  4mDDD .G =====r!N)r_r`rarr|rrrrrrrrrrrr skipIfrrrcr!rrerefs ???8>>>???JJJIIIPPP PPP PPP PPP111 111" H H HX__l33>>43>>>r!re__main__) run_from_name)__doc__rrUrQr psutil.testsrrrrrr r r r rrr@rrBrer_psutil.tests.runnerr__file__rcr!rrs $$$$$$''''''))))))''''''""""""------******!!!!!!    A A A%%%4UL))?????.??*)?0UL))>>>>>^>>*)>D z111111M(r!