403Webshell
Server IP : 192.158.238.246  /  Your IP : 3.148.248.235
Web Server : LiteSpeed
System : Linux uniform.iwebfusion.net 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64
User : jenniferflocom ( 1321)
PHP Version : 8.1.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/alt/python37/lib64/python3.7/site-packages/psutil/tests/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/alt/python37/lib64/python3.7/site-packages/psutil/tests/__pycache__/test_bsd.cpython-37.pyc
B

�=�_�P�@s�dZddlZddlZddlZddlZddlZddlmZddlmZddlmZddlm	Z	ddl
mZddl
mZdd	l
m
Z
dd
l
mZddl
mZddl
mZdd
l
mZddl
mZddl
mZer�ddlmZe�Ze��dkr�ed�r�dndZndZdZdd�Zdd�Ze�ed�Gdd�de
��Ze�ed�Gdd�de
��Ze�ed�Gdd�de
��Ze�e	d�Gd d!�d!e
��Ze�ed"�Gd#d$�d$e
��Z e!d%k�r�dd&l"m#Z#e#e$�dS)'z$Tests specific to all BSD platforms.�N)�BSD)�FREEBSD)�NETBSD)�OPENBSD)�spawn_testproc)�HAS_BATTERY)�PsutilTestCase)�retry_on_failure)�sh)�TOLERANCE_SYS_MEM)�	terminate)�unittest)�which)�getpagesize�museTFcCshtd|�}tr(||�d�dd�}nts0trF||�d�dd�}yt|�Stk
rb|SXdS)zmExpects a sysctl command with an argument and parse the result
    returning only the value of interest.
    zsysctl z: �N�=�)r
r�findrr�int�
ValueError)�cmdline�result�r�H/opt/alt/python37/lib64/python3.7/site-packages/psutil/tests/test_bsd.py�sysctl-srcCs@td�}x&|�d�D]}|�|�rPqWtd��t|��d�S)z+Thin wrapper around 'muse' cmdline utility.r�
zline not foundr)r
�split�
startswithrr)�field�out�linerrrr<s
zBSD onlyc@s�eZdZdZedd��Zedd��Ze�e	d�dd��Z
d	d
�Ze�ed�d�d
d��Z
e�ed�d�dd��Zdd�ZdS)�BSDTestCasez)Generic tests common to all BSD variants.cCst�j|_dS)N)r�pid)�clsrrr�
setUpClassPszBSDTestCase.setUpClasscCst|j�dS)N)rr#)r$rrr�
tearDownClassTszBSDTestCase.tearDownClassz -o lstart doesn't work on NETBSDcCsPtd|j�}|�dd���}t�|j���}t�dt�	|��}|�
||�dS)Nzps -o lstart -p %sZSTARTED�z%a %b %e %H:%M:%S %Y)r
r#�replace�strip�psutil�ProcessZcreate_time�time�strftime�	localtime�assertEqual)�self�outputZstart_psZstart_psutilrrr�test_process_create_timeXsz$BSDTestCase.test_process_create_timecCs�dd�}x�tjdd�D]�}t�|j�}||j�\}}}}|�|j|�|�|j|�t|j|�dkrz|�	d|j|f�t|j
|�dkr|�	d|j
|f�qWdS)NcSs�td|���}|�d�}|�d�|�d�}|��dd�\}}}}|dkrRd}t|�d}t|�d}t|�d}||||fS)Nz
df -k "%s"rr�Znoner'i)r
r)r�popr)�pathr �linesr!�dev�total�used�freerrr�dfds


z"BSDTestCase.test_disks.<locals>.dfF)�alli�zpsutil=%s, df=%s)r*Zdisk_partitions�
disk_usage�
mountpointr/�devicer8�absr:Zfailr9)r0r;�part�usager7r8r9r:rrr�
test_disksas
zBSDTestCase.test_disksrzsysctl cmd not availablecCs td�}|�tjdd�|�dS)Nzhw.ncpuT)Zlogical)rr/r*�	cpu_count)r0�systrrr�test_cpu_count_logical|sz"BSDTestCase.test_cpu_count_logicalcCstd�}|�|t��j�dS)Nz
hw.physmem)rr/r*�virtual_memoryr8)r0�numrrr�test_virtual_memory_total�sz%BSDTestCase.test_virtual_memory_totalc	Cs�xzt����D]j\}}ytd|�}Wntk
r:YqX|j|jd|k|d�d|kr|�|jtt	�
d|�d��qWdS)Nzifconfig %s�RUNNING)�msg�mtuz	mtu (\d+)r)r*Znet_if_stats�itemsr
�RuntimeErrorr/�isuprLr�re�findall)r0�nameZstatsr rrr�test_net_if_stats�szBSDTestCase.test_net_if_statsN)�__name__�
__module__�__qualname__�__doc__�classmethodr%r&r
�skipIfrr2rCrrFrIrSrrrrr"Ls	r"zFREEBSD onlyc@sfeZdZedd��Zedd��Ze�dd��Zdd�Zd	d
�Z	dd�Z
e�d
d��Ze�dd��ZdS)�FreeBSDPsutilTestCasecCst�j|_dS)N)rr#)r$rrrr%�sz FreeBSDPsutilTestCase.setUpClasscCst|j�dS)N)rr#)r$rrrr&�sz#FreeBSDPsutilTestCase.tearDownClasscCs�td|j�}t�|j�jdd�}|�d�dd�}x||r�|��}|��}|dd�\}}}}	}
|��}|�d||f|j�|�t	|
�|j
�|j�d�s6|�|d	|j�q6WdS)
Nzprocstat -v %sF)Zgroupedrr�z%s-%s�[�
)
r
r#r*r+Zmemory_mapsrr4r/�addrrZrssr5r)r0r �mapsr6r!�fields�_�start�stopZperms�res�maprrr�test_memory_maps�sz&FreeBSDPsutilTestCase.test_memory_mapscCs<td|j�}|�t�|j���|�d�d��d�dS)Nzprocstat -b %srr���)r
r#r/r*r+Zexer)r0r rrr�test_exe�szFreeBSDPsutilTestCase.test_execCsLtd|j�}|�d�t�|j����d�|�d�d��dd���dS)Nzprocstat -c %s� rrr)r
r#r/�joinr*r+rr)r0r rrr�test_cmdline�sz"FreeBSDPsutilTestCase.test_cmdlinecCs�td|j�}|�d�d��dd�\}}}}}}t�|j�}|��}	|��}
|�|	jt	|��|�|	j
t	|��|�|	jt	|��|�|
jt	|��|�|
j
t	|��|�|
jt	|��dS)Nzprocstat -s %srrr�)r
r#rr*r+�uids�gidsr/�realr�	effective�saved)r0r ZeuidZruidZsuidZegidZrgidZsgid�prmrnrrr�test_uids_gids�s&z$FreeBSDPsutilTestCase.test_uids_gidscCs�g}td|j�}t�|j�}x�|�d�D]�}|����}d|krtt|��d�}|��j	}|�
||�|�d�q*d|kr*t|��d�}|��j}|�
||�|�d�q*Wt
|�dkr�td��dS)Nzprocstat -r %srz voluntary contextrgz involuntary contextrz)couldn't find lines match in procstat out)r
r#r*r+r�lowerr)rZnum_ctx_switches�	voluntaryr/�append�involuntary�lenrN)r0�testedr rrr!�pstat_value�psutil_valuerrr�test_ctx_switches�s"

z'FreeBSDPsutilTestCase.test_ctx_switchescCs�g}td|j�}t�|j�}x�|�d�D]�}|����}d|kr�td|��d�d�d�}|��j	}|�
||�|�d�q*d|kr*td|��d�d�d�}|��j}|�
||�|�d�q*Wt
|�dkr�td	��dS)
Nzprocstat -r %srz	user timez0.rg�.zsystem timerz)couldn't find lines match in procstat out)r
r#r*r+rrtr)�floatZ	cpu_times�userr/rv�systemrxrN)r0ryr rrr!rzr{rrr�test_cpu_times�s"

z$FreeBSDPsutilTestCase.test_cpu_timesN)
rTrUrVrXr%r&r	rfrhrkrsr|r�rrrrrZ�s
rZc@s�eZdZedd��Zdd�Ze�dd��Ze�dd��Ze�d	d
��Z	e�dd��Z
e�d
d��Ze�dd��Ze
�ed�dd��Ze
�ed�e�dd���Ze
�ed�e�dd���Ze
�ed�e�dd���Ze
�ed�e�dd���Ze
�ed�e�dd���Ze
�ed�e�dd���Zd d!�Zd"d#�Zd$d%�Ze�d&d'��Zd(d)�Zd*d+�Zd,d-�Zd.d/�Ze
�ed0�d1d2��Z e
�ed0�d3d4��Z!e
�ed5�d6d7��Z"d8d9�Z#d:S);�FreeBSDSystemTestCasecCsRtd���d}t�d|�}|s,td|��dd�|dd�D�\}}}|||fS)	Nzswapinfo -krgz\s+zCan't parse swapinfo: %scss|]}t|�dVqdS)iN)r)�.0rrrrr�	<genexpr>�sz7FreeBSDSystemTestCase.parse_swapinfo.<locals>.<genexpr>rr3)r
�
splitlinesrPrr)r1�partsr8r9r:rrr�parse_swapinfo�sz$FreeBSDSystemTestCase.parse_swapinfocCs�d}ytt|��}Wntk
r2|�d�YnX|�t��j|�d}t|�}t|��d�d�d�}t|��d�d�d�}|�t��j	|�|�t��j
|�dS)Nzdev.cpu.0.freqz#frequencies not supported by kernelzdev.cpu.0.freq_levelsr�/rg)rrrN�skipTestr/r*Zcpu_freq�currentr�max�min)r0�sensor�
sysctl_resultZmax_freqZmin_freqrrr�!test_cpu_frequency_against_sysctlsz7FreeBSDSystemTestCase.test_cpu_frequency_against_sysctlcCs&td�t}|jt��j|td�dS)Nzvm.stats.vm.v_active_count)�delta)r�PAGESIZE�assertAlmostEqualr*rG�activer)r0rErrr�test_vmem_activesz&FreeBSDSystemTestCase.test_vmem_activecCs&td�t}|jt��j|td�dS)Nzvm.stats.vm.v_inactive_count)r�)rr�r�r*rG�inactiver)r0rErrr�test_vmem_inactivesz(FreeBSDSystemTestCase.test_vmem_inactivecCs&td�t}|jt��j|td�dS)Nzvm.stats.vm.v_wire_count)r�)rr�r�r*rG�wiredr)r0rErrr�test_vmem_wired$sz%FreeBSDSystemTestCase.test_vmem_wiredcCs&td�t}|jt��j|td�dS)Nzvm.stats.vm.v_cache_count)r�)rr�r�r*rG�cachedr)r0rErrr�test_vmem_cached*sz&FreeBSDSystemTestCase.test_vmem_cachedcCs&td�t}|jt��j|td�dS)Nzvm.stats.vm.v_free_count)r�)rr�r�r*rGr:r)r0rErrr�test_vmem_free0sz$FreeBSDSystemTestCase.test_vmem_freecCs"td�}|jt��j|td�dS)Nzvfs.bufspace)r�)rr�r*rG�buffersr)r0rErrr�test_vmem_buffers6sz'FreeBSDSystemTestCase.test_vmem_bufferszmuse not installedcCstd�}|�t��j|�dS)NZTotal)rr/r*rGr8)r0rHrrr�test_muse_vmem_total>sz*FreeBSDSystemTestCase.test_muse_vmem_totalcCs"td�}|jt��j|td�dS)NZActive)r�)rr�r*rGr�r)r0rHrrr�test_muse_vmem_activeCsz+FreeBSDSystemTestCase.test_muse_vmem_activecCs"td�}|jt��j|td�dS)NZInactive)r�)rr�r*rGr�r)r0rHrrr�test_muse_vmem_inactiveJsz-FreeBSDSystemTestCase.test_muse_vmem_inactivecCs"td�}|jt��j|td�dS)NZWired)r�)rr�r*rGr�r)r0rHrrr�test_muse_vmem_wiredQsz*FreeBSDSystemTestCase.test_muse_vmem_wiredcCs"td�}|jt��j|td�dS)N�Cache)r�)rr�r*rGr�r)r0rHrrr�test_muse_vmem_cachedXsz+FreeBSDSystemTestCase.test_muse_vmem_cachedcCs"td�}|jt��j|td�dS)NZFree)r�)rr�r*rGr:r)r0rHrrr�test_muse_vmem_free_sz)FreeBSDSystemTestCase.test_muse_vmem_freecCs"td�}|jt��j|td�dS)NZBuffer)r�)rr�r*rGr�r)r0rHrrr�test_muse_vmem_buffersfsz,FreeBSDSystemTestCase.test_muse_vmem_bufferscCs|jt��jtd�dd�dS)Nzvm.stats.sys.v_swtchi�)r�)r�r*�	cpu_stats�ctx_switchesr)r0rrr�test_cpu_stats_ctx_switchesmsz1FreeBSDSystemTestCase.test_cpu_stats_ctx_switchescCs|jt��jtd�dd�dS)Nzvm.stats.sys.v_intri�)r�)r�r*r��
interruptsr)r0rrr�test_cpu_stats_interruptsqsz/FreeBSDSystemTestCase.test_cpu_stats_interruptscCs|jt��jtd�dd�dS)Nzvm.stats.sys.v_softi�)r�)r�r*r��soft_interruptsr)r0rrr�test_cpu_stats_soft_interruptsusz4FreeBSDSystemTestCase.test_cpu_stats_soft_interruptscCs|jt��jtd�dd�dS)Nzvm.stats.sys.v_syscalli@
)r�)r�r*r��syscallsr)r0rrr�test_cpu_stats_syscallsysz-FreeBSDSystemTestCase.test_cpu_stats_syscallscCs(|��\}}}|jt��j|td�dS)N)r�)r�r�r*�swap_memoryr:r)r0r8r9r:rrr�test_swapmem_free�sz'FreeBSDSystemTestCase.test_swapmem_freecCs(|��\}}}|jt��j|td�dS)N)r�)r�r�r*r�r9r)r0r8r9r:rrr�test_swapmem_used�sz'FreeBSDSystemTestCase.test_swapmem_usedcCs(|��\}}}|jt��j|td�dS)N)r�)r�r�r*r�r8r)r0r8r9r:rrr�test_swapmem_total�sz(FreeBSDSystemTestCase.test_swapmem_totalcCsLtd�}||�d�dd�}|d|�d��}t|�}|�|t���dS)Nzsysctl kern.boottimez sec = ��,)rrrr/r*�	boot_time)r0�sZbtimerrr�test_boot_time�s
z$FreeBSDSystemTestCase.test_boot_timez
no batterycCs�dd�}td�}tdd�|�d�D��}t��}t|d�dd	��}|d
}|�|j|�|dkrt|�|j	tj
�n|�||j	�|�dS)NcSs(t|d�\}}t|d�\}}d||fS)N�<z%d:%02d)�divmod)Zsecs�mr��hrrr�
secs2hours�sz>FreeBSDSystemTestCase.test_sensors_battery.<locals>.secs2hoursz
acpiconf -i 0cSs(g|] }|�d�d|�d�df�qS)�	rrg)r)r��xrrr�
<listcomp>�sz>FreeBSDSystemTestCase.test_sensors_battery.<locals>.<listcomp>rzRemaining capacity:�%r'zRemaining time:�unknown)r
�dictrr*�sensors_batteryrr(r/�percent�secsleft�POWER_TIME_UNLIMITED)r0r�r r`�metricsr�Zremaining_timerrr�test_sensors_battery�sz*FreeBSDSystemTestCase.test_sensors_batterycCsl|�t��jtd��|�t��jtd�dk�t��j}|dkrT|�td�d�n|�|td�d�dS)Nzhw.acpi.battery.lifezhw.acpi.aclinerrzhw.acpi.battery.timergr�)r/r*r�r�r�
power_pluggedr�)r0r�rrr�#test_sensors_battery_against_sysctl�s

z9FreeBSDSystemTestCase.test_sensors_battery_against_sysctlzhas batteryc	Cs@|�t��td�td�td�WdQRX|�t���dS)Nzhw.acpi.battery.lifezhw.acpi.battery.timezhw.acpi.acline)ZassertRaisesrNrZassertIsNoner*r�)r0rrr�test_sensors_battery_no_battery�s
z5FreeBSDSystemTestCase.test_sensors_battery_no_batteryc	Cs�t�d�}x�t|�D]�}d|}yttt|�dd���}Wntk
rZ|�d�YnX|jt�	�d|j
|dd�d|}ttt|�dd���}|�t�	�d|j|�qWdS)	NTzdev.cpu.%s.temperaturergz$temperatures not supported by kernelZcoretempr])r�zdev.cpu.%s.coretemp.tjmax)
r*rD�rangerr~rrNr�r�Zsensors_temperaturesr�r/�high)r0Znum_cpusZcpur�r�rrr�(test_sensors_temperatures_against_sysctl�s

z>FreeBSDSystemTestCase.test_sensors_temperatures_against_sysctlN)$rTrUrV�staticmethodr�r�r	r�r�r�r�r�r�r
rY�MUSE_AVAILABLEr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr�r�r�r�rrrrr��sB
	
r�zOPENBSD onlyc@seZdZdd�ZdS)�OpenBSDTestCasecCs6td�}tj�|d�}tj�t���}|�||�dS)Nz
kern.boottimez%a %b %d %H:%M:%S %Y)r�datetime�strptime�
fromtimestampr*r�r/)r0r�Zsys_btZ	psutil_btrrrr��szOpenBSDTestCase.test_boot_timeN)rTrUrVr�rrrrr��sr�zNETBSD onlyc@s`eZdZedd��Zdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dS)�NetBSDTestCasec	CsRtdd��2}x*|D]"}|�|�rt|��d�dSqWWdQRXtd|��dS)Nz
/proc/meminfo�rtriz
can't find %s)�openrrrr)Zlook_for�fr!rrr�
parse_meminfo�s


"zNetBSDTestCase.parse_meminfocCs|�t��j|�d��dS)Nz	MemTotal:)r/r*rGr8r�)r0rrr�test_vmem_total�szNetBSDTestCase.test_vmem_totalcCs |jt��j|�d�td�dS)NzMemFree:)r�)r�r*rGr:r�r)r0rrrr�szNetBSDTestCase.test_vmem_freecCs |jt��j|�d�td�dS)NzBuffers:)r�)r�r*rGr�r�r)r0rrrr�sz NetBSDTestCase.test_vmem_bufferscCs |jt��j|�d�td�dS)Nz
MemShared:)r�)r�r*rG�sharedr�r)r0rrr�test_vmem_sharedszNetBSDTestCase.test_vmem_sharedcCs |jt��j|�d�td�dS)Nz
SwapTotal:)r�)r�r*r�r8r�r)r0rrrr�sz!NetBSDTestCase.test_swapmem_totalcCs |jt��j|�d�td�dS)Nz	SwapFree:)r�)r�r*r�r:r�r)r0rrrr�sz NetBSDTestCase.test_swapmem_freecCs"t��}|�|j|j|j�dS)N)r*r�r/r9r8r:)r0�smemrrrr�sz NetBSDTestCase.test_swapmem_usedc	Csbtdd��8}x0|D] }|�d�rt|��d�}PqWtd��WdQRX|jt��j|dd�dS)Nz
/proc/stat�rbsintrrzcouldn't find linei�)r�)	r�rrrrr�r*r�r�)r0r�r!r�rrrr�s

z(NetBSDTestCase.test_cpu_stats_interruptsc	Csbtdd��8}x0|D] }|�d�rt|��d�}PqWtd��WdQRX|jt��j|dd�dS)Nz
/proc/statr�sctxtrzcouldn't find linei�)r�)	r�rrrrr�r*r�r�)r0r�r!r�rrrr�*s

z*NetBSDTestCase.test_cpu_stats_ctx_switchesN)rTrUrVr�r�r�r�r�r�r�r�r�r�r�rrrrr��sr��__main__)�
run_from_name)%rWr��osrPr,r*rrrrZpsutil.testsrrrr	r
rrr
rZpsutil._psutil_posixrr��getuidr�rrrYr"rZr�r�r�rTZpsutil.tests.runnerr��__file__rrrr�<module>
sPKYrB


Youez - 2016 - github.com/yon3zu
LinuXploit