U 1g@sjdZddlZddlZddlmZddlmZddlmZddlmZejj e ddGd d d eZ dS) zAIX specific tests.N)AIX)PsutilTestCase)pytest)shzAIX only)reasonc@s4eZdZddZddZddZddZd d Zd S) AIXSpecificTestCasec Cstd}d}dD]}|d|f7}qt||}|dk s@td}t|d|}t|d|}t|d|}t|d |} t} d ||} | j |kstt | j || kstt | j || kstt | j | | kstdS) Nz/usr/bin/svmon -O unit=KBz memory\s*z+size inuse free pin virtual available mmode(?P<%s>\S+)\s+isize availableZinusefree)rsplitresearchAssertionErrorintgrouppsutilZvirtual_memorytotalabsusedr r ) selfout re_patternfieldmatchobjZKBrr rr psutil_resultZTOLERANCE_SYS_MEMrE/opt/hc_python/lib64/python3.8/site-packages/psutil/tests/test_aix.pytest_virtual_memorys"    z'AIXSpecificTestCase.test_virtual_memorycCsTtd}td|}|dk s tt|d}d}t}t|j||ksPtdS)Nz/usr/sbin/lsps -az=(?P\S+)\s+(?P\S+)\s+(?P\S+)\s+(?P\d+)MBr i) rrrrrrrZ swap_memoryr)rrrZtotal_mbMBrrrrtest_swap_memory0s z$AIXSpecificTestCase.test_swap_memorycCstd}d}dD]}|d|f7}qt||}|dk s@td}t}t|jt | d|ksltt|j t | d|kstt|j t | d|kstt|j t | d |kstdS) 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 syscricsZsyscdevZsoft)rr rrrrZ cpu_statsrZ ctx_switchesrrZsyscallsZ interruptsZsoft_interrupts)rrrrrZCPU_STATS_TOLERANCErrrrtest_cpu_statsGs2   z"AIXSpecificTestCase.test_cpu_statscCs:td}ttd|d}tjdd}||ks6tdS)Nr"z lcpu=(\d+)T)Zlogical)rrrrrr cpu_countr)rrZ mpstat_lcpuZ psutil_lcpurrrtest_cpu_count_logicalis z*AIXSpecificTestCase.test_cpu_count_logicalcCs4td}t|}tt}||ks0tdS)Nz/etc/ifconfig -l)rsetr rZ net_if_addrskeysr)rrZifconfig_namesZ psutil_namesrrrtest_net_if_addrs_namesos z+AIXSpecificTestCase.test_net_if_addrs_namesN)__name__ __module__ __qualname__rr!r%r(r+rrrrrs "r) __doc__rrrZ psutil.testsrrrmarkZskipifrrrrr s