HEX
Server: LiteSpeed
System: Linux atali.colombiahosting.com.co 5.14.0-570.12.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Tue May 13 06:11:55 EDT 2025 x86_64
User: coopserp (1713)
PHP: 8.2.29
Disabled: dl,exec,passthru,proc_open,proc_close,shell_exec,memory_limit,system,popen,curl_multi_exec,show_source,symlink,link,leak,listen,diskfreespace,tmpfile,ignore_user_abord,highlight_file,source,show_source,fpaththru,virtual,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,posix_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setid,posix_times,posix_ttyname,posix_uname,proc_get_status,proc_nice,proc_terminate
Upload Files
File: //usr/local/lib64/python3.9/site-packages/psutil/tests/__pycache__/test_windows.cpython-39.pyc
a

��?h؄�@s�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddlm
Z
ddlmZddlmZddlmZddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm!Z!e
�r�e�s�e�"��:e�#d�ddl$Z$ddl%Z%ddl&Z&ddl'Z'Wd�n1�s�0Ye
�r�ddl(m)Z)ej*j+Z+ej,j-e
dd�ej,j-edd�ej,j-e�o�edd�Gdd�de����Z.dd�Z/e0fd d!�Z1Gd"d#�d#e.�Z2Gd$d%�d%e.�Z3Gd&d'�d'e.�Z4Gd(d)�d)e.�Z5Gd*d+�d+e.�Z6ej,j-e
dd�Gd,d-�d-e��Z7ej,j-e
dd�Gd.d/�d/e��Z8ej,j-e
dd�Gd0d1�d1e��Z9dS)2zWindows specific tests.�N)�WINDOWS)�FileNotFoundError)�super)�which)�APPVEYOR)�GITHUB_ACTIONS)�HAS_BATTERY)�IS_64BIT)�PY3)�PYPY)�TOLERANCE_DISK_USAGE)�TOLERANCE_SYS_MEM)�PsutilTestCase)�mock)�pytest)�retry_on_failure)�sh)�spawn_testproc)�	terminate�ignore)�convert_oserrorzWINDOWS only��reasonzpywin32 not available on PYPYzpywin32 broken on GITHUB + PY2c@seZdZdS)�WindowsTestCaseN)�__name__�
__module__�__qualname__�rr�E/usr/local/lib64/python3.9/site-packages/psutil/tests/test_windows.pyr;srcCs&td�st�d��dd|}t|�S)z�Currently not used, but available just in case. Usage:

    >>> powershell(
        "Get-CIMInstance Win32_PageFileUsage | Select AllocatedBaseSize")
    zpowershell.exezpowershell.exe not availablez?powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive z,-NoProfile -WindowStyle Hidden -Command "%s")rr�skipr)�cmd�cmdlinerrr�
powershellEs
��r"csjtd||f���}d�|��dd����}�durbd|vrXt�fdd�|��D��S�|�Sn|SdS)z�Currently not used, but available just in case. Usage:

    >>> wmic("Win32_OperatingSystem", "FreePhysicalMemory")
    2134124534
    zwmic path %s get %s��N�,csg|]}�|��qSrr��.0�x��	converterrr�
<listcomp>^�zwmic.<locals>.<listcomp>)r�strip�join�
splitlines�tuple�split)�path�whatr*�out�datarr)r�wmicTs
r6c@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)Nr8)�int�os�environ�psutil�	cpu_count)�selfZnum_cpusrrr�&test_cpu_count_vs_NUMBER_OF_PROCESSORSksz2TestCpuAPIs.test_cpu_count_vs_NUMBER_OF_PROCESSORScCs$t��d}t��}||ks J�dS)N�)�win32apiZ
GetSystemInfor<r=�r>�	sys_value�psutil_valuerrr�test_cpu_count_vs_GetSystemInfousz+TestCpuAPIs.test_cpu_count_vs_GetSystemInfocCs2t��}tdd�|��D��}t��|ks.J�dS)Ncss|]}|jVqdS�N)ZNumberOfLogicalProcessors�r'�procrrr�	<genexpr>~sz<TestCpuAPIs.test_cpu_count_logical_vs_wmi.<locals>.<genexpr>��wmi�WMI�sum�Win32_Processorr<r=)r>�wZprocsrrr�test_cpu_count_logical_vs_wmi|s
�z)TestCpuAPIs.test_cpu_count_logical_vs_wmicCs6t��}tdd�|��D��}tjdd�|ks2J�dS)Ncss|]}|jVqdSrF)Z
NumberOfCoresrGrrrrI�r,z:TestCpuAPIs.test_cpu_count_cores_vs_wmi.<locals>.<genexpr>F)�logicalrJ)r>rOZcoresrrr�test_cpu_count_cores_vs_wmi�sz'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�sz'TestCpuAPIs.test_cpu_count_vs_cpu_timescCs@t��}|��d}|jt��jks(J�|jt��jks<J�dS�Nr)	rKrLrNZCurrentClockSpeedr<Zcpu_freq�currentZ
MaxClockSpeed�max)r>rOrHrrr�
test_cpu_freq�szTestCpuAPIs.test_cpu_freqN)rrrr�mark�skipifr:r;r?rErPrRrVrZrrrrr7js�
r7c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zej	j
edd�e�d
d���Z
e�dd��Ze�dd��Zdd�Zdd�Zdd�Zdd�ZdS)�TestSystemAPIscCsRtd�}tjdd���}|D]0}d|�dd���vr6q||vr|�d|��qdS)Nz
ipconfig /allT)Zperniczpseudo-interface� �-z-%r nic wasn't found in 'ipconfig /all' output)rr<Znet_io_counters�keys�replace�lower�fail)r>r4ZnicsZnicrrr�test_nic_names�s�zTestSystemAPIs.test_nic_namescCs,t����d}t|j�t��jks(J�dSrW)rKrLZWin32_ComputerSystemr9ZTotalPhysicalMemoryr<�virtual_memory�total�r>rOrrr�test_total_phymem�sz TestSystemAPIs.test_total_phymemcCs4t����d}tt|j�t��j�t	ks0J�dSrW)
rKrL�Win32_PerfRawData_PerfOS_Memory�absr9ZAvailableBytesr<re�freer
rgrrr�test_free_phymem�s
��zTestSystemAPIs.test_free_phymemcCsht����d}t|j�t��jt��jks2J�t��jdkrdt��j	dksRJ�t��j
dksdJ�dSrW)rKrLrir9ZCommitLimitr<rerf�swap_memoryrk�usedrgrrr�test_total_swapmem�s��z!TestSystemAPIs.test_total_swapmemcCs|t��jdkrxt��jdd�d}t|j�dt|j�}t��j	dksLJ�t
t��j	|�dksfJ�t��j	dksxJ�dS)NrZ_Total)�Name�dr@)r<rmrfrKrLZ#Win32_PerfRawData_PerfOS_PagingFiler9ZPercentUsageZPercentUsage_Base�percentrj)r>rOZpercentSwaprrr�test_percent_swapmem�sz#TestSystemAPIs.test_percent_swapmemztest not relieable on appveyorrcCs:t����}tdd�|D��}tt���}||ks6J�dS)NcSsg|]
}|j�qSr�Z	ProcessIdr&rrrr+�r,z,TestSystemAPIs.test_pids.<locals>.<listcomp>)rKrL�
Win32_Process�setr<�pids)r>rOZwmi_pidsZpsutil_pidsrrr�	test_pids�szTestSystemAPIs.test_pidsc
Cs�tjdd�}t����}|D]�}|D]�}|j�dd�|jkr$|jsFqd|j	vrTq|j�
d�rdqzt�|j�}Wnty�YqYn0|j
t|j�ks�J�t|j�}|j|ks�J�t|j|�dkr�|�d|j|f��qq$|�d	t|���qdS)
NT��all�\r#�cdrom�A:i�zpsutil=%s, wmi=%szcan't find partition %s)r<�disk_partitionsrKrLZWin32_LogicalDiskZdeviceraZDeviceID�
mountpoint�opts�
startswith�
disk_usagerrfr9�SizeZ	FreeSpacerkrjrc�repr)r>Zps_partsZ	wmi_partsZps_partZwmi_part�usageZwmi_freerrr�
test_disks�s0

�zTestSystemAPIs.test_diskscCs�t��D]r}d|jvrqt�|j�}t�|j�}t|d|j�t	ksJJ�t|d|j
�t	ksdJ�|j|j
|jksJ�qdS)Nr|rr$)r<r~r�rAZGetDiskFreeSpaceExrr�rjrkrrfrn)r>ZdiskrCrDrrr�test_disk_usage�s
�zTestSystemAPIs.test_disk_usagecCs>dd�t���d�D�}dd�tjdd�D�}||ks:J�dS)NcSs"g|]}|r|�d�s|d�qS)r}r{)r�r&rrrr+s�z7TestSystemAPIs.test_disk_partitions.<locals>.<listcomp>z\cSsg|]}|j�d�s|j�qS)r})rr�r&rrrr+s�Try)rAZGetLogicalDriveStringsr1r<r~rBrrr�test_disk_partitionss�
�z#TestSystemAPIs.test_disk_partitionscCs\tt���}t����}t�}|D]}|�|j�|�|j�q"||@sXJd||f��dS)Nzno common entries in %s, %s)	rv�cextZnet_if_statsrKrLZWin32_NetworkAdapter�addrpZNetConnectionID)r>Zps_namesZwmi_adaptersZ	wmi_namesZwmi_adapterrrr�test_net_if_stats
s�z TestSystemAPIs.test_net_if_statscCs^t����}|dj�d�d}tj�|d�}tj�t�	��}t
||���}|dksZJ�dS)Nr�.�%Y%m%d%H%M%Sr@)rKrLZWin32_OperatingSystemZLastBootUpTimer1�datetime�strptime�
fromtimestampr<�	boot_timerj�
total_seconds)r>Zwmi_osZ
wmi_btime_strZwmi_btime_dtZ	psutil_dt�diffrrr�test_boot_times�zTestSystemAPIs.test_boot_timecCs�tjddd�� t��dks J�Wd�n1s40Ytjddd�� t��dks^J�Wd�n1sr0Ytjddd�� t��dks�J�Wd�n1s�0Ytjddd�� t��dks�J�Wd�n1s�0YdS)Nz psutil._pswindows.cext.boot_timer@�Zreturn_value��iM)r�patchr<r�rUrrr�test_boot_time_fluctuation#s...z)TestSystemAPIs.test_boot_time_fluctuationN)rrrrdrhrlrorsrr[r\rrrxr�r�r�r�r�r�rrrrr]�s 




r]c@sheZdZdd�Zejjedd�dd��Zejjedd�dd��Z	d	d
�Z
dd�Zd
d�Zdd�Z
dS)�TestSensorsBatterycCs2t��drt��dus.J�nt��dus.J�dS)NZSystemBatteriesPresent)rAZGetPwrCapabilitiesr<�sensors_batteryrUrrr�test_has_battery5sz#TestSensorsBattery.test_has_batteryz
no batteryrcCs:t��}|�d�d}t��}t|j|j�dks6J�dS)N�select * from Win32_Batteryrr$)rKrL�queryr<r�rjrrZEstimatedChargeRemaining�r>rOZbattery_wmiZbattery_psutilrrr�test_percent;s��zTestSensorsBattery.test_percentcCs6t��}|�d�d}t��}|j|jdkks2J�dS)Nr�r�)rKrLr�r<r�Z
power_pluggedZ
BatteryStatusr�rrr�test_power_pluggedEsz%TestSensorsBattery.test_power_pluggedcCsLtjddd��*}t��dus J�|js*J�Wd�n1s>0YdS)N�&psutil._pswindows.cext.sensors_battery)r�rrr�)rr�r<r��called�r>�mrrr�test_emulate_no_batteryNs�z*TestSensorsBattery.test_emulate_no_batterycCsPtjddd��.}t��jtjks$J�|js.J�Wd�n1sB0YdS)Nr�)r$rrrr��rr�r<r��secsleftZPOWER_TIME_UNLIMITEDr�r�rrr�test_emulate_power_connectedVs���z/TestSensorsBattery.test_emulate_power_connectedcCsPtjddd��.}t��jtjks$J�|js.J�Wd�n1sB0YdS)Nr�)r�rrr�r�r�rrr�test_emulate_power_charging`s���z.TestSensorsBattery.test_emulate_power_chargingcCsPtjddd��.}t��jtjks$J�|js.J�Wd�n1sB0YdS)Nr�)rrr���r�)rr�r<r�r�ZPOWER_TIME_UNKNOWNr�r�rrr�test_emulate_secs_left_unknownjs��z1TestSensorsBattery.test_emulate_secs_left_unknownN)rrrr�rr[r\rr�r�r�r�r�r�rrrrr�4s
	


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)$�TestProcesscCst�j|_dSrF�r�pid��clsrrr�
setUpClass{szTestProcess.setUpClasscCst|j�dSrF�rr�r�rrr�
tearDownClassszTestProcess.tearDownClasscCsBt�d�}t�tj��|��Wd�n1s40YdSrW)r<�Processr�raises�AccessDenied�kill�r>�prrr�
test_issue_24�s
zTestProcess.test_issue_24cCs�t�d�}|��dksJ�t|�|��|��dks:J�z|��dd�\}}Wn&tjyxt�	�ddvrt�Yn0|dks�J�dS)Nr��Systemgr�r$)Zvistazwin-7Zwin7r)
r<r��name�str�username�create_time�memory_infor��platform�uname)r>r��rssZ_vmsrrr�test_special_pid�s
zTestProcess.test_special_pidcCsFt�|j�}t�t��|�tj�Wd�n1s80YdSrF)	r<r�r�rr��
ValueError�send_signal�signal�SIGINTr�rrr�test_send_signal�szTestProcess.test_send_signalcCsbt�t���}|��}t�tjtj	t���}|��}||dksDJ�t�
|�|��|ks^J�dS)Nr$)r<r�r:�getpid�num_handlesrA�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�n1sf0Yt
�tj��|�tj�Wd�n1s�0YdSrF)
r<r�rr�r�r�ZCTRL_C_EVENTZCTRL_BREAK_EVENTr��waitrr��
NoSuchProcessr�rrr�test_ctrl_signals�s*zTestProcess.test_ctrl_signalscCs8t�tj�}|�d�r t�d��t���	�|ks4J�dS)N�$zrunning as service account)
rAZ
GetUserNameExr�ZNameSamCompatible�endswithrrr<r�r�)r>r�rrr�
test_username�s

zTestProcess.test_usernamecCsft�ddt�����}d�t�����}|ddkrD|dkrVnn|�	ddd�}||ksbJ�dS)Nz[ ]+r^r�"r#r�)
�re�subrAZGetCommandLiner-r.r<r�r!rarBrrr�test_cmdline�s
 zTestProcess.test_cmdlinecCsJt�tjtjt���}|�tj|�t	�
|�}t���
�}||ksFJ�dSrF)rAr�r�r�r�r:r��
addCleanupr��win32processZGetPriorityClassr<r��nice�r>r�rCrDrrr�	test_nice�s�
zTestProcess.test_nicecCs�t�tjtj|j�}|�tj|�t�	|�}t
�|j���}|d|j
ksNJ�|d|jks`J�|d|jksrJ�|d|jks�J�|d|jks�J�|d|jks�J�|d|jks�J�|d|jks�J�|j|jks�J�|j|jks�J�dS)	NZPeakWorkingSetSize�WorkingSetSizeZQuotaPeakPagedPoolUsageZQuotaPagedPoolUsageZQuotaPeakNonPagedPoolUsageZQuotaNonPagedPoolUsageZ
PagefileUsageZPeakPagefileUsage)rAr�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�
|�}||ksTJ�dSrF)rAr�r�r�r�r�r�r�r<r�rr�r�ZGetExitCodeProcess)r>r�r�rDrCrrr�	test_wait�s�
zTestProcess.test_waitcCs\dd�}t�tjtj|j�}|�tj|�|t�	|�d�}t
�|j���}||ksXJ�dS)Ncs�fdd�td�D�S)Ncsg|]}d|>�@r|�qS)r$r)r'�i�r(rrr+r,zGTestProcess.test_cpu_affinity.<locals>.from_bitmask.<locals>.<listcomp>�@)�ranger�rr�r�from_bitmasksz3TestProcess.test_cpu_affinity.<locals>.from_bitmaskr)
rAr�r�r�r�r�r�r�r�ZGetProcessAffinityMaskr<r�Zcpu_affinity)r>r�r�rCrDrrr�test_cpu_affinitys��zTestProcess.test_cpu_affinitycCs�t�tjtjt���}|�tj|�t	�
|�}t���
�}|j|dksLJ�|j|dks^J�|j|dkspJ�|j|dks�J�|j|dks�J�|j|dks�J�dS)NZReadOperationCountZWriteOperationCountZReadTransferCountZWriteTransferCountZOtherOperationCountZOtherTransferCount)rAr�r�r�r�r:r�r�r�r�ZGetProcessIoCountersr<r��io_countersZ
read_countZwrite_count�
read_bytes�write_bytes�other_countZother_bytesr�rrr�test_io_counterss�
zTestProcess.test_io_counterscCs�ddl}ddl}d}|jj�|d|j�}|�|jjj|�|j�	�}|jj�
||�|��|j}t
�|j���}||ks|J�dS)Nr�)�ctypesZctypes.wintypes�windllZkernel32r�r�r�r�ZwintypesZDWORDZGetProcessHandleCount�byref�valuer<r�r�)r>r�r�r�ZhndcntrCrDrrr�test_num_handles"s�

�zTestProcess.test_num_handlesc
Cs�t�}d|_tjd|d��vt�d��L}t��}t�tj��|�	�Wd�n1sZ0YWd�n1sx0YWd�n1s�0Y|j
dks�J�dS)Ni+z psutil._psplatform.cext.proc_cwd�Zside_effectz
time.sleepr@)�WindowsError�winerrorrr�r<r�rr�r��cwdZ
call_count)r>�excr�r�rrr�test_error_partial_copy4sbz#TestProcess.test_error_partial_copycCsTt��dd}tj�|�}t�tj��|��Wd�n1sF0YdS)Nr�i��)r<rw�_psplatformr�rr�r��exe)r>r�rHrrr�test_exe?szTestProcess.test_exeN)rrr�classmethodr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrrr�zs&

		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.cCst�j|_dSrFr�r�rrrr�KszTestProcessWMI.setUpClasscCst|j�dSrFr�r�rrrr�OszTestProcessWMI.tearDownClasscCs8t��j|jd�d}t�|j�}|��|jks4J�dS�Nrtr)rKrLrur�r<r�r�ZCaption�r>rOr�rrr�	test_nameSszTestProcessWMI.test_namez!unreliable path on GITHUB_ACTIONSrcCs@t��j|jd�d}t�|j�}|����|j��ks<J�dSr)	rKrLrur�r<r�rrbZExecutablePathr	rrrrYszTestProcessWMI.test_execCsFt��j|jd�d}t�|j�}d�|���|j�	dd�ksBJ�dS)Nrtrr^r�r#)
rKrLrur�r<r�r.r!ZCommandLinerar	rrrr�cszTestProcessWMI.test_cmdlinecCsPt��j|jd�d}t�|j�}|��\}}}d||f}|��|ksLJ�dS)Nrtrz%s\%s)rKrLrur�r<r�ZGetOwnerr�)r>rOr��domain�_r�rrrr�hs
zTestProcessWMI.test_usernamecCsBt��j|jd�d}t�|j�}|��j}|t|j	�ks>J�dSr)
rKrLrur�r<r�r�r�r9r�)r>rOr�r�rrr�test_memory_rssos
zTestProcessWMI.test_memory_rsscCs\t��j|jd�d}t�|j�}|��j}t|j	�}|||dfvrX|�
d||f��dS)Nrtrr�zwmi=%s, psutil=%s)rKrLrur�r<r�r�r�r9Z
PageFileUsagerc)r>rOr�r�Z	wmi_usagerrr�test_memory_vmsvs

zTestProcessWMI.test_memory_vmscCs\t��j|jd�d}t�|j�}t|j�d�d�}t	�
dt	�|����}||ksXJ�dS)Nrtrr�r�)
rKrLrur�r<r�r�ZCreationDater1�time�strftime�	localtimer�)r>rOr�Zwmic_createZ
psutil_createrrr�test_create_time�s�zTestProcessWMI.test_create_timeN)rrr�__doc__rr�r�r
rr[r\rrr�r�rr
rrrrrrrHs"

�


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.
    cCst�j|_dSrFr�r�rrrr��sz(TestDualProcessImplementation.setUpClasscCst|j�dSrFr�r�rrrr��sz+TestDualProcessImplementation.tearDownClasscCs�t�|j���}tjdttjd�d���}t�|j���}t	|�t	|�ksLJ�t
t	|��D]@}||dkslJ�||dks|J�t||||�dksXJ�qX|js�J�Wd�n1s�0YdS)Nz(psutil._psplatform.cext.proc_memory_info�msgr�ri)
r<r�r�r�rr��OSError�errno�EPERMrSr�rjr�)r>Zmem_1�funZmem_2r�rrrr��s
�z.TestDualProcessImplementation.test_memory_infocCslt�|j���}tjdttjd�d��2}t�|j���|ks@J�|j	sJJ�Wd�n1s^0YdS)N�"psutil._psplatform.cext.proc_timesrr�)
r<r�r�r�rr�rrrr�)r>�ctimerrrrr�s
�z.TestDualProcessImplementation.test_create_timecCs�t�|j���}tjdttjd�d��Z}t�|j���}|j	sBJ�t
|j|j�dksZJ�t
|j|j�dksrJ�Wd�n1s�0YdS)Nrrr�g{�G�z�?)
r<r�r�rTrr�rrrr�rj�user�system)r>Zcpu_times_1rZcpu_times_2rrr�test_cpu_times�s
�
z,TestDualProcessImplementation.test_cpu_timescCs�t�|j���}tjdttjd�d��X}t�|j���}t	t
|��D] }t||||�dksDJ�qD|jspJ�Wd�n1s�0YdS)Nz(psutil._psplatform.cext.proc_io_countersrr�r@)
r<r�r�r�rr�rrrr�rSrjr�)r>Z
io_counters_1rZ
io_counters_2r�rrrr��s
�z.TestDualProcessImplementation.test_io_counterscCslt�|j���}tjdttjd�d��2}t�|j���|ks@J�|j	sJJ�Wd�n1s^0YdS)Nz(psutil._psplatform.cext.proc_num_handlesrr�)
r<r�r�r�rr�rrrr�)r>r�rrrrr��s
�z.TestDualProcessImplementation.test_num_handlescCs�t��D]r}z tj|dd�}tj|dd�}Wn@tyl}z(t|�}t|tjtjf�sX�WYd}~qd}~00||ksJ�qdS)NT)Zuse_pebF)	r<rwr�Zproc_cmdlinerr�
isinstancer�r�)r>r��a�b�errrrrr��s�z*TestDualProcessImplementation.test_cmdlineN)
rrrrrr�r�r�rrr�r�r�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]H}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�filenamerH�outputrrrr�find_other_interpreter�s�z,RemoteProcessTestCase.find_other_interpreterr$zimport sys; sys.stdin.read()cs�t���|��}|dur$t�d��tr8tj|_||_	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)r�setUpr1rrr	�sys�
executableZpython64Zpython32r:r;�copyr�r�r�	test_argsr)r+�proc32�proc64)r>Zother_pythonr3��	__class__rrr5s&
�
��zRemoteProcessTestCase.setUpcs"t���|j��|j��dSrF)r�tearDownr:r-r;rUr<rrr>s

zRemoteProcessTestCase.tearDowncCs@t�|jj�}t|���dks"J�|��dd�|jks<J�dS�N�r$)r<r�r:r�rSr!r9r�rrr�test_cmdline_32!sz%RemoteProcessTestCase.test_cmdline_32cCs@t�|jj�}t|���dks"J�|��dd�|jks<J�dSr?)r<r�r;r�rSr!r9r�rrr�test_cmdline_64&sz%RemoteProcessTestCase.test_cmdline_64cCs&t�|jj�}|��t��ks"J�dSrF)r<r�r:r�rr:�getcwdr�rrr�test_cwd_32+sz!RemoteProcessTestCase.test_cwd_32cCs&t�|jj�}|��t��ks"J�dSrF)r<r�r;r�rr:rCr�rrr�test_cwd_64/sz!RemoteProcessTestCase.test_cwd_64cCs>t�|jj�}|��}d|vs"J�|dtt���ks:J�dS)Nr2)r<r�r:r�r;r�r:r�)r>r��errr�test_environ_323sz%RemoteProcessTestCase.test_environ_32cCs4t�|jj�}z|��Wntjy.Yn0dSrF)r<r�r;r�r;r�r�rrr�test_environ_649s
z%RemoteProcessTestCase.test_environ_64)rrrr�staticmethodr1r9r5r>rArBrDrErGrH�
__classcell__rrr<rr#�s
r#c@seZdZdd�Zdd�ZdS)�TestServicescCs`tgd��}tgd��}tgd��}t��D�],}|��}t|dt�sLJ�|d��s\J�t|dt�snJ�t|dt�s�J�|d|vs�J�|ddur�t�|d�t|d	t�s�J�t|dt�s�J�t|d
t�s�J�|d
|vs�J�|d|v�sJ�t|dt��sJ�|��}|du�r@t�|�}|�	��s@J�t�
|���}||ks,J�q,dS)N)�running�paused�start�pause�continue�stop�stopped)Z	automaticZmanual�disabled)rLrMZ
start_pendingZ
pause_pendingZcontinue_pendingZstop_pendingrRr��display_namer��statusr�ZbinpathZ
start_type�description)rvr<�win_service_iterZas_dictrr�r-r�r��
is_running�win_service_getr�)r>Zvalid_statusesZvalid_start_typesZservr5r�r��srrr�test_win_service_iterHs0		

z"TestServices.test_win_service_iterc	Cs�tjjj}tjjj}tt�����}t�	tj
��}t�|d�Wd�n1sT0Y|jj|dksrJ�t�|�}t
r�ddd|f}n|df}t|�}tjd|d��Dt�	tj
��|��Wd�n1s�0YWd�n1s�0Ytjd|d��Ft�	tj
��|��Wd�n1�s<0YWd�n1�s\0Yt
�rzddd|f}n|df}t|�}tjd|d��Ft�	tj��|��Wd�n1�s�0YWd�n1�s�0Ytjd|d��Ft�	tj��|��Wd�n1�s,0YWd�n1�sL0Y|��t|�v�slJ�|��t|�v�s�J�|��t|�v�s�J�|��t|�v�s�J�dS)Nz???rrz/psutil._psplatform.cext.winservice_query_statusr�z/psutil._psplatform.cext.winservice_query_config)r<rr��ERROR_SERVICE_DOES_NOT_EXIST�ERROR_ACCESS_DENIED�nextrWr�rr�r�rYr�r
r�rr�rUr�r�r�rTr�)r>r\r]r��cmZservicer%rrrr�test_win_service_gettsP�
,
�D�H�H�Hz!TestServices.test_win_service_getN)rrrr[r`rrrrrKFs,rK):rr�rr(r:r�r�r�r)r6r�warningsr<rZpsutil._compatrrrZpsutil.testsrrrr	r
rrr
rrrrrrr�catch_warnings�simplefilterrAr�r�rKZpsutil._pswindowsrrr�r[r\rr"r9r6r7r]r�r�rrr#rKrrrr�<module>s|

(�(#FOHW]