ó
ŒwÛjc           @   s  d  Z  d d l Z d d l Z d d l Z d d l Z d d l m Z m Z m Z e d ƒ Z	 e j
 d  d k s€ e j
 d k r– e j d	 e j
 ‚ n  e j ƒ  Z e	 j ƒ  Z d
 „  Z d „  Z d „  Z d e j f d „  ƒ  YZ d „  Z e d k re ƒ  n  d S(   s6   PyUnit testing that threads honor our signal semanticsiÿÿÿÿN(   t   run_unittestt   import_modulet   reap_threadst   threadi   t   wint   os2t   riscoss   Can't test signal on %sc         C   sL   t  j  t  j |  ƒ } t  j  t  j | ƒ } t  j  t  j | ƒ } | | | f S(   N(   t   signalt   SIGUSR1t   SIGUSR2t   SIGALRM(   t   for_usr1t   for_usr2t   for_alrmt   usr1t   usr2t   alrm(    (    s�   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_threadsignals.pyt   registerSignals   s    c         C   s,   t  |  d c d 7<t j ƒ  t  |  d <d  S(   Nt   trippedi   t
   tripped_by(   t   signal_blackboardR   t	   get_ident(   t   sigt   frame(    (    s�   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_threadsignals.pyt   handle_signals   s    c           C   s4   t  j t t j ƒ t  j t t j ƒ t j ƒ  d  S(   N(   t   ost   killt   process_pidR   R   R	   t   signalled_allt   release(    (    (    s�   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_threadsignals.pyt   send_signals   s    t   ThreadSignalsc           B   s&   e  Z d  Z e d „  ƒ Z d „  Z RS(   sÞ   Test signal handling semantics of threads.
       We spawn a thread, have the thread send two signals, and
       wait for it to finish. Check that we got both signals
       and that they were run by the main thread.
    c         C   s  t  j ƒ  |  j ƒ  t  j ƒ  t t j d d k sL t t j d d k r{ z t j d ƒ t j ƒ  Wd  t j d ƒ Xn  |  j	 t t j d d ƒ |  j	 t t j d t
 j ƒ  ƒ |  j	 t t j d d ƒ |  j	 t t j d t
 j ƒ  ƒ t  j ƒ  d  S(   NR   i    i   R   (   R   t   acquiret   spawnSignallingThreadR   R   R   R	   t   alarmt   pauset   assertEqualR   R   R   (   t   self(    (    s�   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_threadsignals.pyt   test_signals*   s     


c         C   s   t  j t d ƒ d  S(   N(    (   R   t   start_new_threadR   (   R%   (    (    s�   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_threadsignals.pyR!   E   s    (   t   __name__t
   __module__t   __doc__R   R&   R!   (    (    (    s�   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_threadsignals.pyR   $   s   c          C   s€   i i d d 6d d 6t  j 6i d d 6d d 6t  j 6i d d 6d d 6t  j 6a t t t t ƒ }  z t t ƒ Wd  t |  Œ  Xd  S(   Ni    R   R   (	   R   R   R	   R
   R   R   R   R    R   (   t   oldsigs(    (    s�   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_threadsignals.pyt	   test_mainI   s    t   __main__(   R   R   (   R*   t   unittestR   R   t   syst   test.test_supportR    R   R   R   t   platformt   SkipTestt   getpidR   t   allocate_lockR   R   R   R   t   TestCaseR   R,   R(   (    (    (    s�   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_threadsignals.pyt   <module>   s"   "				%	