<s> import pytest <EOL> from tests . utils . testdriver import TestDriver <EOL> from tests . utils . loop import CounterLoop , BooleanLoop <EOL> rep1 , rep2 = None , None <EOL> def get_services ( ) : <EOL> global rep1 , rep2 <EOL> rep1 = TestDriver ( '<STR_LIT>' , speed_bump = True ) <EOL> rep2 = TestDriver ( '<STR_LIT>' , speed_bump = True ) <EOL> return rep1 , rep2 <EOL> @ pytest . fixture ( autouse = True ) <EOL> def _ ( auto_setup ) : <EOL> pass <EOL> def crash ( launcher , filename , src , dest ) : <EOL> try : <EOL> start_loop = BooleanLoop ( ) <EOL> end_loop = CounterLoop ( <NUM_LIT:2> ) <EOL> launcher . on_transfer_started ( <EOL> start_loop . stop , d_to = dest , filename = filename <EOL> ) <EOL> launcher . on_transfer_restarted ( <EOL> end_loop . check , d_to = dest , filename = filename <EOL> ) <EOL> launcher . on_transfer_ended ( <EOL> end_loop . check , d_to = dest , filename = filename <EOL> ) <EOL> src . generate ( src . path ( '<STR_LIT:default>' , filename ) , <NUM_LIT:100> ) <EOL> launcher ( ) <EOL> start_loop . run ( timeout = <NUM_LIT:10> ) <EOL> launcher . kill ( ) <EOL> launcher ( ) <EOL> end_loop . run ( timeout = <NUM_LIT:10> ) <EOL> assert src . checksum ( src . path ( '<STR_LIT:default>' , filename ) ) == dest . checksum ( dest . path ( '<STR_LIT:default>' , filename ) ) <EOL> finally : <EOL> try : <EOL> src . unlink ( src . path ( '<STR_LIT:default>' , filename ) ) <EOL> dest . unlink ( dest . path ( '<STR_LIT:default>' , filename ) ) <EOL> except : <EOL> pass <EOL> launcher . close ( ) <EOL> pass <EOL> def test_crash_rep1_to_rep2 ( launcher ) : <EOL> crash ( launcher , '<STR_LIT>' , rep1 , rep2 ) <EOL> def test_crash_rep2_to_rep1 ( launcher ) : <EOL> crash ( launcher , '<STR_LIT>' , rep2 , rep1 ) </s>
