0idZddlZddlZddlZddlZddlmZddlmZddlmZddlmZddl m Z ddl m Z d Z d Z Gd d e Zy) 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)PsutilTestCasecttdr3ttdr#tjtjStjS)N clock_gettimeCLOCK_REALTIME)hasattrtimer r G/opt/hc_python/lib64/python3.12/site-packages/psutil/tests/test_sudo.py get_systimers9t_%'$8H*I!!$"5"566 99;rc ttdr6ttdr& tjtj|ytrddl}ddl }tjj|tjj} |j|j|j |j#dz|j$|j&|j(|j*t-|j.dz yt j d #t$rt j dwxYw#|j0$r*}|j2dk(rt j dd}~wwxYw) N clock_settimer z needs rootrii"zneeds Administrator userzsetting systime not supported)r r rr PermissionErrorunittestSkipTestr pywintypeswin32apidatetime fromtimestamptimezoneutc SetSystemTimeyearmonth isoweekdaydayhourminutesecondint microseconderrorwinerror)secsrrdterrs r set_systimer-!s*t_%'$8H*I 2   t22D 9     , ,T83D3D3H3H I   " " !#  BNNT)*  ?@@/ 2##L1 1 2$ ||t#''(BCC  s$$DA;ED>E:%E55E:ceZdZdZdZdZdZdZeje ddZ eje deje d ejed d Zeje d d Zy)TestUpdatedSystemTimez$Tests which update the system clock.cbd|_t|_tj|_y)NF) time_updatedr orig_timer monotonic time_startedselfs rsetUpzTestUpdatedSystemTime.setUpBs"!$ NN,rc|jr:tj|jz }t |j |zyyN)r1r r3r4r-r2)r6extra_ts rtearDownzTestUpdatedSystemTime.tearDownGs8   nn&):)::G 0 1 rcBt|jdzd|_y)NT)r-r2r1r5s rupdate_systimez$TestUpdatedSystemTime.update_systimeLsDNNT)* rctj}|jtj}|j||t ||z }|j |ddyNr=)delta)psutil boot_timer> assertGreaterr&assertAlmostEqualr6t1t2diffs rtest_boot_timez$TestUpdatedSystemTime.test_boot_timeQs\          2r"27| tT3rzbroken on WINDOWSctjj}|jtjj}t ||z }|j |ddyr@)rCProcess create_timer>r&rFrGs rtest_proc_create_timez+TestUpdatedSystemTime.test_proc_create_timeZs\ ^^  ) ) +  ^^  ) ) +27| tT3rzskipped on CI for nowzbroken on OPENBSDzbroken on FREEBSDctj}|jtj}|j|j |j |j||yr9)rCrMr> assertEqual _get_ident)r6p1p2s rtest_proc_identz%TestUpdatedSystemTime.test_proc_identesT^^   ^^  "--/: R rz LINUX onlyc*tjjjd}|j t j dtjjjd}|j||y)NT)r3g?)rCrM_procrNr>r sleeprQ)r6rHrIs rtest_linux_monotonic_proc_timez4TestUpdatedSystemTime.test_linux_monotonic_proc_timeosj ^^  # # / /$ / ?  4 ^^  # # / /$ / ? R rN)__name__ __module__ __qualname____doc__r7r;r>rKrskipIfrrOrrrrUrrYrrrr/r/?s.- 2 ! 4X__W12434X__Z!89X__W12X__W12!33:!X__Y -!.!rr/)r]rr rrCrrrr psutil.testsrrrr-r/rrrr`sA  #' A<6!N6!r