OwlCyberSecurity - MANAGER
Edit File: test_contracts.cpython-312.pyc
� ����X��g�.���������������������������d�Z�ddlZddlZddlZddlmZ�ddlmZ�ddlmZ�ddlmZ�ddlmZ�ddlm Z �dd lm Z �dd lmZ�ddlmZ�ddl mZ�dd l mZ�ddl mZ�ddl mZ�ddl mZ�ddl mZ�ddl mZ�ddl mZ�ddl mZ�ddl mZ�ddl mZ�ddl mZ��G�d��de�������Z�G�d��de�������Z�G�d��de�������Z�G�d��de�������Z�G�d ��d!e�������Zy)"z�Contracts tests. These tests mainly check API sanity in terms of returned types and APIs availability. Some of these are duplicates of tests test_system.py and test_process.py. �����N)�AIX)�FREEBSD)�LINUX)�MACOS)�NETBSD)�OPENBSD)�POSIX)�SUNOS)�WINDOWS)�GITHUB_ACTIONS)�HAS_CPU_FREQ)�HAS_NET_IO_COUNTERS)�HAS_SENSORS_FANS)�HAS_SENSORS_TEMPERATURES)�SKIP_SYSCONS)�PsutilTestCase)�create_sockets)�enum)� is_namedtuple)�kernel_version)�pytestc��������������������r�����e�Zd�Zd��Zd��Zd��Zd��Zej������������������j������������������e xr�ed��������d����������Zy) �TestAvailConstantsAPIsc������������������V�����t��������t��������d�������t��������xs�t��������xs�t��������k(��sJ��y�)N�PROCFS_PATH)�hasattr�psutilr���r ���r�����selfs��� �L/opt/hc_python/lib64/python3.12/site-packages/psutil/tests/test_contracts.py�test_PROCFS_PATHz'TestAvailConstantsAPIs.test_PROCFS_PATH0���s!�������v�}�-�%�2G�5�2G�C�H�H�H�����c������������������`����|�j�������������������}�|t��������t��������d�������t�����������������|t��������t��������d�������t�����������������|t��������t��������d�������t�����������������|t��������t��������d�������t�����������������|t��������t��������d�������t�����������������|t��������t��������d�������t����������������y�)N�ABOVE_NORMAL_PRIORITY_CLASS�BELOW_NORMAL_PRIORITY_CLASS�HIGH_PRIORITY_CLASS�IDLE_PRIORITY_CLASS�NORMAL_PRIORITY_CLASS�REALTIME_PRIORITY_CLASS��assertEqualr���r���r����r����aes��� r ����test_win_priorityz(TestAvailConstantsAPIs.test_win_priority3���sy������ � � �� �7�6�8�9�7�C� �7�6�8�9�7�C� �7�6�0�1�7�;� �7�6�0�1�7�;� �7�6�2�3�W�=� �7�6�4�5�w�?r"���c������������������������|�j�������������������}�|t��������t��������d�������t�����������������|t��������t��������d�������t�����������������|t��������t��������d�������t�����������������|t��������t��������d�������t����������������y�)N�IOPRIO_CLASS_NONE�IOPRIO_CLASS_RT�IOPRIO_CLASS_BE�IOPRIO_CLASS_IDLE)r+���r���r���r���r,���s��� r ����test_linux_ioprio_linuxz.TestAvailConstantsAPIs.test_linux_ioprio_linux<���sU������ � � �� �7�6�.�/��7� �7�6�,�-�u�5� �7�6�,�-�u�5� �7�6�.�/��7r"���c������������������������|�j�������������������}�|t��������t��������d�������t�����������������|t��������t��������d�������t�����������������|t��������t��������d�������t�����������������|t��������t��������d�������t����������������y�)N�IOPRIO_HIGH� IOPRIO_NORMAL� IOPRIO_LOW�IOPRIO_VERYLOWr*���r,���s��� r ����test_linux_ioprio_windowsz0TestAvailConstantsAPIs.test_linux_ioprio_windowsC���sR������ � � �� �7�6�=�)�7�3� �7�6�?�+�W�5� �7�6�<�(�'�2� �7�6�+�,�g�6r"����%unsupported on GITHUB_ACTIONS + LINUX��reasonc����������������������|�j�������������������}�|t��������t��������d�������t��������xs�t�����������������|t��������t��������d�������t��������xs�t�����������������|t��������t��������d�������t��������xs�t�����������������|t��������t��������d�������t��������xs�t�����������������|t��������t��������d�������t��������xs�t�����������������|t��������t��������d�������t��������xs�t�����������������|t��������t��������d�������t��������xs�t�����������������|t��������t��������d�������t��������xs�t�����������������|t��������t��������d �������t��������xs�t�����������������|t��������t��������d �������t��������xs�t�����������������|t��������t��������d�������t��������xs�t�����������������|t��������t��������d�������t����������������t ��������r�t ����������������d k\��r�|t��������t��������d�������t����������������t ����������������dk\��r�|t��������t��������d�������t����������������t ����������������dk\��r�|t��������t��������d�������t����������������t ����������������dk\��r�|t��������t��������d�������t����������������t ����������������d k\��r�|t��������t��������d�������t�����������������|t��������t��������d�������t�����������������|t��������t��������d�������t�����������������|t��������t��������d�������t����������������y�)N� RLIM_INFINITY� RLIMIT_AS�RLIMIT_CORE� RLIMIT_CPU�RLIMIT_DATA�RLIMIT_FSIZE�RLIMIT_MEMLOCK� RLIMIT_NOFILE�RLIMIT_NPROC� RLIMIT_RSS�RLIMIT_STACK�RLIMIT_LOCKS)�������������RLIMIT_MSGQUEUE)rK���rL��������RLIMIT_NICE� RLIMIT_RTPRIO)rK���rL�������� RLIMIT_RTTIME�RLIMIT_SIGPENDING�RLIMIT_SWAP� RLIMIT_SBSIZE�RLIMIT_NPTS)r+���r���r���r���r���r ���r���r,���s��� r ����test_rlimitz"TestAvailConstantsAPIs.test_rlimitJ���s������ �� � �� �7�6�?�+�U�-=�g�>� �7�6�;�'��)9�'�:� �7�6�=�)�5�+;�G�<� �7�6�<�(�%�*:�7�;� �7�6�=�)�5�+;�G�<� �7�6�>�*�E�,<�W�=� �7�6�+�,�e�.>�w�?� �7�6�?�+�U�-=�g�>� �7�6�>�*�E�,<�W�=� �7�6�<�(�%�*:�7�;� �7�6�>�*�E�,<�W�=� �7�6�>�*�E�2����9�,��7�6�#4�5�u�=���:�-��7�6�=�1�5�9���:�-��7�6�?�3�U�;���:�-��7�6�?�3�U�;���9�,��7�6�#6�7��?� �7�6�=�)�7�3� �7�6�?�+�W�5� �7�6�=�)�7�3r"���N) �__name__� __module__�__qualname__r!���r.���r4���r:���r����mark�skipifr���r���rX�����r"���r ���r���r���/���sK������I�@�8�7���[�[���� �5�6�����4� �4r"���r���c��������������������0�����e�Zd�Zd��Zd��Zd��Zd��Zd��Zd��Zy)�TestAvailSystemAPIsc������������������6�����t��������t��������d�������t��������k(��sJ��y�)N�win_service_iter�r���r���r���r���s��� r ����test_win_service_iterz)TestAvailSystemAPIs.test_win_service_itero���s�������v�1�2�g�=�=�=r"���c������������������6�����t��������t��������d�������t��������k(��sJ��y�)N�win_service_getrc���r���s��� r ����test_win_service_getz(TestAvailSystemAPIs.test_win_service_getr���s�������v�0�1�W�<�<�<r"���c������������������v�����t��������t��������d�������t��������xs�t��������xs�t��������xs�t ��������xs�t��������k(��sJ��y�)N�cpu_freq)r���r���r���r���r���r���r���r���s��� r ���� test_cpu_freqz!TestAvailSystemAPIs.test_cpu_frequ���s2�������v�z�*��;�U�;�g�;��;�G� �� �� r"���c������������������F�����t��������t��������d�������t��������xs�t��������k(��sJ��y�)N�sensors_temperatures)r���r���r���r���r���s��� r ����test_sensors_temperaturesz-TestAvailSystemAPIs.test_sensors_temperaturesz���s�������v�5�6�5�;K�G�L�L�Lr"���c������������������6�����t��������t��������d�������t��������k(��sJ��y�)N�sensors_fans)r���r���r���r���s��� r ����test_sensors_fansz%TestAvailSystemAPIs.test_sensors_fans}���s�������v�~�.�%�7�7�7r"���c������������������f�����t��������t��������d�������t��������xs�t��������xs�t��������xs�t ��������k(��sJ��y�)N�sensors_battery)r���r���r���r���r���r���r���s��� r ����test_batteryz TestAvailSystemAPIs.test_battery����s.�������v�0�1��0�W�0��0�5� �� �� r"���N) rY���rZ���r[���rd���rg���rj���rm���rp���rs���r^���r"���r ���r`���r`���n���s!������>�=� � M�8� r"���r`���c�������������������������e�Zd�Zd��Zd��Zd��Zd��Zd��Zej������������������j������������������exr�ed��������d����������Z d ��Zd ��Zd��Zd��Zd ��Zd��Zy)�TestAvailProcessAPIsc�����������������������t��������t��������j������������������d�������t��������xs6�t��������xs.�t ��������xs&�t��������xs�t��������xs�t��������xs�t��������xs�t��������k(��sJ��y�)N�environ)r���r����Processr���r���r���r���r ���r���r���r���r���s��� r ����test_environz!TestAvailProcessAPIs.test_environ����sd�������v�~�~�y�1��� �� �� ��� ��� � �� ��� ��� �� �� r"���c������������������J�����t��������t��������j������������������d�������t��������k(��sJ��y��N�uids�r���r���rx���r ���r���s��� r ���� test_uidszTestAvailProcessAPIs.test_uids������������v�~�~�v�.�%�7�7�7r"���c������������������J�����t��������t��������j������������������d�������t��������k(��sJ��y�r{���r}���r���s��� r ���� test_gidszTestAvailProcessAPIs.test_gids����r���r"���c������������������J�����t��������t��������j������������������d�������t��������k(��sJ��y�)N�terminalr}���r���s��� r ���� test_terminalz"TestAvailProcessAPIs.test_terminal����s�������v�~�~�z�2�e�;�;�;r"���c������������������Z�����t��������t��������j������������������d�������t��������xs�t��������k(��sJ��y�)N�ionice)r���r���rx���r���r���r���s��� r ����test_ionicez TestAvailProcessAPIs.test_ionice����s �������v�~�~�x�0�U�5E�g�F�F�Fr"���r;���r<���c������������������Z�����t��������t��������j������������������d�������t��������xs�t��������k(��sJ��y�)N�rlimit)r���r���rx���r���r���r���s��� r ���rX���z TestAvailProcessAPIs.test_rlimit����s"������ ��v�~�~�x�0�U�5E�g�F�F�Fr"���c������������������`�����t��������t��������j������������������d�������}|t��������xs�t���������k(��sJ��y�)N�io_counters)r���r���rx���r���r ����r����hasits��� r ����test_io_countersz%TestAvailProcessAPIs.test_io_counters����s'���������� �6���e�n�u�-�.�.�.r"���c������������������J�����t��������t��������j������������������d�������t��������k(��sJ��y�)N�num_fdsr}���r���s��� r ����test_num_fdsz!TestAvailProcessAPIs.test_num_fds����s�������v�~�~�y�1�U�:�:�:r"���c������������������J�����t��������t��������j������������������d�������t��������k(��sJ��y�)N�num_handles)r���r���rx���r���r���s��� r ����test_num_handlesz%TestAvailProcessAPIs.test_num_handles����s�������v�~�~�}�5��@�@�@r"���c������������������j�����t��������t��������j������������������d�������t��������xs�t��������xs�t ��������k(��sJ��y�)N�cpu_affinity)r���r���rx���r���r���r���r���s��� r ����test_cpu_affinityz&TestAvailProcessAPIs.test_cpu_affinity����s,�������v�~�~�~�6��'�W�'�� �� �� r"���c������������������j�����t��������t��������j������������������d�������t��������xs�t��������xs�t ��������k(��sJ��y�)N�cpu_num)r���r���rx���r���r���r ���r���s��� r ����test_cpu_numz!TestAvailProcessAPIs.test_cpu_num����s,�������v�~�~�y�1��%�W�%�� �� �� r"���c�����������������������t��������t��������j������������������d�������}|t��������xs�t��������xs�t ��������xs�t���������k(��sJ��y�)N�memory_maps)r���r���rx���r���r���r���r���r����s��� r ����test_memory_mapsz%TestAvailProcessAPIs.test_memory_maps����s2���������� �6���g�?��?�3�?�%�@�A�A�Ar"���N)rY���rZ���r[���ry���r~���r����r����r����r���r\���r]���r���r���rX���r����r����r����r����r����r����r^���r"���r ���ru���ru�������sq������ �8�8�<�G���[�[���� �5�6�����G� �G�/�;�A� � � Br"���ru���c��������������������:����e�Zd�ZdZed����������Zedfd�Zd��Zd��Z d��Z d��Zej������������������j������������������exr��ej"��������������������������d k(��d ��������ej������������������j������������������e�d��������d ������������������Zd��Zd��Zej������������������j������������������ed��������d����������Zd��Zd��Zej������������������j������������������e�d��������d����������Zej������������������j������������������e�d��������d����������Zej������������������j������������������e�d��������d����������Zd��Z d��Z!y)�TestSystemAPITypeszhCheck the return types of system related APIs. https://github.com/giampaolo/psutil/issues/1039. c������������������6�����t��������j��������������������������|�_��������y��N)r���rx����proc)�clss��� r ���� setUpClasszTestSystemAPITypes.setUpClass����s�������>�>�#��r"���Tc������������������\�����t��������|�������sJ��|D�]��}t��������||�������sJ��|s�|dk\��r�J���y�)Nr���)r���� isinstance)r����nt�type_�gezero�ns��� r ����assert_ntuple_of_numsz(TestSystemAPITypes.assert_ntuple_of_nums����s8�������R� � � ��A��a��'�'�'���A�v� �v��r"���c�����������������������|�j������������������t��������j����������������������������������t��������j������������������d��������D�]��}|�j������������������|����������y�)NT)�percpu)r����r���� cpu_times)r���r����s��� r ����test_cpu_timesz!TestSystemAPITypes.test_cpu_times����s<�������"�"�6�#3�#3�#5�6��"�"�$�/�B��&�&�r�*��0r"���c�����������������������t��������t��������j������������������d���������t���������������sJ��t��������t��������j������������������d��������t���������������sJ��y�)N��intervalg�h㈵��>)r����r����cpu_percent�floatr���s��� r ����test_cpu_percentz#TestSystemAPITypes.test_cpu_percent����s8�������&�,�,�d�;�U�C�C�C��&�,�,�g�>��F�F�Fr"���c�����������������������|�j������������������t��������j������������������d�����������������|�j������������������t��������j������������������d����������������y�)Nr����g-C��6?)r����r����cpu_times_percentr���s��� r ����test_cpu_times_percentz)TestSystemAPITypes.test_cpu_times_percent����s4�������"�"�6�#;�#;�T�#J�K��"�"�6�#;�#;�V�#L�Mr"���c������������������L�����t��������t��������j��������������������������t���������������sJ��y�r����)r����r���� cpu_count�intr���s��� r ����test_cpu_countz!TestSystemAPITypes.test_cpu_count����s�������&�*�*�,�c�2�2�2r"����arm64zskipped due to #1892r<���z not supportedc�����������������������t��������j���������������������������t��������j������������������d��������|�j ������������������t��������j��������������������������t ��������t��������f���������y�)Nzcpu_freq() returns None�r����)r���ri���r����skipr����r����r����r���s��� r ���rj���z TestSystemAPITypes.test_cpu_freq����s?������ ��?�?��$��+�+�7�8�8��"�"�6�?�?�#4�U�C�L�"�Ir"���c�����������������������t��������j������������������d��������j��������������������������D�].��\��}}t��������|t���������������sJ��|�j������������������|t������������������0�y�)NT)�perdiskr����)r����disk_io_counters�itemsr�����strr����r����)r����k�vs��� r ����test_disk_io_countersz(TestSystemAPITypes.test_disk_io_counters����sH�������+�+�D�9�?�?�A�D�A�q��a��%�%�%��&�&�q��&�4��Br"���c����������������������t��������j��������������������������D�]r��}t��������|j������������������t���������������sJ��t��������|j ������������������t���������������sJ��t��������|j������������������t���������������sJ��t��������|j������������������t���������������r�rJ���y�r����)r����disk_partitionsr�����devicer����� mountpoint�fstype�opts)r����disks��� r ����test_disk_partitionsz'TestSystemAPITypes.test_disk_partitions����se�������*�*�,�D��d�k�k�3�/�/�/��d�o�o�s�3�3�3��d�k�k�3�/�/�/��d�i�i��-�-�-� �-r"���z requires rootc������������������������t����������������5��t��������j������������������d�������}t��������|�������t��������t ��������|��������������k(��sJ��|D�]��}t��������|�������r�J��� �d�d�d���������y�#�1�sw�Y���y�xY�w)N�all)r���r����net_connections�len�setr���)r����ret�conns��� r ����test_net_connectionsz'TestSystemAPITypes.test_net_connections����sV������ � ��(�(��/�C��s�8�s�3�s�8�}�,�,�,���$�T�*�*�*����� � �s����AA!�A!�!A*c����������� �����������t��������j��������������������������j��������������������������D�]���\��}}t��������|t���������������sJ��|D�]���}t��������|j ������������������t��������j�������������������������sJ��t��������|j������������������t���������������sJ��t��������|j������������������t��������t��������d��������f�������sJ��t��������|j������������������t��������t��������d��������f�������r��J������y�r����)r����net_if_addrsr����r����r�����familyr����IntEnum�address�netmask�type� broadcast)r����ifname�addrs�addrs��� r ����test_net_if_addrsz$TestSystemAPITypes.test_net_if_addrs��s�������#�0�0�2�8�8�:�M�F�E��f�c�*�*�*���!�$�+�+�t�|�|�<�<�<�!�$�,�,��4�4�4�!�$�,�,��d�4�j�0A�B�B�B�!�$�.�.�3��T� �2C�D�D�D� ���;r"���c������������������p����t��������j��������������������������j��������������������������D�]���\��}}t��������|t���������������sJ��t��������|j ������������������t���������������sJ��t��������|j������������������t��������j�������������������������sJ��t��������|j������������������t���������������sJ��t��������|j������������������t���������������r��J���y�r����) r����net_if_statsr����r����r�����isup�bool�duplexr���r�����speedr�����mtu)r���r�����infos��� r ����test_net_if_statsz$TestSystemAPITypes.test_net_if_stats��s�������"�/�/�1�7�7�9�L�F�D��f�c�*�*�*��d�i�i��.�.�.��d�k�k�4�<�<�8�8�8��d�j�j�#�.�.�.��d�h�h��,�,�,��:r"���c������������������^�����t��������j������������������d��������D�]��}t��������|t���������������r�J���y�)NT)�pernic)r����net_io_countersr����r����)r���r����s��� r ����test_net_io_countersz'TestSystemAPITypes.test_net_io_counters��s)��������,�,�D�9�F��f�c�*�*�*��:r"���c����������� �����������t��������j��������������������������j��������������������������D�]f��\��}}t��������|t���������������sJ��|D�]J��}t��������|j ������������������t���������������sJ��t��������|j������������������t��������t��������t��������d��������f�������r�JJ����h�y�r����) r���ro���r����r����r�����label�currentr����r����r�����r����name�units�units��� r ���rp���z$TestSystemAPITypes.test_sensors_fans��sq�������"�.�.�0�6�6�8�K�D�%��d�C�(�(�(���!�$�*�*�c�2�2�2�!�$�,�,���T�$�Z�0H�I�I�I����9r"���c����������� ������������t��������j��������������������������j��������������������������D�]���\��}}t��������|t���������������sJ��|D�]���}t��������|j ������������������t���������������sJ��t��������|j������������������t��������t��������t��������d��������f�������sJ��t��������|j������������������t��������t��������t��������d��������f�������sJ��t��������|j������������������t��������t��������t��������d��������f�������r��J������y�r����)r���rl���r����r����r����r����r����r����r����r�����high�criticalr����s��� r ���rm���z,TestSystemAPITypes.test_sensors_temperatures&��s��������"�6�6�8�>�>�@�K�D�%��d�C�(�(�(���!�$�*�*�c�2�2�2�!�$�,�,���T�$�Z�0H�I�I�I�!�$�)�)�e�S�$�t�*�-E�F�F�F�!�$�-�-�%��d�4�j�1I�J�J�J� ���Ar"���c������������������L�����t��������t��������j��������������������������t���������������sJ��y�r����)r����r���� boot_timer����r���s��� r ����test_boot_timez!TestSystemAPITypes.test_boot_time1��s�������&�*�*�,�e�4�4�4r"���c������������������X����t��������j��������������������������D�]���}t��������|j������������������t���������������sJ��t��������|j ������������������t��������t ��������d��������f�������sJ��t��������|j������������������t��������t ��������d��������f�������sJ��t��������|j������������������t��������t ��������d��������f�������r��J���y�r����) r����usersr����r����r����r����r�����host�pidr����)r����users��� r ���� test_userszTestSystemAPITypes.test_users5��s}�������L�L�N�D��d�i�i��-�-�-��d�m�m�c�4��:�->�?�?�?��d�i�i�#�t�D�z�):�;�;�;��d�h�h��d�4�j�(9�:�:�:� �#r"���N)"rY���rZ���r[����__doc__�classmethodr����r����r����r����r����r����r����r���r\���r]���r����platform�machiner ���rj���r����r����r���r����r����r����r���r����r���rp���r���rm���r����r��r^���r"���r ���r����r��������sw��������$���$��/4�D���+� G�N�3���[�[��� �/�"�(�"�"�$��/�8N�������[�[���L�(���A�J��B��J� 5�.���[�[����_��=�+��>�+�E�-���[�[���/�/���H�+��I�+� ��[�[���,�,�_��E�J��F�J���[�[���4�4�_��M�K��N�K�5�;r"���r����c��������������������T�����e�Zd�Zej������������������j������������������e�d��������d����������Zy)�TestProcessWaitTypez not POSIXr<���c����������������������t��������j������������������|�j��������������������������j�������������������������}|j ���������������������������|j��������������������������}|t��������j�������������������k(��sJ��t��������|t��������j�������������������������sJ��y�r����)r���rx����spawn_testprocr��� terminate�wait�signal�SIGTERMr����r���r����)r����p�codes��� r ����test_negative_signalz(TestProcessWaitType.test_negative_signal?��s[�������N�N�4�.�.�0�4�4�5�� ��� ��v�v�x�������&�&�&��$����-�-�-r"���N)rY���rZ���r[���r���r\���r]���r ���r��r^���r"���r ���r ��r ��>��s*�������[�[���E� �+��6�.��7�.r"���r ��)r��r��r��r���r���r���r���r���r���r���r ���r ���r����psutil.testsr���r ���r���r���r���r���r���r���r���r���r���r���r���r`���ru���r����r ��r^���r"���r ����<module>r�����s������� ��� �� ��������������������'��%��,��)��1��%��'��'����&��'���<4�^��<4�~ �.�� �06B�>��6B�|w;���w;�t.�.��.r"���