ó
\K]c           @@ s×   d  d l  m Z m Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l m Z d  d l	 m
 Z
 m Z m Z d  d l m Z d e e
 j f d „  ƒ  YZ d e e
 j f d	 „  ƒ  YZ e d
 k rÓ e
 j ƒ  n  d S(   i    (   t   absolute_importt   print_functionN(   t   cuda(   t   unittestt   SerialMixint   skip_on_cudasim(   t   captured_stdoutt   TestCudaDetectc           B@ s   e  Z d  „  Z RS(   c         C@ sL   t  ƒ   } t j ƒ  Wd  QX| j ƒ  } |  j d | ƒ |  j d | ƒ d  S(   Nt   Founds   CUDA devices(   R   R   t   detectt   getvaluet   assertIn(   t   selft   outt   output(    (    sC   lib/python2.7/site-packages/numba/cuda/tests/cudadrv/test_detect.pyt   test_cuda_detect   s
    (   t   __name__t
   __module__R   (    (    (    sC   lib/python2.7/site-packages/numba/cuda/tests/cudadrv/test_detect.pyR      s   t   TestCUDAFindLibsc           B@ sN   e  Z d  „  Z d „  Z e d ƒ e j e j j	 d ƒ d ƒ d „  ƒ ƒ Z
 RS(   c         C@ s„   t  j | d t  j d t  j d | ƒ} t j d | j ƒ } z6 | j ƒ  | j ƒ  \ } } | j ƒ  | j ƒ  f SWd  | j	 ƒ  Xd S(   Nt   stdoutt   stderrt   envi   g      N@g     Àr@(   NN(   t
   subprocesst   Popent   PIPEt	   threadingt   Timert   killt   startt   communicatet   decodet   cancelt   None(   R   t   cmdlineR   t   popent   timeoutR   t   err(    (    sC   lib/python2.7/site-packages/numba/cuda/tests/cudadrv/test_detect.pyt   run_cmd   s    			
c         C@ sG   t  j j ƒ  } t | ƒ | | <d } t j d | g } |  j | | ƒ S(   Nsž   if 1:
            from numba import cuda
            @cuda.jit('(int64,)')
            def kernel(x):
                pass
            kernel(1,)
            s   -c(   t   ost   environt   copyt   strt   syst
   executableR%   (   R   t   envvart   envvar_valuet   env_copyt   codeR!   (    (    sC   lib/python2.7/site-packages/numba/cuda/tests/cudadrv/test_detect.pyt   run_test_in_separate_process(   s
    s6   Simulator does not hit device library search code patht   linuxs
   linux onlyc         C@ s»   d d g } d } x? | D]7 } t j j t j j | ƒ } t j j | ƒ r Pq q W| d k	 r· |  j d | ƒ \ } } |  j | d k	 ƒ |  j | d k	 ƒ |  j d t	 | ƒ ƒ n  d S(   sŒ   
        This tests that the find_libs works as expected in the case of an
        environment variable being used to set the path.
        t   libt   lib64t   NUMBAPRO_LIBDEVICEs   Missing libdevice file forN(
   R    R&   t   patht   joint   sept   existsR0   t
   assertTrueR   R)   (   R   t   locst   looking_fort   lR   R$   (    (    sC   lib/python2.7/site-packages/numba/cuda/tests/cudadrv/test_detect.pyt   test_cuda_find_lib_errors5   s    		(   R   R   R%   R0   R   R   t   skipIfR*   t   platformt
   startswithR=   (    (    (    sC   lib/python2.7/site-packages/numba/cuda/tests/cudadrv/test_detect.pyR      s   			t   __main__(   t
   __future__R    R   R&   R*   R   R   t   numbaR   t   numba.cuda.testingR   R   R   t   numba.tests.supportR   t   TestCaseR   R   R   t   main(    (    (    sC   lib/python2.7/site-packages/numba/cuda/tests/cudadrv/test_detect.pyt   <module>   s   
;