Your IP : 52.14.49.59
3
��JZm � @ sx d Z ddlZddlmZ ddlmZ ddlmZ ddlmZ ddlZeje d�G dd � d ej ��Z
ed
krtee� dS )zAIX specific tests.� N)�AIX)�run_test_module_by_name)�sh)�unittestzAIX onlyc @ s4 e Zd Zdd� Zdd� Zdd� Zdd� Zd d
� ZdS )�AIXSpecificTestCasec C s� t d�}d}xdj� D ]}|d|f 7 }qW tj||�}| j|d� d}t|jd��| }t|jd��| }t|jd ��| }t|jd
��| } tj� }
d| | }| j |
j
|� | j|
j||d� | j|
j
||d� | j|
j| |d� d S )
Nz/usr/bin/svmon -O unit=KBz memory\s*z+size inuse free pin virtual available mmodez(?P<%s>\S+)\s+z(svmon command returned unexpected outputi �size� availableZinuse�free� )�delta)r �split�re�search�assertIsNotNone�int�group�psutilZvirtual_memory�assertEqual�total�assertAlmostEqual�usedr r )�self�out�
re_pattern�field�matchobjZKBr r r r �
psutil_resultZMEMORY_TOLERANCE� r � /usr/lib64/python3.6/test_aix.py�test_virtual_memory s* z'AIXSpecificTestCase.test_virtual_memoryc C sT t d�}tjd|�}| j|d� t|jd��}d}tj� }| jt|j | �|� d S )Nz/usr/sbin/lsps -az=(?P<space>\S+)\s+(?P<vol>\S+)\s+(?P<vg>\S+)\s+(?P<size>\d+)MBz'lsps command returned unexpected outputr i r
i )
r r
r r r r r Zswap_memoryr r )r r r Ztotal_mbZMBr r r r �test_swap_memory4 s z$AIXSpecificTestCase.test_swap_memoryc C s� t d�}d}xdj� D ]}|d|f 7 }qW tj||�}| j|d� d}tj� }| j|jt |j
d��|d� | j|jt |j
d ��|d� | j|jt |j
d
��|d� | j|j
t |j
d��|d� d S )Nz/usr/bin/mpstat -azALL\s*zfmin maj mpcs mpcr dev soft dec ph cs ics bound rq push S3pull S3grd S0rd S1rd S2rd S3rd S4rd S5rd syscz(?P<%s>\S+)\s+z)mpstat command returned unexpected outputi� Zcs)r ZsyscZdevZsoft)r r r
r r r Z cpu_statsr Zctx_switchesr r ZsyscallsZ
interruptsZsoft_interrupts)r r r r r ZCPU_STATS_TOLERANCEr r r r �test_cpu_statsI s2 z"AIXSpecificTestCase.test_cpu_statsc C s: t d�}ttjd|�jd��}tjdd�}| j||� d S )Nz/usr/bin/mpstat -az
lcpu=(\d+)� T)Zlogical)r r r
r r r � cpu_countr )r r Zmpstat_lcpuZpsutil_lcpur r r �test_cpu_count_logicalj s z*AIXSpecificTestCase.test_cpu_count_logicalc C s4 t d�}t|j� �}ttj� j� �}| j||� d S )Nz/etc/ifconfig -l)r �setr r Znet_if_addrs�keysZassertSetEqual)r r Zifconfig_namesZpsutil_namesr r r �test_net_if_addrs_namesp s z+AIXSpecificTestCase.test_net_if_addrs_namesN)�__name__�
__module__�__qualname__r r r! r$ r'