관리-도구
편집 파일: test_aix.cpython-37.pyc
B xe�_� � @ s� d Z ddlZddlmZ ddlmZ ddlmZ ddlmZ ddlZe�e d�G dd � d e��Z e d kr~ddlmZ ee � dS )zAIX specific tests.� N)�AIX)�PsutilTestCase)�sh)�unittestzAIX onlyc @ s4 e Zd Zdd� Zdd� Zdd� Zdd� Zd d � ZdS )�AIXSpecificTestCasec C s� t d�}d}xd�� D ]}|d|f 7 }qW t�||�}| �|d� d}t|�d��| }t|�d��| }t|�d ��| }t|�d ��| } t�� } d| | }| � | 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_resultZTOLERANCE_SYS_MEM� r �H/opt/alt/python37/lib64/python3.7/site-packages/psutil/tests/test_aix.py�test_virtual_memory s* z'AIXSpecificTestCase.test_virtual_memoryc C sT t d�}t�d|�}| �|d� t|�d��}d}t�� }| �t|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 r r r r r r Zswap_memoryr r )r r r Ztotal_mbZMBr r r r �test_swap_memory5 s z$AIXSpecificTestCase.test_swap_memoryc C s� t d�}d}xd�� D ]}|d|f 7 }qW t�||�}| �|d� d}t�� }| j|jt |� d��|d� | j|jt |� d ��|d� | j|jt |� d ��|d� | j|j t |� 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� �cs)r Zsysc�devZsoft)r r r r r r Z cpu_statsr �ctx_switchesr r �syscalls� interrupts�soft_interrupts)r r r r r ZCPU_STATS_TOLERANCEr r r r �test_cpu_statsJ s2 z"AIXSpecificTestCase.test_cpu_statsc C s: t d�}tt�d|��d��}tjdd�}| �||� 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_logicalk s z*AIXSpecificTestCase.test_cpu_count_logicalc C s4 t d�}t|�� �}tt�� �� �}| �||� d S )Nz/etc/ifconfig -l)r �setr r Znet_if_addrs�keysZassertSetEqual)r r Zifconfig_namesZpsutil_namesr r r �test_net_if_addrs_namesq s z+AIXSpecificTestCase.test_net_if_addrs_namesN)�__name__� __module__�__qualname__r r r'