Current File : //usr/local/apps/python3/lib/python3.11/test/__pycache__/test_resource.cpython-311.opt-2.pyc
�

�Kev���ddlZddlZddlZddlmZddlmZddlmZddlZej	d��Z
Gd�dej��Ze
dkrej��dSdS)	�N)�support)�
import_helper)�	os_helper�resourcec�6�eZdZd�Zejejdkd��d���Zd�Z	d�Z
ejee
d��d��d	���Zejejdkd
��d���Zd�Zejejd
kd��d���Zd�Zejee
d��d��ejddd��d�����Zejee
d��d��ejddd��d�����ZdS)�ResourceTestc�8�|�ttj��|�ttjdd��|�ttj��|�ttjddd��dS�N�*)�assertRaises�	TypeErrorr�	getrlimit�	setrlimit��selfs �</usr/local/apps/python3/lib/python3.11/test/test_resource.py�	test_argszResourceTest.test_argssv�����)�X�%7�8�8�8����)�X�%7��R�@�@�@����)�X�%7�8�8�8����)�X�%7��R��D�D�D�D�D��vxworksz0setting RLIMIT_FSIZE is not supported on VxWorksc��	t�tj��\}}|�tj|��t�tj||f��dS#t$rYdSwxYw)N)rr�RLIMIT_FSIZE�assertEqual�
RLIM_INFINITYr�AttributeError)r�cur�maxs   r�test_fsize_ismaxzResourceTest.test_fsize_ismaxs���	B�!�+�+�H�,A�B�B�J�S�#�
���X�3�S�9�9�9����x�4�s�C�j�A�A�A�A�A���	�	�	��D�D�	���s�'A2�2
B�?Bc��	t�tj��\}}		t�tjd|f��d}n#t$rd}YnwxYwttjd��}	|�d��	|�d��|�	��td��D]*}tjd��|�	���+n#t$r|s�YnwxYw|r't�tj||f��|���n#|���wxYw	|r't�tj||f��t
jtj��dS#|r't�tj||f��t
jtj��wxYw#t $rYdSwxYw)	NiTF�wbsXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX�Y�g�������?)rrrr�
ValueError�openr�TESTFN�write�flush�range�time�sleep�OSError�close�unlinkr)rrr�	limit_set�f�is      r�test_fsize_enforcedz ResourceTest.test_fsize_enforced%s��,	3�!�+�+�H�,A�B�B�J�S�#� 
3�&��&�&�x�'<�t�S�k�J�J�J� $�I�I��!�&�&�&� %�I�I�I�&������)�4�0�0����G�G�K�(�(�(�
"�����
�
�
����	�	�	�"'�q���&�&�A� �J�r�N�N�N��G�G�I�I�I�I�&��#�"�"�"�(�"�!�"�"�"����!�N�!�*�*�8�+@�3��*�M�M�M��G�G�I�I�I�I��A�G�G�I�I�I�I����I��J��&�&�x�'<�s�C�j�I�I�I�� ��!1�2�2�2�2�2���J��&�&�x�'<�s�C�j�I�I�I�� ��!1�2�2�2�2�����U�	�	�	��D�D�	���sx�'G<�)A�F0�A$�!F0�#A$�$F0�E
�A#C<�;E
�<
D�	E
�D�,E
�8F0�
E#�#F0�0A	G9�<
H
�	H
c��ddz}	t�tj��\}}	t�tj||f��n#tt
f$rYnwxYw	t�tj||f��dS#tt
f$rYdSwxYw#t$rYdSwxYw)N�
�2)rrrr�
OverflowErrorr"r)r�too_bigrrs    r�test_fsize_toobigzResourceTest.test_fsize_toobigTs����b�&��	�!�+�+�H�,A�B�B�J�S�#�
��"�"�8�#8�7�C�.�I�I�I�I��!�:�.�
�
�
���
����
��"�"�8�#8�3��.�I�I�I�I�I��!�:�.�
�
�
����
������	�	�	��D�D�	���s4�'B0�'A�A+�*A+�/'B�B-�,B-�0
B>�=B>�	getrusagezneeds getrusagec�"�|�ttj��|�ttjdd��t�tj��}t�tj��}	t�tj��}n#ttf$rYnwxYw	t�tj	��}dS#ttf$rYdSwxYwr
)
rr
rr7�RUSAGE_SELF�RUSAGE_CHILDREN�RUSAGE_BOTHr"r�
RUSAGE_THREAD)r�	usageself�
usagechildren�	usageboth�usage_threads     r�test_getrusagezResourceTest.test_getrusagees������)�X�%7�8�8�8����)�X�%7��R�@�@�@��&�&�x�';�<�<�	� �*�*�8�+C�D�D�
�	� �*�*�8�+?�@�@�I�I���N�+�	�	�	��D�	����	�#�-�-�h�.D�E�E�L�L�L���N�+�	�	�	��D�D�	���s$�$B;�;C�C�$C9�9D�
Dz.setting RLIMIT_CPU is not supported on VxWorksc���	t�tj��}Gd�d��}t�tj|����dS#t$rYdSwxYw)Nc��eZdZd�Zd�ZdS)�9ResourceTest.test_setrusage_refcount.<locals>.BadSequencec��dS�N��rs r�__len__zAResourceTest.test_setrusage_refcount.<locals>.BadSequence.__len__s���1rc�j�|dvr)tttd������St�)N)r�i@B)�len�tupler'�
IndexError)r�keys  r�__getitem__zEResourceTest.test_setrusage_refcount.<locals>.BadSequence.__getitem__�s-���f�}�}�"�5��w���#8�#8�9�9�9�$�$rN��__name__�
__module__�__qualname__rIrPrHrr�BadSequencerD~s2���������%�%�%�%�%rrU)rr�
RLIMIT_CPUrr)r�limitsrUs   r�test_setrusage_refcountz$ResourceTest.test_setrusage_refcountvs���
	C��'�'��(;�<�<�F�
%�
%�
%�
%�
%�
%�
%�
%�
���x�2�K�K�M�M�B�B�B�B�B���	�	�	��D�D�	���s�$A"�"
A0�/A0c��t���}|�|t��|�|d��dS)Nr)r�getpagesize�assertIsInstance�int�assertGreaterEqual)r�pagesizes  r�
test_pagesizezResourceTest.test_pagesize�sE���'�'�)�)�����h��,�,�,�����!�,�,�,�,�,r�linuxztest requires Linuxc	���dD]d}tjt��5|�t	t
d|z��t��ddd��n#1swxYwY�edS)N)�MSGQUEUE�NICE�RTPRIO�RTTIME�
SIGPENDING�RLIMIT_��
contextlib�suppressrr[�getattrrr\�r�attrs  r�test_linux_constantsz!ResourceTest.test_linux_constants�s���J�	P�	P�D��$�^�4�4�
P�
P��%�%�g�h�	�D�8H�&I�&I�3�O�O�O�
P�
P�
P�
P�
P�
P�
P�
P�
P�
P�
P����
P�
P�
P�
P��	P�	P��2A�A 	�#A 	c	���dD]d}tjt��5|�t	t
d|z��t��ddd��n#1swxYwY�edS)N)�SWAP�SBSIZE�NPTSrgrhrls  r�test_freebsd_contantsz"ResourceTest.test_freebsd_contants�s���.�	P�	P�D��$�^�4�4�
P�
P��%�%�g�h�	�D�8H�&I�&I�3�O�O�O�
P�
P�
P�
P�
P�
P�
P�
P�
P�
P�
P����
P�
P�
P�
P��	P�	Pro�prlimitz
no prlimitrG��$c���|�ttj��|�ttjdtj��t�tj��}|�t�dtj��|��|�t�dtj|��|��dS)N���r)rr
rru�ProcessLookupError�	RLIMIT_ASrr)r�limits  r�test_prlimitzResourceTest.test_prlimit�s���	
���)�X�%5�6�6�6����,�h�.>��h�0�	2�	2�	2��"�"�8�#5�6�6������)�)�!�X�-?�@�@�%�H�H�H�����)�)�!�X�-?��G�G��	 �	 �	 �	 �	 rc����G�fd�d��}t�tj���|�t�dtj|�������dS)Nc� ��eZdZd�Z�fd�ZdS)�2ResourceTest.test_prlimit_refcount.<locals>.BadSeqc��dSrFrHrs rrIz:ResourceTest.test_prlimit_refcount.<locals>.BadSeq.__len__�s���qrc����|dz
S)NrKrH)rrOrWs  �rrPz>ResourceTest.test_prlimit_refcount.<locals>.BadSeq.__getitem__�s����c�{�Q��&rNrQ)rWs�r�BadSeqr��s=�������
�
�
�
'�
'�
'�
'�
'�
'�
'rr�r)rrr{rru)rr�rWs  @r�test_prlimit_refcountz"ResourceTest.test_prlimit_refcount�s����	'�	'�	'�	'�	'�	'�	'�	'�	'�	'��#�#�H�$6�7�7������)�)�!�X�-?�����J�J��	!�	!�	!�	!�	!rN)rRrSrTr�unittest�skipIf�sys�platformrr0r6�
skipUnless�hasattrrrArXr_rnrtr�requires_linux_versionr}r�rHrrrr
s�������E�E�E��X�_�S�\�Y�.�G�I�I�B�B�I�I�B�-3�-3�-3�^���"�X�����;�7�7�9J�K�K�
�
�L�K�
� �X�_�S�\�Y�.�E�G�G�C�C�G�G�C� -�-�-�
�X�����0�2G�H�H�P�P�I�H�P�
P�P�P�
�X�����9�5�5�|�D�D�#�W�#�A�q�"�-�-� � �.�-�E�D� ��X�����9�5�5�|�D�D�#�W�#�A�q�"�-�-�	!�	!�.�-�E�D�	!�	!�	!rr�__main__)rir�r��testr�test.supportrrr(�
import_moduler�TestCaserrR�mainrHrr�<module>r�s�������
�
�
�
�����������&�&�&�&�&�&�"�"�"�"�"�"�����&�=�&�z�2�2��b!�b!�b!�b!�b!�8�$�b!�b!�b!�J�z����H�M�O�O�O�O�O��r