
    |j`                     \    d dl Zd dlmc mZ d dlmZ d Zd Z	d Z
d Zd Zd Zd	 Zd
 ZdS )    N)reboot_guardc                    t           j        } |            }d}||k    }|st          j        d|fd||f          dt	          j                    v st          j        t                     rt          j        t                     ndt          j        |          t          j        |          t          j        |          dz  }dd|iz  }t          t          j	        |                    d x}x}x}}d S Nr   ==zI%(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.read_count
}()
} == %(py7)sr   py0py2py4py7assert %(py9)spy9)
r   
read_count
@pytest_ar_call_reprcompare@py_builtinslocals_should_repr_global_name	_safereprAssertionError_format_explanationsim_env@py_assert1@py_assert3@py_assert6@py_assert5@py_format8@py_format10s          FC:\Users\jvoigtlander\Desktop\BubbleCamCode\tests\test_reboot_guard.py)test_read_count_zero_when_no_counter_filer"      s   ")""$$))$))))))))))$))))))))))))<)))))<))))))"))))$)))))))))))))))))))))))))))))))))))    c                    t           j        } |            }d}||k    }|st          j        d|fd||f          dt	          j                    v st          j        t                     rt          j        t                     ndt          j        |          t          j        |          t          j        |          dz  }dd|iz  }t          t          j	        |                    d x}x}x}}t           j        } |            }d}||k    }|st          j        d|fd||f          dt	          j                    v st          j        t                     rt          j        t                     ndt          j        |          t          j        |          t          j        |          dz  }dd|iz  }t          t          j	        |                    d x}x}x}}t           j
        } |            }d}||k    }|st          j        d|fd	||f          dt	          j                    v st          j        t                     rt          j        t                     ndt          j        |          t          j        |          t          j        |          dz  }dd|iz  }t          t          j	        |                    d x}x}x}}d S )
N   r   )zH%(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.increment
}()
} == %(py7)sr   r	   r   r      r   )r   	incrementr   r   r   r   r   r   r   r   r   r   s          r!   -test_increment_persists_and_returns_new_countr(      s   !(!!##(q(#q((((((((((#q((((((((((((<(((((<((((((!((((#((((q(((((((((((((((((((((((((((((!(!!##(q(#q((((((((((#q((((((((((((<(((((<((((((!((((#((((q(((((((((((((((((((((((((((((")""$$))$))))))))))$))))))))))))<)))))<))))))"))))$)))))))))))))))))))))))))))))))))))r#   c                 V   t          j                     t          j                     t          j                     t           j        } |            }d}||k    }|st	          j        d|fd||f          dt          j                    v st	          j        t                     rt	          j	        t                     ndt	          j	        |          t	          j	        |          t	          j	        |          dz  }dd|iz  }t          t	          j        |                    d x}x}x}}d S r   )r   r'   resetr   r   r   r   r   r   r   r   r   r   s          r!   test_reset_clears_counterr+      s:   ")""$$))$))))))))))$))))))))))))<)))))<))))))"))))$)))))))))))))))))))))))))))))))))))r#   c                 
   t          j                     t           j        } |            }d}||k    }|st          j        d|fd||f          dt          j                    v st          j        t                     rt          j        t                     ndt          j        |          t          j        |          t          j        |          dz  }dd|iz  }t          t          j
        |                    d x}x}x}}d S r   )r   r*   r   r   r   r   r   r   r   r   r   r   s          r!   *test_reset_when_no_counter_file_is_a_no_opr-      s   ")""$$))$))))))))))$))))))))))))<)))))<))))))"))))$)))))))))))))))))))))))))))))))))))r#   c                    ddl |                    t          dfd           |                    t          j        dd                                           }t          j        } |            }d}||k    }|st          j        d|fd||f          d	t          j	                    v st          j
        t                    rt          j        t                    nd	t          j        |          t          j        |          t          j        |          d
z  }dd|iz  }t          t          j        |                    dx}x}x}}j        } |            }||z
  }d}	||	k     }
|
st          j        d|
fd||	f          dt          j	                    v st          j
                  rt          j                  ndt          j        |          t          j        |          dt          j	                    v st          j
        |          rt          j        |          ndt          j        |	          dz  }dd|iz  }t          t          j        |                    dx}x}x}x}
}	dS )zA wedged SD card must not deadlock the watchdog's escalation: the
    counter reads as 0 ("attempts remaining") so the reboot still happens.
    This is the failure that left a real soak hung for 8.5 hours.r   N_read_count_blockingc                  .                          d          S N   sleeptimes   r!   <lambda>z9test_read_count_zero_when_storage_hangs.<locals>.<lambda>        djjQSnn r#   DEFAULT_TIMEOUT_SECONDS皙?r   r   r   r	   r   r   g      @)<)zS(%(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.monotonic
}()
} - %(py5)s) < %(py9)sr6   started)r
   r   r   py5r   assert %(py11)spy11)r6   setattrr   
bounded_io	monotonicr   r   r   r   r   r   r   r   r   )r   monkeypatchr<   r   r   r   r   r   r    @py_assert8@py_assert7@py_format12r6   s               @r!   'test_read_count_zero_when_storage_hangsrG      s    KKK&<>T>T>T>TUUU/1JCPPPnnG")""$$))$))))))))))$))))))))))))<)))))<))))))"))))$)))))))))))))))))))))))))))))))))>+>>+g%++%++++++++++%++++++++++++4+++++4++++++>+++++++++++++++g+++++g+++++++++++++++++++++++++++++++++++++++r#   c                   	 dd l 	|                    t          d	fd           |                    t          j        dd           t          j        }d} ||          }d}||u }|st          j        d|fd	||f          d
t          j                    v st          j	        t                    rt          j
        t                    nd
t          j
        |          t          j
        |          t          j
        |          t          j
        |          dz  }dd|iz  }t          t          j        |                    d x}x}x}x}}d S )Nr   r/   c                  .                          d          S r1   r3   r5   s   r!   r7   z9test_exhausted_false_when_storage_hangs.<locals>.<lambda>*   r8   r#   r9   r:      FiszO%(py6)s
{%(py6)s = %(py2)s
{%(py2)s = %(py0)s.exhausted
}(%(py4)s)
} is %(py9)sr   r
   r   r   py6r   r>   r?   )r6   r@   r   rA   	exhaustedr   r   r   r   r   r   r   r   )
r   rC   r   r   r   rD   rE   r    rF   r6   s
            @r!   'test_exhausted_false_when_storage_hangsrQ   '   sq   KKK&<>T>T>T>TUUU/1JCPPP!-!-!!!$$--$----------$------------<-----<------!----!----$-------------------------------------r#   c                 n   dd l |                    t          dfd           |                    t          j        dd           t          j        } |            }d}||k    }|st          j        d|fd||f          d	t          j                    v st          j	        t                    rt          j
        t                    nd	t          j
        |          t          j
        |          t          j
        |          d
z  }dd|iz  }t          t          j        |                    d x}x}x}}d S )Nr   _increment_blockingc                  .                          d          S r1   r3   r5   s   r!   r7   zGtest_increment_still_returns_a_count_when_write_hangs.<locals>.<lambda>3   s    TZZPR^^ r#   r9   r:   r%   )>=)zH%(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.increment
}()
} >= %(py7)sr   r	   r   r   )r6   r@   r   rA   r'   r   r   r   r   r   r   r   r   )	r   rC   r   r   r   r   r   r    r6   s	           @r!   5test_increment_still_returns_a_count_when_write_hangsrV   0   sV   KKK&;=S=S=S=STTT/1JCPPP!(!!##(q(#q((((((((((#q((((((((((((<(((((<((((((!((((#((((q(((((((((((((((((((((((((((((((r#   c                    t           j        }d} ||          }d}||u }|st          j        d|fd||f          dt	          j                    v st          j        t                     rt          j        t                     ndt          j        |          t          j        |          t          j        |          t          j        |          dz  }dd|iz  }t          t          j	        |                    d x}x}x}x}}t          j
                     t          j
                     t           j        }d} ||          }d}||u }|st          j        d|fd||f          dt	          j                    v st          j        t                     rt          j        t                     ndt          j        |          t          j        |          t          j        |          t          j        |          dz  }dd|iz  }t          t          j	        |                    d x}x}x}x}}t          j
                     t           j        }d} ||          }d	}||u }|st          j        d|fd||f          dt	          j                    v st          j        t                     rt          j        t                     ndt          j        |          t          j        |          t          j        |          t          j        |          dz  }dd|iz  }t          t          j	        |                    d x}x}x}x}}d S )
NrJ   FrK   rM   r   rN   r>   r?   T)r   rP   r   r   r   r   r   r   r   r   r'   )r   r   r   r   rD   rE   r    rF   s           r!   test_exhaustedrX   8   s   !-!-!!!$$--$----------$------------<-----<------!----!----$-----------------------------------!-!-!!!$$--$----------$------------<-----<------!----!----$-----------------------------------!,!,!!!$$,,$,,,,,,,,,,$,,,,,,,,,,,,<,,,,,<,,,,,,!,,,,!,,,,$,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,r#   )builtinsr   _pytest.assertion.rewrite	assertionrewriter   	bubblecamr   r"   r(   r+   r-   rG   rQ   rV   rX    r#   r!   <module>r_      s                  " " " " " "* * ** * ** * ** * *

, 
, 
,. . .) ) )- - - - -r#   