관리-도구
편집 파일: test_posix.cpython-37.pyc
B �=�_'; � @ s� d Z ddlZddlZddlZddlZddlZddlZddlZddlmZ ddlm Z ddlm Z ddlmZ ddlmZ ddlm Z dd lmZ dd lmZ ddlmZ ddlmZ dd lmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ e �rBddlZddlZddlmZ d*dd�Z dd� Z!dd� Z"dd� Z#dd � Z$e�%e d!�G d"d#� d#e��Z&e�%e d!�G d$d%� d%e��Z'e�%e d!�G d&d'� d'e��Z(e)d(k�r�dd)l*m+Z+ e+e,� dS )+zPOSIX specific tests.� N)�AIX)�BSD)�LINUX)�MACOS)�OPENBSD)�POSIX)�SUNOS)� CI_TESTING)�spawn_testproc)�HAS_NET_IO_COUNTERS)�mock)�PsutilTestCase)� PYTHON_EXE)�retry_on_failure)�sh)�skip_on_access_denied)� terminate)�unittest)�which)�getpagesizec C s� dg}t r|�d� |dk r0|�dt|�g� nts8trD|�d� n |�d� trftd�}|�| | �} |�d| g� t|�}t r�|� � }n|� � d d� }g }x@|D ]8}|� � }yt|�}W n tk r� Y nX |�|� q�W |dkr�|S |d S dS )z| Wrapper for calling the ps command with a little bit of cross-platform support for a narrow range of features. �psz--no-headersNz-pz-AZax)�command�comm�startZstimez-o� r ) r �append�extend�strr r �set�getr � splitlines�strip�int� ValueError)�fmt�pid�cmdZfmt_map�outputZ all_output�line� r) �J/opt/alt/python37/lib64/python3.7/site-packages/psutil/tests/test_posix.pyr - s6 r c C s d}t rd}t|| ��� d S )Nr r r )r r �split)r% �fieldr) r) r* �ps_namei s r- c C s d}t strd}t|| �S )Nr �args)r r r )r% r, r) r) r* �ps_argsp s r/ c C s d}t rd}t|| �S )NZrssZrssize)r r )r% r, r) r) r* �ps_rssw s r0 c C s d}t rd}t|| �S )NZvszZvsize)r r )r% r, r) r) r* �ps_vsz~ s r1 z POSIX onlyc @ s� e Zd ZdZedd� �Zedd� �Zdd� Zdd � Zd d� Z dd � Z dd� Ze� e � dd� ��Ze� e � dd� ��Zdd� Zdd� Zdd� Zdd� Ze�ep�ed�dd� �Zdd � Zd!d"� Ze�ed#�e�ed$�d%d&� ��Zd'S )(�TestProcesszBCompare psutil results against 'ps' command line utility (mainly).c C s t tddgtjd�j| _d S )Nz-Ez-O)�stdin)r r � subprocess�PIPEr% )�clsr) r) r* � setUpClass� s zTestProcess.setUpClassc C s t | j� d S )N)r r% )r6 r) r) r* � tearDownClass� s zTestProcess.tearDownClassc C s, t d| j�}t�| j��� }| �||� d S )N�ppid)r r% �psutil�Processr9 �assertEqual)�selfZppid_psZppid_psutilr) r) r* � test_ppid� s zTestProcess.test_ppidc C s. t d| j�}t�| j��� j}| �||� d S )N�uid)r r% r: r; �uids�realr<