anchor.diff:        , ?_assertThrow( { timeout, _ }, get_event( Port, "SomeEvent" ) ) }
       , { "stop driver" , ?_assertEqual( ok, stop_driver( Port ) ) }
       ].
  +
  +stop_idempotent_test_() ->
  +    { ok, Port } = start_test_driver( "echo.sh" ),
  +    Tries = 2,
  +    [ { lists:flatten( io_lib:format( "stop ~B", [ Try ] ) ),
  +        ?_assertEqual( ok, stop_driver( Port ) ) }
  +      || Try <- lists:seq( 1, Tries ) ].
   
   
   % server tests - API
  
positive.code:         error:Error -> { error, Error }
      end.
  
  
  -spec stop_driver( port() ) -> ok.
  stop_driver( Port ) ->
      { os_pid, Pid } = erlang:port_info( Port, os_pid ),
      erlang:port_close( Port ),
      % TODO - give the driver some time to finish cleanly
      case lurch_os:is_os_process_alive( Pid ) of
          true -> lurch_os:kill_os_process(9, Pid),
  
negative.code: stuck_test_() ->
      { ok, Port } = start_test_driver( "stuck.sh" ),
      { os_pid, OsPid } = erlang:port_info( Port, os_pid ),
      ResStop = stop_driver( Port ),
      IsOsPidAliveCmd = lists:flatten( io_lib:format("kill -0 ~b", [ OsPid ] ) ),
      [ { "stop driver", ?_assertEqual( ok, ResStop ) }
      , { "process killed", ?_assertCmdStatus( 1, IsOsPidAliveCmd ) }
      ].
  
  
  get_event_test_() ->
      { ok, Port } = start_test_driver( "echo.sh" ),
      Res = get_event( Port, "SomeEvent" ),
      ResStop = stop_driver( Port ),
      ExpData = { ok, [ "EVENT", "SomeEvent" ] },
      [ { "get event", ?_assertEqual( ExpData, Res ) }
      , { "stop driver", ?_assertEqual( ok, ResStop ) }
      ].
  
  
  