
    Vh                         d Z ddlmZ ddlZddlmZmZmZmZm	Z	 ddl
mZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ  G d de      Zy).Sanity test for symlinks in the bin directory.    )annotationsN   )SanityVersionNeutralSanityMessageSanityFailureSanitySuccessSanityTargets   )__file__)
TestResult)SanityConfig)data_context)ANSIBLE_BIN_SYMLINK_MAP)ANSIBLE_SOURCE_ROOTc                  @    e Zd ZdZdZedd       Zedd       ZddZy)	BinSymlinksTestr   Tc                     y)z)True if the test supports ignore entries.F selfs    c/home/dcms/DCMS/lib/python3.12/site-packages/ansible_test/_internal/commands/sanity/bin_symlinks.py
can_ignorezBinSymlinksTest.can_ignore,   s         c                     y)zPTrue if the test does not use test targets. Mutually exclusive with all_targets.Tr   r   s    r   
no_targetszBinSymlinksTest.no_targets1   s     r   c                   t         j                  j                  t        d      t        j                        }t        fd|D              }g }t         j                  j                  t        t               j                  j                        }|D ]c  }t         j                  j                  |      s|j                  |df       7t        j                  |      }t         j                  j                  |      s|j                  |d|z  f       t         j                  j                  |      s|j                  |d|z  f       t!        j"                  t         j                  j%                  |            }	|	s|j                  |d|z  f       ||	k7  r|j                  |d|d|	d	|d
f       (t        j&                  |t         j(                        rN|j                  |d|z  f       f t!        j*                         D ]D  \  }
}|
|vst         j                  j                  |
      }|j                  |d|d|d
f       F |D cg c]M  \  }}t-        |t         j                  j                  |t               j                  j                        d      O }}}|rt/        | j0                  |      S t3        | j0                        S c c}}w )Nbinc              3  ^   K   | ]$  }t         j                  j                  |       & y w)N)ospathjoin).0r!   bin_roots     r   	<genexpr>z'BinSymlinksTest.test.<locals>.<genexpr>9   s      ND277<<$7Ns   *-znot a symbolic linkz points to non-existent path "%s"zpoints to non-file "%s"z1missing from ANSIBLE_BIN_SYMLINK_MAP in file "%s"zpoints to "z" instead of "z(" from ANSIBLE_BIN_SYMLINK_MAP in file ""z"points to non-executable file "%s"zmissing symlink to "z." defined in ANSIBLE_BIN_SYMLINK_MAP in file "d   )messager!   
confidence)messages)r    r!   r"   r   listdirsortedrelpathsymlink_map_full_pathr   contentrootislinkappendreadlinkexistsisfiler   getbasenameaccessX_OKitemsr   r   namer	   )r   argstargets	bin_names	bin_pathserrorssymlink_map_pathbin_pathdestmap_destbin_namer!   r(   r*   r$   s                 @r   testzBinSymlinksTest.test6   sz   77<< 3U;JJx(	NINN	(*77??+@,.BXBXB]B]^! 	H77>>(+x)>?@;;x(D77>>(+x)Kd)RST77>>(+x)BT)IJK.222773C3CH3MNHx)\_o)opqxxw{  ~F  HX  *Y  Z  [99Xrww/x)MPT)TUV7	: 6;;= 	PNHdy(77<<(;xvz  }M  *N  O  P	P
 RX  Y  AN  AE  GNM'lnNdNdNiNi8jwz{  Y  Y X>>TYY'' Ys   AKN)returnbool)r<   r   r=   r
   rG   r   )	__name__
__module____qualname____doc__ansible_onlypropertyr   r   rF   r   r   r   r   r   '   s5    8L   0(r   r   )rL   
__future__r   r     r   r   r   r	   r
   	constantsr   r.   rF   r   configr   datar   payloadr   utilr   r   r   r   r   <module>rV      sC    4 " 	 
?(* ?(r   