HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //opt/osm/venv/lib/python3.10/site-packages/psutil/tests/__pycache__/test_windows.cpython-310.pyc
o

=iu��@s�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
mZddlZddlmZddlmZddlmZddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddlmZddlmZddlmZer�es�e���e�d�ddl Z ddl!Z!ddl"Z"ddl#Z#Wd�n1s�wYer�ddl$m%Z%ej&j'Z'ej(j)edd�ej(j)edd�Gdd�de���Z*dd�Z+e,fdd�Z-Gdd�de*�Z.Gdd�de*�Z/Gd d!�d!e*�Z0Gd"d#�d#e*�Z1Gd$d%�d%e*�Z2ej(j)edd�Gd&d'�d'e��Z3ej(j)edd�Gd(d)�d)e��Z4ej(j)edd�Gd*d+�d+e��Z5dS),zWindows specific tests.�N)�mock)�WINDOWS)�GITHUB_ACTIONS)�HAS_BATTERY)�IS_64BIT)�PYPY)�TOLERANCE_DISK_USAGE)�TOLERANCE_SYS_MEM)�PsutilTestCase)�pytest)�retry_on_failure)�sh)�
spawn_subproc)�	terminate�ignore)�convert_oserrorzWINDOWS only��reasonzpywin32 not available on PYPYc@seZdZdS)�WindowsTestCaseN)�__name__�
__module__�__qualname__�rr�G/opt/osm/venv/lib/python3.10/site-packages/psutil/tests/test_windows.pyr5srcCs(t�d�s
t�d�Sd|�d�}t|�S)z�Currently not used, but available just in case. Usage:

    >>> powershell(
        "Get-CIMInstance Win32_PageFileUsage | Select AllocatedBaseSize")
    zpowershell.exezpowershell.exe not availablezhpowershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -WindowStyle Hidden -Command "�")�shutil�whichr�skipr
)�cmd�cmdlinerrr�
powershell;s

��r cshtd|�d|�����}d�|��dd����}�dur2d|vr.t�fdd�|��D��S�|�S|S)	z�Currently not used, but available just in case. Usage:

    >>> wmic("Win32_OperatingSystem", "FreePhysicalMemory")
    2134124534
    z
wmic path z get ��N�,c3s�|]}�|�VqdS�Nr��.0�x��	converterrr�	<genexpr>Ts�zwmic.<locals>.<genexpr>)r
�strip�join�
splitlines�tuple�split)�path�whatr)�out�datarr(r�wmicJsr4c@sReZdZejjdejvdd�dd��Zdd�Z	dd	�Z
d
d�Zdd
�Zdd�Z
dS)�TestCpuAPIs�NUMBER_OF_PROCESSORSz-NUMBER_OF_PROCESSORS env var is not availablercCs"ttjd�}|t��ksJ�dS)Nr6)�int�os�environ�psutil�	cpu_count)�selfZnum_cpusrrr�&test_cpu_count_vs_NUMBER_OF_PROCESSORSasz2TestCpuAPIs.test_cpu_count_vs_NUMBER_OF_PROCESSORScCs$t��d}t��}||ksJ�dS)N�)�win32apiZ
GetSystemInfor:r;�r<�	sys_value�psutil_valuerrr�test_cpu_count_vs_GetSystemInfoksz+TestCpuAPIs.test_cpu_count_vs_GetSystemInfocCs2t��}tdd�|��D��}t��|ksJ�dS)Ncs��|]}|jVqdSr$)ZNumberOfLogicalProcessors�r&�procrrrr*ts�
�z<TestCpuAPIs.test_cpu_count_logical_vs_wmi.<locals>.<genexpr>��wmi�WMI�sum�Win32_Processorr:r;)r<�wZprocsrrr�test_cpu_count_logical_vs_wmirs
�z)TestCpuAPIs.test_cpu_count_logical_vs_wmicCs6t��}tdd�|��D��}tjdd�|ksJ�dS)NcsrDr$)Z
NumberOfCoresrErrrr*{s�z:TestCpuAPIs.test_cpu_count_cores_vs_wmi.<locals>.<genexpr>F)ZlogicalrG)r<rLZcoresrrr�test_cpu_count_cores_vs_wmiysz'TestCpuAPIs.test_cpu_count_cores_vs_wmicCs t��ttjdd��ksJ�dS)NT)Zpercpu)r:r;�len�	cpu_times�r<rrr�test_cpu_count_vs_cpu_times~s z'TestCpuAPIs.test_cpu_count_vs_cpu_timescCs@t��}|��d}|jt��jksJ�|jt��jksJ�dS�Nr)	rHrIrKZCurrentClockSpeedr:Zcpu_freq�currentZ
MaxClockSpeed�max)r<rLrFrrr�
test_cpu_freq�szTestCpuAPIs.test_cpu_freqN)rrrr�mark�skipifr8r9r=rCrMrNrRrVrrrrr5`s�
r5c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Ze�dd��Z	e�d
d��Z
e�dd��Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�ZdS)�TestSystemAPIscCsXtd�}tjdd���}|D]}d|�dd���vrq||vr)t�|�d��SqdS)Nz
ipconfig /allT)Zperniczpseudo-interface� �-z+ nic wasn't found in 'ipconfig /all' output)r
r:Znet_io_counters�keys�replace�lowerr�fail)r<r2ZnicsZnicrrr�test_nic_names�s���zTestSystemAPIs.test_nic_namescCs,t����d}t|j�t��jksJ�dSrS)rHrIZWin32_ComputerSystemr7ZTotalPhysicalMemoryr:�virtual_memory�total�r<rLrrr�test_total_phymem�sz TestSystemAPIs.test_total_phymemcCs4t����d}tt|j�t��j�t	ksJ�dSrS)
rHrI�Win32_PerfRawData_PerfOS_Memory�absr7ZAvailableBytesr:ra�freer	rcrrr�test_free_phymem�s�zTestSystemAPIs.test_free_phymemcCslt����d}t|j�t��jt��jksJ�t��jdkr2t��j	dks)J�t��j
dks4J�dSdSrS)rHrIrer7ZCommitLimitr:rarb�swap_memoryrg�usedrcrrr�test_total_swapmem�s��z!TestSystemAPIs.test_total_swapmemcCs�t��jdkr<t��jdd�d}t|j�dt|j�}t��j	dks&J�t
t��j	|�dks3J�t��j	dks>J�dSdS)NrZ_Total)�Name�dr>)r:rirbrHrIZ#Win32_PerfRawData_PerfOS_PagingFiler7ZPercentUsageZPercentUsage_Base�percentrf)r<rLZpercentSwaprrr�test_percent_swapmem�s�z#TestSystemAPIs.test_percent_swapmemcCs6t����}dd�|D�}tt���}||ksJ�dS)NcSsh|]}|j�qSr�Z	ProcessIdr%rrr�	<setcomp>�sz+TestSystemAPIs.test_pids.<locals>.<setcomp>)rHrI�
Win32_Process�setr:�pids)r<rLZwmi_pidsZpsutil_pidsrrr�	test_pids�szTestSystemAPIs.test_pidsc
Cstjdd�}t����}|D]s}|D]d}|j�dd�|jkrv|js#n^d|j	vr*nW|j�
d�r2nOzt�|j�}Wn
tyDYn=w|j
t|j�ksOJ�t|j�}|j|ks[J�t|j|�dkrtt�d|j�d	|���Snqt�d
|���SqdS)NT��all�\r!�cdrom�A:i�zpsutil=z, wmi=zcan't find partition )r:�disk_partitionsrHrIZWin32_LogicalDiskZdevicer]ZDeviceID�
mountpoint�opts�
startswith�
disk_usage�FileNotFoundErrorrbr7�SizeZ	FreeSpacergrfrr_)r<Zps_partsZ	wmi_partsZps_partZwmi_part�usageZwmi_freerrr�
test_disks�s8
�
����zTestSystemAPIs.test_diskscCs�t��D]9}d|jvrqt�|j�}t�|j�}t|d|j�t	ks%J�t|d|j
�t	ks2J�|j|j
|jks=J�qdS)Nryrr")r:r{r}r?ZGetDiskFreeSpaceExr|rrfrgrrbrj)r<ZdiskrArBrrr�test_disk_usage�s
�zTestSystemAPIs.test_disk_usagecCs>dd�t���d�D�}dd�tjdd�D�}||ksJ�dS)NcSs"g|]
}|r|�d�s|d�qS)rzrx)r~r%rrr�
<listcomp>�s���z7TestSystemAPIs.test_disk_partitions.<locals>.<listcomp>z\cSsg|]}|j�d�s|j�qS)rz)r|r~r%rrrr��s
��Trv)r?ZGetLogicalDriveStringsr/r:r{r@rrr�test_disk_partitions�s�
�z#TestSystemAPIs.test_disk_partitionscCs�d}d}d}d}d}||i}tjd|jd��"}tj�|�|ks!J�tj�|�|ks+J�|js0J�Wd�dS1s;wYdS)NzC:\Windows\TempzC:z\Device\HarddiskVolume1z\??\C:\Windows\Tempz$\Device\HarddiskVolume1\Windows\Tempz%psutil._pswindows.cext.QueryDosDevice�Zside_effect)r�patch�getr:�
_pswindows�convert_dos_path�called)r<�winpathZdriveletterZ
devicepath�ntpath1�ntpath2Zdevices�mrrr�test_convert_dos_path_drives�"�z*TestSystemAPIs.test_convert_dos_path_drivecCsLd}d}d}tj�|�|ksJ�tj�|�|ksJ�tj�|�|ks$J�dS)Nz\\localhost\C$\Windows\Tempz!\??\UNC\localhost\C$\Windows\Tempz%\Device\Mup\localhost\C$\Windows\Temp)r:r�r�)r<r�r�r�rrr�test_convert_dos_path_uncsz(TestSystemAPIs.test_convert_dos_path_unccCs`tt���}t����}t�}|D]}|�|j�|�|j�q||@s.Jd|�d|����dS)Nzno common entries in z, )	rs�cextZnet_if_statsrHrIZWin32_NetworkAdapter�addrlZNetConnectionID)r<Zps_namesZwmi_adaptersZ	wmi_namesZwmi_adapterrrr�test_net_if_stats"s��z TestSystemAPIs.test_net_if_statscCsft����}|dj�d�d}tj�|d�}tj�t�	��}t
||���}|dks1J||f��dS)Nr�.�%Y%m%d%H%M%Sr>)rHrIZWin32_OperatingSystemZLastBootUpTimer/�datetime�strptime�
fromtimestampr:Z	boot_timerf�
total_seconds)r<Zwmi_osZ
wmi_btime_strZwmi_btime_dtZ	psutil_dt�diffrrr�test_boot_time-s�zTestSystemAPIs.test_boot_timecCs0tjj��}|d}tt��|�dksJ�dS)Ng@�@g�?)�ctypes�windll�kernel32ZGetTickCount64rfr�Zuptime)r<�msZsecsrrr�test_uptime7szTestSystemAPIs.test_uptimeN)rrrr`rdrhrkrorrur�r�r�r�r�r�r�r�rrrrrY�s$





rYc@sheZdZdd�Zejjedd�dd��Zejjedd�dd��Z	d	d
�Z
dd�Zd
d�Zdd�Z
dS)�TestSensorsBatterycCs4t��drt��dusJ�dSt��dusJ�dS)NZSystemBatteriesPresent)r?ZGetPwrCapabilitiesr:�sensors_batteryrQrrr�test_has_batteryEsz#TestSensorsBattery.test_has_batteryz
no batteryrcCs:t��}|�d�d}t��}t|j|j�dksJ�dS)N�select * from Win32_Batteryrr")rHrI�queryr:r�rfrnZEstimatedChargeRemaining�r<rLZbattery_wmiZbattery_psutilrrr�test_percentKs�zTestSensorsBattery.test_percentcCs6t��}|�d�d}t��}|j|jdkksJ�dS)Nr�r�)rHrIr�r:r�Z
power_pluggedZ
BatteryStatusr�rrr�test_power_pluggedUsz%TestSensorsBattery.test_power_pluggedcCsNtjddd��}t��dusJ�|jsJ�Wd�dS1s wYdS)N�&psutil._pswindows.cext.sensors_battery)r�rr��return_value)rr�r:r�r��r<r�rrr�test_emulate_no_battery^s�"�z*TestSensorsBattery.test_emulate_no_batterycC�Rtjddd��}t��jtjksJ�|jsJ�Wd�dS1s"wYdS)Nr�)r"rrrr��rr�r:r��secsleftZPOWER_TIME_UNLIMITEDr�r�rrr�test_emulate_power_connectedf���"�z/TestSensorsBattery.test_emulate_power_connectedcCr�)Nr�)r�rrr�r�r�rrr�test_emulate_power_chargingpr�z.TestSensorsBattery.test_emulate_power_chargingcCr�)Nr�)rrr���r�)rr�r:r�r�ZPOWER_TIME_UNKNOWNr�r�rrr�test_emulate_secs_left_unknownzs�"�z1TestSensorsBattery.test_emulate_secs_left_unknownN)rrrr�rrWrXrr�r�r�r�r�r�rrrrr�Ds
	


r�c@s�eZdZedd��Zedd��Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#S)$�TestProcesscC�t�j|_dSr$�r�pid��clsrrr�
setUpClass��zTestProcess.setUpClasscC�t|j�dSr$�rr�r�rrr�
tearDownClass�r�zTestProcess.tearDownClasscCsDt�d�}t�tj��
|��Wd�dS1swYdSrS)r:�Processr�raises�AccessDenied�kill�r<�prrr�
test_issue_24�s

"�zTestProcess.test_issue_24cCs�t�d�}|��dks
J�t|�|��|��dksJ�z|��dd�\}}Wntjy=t�	�ddvr:�YdSw|dksDJ�dS)N��Systemgr�r">ZvistaZwin7zwin-7r)
r:r��name�str�username�create_time�memory_infor��platform�uname)r<r��rssZ_vmsrrr�test_special_pid�s
��zTestProcess.test_special_pidcCsHt�|j�}t�t��|�tj�Wd�dS1swYdSr$)	r:r�r�rr��
ValueError�send_signal�signal�SIGINTr�rrr�test_send_signal�s"�zTestProcess.test_send_signalcCsbt�t���}|��}t�tjtj	t���}|��}||dks"J�t�
|�|��|ks/J�dS)Nr")r:r�r8�getpid�num_handlesr?�OpenProcess�win32con�PROCESS_QUERY_INFORMATION�FALSE�CloseHandle)r<r��before�handle�afterrrr�test_num_handles_increment�s�
z&TestProcess.test_num_handles_incrementcCs�t�|��j�}|�tj�|�tj�|��|�	�t
�tj��|�tj�Wd�n1s3wYt
�tj��|�tj�Wd�dS1sPwYdSr$)
r:r�rr�r�r�ZCTRL_C_EVENTZCTRL_BREAK_EVENTr��waitrr��
NoSuchProcessr�rrr�test_ctrl_signals�s�"�zTestProcess.test_ctrl_signalscCs8t�tj�}|�d�rt�d�St���	�|ksJ�dS)N�$zrunning as service account)
r?Z
GetUserNameExr�ZNameSamCompatible�endswithrrr:r�r�)r<r�rrr�
test_username�s

zTestProcess.test_usernamecCsPt�ddt�����}d�t�����}|�	dd�}|�	dd�}||ks&J�dS)Nz[ ]+rZrr!)
�re�subr?ZGetCommandLiner+r,r:r�rr]r@rrr�test_cmdline�s
zTestProcess.test_cmdlinecCsJt�tjtjt���}|�tj|�t	�
|�}t���
�}||ks#J�dSr$)r?r�r�r�r�r8r��
addCleanupr��win32processZGetPriorityClassr:r��nice�r<r�rArBrrr�	test_nice�s�
zTestProcess.test_nicecCs�t�tjtj|j�}|�tj|�t�	|�}t
�|j���}|d|j
ks'J�|d|jks0J�|d|jks9J�|d|jksBJ�|d|jksKJ�|d|jksTJ�|d|jks]J�|d|jksfJ�|j|jksnJ�|j|jksvJ�dS)	NZPeakWorkingSetSize�WorkingSetSizeZQuotaPeakPagedPoolUsageZQuotaPagedPoolUsageZQuotaPeakNonPagedPoolUsageZQuotaNonPagedPoolUsageZ
PagefileUsageZPeakPagefileUsage)r?r�r�r�r�r�r�r�r�ZGetProcessMemoryInfor:r�r�Z	peak_wsetZwsetZpeak_paged_poolZ
paged_poolZpeak_nonpaged_poolZ
nonpaged_poolZpagefileZ
peak_pagefiler��vmsr�rrr�test_memory_info�s(�
��zTestProcess.test_memory_infocCsXt�tjtj|j�}|�tj|�t�	|j�}|�
�|��}t�
|�}||ks*J�dSr$)r?r�r�r�r�r�r�r�r:r�rr�r�ZGetExitCodeProcess)r<r�r�rBrArrr�	test_waits�
zTestProcess.test_waitcCs\dd�}t�tjtj|j�}|�tj|�|t�	|�d�}t
�|j���}||ks,J�dS)Ncs�fdd�td�D�S)Ncsg|]
}d|>�@r|�qS)r"r)r&�i�r'rrr�szGTestProcess.test_cpu_affinity.<locals>.from_bitmask.<locals>.<listcomp>�@)�ranger�rr�r�from_bitmasksz3TestProcess.test_cpu_affinity.<locals>.from_bitmaskr)
r?r�r�r�r�r�r�r�r�ZGetProcessAffinityMaskr:r�Zcpu_affinity)r<r�r�rArBrrr�test_cpu_affinitys��zTestProcess.test_cpu_affinitycCs�t�tjtjt���}|�tj|�t	�
|�}t���
�}|j|dks&J�|j|dks/J�|j|dks8J�|j|dksAJ�|j|dksJJ�|j|dksSJ�dS)NZReadOperationCountZWriteOperationCountZReadTransferCountZWriteTransferCountZOtherOperationCountZOtherTransferCount)r?r�r�r�r�r8r�r�r�r�ZGetProcessIoCountersr:r��io_countersZ
read_countZwrite_count�
read_bytes�write_bytes�other_countZother_bytesr�rrr�test_io_counters!s�
zTestProcess.test_io_counterscCs�ddl}ddl}d}|jj�|d|j�}|�|jjj|�|j�	�}|jj�
||�|��|j}t
�|j���}||ks>J�dS)Nr�)r�Zctypes.wintypesr�r�r�r�r�r�ZwintypesZDWORDZGetProcessHandleCountZbyref�valuer:r�r�)r<r�r�r�ZhndcntrArBrrr�test_num_handles/s�

�zTestProcess.test_num_handlesc
Cs�t�}d|_tjd|d��;t�d��&}t��}t�tj��|�	�Wd�n1s-wYWd�n1s<wYWd�n1sKwY|j
dksWJ�dS)Ni+z psutil._psplatform.cext.proc_cwdr�z
time.sleepr>)�OSError�winerrorrr�r:r�rr�r��cwdZ
call_count)r<�excr�r�rrr�test_error_partial_copyAs
�����z#TestProcess.test_error_partial_copycCsVt��dd}tj�|�}t�tj��
|��Wd�dS1s$wYdS)Nr�i��)r:rt�_psplatformr�rr�r��exe)r<r�rFrrr�test_exeLs

"�zTestProcess.test_exeN)rrr�classmethodr�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrrrrr��s(

		r�c@s|eZdZdZedd��Zedd��Zdd�Zej	j
edd	�d
d��Zdd
�Z
dd�Ze�dd��Ze�dd��Zdd�ZdS)�TestProcessWMIz%Compare Process API results with WMI.cCr�r$r�r�rrrr�Xr�zTestProcessWMI.setUpClasscCr�r$r�r�rrrr�\r�zTestProcessWMI.tearDownClasscCs8t��j|jd�d}t�|j�}|��|jksJ�dS�Nrpr)rHrIrrr�r:r�r�ZCaption�r<rLr�rrr�	test_name`szTestProcessWMI.test_namez!unreliable path on GITHUB_ACTIONSrcCs@t��j|jd�d}t�|j�}|����|j��ksJ�dSr)	rHrIrrr�r:r�rr^ZExecutablePathrrrrrfszTestProcessWMI.test_execCsFt��j|jd�d}t�|j�}d�|���|j�	dd�ks!J�dS)NrprrZrr!)
rHrIrrr�r:r�r,rZCommandLiner]rrrrr�ps$zTestProcessWMI.test_cmdlinecCsRt��j|jd�d}t�|j�}|��\}}}|�d|��}|��|ks'J�dS)Nrprrx)rHrIrrr�r:r�ZGetOwnerr�)r<rLr��domain�_r�rrrr�us
zTestProcessWMI.test_usernamecCsBt��j|jd�d}t�|j�}|��j}|t|j	�ksJ�dSr)
rHrIrrr�r:r�r�r�r7r�)r<rLr�r�rrr�test_memory_rss|s
zTestProcessWMI.test_memory_rsscCs`t��j|jd�d}t�|j�}|��j}t|j	�}|||dhvr.t
�d|�d|���SdS)Nrprrzwmi=z	, psutil=)rHrIrrr�r:r�r�r�r7Z
PageFileUsagerr_)r<rLr�r�Z	wmi_usagerrr�test_memory_vms�s

�zTestProcessWMI.test_memory_vmscCs\t��j|jd�d}t�|j�}t|j�d�d�}t	�
dt	�|����}||ks,J�dS)Nrprr�r�)
rHrIrrr�r:r�r�ZCreationDater/�time�strftime�	localtimer�)r<rLr�Zwmic_createZ
psutil_createrrr�test_create_time�s�zTestProcessWMI.test_create_timeN)rrr�__doc__rr�r�rrrWrXrrr�r�rrrrrrrrrUs$

�


rc@sXeZdZdZedd��Zedd��Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�ZdS)�TestDualProcessImplementationawCertain APIs on Windows have 2 internal implementations, one
    based on documented Windows APIs, another one based
    NtQuerySystemInformation() which gets called as fallback in
    case the first fails because of limited permission error.
    Here we test that the two methods return the exact same value,
    see:
    https://github.com/giampaolo/psutil/issues/304.
    cCr�r$r�r�rrrr��r�z(TestDualProcessImplementation.setUpClasscCr�r$r�r�rrrr��r�z+TestDualProcessImplementation.tearDownClasscCs�t�|j���}tjdtd��G}t�|j���}t|�t|�ks"J�tt|��D] }||dks2J�||dks:J�t	||||�dksHJ�q(|j
sNJ�Wd�dS1sYwYdS)Nz(psutil._psplatform.cext.proc_memory_infor�ri)r:r�r�r�rr��PermissionErrorrOr�rfr�)r<Zmem_1�funZmem_2r�rrrr��s�"�z.TestDualProcessImplementation.test_memory_infocC�ft�|j���}tjdtd��}t�|j���|ksJ�|js!J�Wd�dS1s,wYdS)N�"psutil._psplatform.cext.proc_timesr�)r:r�r�r�rr�rr�)r<�ctimer rrrr���"�z.TestDualProcessImplementation.test_create_timecCs�t�|j���}tjdtd��.}t�|j���}|jsJ�t|j	|j	�dks)J�t|j
|j
�dks5J�Wd�dS1s@wYdS)Nr"r�g{�G�z�?)r:r�r�rPrr�rr�rf�user�system)r<Zcpu_times_1r Zcpu_times_2rrr�test_cpu_times�s�
"�z,TestDualProcessImplementation.test_cpu_timescCs�t�|j���}tjdtd��-}t�|j���}tt|��D]}t	||||�dks.J�q|j
s4J�Wd�dS1s?wYdS)Nz(psutil._psplatform.cext.proc_io_countersr�r>)r:r�r�rrr�rr�rOrfr�)r<Z
io_counters_1r Z
io_counters_2r�rrrr�s�"�z.TestDualProcessImplementation.test_io_counterscCr!)Nz(psutil._psplatform.cext.proc_num_handlesr�)r:r�r�r�rr�rr�)r<r�r rrrr�r$z.TestDualProcessImplementation.test_num_handlescCs�t��D]9}ztj|dd�}tj|dd�}Wn ty6}zt|�}t|tjtjf�s,�WYd}~qd}~ww||ks=J�qdS)NT)Zuse_pebF)	r:rtr�Zproc_cmdlinerr�
isinstancer�r�)r<r��a�b�errrrrr��s�����z*TestDualProcessImplementation.test_cmdlineN)
rrrrrr�r�r�rr'rrr�rrrrr�s	

		rcspeZdZdZedd��ZddgZ�fdd�Z�fdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Z�ZS)�RemoteProcessTestCasez�Certain functions require calling ReadProcessMemory.
    This trivially works when called on the current process.
    Check that this works on other processes, especially when they
    have a different bitness.
    cCs\d}t�d�D]$}tj|d|gtjtjd�}|��\}}|��|tt�kr+|SqdS)Nz6import sys; sys.stdout.write(str(sys.maxsize > 2**32))zC:\Python*\python.exe�-c)�args�stdout�stderr)	�glob�
subprocess�Popen�PIPE�STDOUT�communicater�r�r)�code�filenamerF�outputrrrr�find_other_interpreter�s���z,RemoteProcessTestCase.find_other_interpreterr-zimport sys; sys.stdin.read()cs�t���|��}|durt�d�Strtj|_||_	n||_tj|_	t
j��}t
t
���|d<|j|j	g|j|tjd�|_|j|jg|j|tjd�|_dS)Nz0could not find interpreter with opposite bitness�THINK_OF_A_NUMBER)�env�stdin)�super�setUpr:rrr�sys�
executableZpython64Zpython32r8r9�copyr�r�r�	test_argsr2r4�proc32�proc64)r<Zother_pythonr<��	__class__rrr?s&
�
��zRemoteProcessTestCase.setUpcs"t���|j��|j��dSr$)r>�tearDownrDr6rErQrFrrrH)s

zRemoteProcessTestCase.tearDowncC�@t�|jj�}t|���dksJ�|��dd�|jksJ�dS�N�r")r:r�rDr�rOrrCr�rrr�test_cmdline_32.�z%RemoteProcessTestCase.test_cmdline_32cCrIrJ)r:r�rEr�rOrrCr�rrr�test_cmdline_643rMz%RemoteProcessTestCase.test_cmdline_64cC�&t�|jj�}|��t��ksJ�dSr$)r:r�rDr�r
r8�getcwdr�rrr�test_cwd_328�z!RemoteProcessTestCase.test_cwd_32cCrOr$)r:r�rEr�r
r8rPr�rrr�test_cwd_64<rRz!RemoteProcessTestCase.test_cwd_64cCs>t�|jj�}|��}d|vsJ�|dtt���ksJ�dS)Nr;)r:r�rDr�r9r�r8r�)r<r��errr�test_environ_32@sz%RemoteProcessTestCase.test_environ_32cCs4t�|jj�}z|��WdStjyYdSwr$)r:r�rEr�r9r�r�rrr�test_environ_64Fs�z%RemoteProcessTestCase.test_environ_64)rrrr�staticmethodr:rCr?rHrLrNrQrSrUrV�
__classcell__rrrFrr,�s
r,c@seZdZdd�Zdd�ZdS)�TestServicescCsXhd�}hd�}hd�}t��D]�}|��dkrq|��}t|dt�s&J�|d��s.J�t|dt�s7J�t|dt�s@J�|d|vsHJ�|d	durUt�|d	�t|d
t�s^J�t|dt�sgJ�t|dt�spJ�|d|vsxJ�|d|vs�J�t|dt�s�J�|��}|dur�t�|�}|�	�s�J�t�
|���}||ks�J�qdS)
N>�stop�start�paused�pause�stopped�running�continue>Z	automaticZmanual�disabled>r\r^r_Z
pause_pendingZcontinue_pendingZstop_pendingZ
start_pendingZWaaSMedicSvcr��display_namer��statusr�ZbinpathZ
start_type�description)r:�win_service_iterr��as_dictr(r�r+r�r�Z
is_running�win_service_get)r<Zvalid_statusesZvalid_start_typesZservr3r�r��srrr�test_win_service_iterUs6		
�z"TestServices.test_win_service_iterc	Cs�tjjj}tjjj}tt�����}t�	tj
��}t�|d�Wd�n1s*wY|jj|dks9J�t�|�}t
ddd�}||_tjd|d��"t�	tj
��|��Wd�n1sdwYWd�n1sswYtjd|d��"t�	tj
��|��Wd�n1s�wYWd�n1s�wYt
ddd�}||_tjd|d��"t�	tj��|��Wd�n1s�wYWd�n1s�wYtjd|d��#t�	tj��|��Wd�n	1�swYWd�n	1�swY|��t|�v�s!J�|��t|�v�s,J�|��t|�v�s7J�|��t|�v�sBJ�dS)Nz???r�msgz/psutil._psplatform.cext.winservice_query_statusr�z/psutil._psplatform.cext.winservice_query_config)r:r
r��ERROR_SERVICE_DOES_NOT_EXIST�ERROR_ACCESS_DENIED�nextrer�rr�r�rgrrr	rr�rcr�r�r�rb�repr)r<rkrlr��cmZservicerrrr�test_win_service_get�sb�
�
�
����
����
����
���z!TestServices.test_win_service_getN)rrrrirprrrrrYSs1rY)6rr�r�r1r8r�r�rr�r2r@r�warningsZunittestrr:rZpsutil.testsrrrrrr	r
rrr
rr�catch_warnings�simplefilterr?r�r�rHZpsutil._pswindowsrr
r�rWrXrr r7r4r5rYr�r�rrr,rYrrrr�<module>sr


�(=FLHW]