
    daf                         d dl Z d dlZd dlZd dlZd dlmZ  eed      s ej                  d      d Z G d dej                        Z
edk(  r ej                          yy)	    N)cpython_onlydevpollz$test works only on Solaris OS familyc                 L    g }| D ]  \  }}||z  s|j                  |        |S )N)append)readyflagmatchfdmodes        ,/root/Python-3.12.4/Lib/test/test_devpoll.pyfind_ready_matchingr      s4    E D$;LL L    c                   :    e Zd Zd Zd Zd Zd Zd Zed        Z	y)DevPollTestsc                    t        j                         }d}d}t        |      }g }g }i }i }t        |      D ]  }	t	        j
                         \  }
}|j                  |
       |j                  |
t         j                         |j                  |t         j                         |j                  |
       |j                  |       |||
<   |
||<    g }|rl|j                         }t        |t         j                        }|s| j                  d       t        j                  |      }t	        j                   ||       |j                         }t        |t         j                        }|s| j                  d       | j#                  ||   g|       |d   }
t	        j$                  |
|      }| j#                  t        |      |       |j                  |       t	        j&                  ||
          t	        j&                  |
       |j)                  ||
          |j)                  |
       |j+                  ||
          |rl| j#                  ||g|z         y )N   s    This is a test.zno pipes ready for writingzno pipes ready for readingr   )selectr   lenrangeospiperegistermodifyPOLLINPOLLOUTr   pollr   failrandomchoicewriteassertEqualreadclose
unregisterremove)selfp	NUM_PIPESMSGMSG_LENreaderswritersr2ww2rirdwrbufsr   ready_writersready_readersbufs                    r   test_devpoll1zDevPollTests.test_devpoll1   s    NN	!c(y! 	AWWYFBJJrNHHR'JJr6>>*NN2NN2CGCG	 FFHE/v~~FM 		67}-BHHRFFHE/v}}EM 		67c"gY6q!B''"g&CSXw/KKHHSWLLR!LLNN3r7#) , 	uy01r   c                    t        j                         }t        j                         \  }}|j	                  |       |j                  d       | j                  t        |j
                  d       | j                  t        |j
                  d       | j                  t        |j
                  d       |j                  d       |j                  d       |j                  d       | j                  t        |j
                  d       | j                  t        |j
                  d	       | j                  t        |j
                  d
       y )Ni   l         r      i   @l        l                        )r   r   r   r   r   r   assertRaisesOverflowErrorr&   pollsterwrs       r   test_timeout_overflowz"DevPollTests.test_timeout_overflowJ   s    >>#wwy1!b-;-A-Aaag-@-@-@r   c                    t        t        d      }| j                  |j                         |j	                         }t        j                         }| j                  |j	                         t               | j                  |j                         |j                          | j                  |j                         | j                  t        |j                         |j                          | j                  t        |j                  |t
        j                         | j                  t        |j                          | j                  t        |j"                  |t
        j                         | j                  t        |j$                  |       y )Nrb)open__file__
addCleanupr#   filenor   r   assertIsInstanceintassertFalseclosed
assertTruer<   
ValueErrorr   r   r   r   r$   )r&   	open_filer
   r   s       r   
test_closezDevPollTests.test_close[   s   4(		(.." 	gnn.4( 	'*gnn5 	 	*gnnb&--H*gll3*g&6&6FMMJ*g&8&8"=r   c                     t        j                         }| j                  |j                         | j	                  t        j                  |j                               d       y )NF)r   r   rG   r#   r!   r   get_inheritablerH   )r&   r   s     r   test_fd_non_inheritablez$DevPollTests.test_fd_non_inheritables   s@    .."&++GNN,<=uEr   c                    t        j                         }t        j                         \  }}|j	                  |       | j                  t        |j                  dd       | j                  t        |j                  dd       | j                  t        |j                  dd       | j                  t        |j                  dd       y )Nr   r8   r;   r:   )	r   r   r   r   r   r<   rN   r=   r   r>   s       r   test_events_mask_overflowz&DevPollTests.test_events_mask_overflowx   s    >>#wwy1!*h&7&7B?-):):AwG*hooq"=-!WEr   c                    ddl m} t        j                         }t	        j
                         \  }}|j                  |       | j                  t        |j                  d|dz          | j                  t        |j                  d|dz          y )Nr   )	USHRT_MAXr:   )
	_testcapirW   r   r   r   r   r   r<   r=   r   )r&   rW   r?   r@   rA   s        r   "test_events_mask_overflow_c_limitsz/DevPollTests.test_events_mask_overflow_c_limits   sh    '>>#wwy1!-):):Ay1}M-!Y]Kr   N)
__name__
__module____qualname__r6   rB   rP   rS   rU   r   rY    r   r   r   r      s5    02dA">0F
F L Lr   r   __main__)r   r   r   unittesttest.supportr   hasattrSkipTestr   TestCaser   rZ   mainr]   r   r   <module>re      sj   
 
    %vy!
(

B
CCtL8$$ tLn zHMMO r   