
    9i                         S r SSKrSSKrSSKrSSKrSSKJr  SSKJr  SSKJr  SSKJr  SSK	J
r
  SSK	Jr  S	 rS
 r " S S\5      rg)zTests which are meant to be run as root.

NOTE: keep this module compatible with unittest: we want to run this
file with the unittest runner, since pytest may not be installed for
the root user.
    N)FREEBSD)LINUX)OPENBSD)WINDOWS)
CI_TESTING)PsutilTestCasec                      [        [        S5      (       a9  [        [        S5      (       a$  [        R                  " [        R                  5      $ [        R                  " 5       $ )Nclock_gettimeCLOCK_REALTIME)hasattrtimer
   r        V/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/psutil/tests/test_sudo.pyget_systimer      s?    t_%%'$8H*I*I!!$"5"56699;r   c                 &   [        [        S5      (       a<  [        [        S5      (       a'   [        R                  " [        R                  U 5        g [        (       a  SS KnSS K	n[        R                  R                  U [        R                  R                  5      n UR                  UR                  UR                   UR#                  5       S-  UR$                  UR&                  UR(                  UR*                  [-        UR.                  S-  5      5        g [
        R                  " S	5      e! [         a    [
        R                  " S5      ef = f! UR0                   a,  nUR2                  S:X  a  [
        R                  " S5      ee S nAff = f)
Nclock_settimer   z
needs rootr      i  i"  zneeds Administrator userzsetting systime not supported)r   r   r   r   PermissionErrorunittestSkipTestr   
pywintypeswin32apidatetimefromtimestamptimezoneutcSetSystemTimeyearmonth
isoweekdaydayhourminutesecondintmicroseconderrorwinerror)secsr   r   dterrs        r   set_systimer-   !   s2   t_%%'$8H*I*I	2t22D9 
,,T83D3D3H3HI	""!#				BNNT)*	  ?@@/  	2##L11	2$  	||t#''(BCC	s$   %D0 A;E 0!EF$'FFc                   (   \ rS rSrSrS rS rS rS r\	R                  " \S5      S 5       r\	R                  " \S	5      \	R                  " \S
5      \	R                  " \S5      S 5       5       5       r\	R                  " \(       + S5      S 5       rSrg)TestUpdatedSystemTime?   z$Tests which update the system clock.c                 d    SU l         [        5       U l        [        R                  " 5       U l        g )NF)time_updatedr   	orig_timer   	monotonictime_startedselfs    r   setUpTestUpdatedSystemTime.setUpB   s"    !$ NN,r   c                     U R                   (       a;  [        R                  " 5       U R                  -
  n[	        U R
                  U-   5        g g N)r2   r   r4   r5   r-   r3   )r7   extra_ts     r   tearDownTestUpdatedSystemTime.tearDownG   s8    nn&):)::G01 r   c                 B    [        U R                  S-   5        SU l        g )N  T)r-   r3   r2   r6   s    r   update_systime$TestUpdatedSystemTime.update_systimeL   s    DNNT)* r   c                     [         R                  " 5       nU R                  5         [         R                  " 5       nU R                  X!5        [	        X!-
  5      nU R                  USSS9  g Nr@      )delta)psutil	boot_timerA   assertGreaterr&   assertAlmostEqualr7   t1t2diffs       r   test_boot_time$TestUpdatedSystemTime.test_boot_timeQ   sX    2"27|tT3r   zbroken on WINDOWSc                     [         R                  " 5       R                  5       nU R                  5         [         R                  " 5       R                  5       n[	        X!-
  5      nU R                  USSS9  g rD   )rG   Processcreate_timerA   r&   rJ   rK   s       r   test_proc_create_time+TestUpdatedSystemTime.test_proc_create_timeZ   sZ    
 ^^))+^^))+27|tT3r   zskipped on CI for nowzbroken on OPENBSDzbroken on FREEBSDc                     [         R                  " 5       nU R                  5         [         R                  " 5       nU R                  UR	                  5       UR	                  5       5        U R                  X5        g r;   )rG   rR   rA   assertEqual
_get_ident)r7   p1p2s      r   test_proc_ident%TestUpdatedSystemTime.test_proc_idente   sR     ^^^^"--/: r   z
LINUX onlyc                 "   [         R                  " 5       R                  R                  SS9nU R	                  5         [
        R                  " S5        [         R                  " 5       R                  R                  SS9nU R                  X5        g )NT)r4   g?)rG   rR   _procrS   rA   r   sleeprW   )r7   rL   rM   s      r   test_linux_monotonic_proc_time4TestUpdatedSystemTime.test_linux_monotonic_proc_timeo   sh    ^^##//$/?

4^^##//$/? r   )r3   r5   r2   N)__name__
__module____qualname____firstlineno____doc__r8   r=   rA   rO   r   skipIfr   rT   r   r   r   r[   r   r`   __static_attributes__r   r   r   r/   r/   ?   s    .-
2
!
4 __W124 34 __Z!89__W12__W12! 3 3 :! __Y-! .!r   r/   )rf   r   r   r   rG   r   r   r   r   psutil.testsr   r   r   r-   r/   r   r   r   <module>rj      sA            # 'A<6!N 6!r   