U 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}d�� D ]}|d|f 7 }qt�||�}| �|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 mmode�(?P<%s>\S+)\s+z(svmon command returned unexpected outputi �size� availableZinuse�free� �Zdelta)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/python38/lib64/python3.8/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}d�� D ]}|d|f 7 }qt�||�}| �|d� d}t�� }| j|jt |� d��|d� | j|jt |� d ��|d� | j|jt |� d ��|d� | j|j t |� d��|d� d S )N�/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 syscr z)mpstat command returned unexpected outputi� Zcsr 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_statsJ s>