[ Avaa Bypassed ]




Upload:

Command:

hmhc3928@18.190.253.57: ~ $


Cs[�%�@s�dZddlZddlZddlZddlZddlmZddlmZddlmZddlm	Z	ddlm
Z
ddlmZdd	lmZdd
lm
Z
ddlmZddlmZer�ejd
�ndZdd�Zdd�Zdd�Zejed�Gdd�dej��Zejed�Gdd�dej��Zejed�Gdd�dej��Zedkr�e
e�dS)zMACOS specific tests.�N)�MACOS)�create_zombie_proc)�get_test_subprocess)�HAS_BATTERY)�MEMORY_TOLERANCE)�
reap_children)�retry_before_failing)�run_test_module_by_name)�sh)�unittest�SC_PAGE_SIZEcCsGt|�}|j�d}yt|�SWntk
rB|SYnXdS)zmExpects a sysctl command with an argument and parse the result
    returning only the value of interest.
    �N)r
�split�int�
ValueError)�cmdline�out�result�r�/test_osx.py�sysctls
rcCsbtd�}x0|jd�D]}||krPqWtd��ttjd|�jd��tS)z)Wrapper around 'vm_stat' cmdline utility.�vm_stat�
zline not foundz\d+r)r
rrr�re�search�group�PAGESIZE)Zfieldr�linerrrr)src	
CsEddi}|}d}xT|r7|dd
�j�sM|dd
�dkrn||d7}|d
d�}qWt|�}|j�}x\|j�D]\}}||kr�Pq�W|dkr�|d}|j�}ntd|��|dd
i}x:t|d
d��D]"\}}d
|d
d>||<q
Wt|||�S)NZ	customary�B�K�M�G�T�P�E�Z�Y�rr
�.�kzcan't interpret %r�
)	rrr r!r"r#r$r%r&)�isdigit�float�strip�items�upperr�	enumerater)	�sZSYMBOLSZinit�numZletter�nameZsset�prefix�irrr�human2bytes5s&5
#r6z
MACOS onlyc@s@eZdZedd��Zedd��Zdd�ZdS)�TestProcesscCst�j|_dS)N)r�pid)�clsrrr�
setUpClassRszTestProcess.setUpClasscCst�dS)N)r)r9rrr�
tearDownClassVszTestProcess.tearDownClasscCs�td|j�}|jdd�j�}|jd�d	}|jd�d
}tj|j�j�}|j|t	j
dt	j|���|j|t	j
dt	j|���dS)Nzps -o lstart -p %sZSTARTEDr'� �r
z%H:%M:%Sz%Y������)r
r8�replacer-r�psutil�Process�create_time�assertEqual�time�strftime�	localtime)�self�outputZstart_psZhhmmssZyearZstart_psutilrrr�test_process_create_timeZsz$TestProcess.test_process_create_timeN)�__name__�
__module__�__qualname__�classmethodr:r;rJrrrrr7Osr7c@s�eZdZedd��Zedd��Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!S)"�TestZombieProcessAPIscCst�}tj|�|_dS)N)rrArB�p)r9Zzpidrrrr:ks	z TestZombieProcessAPIs.setUpClasscCstdd�dS)NZ	recursiveT)r)r9rrrr;psz#TestZombieProcessAPIs.tearDownClasscCsa|j|jj�tj�|jj�|jj�|jj�|jj�|jj	�dS)N)
rDrP�statusrAZ
STATUS_ZOMBIEZppidZuidsZgidsZterminalrC)rHrrr�test_pidtask_infots



z'TestZombieProcessAPIs.test_pidtask_infocCs|jtj|jj�dS)N)�assertRaisesrA�
ZombieProcessrPZexe)rHrrr�test_exe|szTestZombieProcessAPIs.test_execCs|jtj|jj�dS)N)rSrArTrPr)rHrrr�test_cmdlinesz"TestZombieProcessAPIs.test_cmdlinecCs|jtj|jj�dS)N)rSrArTrP�environ)rHrrr�test_environ�sz"TestZombieProcessAPIs.test_environcCs|jtj|jj�dS)N)rSrArTrP�cwd)rHrrr�test_cwd�szTestZombieProcessAPIs.test_cwdcCs|jtj|jj�dS)N)rSrArTrPZmemory_full_info)rHrrr�test_memory_full_info�sz+TestZombieProcessAPIs.test_memory_full_infocCs|jtj|jj�dS)N)rSrArTrPZ	cpu_times)rHrrr�test_cpu_times�sz$TestZombieProcessAPIs.test_cpu_timescCs|jtj|jj�dS)N)rSrArTrPZnum_ctx_switches)rHrrr�test_num_ctx_switches�sz+TestZombieProcessAPIs.test_num_ctx_switchescCs|jtj|jj�dS)N)rSrArTrPZnum_threads)rHrrr�test_num_threads�sz&TestZombieProcessAPIs.test_num_threadscCs|jtj|jj�dS)N)rSrArTrPZ
open_files)rHrrr�test_open_files�sz%TestZombieProcessAPIs.test_open_filescCs|jtj|jj�dS)N)rSrArTrPZconnections)rHrrr�test_connections�sz&TestZombieProcessAPIs.test_connectionscCs|jtj|jj�dS)N)rSrArTrPZnum_fds)rHrrr�test_num_fds�sz"TestZombieProcessAPIs.test_num_fdscCs&|jtjtjf|jj�dS)N)rSrArTZAccessDeniedrP�threads)rHrrr�test_threads�sz"TestZombieProcessAPIs.test_threadscCs|jtj|jj�dS)N)rSrArTrPZmemory_maps)rHrrr�test_memory_maps�sz&TestZombieProcessAPIs.test_memory_mapsN)rKrLrMrNr:r;rRrUrVrXrZr[r\r]r^r_r`rarcrdrrrrrOhs rOc@s
eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Ze�dd��Z	e�d
d��Z
e�dd��Ze�dd��Ze�dd��Z
e�dd��Ze�dd��Zdd�Zejed�dd��ZdS)�TestSystemAPIscCs�dd�}x�tjdd�D]�}tj|j�}||j�\}}}}|j|j|�|j|j|�t|j|�d	kr�|j	d|j|�t|j
|�dkr|j	d|j
|�qWdS)NcSs�td|�j�}|jd�}|jd�|jd�}|j�dd�\}}}}|dkrud}t|�d}t|�d}t|�d}||||fS)Nz
df -k "%s"rr�Znoner'i)r
r-r�popr)�pathr�linesr�dev�total�used�freerrr�df�s
"z%TestSystemAPIs.test_disks.<locals>.df�allFr*izpsutil=%s, df=%si(i�i(i�)rAZdisk_partitions�
disk_usageZ
mountpointrDZdevicerk�absrmZfailrl)rHrn�part�usagerjrkrlrmrrr�
test_disks�s
zTestSystemAPIs.test_diskscCs,td�}|j|tjdd��dS)Nzsysctl hw.logicalcpu�logicalT)rrDrA�	cpu_count)rHr2rrr�test_cpu_count_logical�sz%TestSystemAPIs.test_cpu_count_logicalcCs,td�}|j|tjdd��dS)Nzsysctl hw.physicalcpuruF)rrDrArv)rHr2rrr�test_cpu_count_physical�sz&TestSystemAPIs.test_cpu_count_physicalcCsstj�}|j|jddtd��|j|jddtd��|j|jddtd��dS)Ni�zsysctl hw.cpufrequencyzsysctl hw.cpufrequency_minzsysctl hw.cpufrequency_max)rAZcpu_freqrD�currentr�min�max)rHZfreqrrr�
test_cpu_freq�szTestSystemAPIs.test_cpu_freqcCs)td�}|j|tj�j�dS)Nzsysctl hw.memsize)rrDrA�virtual_memoryrk)rHZsysctl_hwphymemrrr�test_vmem_total�szTestSystemAPIs.test_vmem_totalcCs5td�}tj�j}|j||dt�dS)Nrm�delta)rrAr}rm�assertAlmostEqualr)rH�
vmstat_val�
psutil_valrrr�test_vmem_free�szTestSystemAPIs.test_vmem_freecCs?td�td�}tj�j}|j||dt�dS)N�inactivermr)rrAr}Z	availabler�r)rHr�r�rrr�test_vmem_available�sz"TestSystemAPIs.test_vmem_availablecCs5td�}tj�j}|j||dt�dS)N�activer)rrAr}r�r�r)rHr�r�rrr�test_vmem_active�szTestSystemAPIs.test_vmem_activecCs5td�}tj�j}|j||dt�dS)Nr�r)rrAr}r�r�r)rHr�r�rrr�test_vmem_inactive�sz!TestSystemAPIs.test_vmem_inactivecCs5td�}tj�j}|j||dt�dS)N�wiredr)rrAr}r�r�r)rHr�r�rrr�test_vmem_wired�szTestSystemAPIs.test_vmem_wiredcCs/td�}tj�j}|j||�dS)NZPageins)rrA�swap_memory�sinrD)rHr�r�rrr�test_swapmem_sin�szTestSystemAPIs.test_swapmem_sincCs/td�}tj�j}|j||�dS)NZPageout)rrAr�ZsoutrD)rHr�r�rrr�test_swapmem_soutsz TestSystemAPIs.test_swapmem_soutcCs�x�tj�j�D]}\}}ytd|�}Wntk
rGYqX|j|jd|kd|�|j|jtt	j
d|�d��qWdS)Nzifconfig %s�RUNNING�msgz	mtu (\d+)r)rAZnet_if_statsr.r
�RuntimeErrorrDZisupZmturr�findall)rHr3Zstatsrrrr�test_net_if_statss
z TestSystemAPIs.test_net_if_statsz
no batterycCs�td�}tjd|�jd�}tjd|�jd�}|dk}tj�}|j|j|�|j|jt	|��dS)Nz
pmset -g battz(\d+)%r
zNow drawing from '([^']+)'zAC Power)
r
rrrrAZsensors_batteryrD�
power_plugged�percentr)rHrr�Zdrawing_fromr�Z
psutil_resultrrr�test_sensors_battery#sz#TestSystemAPIs.test_sensors_batteryN)rKrLrMrtrwrxr|r~rr�r�r�r�r�r�r�r�r�skipIfrr�rrrrre�s
re�__main__)�__doc__�osrrErArZpsutil.testsrrrrrrr	r
r�sysconfrrrr6r�ZTestCaser7rOrerK�__file__rrrr�<module>s4<�

Filemanager

Name Type Size Permission Actions
__init__.cpython-35.opt-1.pyc File 31.72 KB 0644
__init__.cpython-35.pyc File 33.22 KB 0644
__main__.cpython-35.opt-1.pyc File 2.66 KB 0644
__main__.cpython-35.pyc File 2.66 KB 0644
test_aix.cpython-35.opt-1.pyc File 3.48 KB 0644
test_aix.cpython-35.pyc File 3.48 KB 0644
test_bsd.cpython-35.opt-1.pyc File 20.06 KB 0644
test_bsd.cpython-35.pyc File 20.06 KB 0644
test_connections.cpython-35.opt-1.pyc File 15.7 KB 0644
test_connections.cpython-35.pyc File 16.1 KB 0644
test_contracts.cpython-35.opt-1.pyc File 23.32 KB 0644
test_contracts.cpython-35.pyc File 24.36 KB 0644
test_linux.cpython-35.opt-1.pyc File 69.39 KB 0644
test_linux.cpython-35.pyc File 70.81 KB 0644
test_memory_leaks.cpython-35.opt-1.pyc File 22.99 KB 0644
test_memory_leaks.cpython-35.pyc File 22.99 KB 0644
test_misc.cpython-35.opt-1.pyc File 35.69 KB 0644
test_misc.cpython-35.pyc File 36.91 KB 0644
test_osx.cpython-35.opt-1.pyc File 11.44 KB 0644
test_osx.cpython-35.pyc File 11.44 KB 0644
test_posix.cpython-35.opt-1.pyc File 14.02 KB 0644
test_posix.cpython-35.pyc File 14.18 KB 0644
test_process.cpython-35.opt-1.pyc File 43.88 KB 0644
test_process.cpython-35.pyc File 44.94 KB 0644
test_sunos.cpython-35.opt-1.pyc File 1.53 KB 0644
test_sunos.cpython-35.pyc File 1.53 KB 0644
test_system.cpython-35.opt-1.pyc File 27.54 KB 0644
test_system.cpython-35.pyc File 29.27 KB 0644
test_unicode.cpython-35.opt-1.pyc File 11.7 KB 0644
test_unicode.cpython-35.pyc File 11.76 KB 0644
test_windows.cpython-35.opt-1.pyc File 31.05 KB 0644
test_windows.cpython-35.pyc File 31.31 KB 0644