o
    Y۷i
                     @   s   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	m
Z
 d dlmZ G dd deZe
dG dd	 d	eZed
krFe  dS dS )    N)cuda)unittestCUDATestCaseskip_on_cudasimskip_under_cuda_memcheck)captured_stdoutc                   @   s   e Zd Zdd ZdS )TestCudaDetectc                 C   sR   t  }t  W d    n1 sw   Y  | }| d| | d| d S )NFoundzCUDA devices)r   r   detectgetvalueassertIn)selfoutoutput r   Z/home/ubuntu/vllm_env/lib/python3.10/site-packages/numba/cuda/tests/cudadrv/test_detect.pytest_cuda_detect   s   
zTestCudaDetect.test_cuda_detectN)__name__
__module____qualname__r   r   r   r   r   r      s    r   zHangs cuda-memcheckc                   @   sB   e Zd Zdd Zdd Zedeej	
d ddd	 Zd
S )TestCUDAFindLibsc                 C   s^   t j|t jt j|d}td|j}z|  | \}}| | fW |	  S |	  w )N)stdoutstderrenvg     r@)

subprocessPopenPIPE	threadingTimerkillstartcommunicatedecodecancel)r   cmdliner   popentimeoutr   errr   r   r   run_cmd   s   zTestCUDAFindLibs.run_cmdc                 C   s2   t j }t|||< d}tjd|g}| ||S )Nzif 1:
            from numba import cuda
            @cuda.jit('(int64,)')
            def kernel(x):
                pass
            kernel(1,)
            z-c)osenvironcopystrsys
executabler(   )r   envvarenvvar_valueenv_copycoder$   r   r   r   run_test_in_separate_process)   s
   
z-TestCUDAFindLibs.run_test_in_separate_processz6Simulator does not hit device library search code pathlinuxz
linux onlyc                 C   st   ddg}d}|D ]}t jt jj|}t j|r nq|dur8| d|\}}| |du | |du dS dS )z
        This tests that the find_libs works as expected in the case of an
        environment variable being used to set the path.
        liblib64NNUMBA_CUDA_DRIVER)r)   pathjoinsepexistsr3   
assertTrue)r   locslooking_forlr   r'   r   r   r   test_cuda_find_lib_errors6   s   	z*TestCUDAFindLibs.test_cuda_find_lib_errorsN)r   r   r   r(   r3   r   r   skipIfr-   platform
startswithr@   r   r   r   r   r      s    r   __main__)r)   r-   r   r   numbar   numba.cuda.testingr   r   r   r   numba.tests.supportr   r   r   r   mainr   r   r   r   <module>   s    
: