+
    qj(  c            	       h   ^ RI t^ RIHu Ht ^ RIt^ RIt^ RI	t	^ RI
t
^ RIt^ RIt^ RIHt ]! ]4      P!                  4       P"                  ^,          R,          R,          t]P&                  P)                  R]P*                  P-                  R]! ]4      4      4      t]P&                  P3                  ]4      t]P6                  P9                  ]4       ]P:                  tR tR tR t R	 t!R
 t"R t#R t$R t%R t&R t'R t(R t)R t*R t+R t,R t-R!R lt.R t/R t0R t1R t2R t3R t4R t5R t6R t7R  t8R# )"    N)Pathbinzstall-guardstall_guardc                d    V  UUUUUu. uF  w  rr4pRVRVRVRVRV/NK  	  uppppp# u upppppi )z'points: list of (t, out, cpu, io, beat)toutcpuiobeat )pointsr   ocibs   &     F/home/user/Projects/overdeck/modules/monitor/tests/test_stall_guard.pytracer      s7    RXYRXqQS!UAuaq&!<RXYYYs   )c                  
   \        \        ^ R^<4       U u. uF	  q ^d^2RR3NK  	  up 4      pRp\        W4      pRqCVJqU'       Eg3   \        P                  ! RV3RW434      RR\
        P                  ! 4       9   g!   \        P                  ! \        4      '       d   \        P                  ! \        4      MRRR\
        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRR	\        P                  ! V4      R
\        P                  ! V4      R\        P                  ! V4      /,          pRRV/,          p\        \        P                  ! V4      4      hR;p;p;rTR# u up i )r               Npy0classifypy1samplespy3py5py8assert %(py10)spy10is notz=%(py5)s
{%(py5)s = %(py0)s(%(py1)s, %(py3)s)
} is not %(py8)sr   ranger   
@pytest_ar_call_reprcompare@py_builtinslocals_should_repr_global_name	_safereprAssertionError_format_explanationr   r   @py_assert2@py_assert4@py_assert7@py_assert6@py_format9@py_format11s           r   test_all_signals_flat_firesr4      s    U1dB5GH5Gb#s+5GHIG -8G!-------!------8----8-------G----G---S---!----------- I   F c                     \        R.\        ^<R^<4       U u. uF	  q ^
^^PR3NK  	  up ,           4      pRp\        W4      pRqCVJqU'       Eg3   \        P                  ! RV3RW434      RR\
        P                  ! 4       9   g!   \        P                  ! \        4      '       d   \        P                  ! \        4      MRRR\
        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRR	\        P                  ! V4      R
\        P                  ! V4      R\        P                  ! V4      /,          pRRV/,          p\        \        P                  ! V4      4      hR;p;p;rTR# u up i )r   r     r   Nr   r   r   r   r   r   r   r   r   r   
      P   r   r    r"   r#   r-   s           r   test_epoll_blocked_run_firesr<      s    ()%PRTXZ\J],^J]QQC-@J],^^_G -8G!-------!------8----8-------G----G---S---!----------- -_s   F
c                     \        \        ^ R^<4       U u. uF  q ^d^2V ,           RR3NK  	  up 4      pRp\        W4      pRqCVJ qU'       Eg3   \        P                  ! RV3RW434      RR\
        P                  ! 4       9   g!   \        P                  ! \        4      '       d   \        P                  ! \        4      MRRR\
        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRR	\        P                  ! V4      R
\        P                  ! V4      R\        P                  ! V4      /,          pRRV/,          p\        \        P                  ! V4      4      hR;p;p;rTR# u up i r   r   r   r   Nr   r   r   r   r   r   r   r   r   isz9%(py5)s
{%(py5)s = %(py0)s(%(py1)s, %(py3)s)
} is %(py8)sr#   r-   s           r   (test_silent_compile_burning_cpu_is_quietrB   %   s    q$9KL9KAb1fc3/9KLMG )8G!)T)T)))))!))))))8))))8)))))))G))))G)))S)))!)))T)))))))) M   Fc                  &   \        \        ^ R^<4       U u. uF  q ^d^2RV ^
,          ,           R3NK  	  up 4      pRp\        W4      pRqCVJ qU'       Eg3   \        P                  ! RV3RW434      RR\
        P                  ! 4       9   g!   \        P                  ! \        4      '       d   \        P                  ! \        4      MRRR\
        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRR	\        P                  ! V4      R
\        P                  ! V4      R\        P                  ! V4      /,          pRRV/,          p\        \        P                  ! V4      4      hR;p;p;rTR# u up i r>   r#   r-   s           r   'test_network_wait_moving_bytes_is_quietrE   +   s    eAtR>PQ>Pb#B,4>PQRG )8G!)T)T)))))!))))))8))))8)))))))G))))G)))S)))!)))T)))))))) Rs   Fc                     \        \        ^ R^<4       U u. uF  q ^d^2RRV ,           3NK  	  up 4      pRp\        W4      pRqCVJ qU'       Eg3   \        P                  ! RV3RW434      RR\
        P                  ! 4       9   g!   \        P                  ! \        4      '       d   \        P                  ! \        4      MRRR\
        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRR	\        P                  ! V4      R
\        P                  ! V4      R\        P                  ! V4      /,          pRRV/,          p\        \        P                  ! V4      4      hR;p;p;rTR# u up i )r   r   r   g     @@Nr   r   r   r   r   r   r   r   r   r?   rA   r#   r-   s           r   0test_declared_heartbeat_keeps_a_queue_wait_quietrG   1   s    E!T2<NO<Nqb#vz2<NOPG )8G!)T)T)))))!))))))8))))8)))))))G))))G)))S)))!)))T)))))))) PrC   c                     \        \        ^ R^<4       U u. uF  q ^dV ,           ^2RR3NK  	  up 4      pRp\        W4      pRqCVJ qU'       Eg3   \        P                  ! RV3RW434      RR\
        P                  ! 4       9   g!   \        P                  ! \        4      '       d   \        P                  ! \        4      MRRR\
        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRR	\        P                  ! V4      R
\        P                  ! V4      R\        P                  ! V4      /,          pRRV/,          p\        \        P                  ! V4      4      hR;p;p;rTR# u up i r>   r#   r-   s           r   "test_output_still_growing_is_quietrI   7   s    q$9KL9KAq"c3/9KLMG )8G!)T)T)))))!))))))8))))8)))))))G))))G)))S)))!)))T)))))))) MrC   c                     \        RR.4      p Rp\        W4      pRq2VJ qD'       Eg3   \        P                  ! RV3RW#34      RR\        P
                  ! 4       9   g!   \        P                  ! \        4      '       d   \        P                  ! \        4      MRRR\        P
                  ! 4       9   g   \        P                  ! V 4      '       d   \        P                  ! V 4      MRR\        P                  ! V4      R\        P                  ! V4      R	\        P                  ! V4      /,          pR
RV/,          p\        \        P                  ! V4      4      hR;p;p;rCR# )r   r   Nr   r   r   r   r   r   r   r   r   r8   )<   r9   r:   r;   r   r?   rA   )
r   r   r%   r&   r'   r(   r)   r*   r+   r,   )r   r.   r/   r0   r1   r2   r3   s          r   test_short_history_never_firesrL   >   s    (*>?@G )8G!)T)T)))))!))))))8))))8)))))))G))))G)))S)))!)))T))))))))    c                  
   \        \        ^ ^^<4       U u. uF	  q ^
^^PR3NK  	  up 4      pRp\        W4      pRqCVJ qU'       Eg3   \        P                  ! RV3RW434      RR\
        P                  ! 4       9   g!   \        P                  ! \        4      '       d   \        P                  ! \        4      MRRR\
        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRR\        P                  ! V4      R	\        P                  ! V4      R
\        P                  ! V4      /,          pRRV/,          p\        \        P                  ! V4      4      hR;p;p;rTR# u up i )r   r   r   Nr   r   r   r   r   r   r   r   r   r?   rA   r#   r-   s           r   !test_window_must_be_fully_coveredrO   C   s    %32CD2CQQC(2CDEG )8G!)T)T)))))!))))))8))))8)))))))G))))G)))S)))!)))T)))))))) Er5   c                     \        \        ^ R^<4       U u. uF  q ^dV ,           ^ ^ R3NK  	  up 4      pRp\        W4      pRqCVJ qU'       Eg3   \        P                  ! RV3RW434      RR\
        P                  ! 4       9   g!   \        P                  ! \        4      '       d   \        P                  ! \        4      MRRR\
        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRR	\        P                  ! V4      R
\        P                  ! V4      R\        P                  ! V4      /,          pRRV/,          p\        \        P                  ! V4      4      hR;p;p;rTR# u up i )r   r   r   r   Nr   r   r   r   r   r   r   r   r   r?   rA   r#   r-   s           r   *test_unreadable_counters_do_not_fire_alonerQ   I   s     eAtR6HI6Hq!Q,6HIJG )8G!)T)T)))))!))))))8))))8)))))))G))))G)))S)))!)))T)))))))) JrC   c                     \        ^ R^<4       U u. uF	  q ^d^2RR3NK  	  pp \        RR^<4       U u. uF  q ^dV ,           ^2V ,           RV ,           R3NK   	  pp W,           p\        V4      pRp\        WE4      pRqvVJ q'       Eg   \        P                  ! RV3RWg34      RR\
        P                  ! 4       9   g!   \        P                  ! \        4      '       d   \        P                  ! \        4      MRRR	\
        P                  ! 4       9   g!   \        P                  ! \        4      '       d   \        P                  ! \        4      MR	R
R\
        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRRR\
        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRR\        P                  ! V4      R\        P                  ! V4      R\        P                  ! V4      R\        P                  ! V4      /,          p	RRV	/,          p
\        \        P                  ! V
4      4      hR;p;p;p;p;rR# u up i u up i )r   X  r   r   r7   Nr   r   r   r   py2flatr   movingpy6r   r   py13zassert %(py15)spy15r?   )zf%(py10)s
{%(py10)s = %(py0)s(%(py6)s
{%(py6)s = %(py1)s((%(py2)s + %(py3)s))
}, %(py8)s)
} is %(py13)s)r$   r   r   r%   r&   r'   r(   r)   r*   r+   r,   )r   rU   rV   r/   @py_assert5r0   @py_assert9@py_assert12@py_assert11@py_format14@py_format16s              r   (test_recovery_after_flat_period_is_quietr`   P   s{   ,1!S",=>,=qRc",=D>:?T2:NO:NQ#'2637C0:NFO-6E-(6#68(.6$6$66666.6666668666686666666E6666E6666666$6666$66666666666666(666#666.666$666666666 ?Os
   I<$Jc                  v   \        \        ^ R^<4       U u. uF	  q ^d^2RR3NK  	  up 4      pT\        \        RR^<4       U u. uF	  q ^d^(RR3NK  	  up 4      ,          pRp\        W4      pRqCVJqU'       Eg3   \        P                  ! RV3RW434      RR\
        P                  ! 4       9   g!   \        P                  ! \        4      '       d   \        P                  ! \        4      MRRR	\
        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MR	R
\        P                  ! V4      R\        P                  ! V4      R\        P                  ! V4      /,          pRRV/,          p\        \        P                  ! V4      4      hR;p;p;rTR# u up i u up i )r   rS   r   r   r7   Nr   r   r   r   r   r   r   r   r   r    r"   r#   r-   s           r   1test_decreasing_counter_cannot_suppress_detectionrb   V   s    U1c25FG5Fb#s+5FGHGueCr6JK6J#r3,6JKLLG -8G!-------!------8----8-------G----G---S---!----------- HKs   F1 F6
c                     \        \        ^ R^<4       U u. uF  q ^dV ,           ^2RR3NK  	  up 4      pT\        \        RR^<4       U u. uF  q V R,
          ^2RR3NK  	  up 4      ,          pRp\        W4      pRqCVJ qU'       Eg3   \        P                  ! RV3RW434      RR\
        P                  ! 4       9   g!   \        P                  ! \        4      '       d   \        P                  ! \        4      MRR	R
\
        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MR
R\        P                  ! V4      R\        P                  ! V4      R\        P                  ! V4      /,          pRRV/,          p\        \        P                  ! V4      4      hR;p;p;rTR# u up i u up i )r   rS   r   r   r7   iN  Nr   r   r   r   r   r   r   r   r   r?   rA   r#   r-   s           r   'test_decrease_then_regrowth_is_progressrd   ^   s   q#r9JK9JAq"c3/9JKLGu%T2:NO:NQ!c'2sC0:NOPPG )8G!)T)T)))))!))))))8))))8)))))))G))))G)))S)))!)))T)))))))) LOs   F?G
c                     \        \        ^ R^<4       U u. uF  q ^d^2V ,           RV ,           R3NK  	  up 4      pRp\        W4      pRqCVJ qU'       Eg3   \        P                  ! RV3RW434      RR\
        P                  ! 4       9   g!   \        P                  ! \        4      '       d   \        P                  ! \        4      MRRR\
        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRR	\        P                  ! V4      R
\        P                  ! V4      R\        P                  ! V4      /,          pRRV/,          p\        \        P                  ! V4      4      hR;p;p;rTRpRp	Rp\        WV4      qV
9   q"'       EgI   \        P                  ! RV3RW34      R\        P                  ! V4      R	R\
        P                  ! 4       9   g!   \        P                  ! \        4      '       d   \        P                  ! \        4      MRRR\
        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRR\        P                  ! V	4      R\        P                  ! V4      R\        P                  ! V
4      /,          pRRV/,          p\        \        P                  ! V4      4      hR;p;p;p	;rJR# u up i )r   i  r   r   Nr   r   r   r   r   r   r   r   r   ceiling  py4rW   assert %(py12)spy12r?   rA   in)zD%(py1)s in %(py10)s
{%(py10)s = %(py3)s(%(py4)s, %(py6)s, %(py8)s)
}r#   )r   r   r.   r/   r0   r1   r2   r3   @py_assert0rZ   r[   @py_format13s               r   *test_spin_loop_fires_on_the_output_ceilingro   g   s   U1dB=OP=Ob1fcAgs3=OPQG )8G!)T)T)))))!))))))8))))8)))))))G))))G)))S)))!)))T))))))))4#4t4t4444444494449444444444444444444444444#444t4444444444444 Qs   K=c                  j   \        \        ^ R^<4       U u. uF  q ^dV ,           ^2V ,           RV ,           R3NK   	  up 4      pRpRp\        WV4      pRqTVJ qf'       EgI   \        P                  ! RV3RWE34      RR\
        P                  ! 4       9   g!   \        P                  ! \        4      '       d   \        P                  ! \        4      MRRR	\
        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MR	R
\        P                  ! V4      R\        P                  ! V4      R\        P                  ! V4      R\        P                  ! V4      /,          pRRV/,          p\        \        P                  ! V4      4      hR;p;p;p;reR# u up i )r   i(#  r   r   rg   Nr   r   r   r   r   r   py7r   ri   rj   r?   zC%(py7)s
{%(py7)s = %(py0)s(%(py1)s, %(py3)s, %(py5)s)
} is %(py10)sr#   	r   r   r.   r/   r1   r[   @py_assert8r3   rn   s	            r   +test_ceiling_stays_quiet_while_output_movesru   n   s   q$PRASTASAq"q&#'37ASTUG /$/8G$'/4/4/////'//////8////8///////G////G///S///$///'///4///////// Us   $F0c                  \   \        \        ^ R^<4       U u. uF  q ^d^2V ,           RV ,           R3NK  	  up 4      pRpRp\        WV4      pRqTVJ qf'       EgI   \        P                  ! RV3RWE34      RR\
        P                  ! 4       9   g!   \        P                  ! \        4      '       d   \        P                  ! \        4      MRRR	\
        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MR	R
\        P                  ! V4      R\        P                  ! V4      R\        P                  ! V4      R\        P                  ! V4      /,          pRRV/,          p\        \        P                  ! V4      4      hR;p;p;p;reR# u up i )r   r   r   r   rg   Nr   r   r   r   r   r   rq   r   ri   rj   r?   rr   r#   rs   s	            r   *test_ceiling_needs_the_full_window_coveredrw   s   s    U1dB=OP=Ob1fcAgs3=OPQG /$/8G$'/4/4/////'//////8////8///////G////G///S///$///'///4///////// Qs   F)c                   \         P                  ! V \         P                  \         P                  RRR7      p VP                  VR7      w  r4\         P                  ! YP                  Y44      #   \         P                   dT    \
        P                  ! TP                  \        P                  4       TP                  4       w  r4\        RT RT 24      hi ; i)zURun stall-guard in its own session; a timeout kills the whole tree, never orphans it.T)stdoutstderrtextstart_new_session)timeoutz stall-guard did not exit within zs
)
subprocessPopenPIPEcommunicateTimeoutExpiredoskillpgpidsignalSIGKILLr+   CompletedProcess
returncode)argvr}   procr   errs   &&   r   	run_guardr   z   s    Z__Z__4[_DS##G#4
 &&t__cGG	 $$ S
		$((FNN+##%?yC5QRRSs   A. .A(Cc                 	   \        \        P                  \        \        4      R RRRRRRRRRR	\        V R
,          4      R\        V R,          4      RRR.4      pVP
                  p\        P                  q2V8H  qD'       EgB   \        P                  ! R#V3R$W#34      RR\        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRR\        P                  ! V4      RR\        P                  ! 4       9   g!   \        P                  ! \        4      '       d   \        P                  ! \        4      MRR\        P                  ! V4      /,          p\        P                  ! VP                  4      R,           RV/,          p\!        \        P"                  ! V4      4      hR;p;rCRqqP                  qV9   q'       g   \        P                  ! R%V	3R&Wx34      R\        P                  ! V4      RR\        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRR\        P                  ! V4      /,          p
RRV
/,          p\!        \        P"                  ! V4      4      hR;p;rRqqP                  qV9   q'       g   \        P                  ! R%V	3R&Wx34      R\        P                  ! V4      RR\        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRR\        P                  ! V4      /,          p
RRV
/,          p\!        \        P"                  ! V4      4      hR;p;rR qqP                  qV9   q'       g   \        P                  ! R%V	3R&Wx34      R\        P                  ! V4      RR\        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRR\        P                  ! V4      /,          p
\        P                  ! R!4      R",           RV
/,          p\!        \        P"                  ! V4      4      hR;p;rR# )'run--keyselftest--idle-window4--sample-interval1--kill-grace	--enforce--tracezt.jsonl--logzo.log--sleep120r   resultrT   rh   r   rW   
>assert %(py8)sr   NSTALL DETECTEDr   r   r   assert %(py7)srq   zFAILED LOUDLYzdesktop notification suppressedzHthe gate did not reach the subprocess; this suite is popping the session
>assert %(py7)s==zR%(py2)s
{%(py2)s = %(py0)s.returncode
} == %(py6)s
{%(py6)s = %(py4)s.STALL_EXIT
}rk   z.%(py1)s in %(py5)s
{%(py5)s = %(py3)s.stderr
}r   sys
executablestrBINr   r   
STALL_EXITr%   r&   r'   r(   r)   r*   _format_assertmsgrz   r+   r,   tmp_pathr   @py_assert1rZ   @py_assert3@py_format7r2   rm   r/   r.   @py_format6@py_format8s   &           r   (test_live_stalled_child_is_killed_loudlyr      s   	S5':PS	c>3	C9,-wHw<N8O	w	F E 6 6E 66EEEEEEEEEE6EEEE6EEEEEEEEEEEEEEEE 6EEEEEEEEEEEE,}},},,,,,,,,,,,,,,v,,,,v,,,},,,,,,,,+mm+m+++++?+++?++++++f++++f+++m++++++++,  =   ,   ,               R      rM   c                    \        \        P                  \        \        4      R RRRRRRRR\        V R	,          4      R
\        V R,          4      RRRR.4      pVP
                  p^ q2V8H  qD'       g   \        P                  ! RV3RW#34      RR\        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRR\        P                  ! V4      R\        P                  ! V4      /,          p\        P                  ! VP                  4      R,           RV/,          p\        \        P                  ! V4      4      hR;p;rCRqqP                  q7V9  q'       g   \        P                  ! RV3RWs34      R\        P                  ! V4      RR\        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRR\        P                  ! V4      /,          pRRV/,          p\        \        P                  ! V4      4      hR;p;rR# )r   r   zselftest-okr   r   r   r   r   r   zt2.jsonlr   zo2.logr   sh-cz4for i in $(seq 12); do echo tick $i; sleep 0.5; doner   r   rT   r   r   rq   Nr   r   r   r   r   z2%(py2)s
{%(py2)s = %(py0)s.returncode
} == %(py5)snot inz2%(py1)s not in %(py5)s
{%(py5)s = %(py3)s.stderr
}r   r   r   r   r   r   r%   r&   r'   r(   r)   r*   r   rz   r+   r,   	r   r   r   r/   r   r   r   rm   r.   s	   &        r   %test_live_working_child_is_not_killedr      sT   	S5'=/SV	c;	C:-.X=P9Q	tTQ	SF 00!000000000060000600000000006==000000000==0=00000000000000600006000=00000000rM   c                 d   \        \        P                  \        \        4      R RRRRRRRRR	RR
R\        V R,          4      R\        V R,          4      RRRRRR.4      pVP
                  p\        P                  q2V8H  qD'       EgB   \        P                  ! R$V3R%W#34      RR\        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRR\        P                  ! V4      RR\        P                  ! 4       9   g!   \        P                  ! \        4      '       d   \        P                  ! \        4      MRR\        P                  ! V4      /,          p\        P                  ! VP                  4      R,           RV/,          p\!        \        P"                  ! V4      4      hR;p;rCRqqP                  qV9   q'       g   \        P                  ! R&V	3R'Wx34      R\        P                  ! V4      R R\        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRR!\        P                  ! V4      /,          p
R"R#V
/,          p\!        \        P"                  ! V4      4      hR;p;rR# )(r   r   zselftest-spinr   3600z--output-ceiling5r   r   r   r   r   zt4.jsonlr   zo4.logr   r}   60r   r   zwhile :; do :; doner   r   rT   rh   r   rW   r   r   Nzno output forr   r   r   r   rq   r   r   rk   r   r   r   s   &           r   ,test_live_spin_loop_is_killed_on_the_ceilingr      s   	S5'?OU[	S"5sNCQ\	C:-.X=P9Q	y$d,A	CF E 6 6E 66EEEEEEEEEE6EEEE6EEEEEEEEEEEEEEEE 6EEEEEEEEEEEE+mm+m+++++?+++?++++++f++++f+++m++++++++rM   c                    V R ,          pV R,          pVP                  R\        V4      : R24       V R,          pVP                  R\        V4      : R24       \        \        P                  \        \
        4      RRR	R
RRRRRRR\        V R,          4      R\        V R,          4      R\        P                  \        V4      .4      pVP                  p\        P                  qeV8H  qw'       EgB   \        P                  ! R(V3R)WV34      RR\        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRR\        P                  ! V4      RR\        P                  ! 4       9   g!   \        P                  ! \        4      '       d   \        P                  ! \        4      MRR\        P                  ! V4      /,          p\        P                  ! VP                   4      R,           RV/,          p	\#        \        P$                  ! V	4      4      hR;p;rvVP&                  qU! 4       qw'       g   \        P                  ! R4      R,           RR \        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MR R\        P                  ! V4      R\        P                  ! V4      /,          p
\#        \        P$                  ! V
4      4      hR;rW\(        P*                  ! ^4       \,        P.                  ! R!R"\        V4      .R#R#R$7      P0                  P3                  4       pV'       * qU'       g   \        P                  ! R%V 24      R&,           RR'\        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MR'/,          p\#        \        P$                  ! V4      4      hRpR# )*zgrandchild.alivezgrandchild.pyz"import pathlib, time
pathlib.Path(z).touch()
time.sleep(120)
z	parent.pyz?import subprocess, sys, time
subprocess.Popen([sys.executable, z+], start_new_session=True)
time.sleep(120)
r   r   zselftest-treer   r   r   r   r   r   r   zt5.jsonlr   zo5.logr   r   r   rT   rh   r   rW   r   r   Nz1grandchild never started; the test proves nothingzC
>assert %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.exists
}()
}markerpgrepz-fT)capture_outputr{   zgrandchild survived the kill: z
>assert not %(py0)s	survivorsr   r   )
write_textr   r   r   r   r   r   r   r   r%   r&   r'   r(   r)   r*   r   rz   r+   r,   existstimer   r~   r   ry   split)r   r   
grandchildparentr   r   rZ   r   r   r2   @py_format5r   @py_format2s   &            r   1test_live_grandchild_in_its_own_session_is_killedr      s}   **FO+JF '	
 #F
--0_,? @	
 	S5'?OUX	c>3	C:-.X=P9Q	s~~s6{	,F E 6 6E 66EEEEEEEEEE6EEEE6EEEEEEEEEEEEEEEE 6EEEEEEEEEEEE==O=?O?OOOOOOOOOO6OOOO6OOO=OOO?OOOOOOJJqM	$J(DfUUW  =F=FF:9+FFFFFFFFyFFFFyFFFFFFFrM   c                 	   \        \        P                  \        \        4      R RRRRRRRRR	R
\        V R,          4      R\        V R,          4      RRRR.4      pVP
                  p^ q2V8H  qD'       g   \        P                  ! R%V3R&W#34      RR\        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRR\        P                  ! V4      R\        P                  ! V4      /,          p\        P                  ! VP                  4      R,           RV/,          p\        \        P                  ! V4      4      hR;p;rCRqqP                  q7V9   q'       g   \        P                  ! R'V3R(Ws34      R\        P                  ! V4      RR\        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRR\        P                  ! V4      /,          pRRV/,          p\        \        P                  ! V4      4      hR;p;rRqqP                  q7V9  q'       g   \        P                  ! R)V3R*Ws34      R\        P                  ! V4      RR\        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRR\        P                  ! V4      /,          pRRV/,          p\        \        P                  ! V4      4      hR;p;rVP                  q"P                   pRq! V	4      p
^qV8H  q'       Eg$   \        P                  ! R%V3R+W34      RR\        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRR\        P                  ! V4      R\        P                  ! V4      R\        P                  ! V	4      R \        P                  ! V
4      R!\        P                  ! V4      /,          p\        P                  ! R"4      R#,           R$V/,          p\        \        P                  ! V4      4      hR;p;p;p	;p
;rR# ),r   r   zselftest-slowr   r   z--wall-notice2r   r   r   r   zt6.jsonlr   zo6.logr   r   r   z=for i in $(seq 8); do echo waiting for lock...; sleep 1; doner   r   rT   r   r   rq   NzSLOW:r   r   r   r   rh   rW   r   py11z)advisory must fire once, not every samplez
>assert %(py13)srX   r   r   rk   r   r   r   )zh%(py8)s
{%(py8)s = %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.stderr
}.count
}(%(py6)s)
} == %(py11)s)r   r   r   r   r   r   r%   r&   r'   r(   r)   r*   r   rz   r+   r,   count)r   r   r   r/   r   r   r   rm   r.   rZ   r0   @py_assert10r[   @py_format12r^   s   &              r   -test_wall_notice_warns_loudly_without_killingr      s    	S5'?OU[	#2C	C:-.X=P9Q	tTZ	\F 00!000000000060000600000000006==00000000#mm#m#####7###7######f####f###m########0==0=00000000000000600006000=00000000==YYwYw'Y1Y1,YYYY'YYYYYY6YYYY6YYY=YYYYYYwYYY'YYY1YYYY.YYYYYYYYYYrM   c                 P   \        \        P                  \        \        4      R RRRRRRR\        V R,          4      R	\        V R
,          4      RRR.4      pVP
                  p^ q2V8H  qD'       g   \        P                  ! RV3RW#34      RR\        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRR\        P                  ! V4      R\        P                  ! V4      /,          p\        P                  ! VP                  4      R,           RV/,          p\        \        P                  ! V4      4      hR;p;rCRqqP                  q7V9   q'       g   \        P                  ! RV3RWs34      R\        P                  ! V4      RR\        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRR\        P                  ! V4      /,          pRRV/,          p\        \        P                  ! V4      4      hR;p;rRqqP                  q7V9   q'       g   \        P                  ! RV3RWs34      R\        P                  ! V4      RR\        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRR\        P                  ! V4      /,          pRRV/,          p\        \        P                  ! V4      4      hR;p;rR# )r   r   zselftest-observer   r   r   r   r   zt3.jsonlr   zo3.logr   r   8r   r   rT   r   r   rq   Nzobserve moder   r   r   zwould have failedr   r   rk   r   r   r   s	   &        r   )test_observe_mode_reports_without_killingr      s   	S5'3EX[	c	C:-.X=P9Q	w	F 00!000000000060000600000000006==00000000*]]*]*****>***>******V****V***]********/--/-//////////////&////&///-////////rM   c                 V   a . oV P                  \        P                  R V3R l4       S# )r   c                 &   < SP                  V 4      # )N)append)r   kwcallss   &,r   <lambda>%_record_notify_send.<locals>.<lambda>   s    %,,W[J\rM   )setattrr   r~   )monkeypatchr   s   &@r   _record_notify_sendr      s&    E..7\]LrM   c                    \        V 4      pV P                  R R4       \        P                  RR4       . q!q1'       d   V^ ,          ^ ,          pRqTV8H  qfpV'       Eg"   RRR\        P
                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MR/,          qrP                  V4       V'       dk   \        P                  ! RX3RXX34      R\        P                  ! V4      R	\        P                  ! V4      /,          pR
RV/,          qP                  V	4       \        P                  ! V^ 4      / ,          p
RRV
/,          p\        \        P                  ! V4      4      hR;p;p;p;reR# )STALL_GUARD_NOTIFYr   stuckno progressznotify-sendz%(py2)srT   r   r   r   z%(py10)sr   zassert %(py13)srX   Nr   )z%(py5)s == %(py8)s)r   setenvr   notifyr'   r(   r%   r)   r*   r   r&   _format_boolopr+   r,   )r   r   r   rm   r/   r0   r1   @py_format3r2   r3   r   r^   s   &           r   .test_notify_reaches_the_desktop_under_the_gater      s    ,E+S1w.15U1Xa[1M1M1111111151111511115111[M111[111M1111111111111111rM   c                 z   \        V 4      pV P                  R RR7       \        P                  RR4       V'       * q"'       gw   RRR\        P
                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MR/,          p\        \        P                  ! V4      4      hRpR# )	r   F)raisingr   r   assert not %(py0)sr   r   N)r   delenvr   r   r'   r(   r%   r)   r*   r+   r,   r   r   r   r   s   &   r   &test_notify_is_silent_without_the_gater      sq    ,E+U;w.99uurM   c                 x   \        V 4      pV P                  R R4       \        P                  RR4       V'       * q"'       gw   RRR\        P
                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MR/,          p\        \        P                  ! V4      4      hRpR# )r   0r   r   r   r   r   N)r   r   r   r   r'   r(   r%   r)   r*   r+   r,   r   s   &   r   ,test_notify_is_silent_under_an_explicit_zeror      sn    ,E+S1w.99uurM   )Z   )9builtinsr'   _pytest.assertion.rewrite	assertionrewriter%   importlib.util	importlibr   r   r~   r   r   pathlibr   __file__resolveparentsr   utilspec_from_loader	machinerySourceFileLoaderr   specmodule_from_specr   loaderexec_moduler   r   r4   r<   rB   rE   rG   rI   rL   rO   rQ   r`   rb   rd   ro   ru   rw   r   r   r   r   r   r   r   r   r   r   r   r   rM   r   <module>r     s3       	   
  
8n&&q)E1MA~~&&}i6I6I6Z6Z[hjmnqjr6stnn--d3    $Z.
.*****
**7.*50
0H1,G:Z	02rM   