anchor.diff:      ssh:stop().
   
   %%-------------------------------------------------------------------------
  +%% Help macro
  +%%-------------------------------------------------------------------------
  +-define(wait_match(Pattern, FunctionCall, Bind),
  +	Bind = 
  +	    (fun() -> 
  +		     F = fun(N, F1) ->
  +				 case FunctionCall of
  +				     Pattern -> Bind;
  +				     _ when N>0 ->
  +					 ct:pal("Must sleep ~p ms at ~p:~p",[?WAIT_FOR_SHUTDOWN,?MODULE,?LINE]),
  +					 timer:sleep(?WAIT_FOR_SHUTDOWN),
  +					 F1(N-1, F1);
  +				     Other ->  
  +					 ct:fail("Unexpected ~p:~p  ~p",[?MODULE,?LINE,Other])
  +				 end
  +			 end,
  +		     F((5000 div ?WAIT_FOR_SHUTDOWN), F)
  +	     end)()
  +       ).
  +
  +-define(wait_match(Pattern, FunctionCall), ?wait_match(Pattern, FunctionCall, ok)).
  +
  +%%-------------------------------------------------------------------------
   %% Test cases 
   %%-------------------------------------------------------------------------
   default_tree() ->
  
positive.code: 	lists:keysearch(sshc_sup, 1, TopSupChildren),
      {value, {sshd_sup, _,supervisor,[sshd_sup]}} = 
  	lists:keysearch(sshd_sup, 1, TopSupChildren),
      [] = supervisor:which_children(sshc_sup),
      [] = supervisor:which_children(sshd_sup).
  
  sshc_subtree() ->
      [{doc, "Make sure the sshc subtree is correct"}].
  
negative.code:     {_Pid, Host, Port} = ?config(server, Config),
      UserDir = ?config(userdir, Config),
  
      ?wait_match([], supervisor:which_children(sshc_sup)),
  
      {ok, Pid1} = ssh:connect(Host, Port, [{silently_accept_hosts, true},
  					  {user_interaction, false},
  					  {user, ?USER}, {password, ?PASSWD},{user_dir, UserDir}]),
      ?wait_match([{_, _,supervisor,[ssh_connection_handler]}],
  		supervisor:which_children(sshc_sup)),
  
      {ok, Pid2} = ssh:connect(Host, Port, [{silently_accept_hosts, true},
  					  {user_interaction, false},
  					  {user, ?USER}, {password, ?PASSWD}, {user_dir, UserDir}]),
      ?wait_match([{_,_,supervisor,[ssh_connection_handler]}, 
  		 {_,_,supervisor,[ssh_connection_handler]}],
  		supervisor:which_children(sshc_sup)),
  
      ssh:close(Pid1),
      ?wait_match([{_,_,supervisor,[ssh_connection_handler]}],
  		supervisor:which_children(sshc_sup)),
      ssh:close(Pid2),
      ?wait_match([], supervisor:which_children(sshc_sup)).
  
  sshd_subtree() ->
      [{doc, "Make sure the sshd subtree is correct"}].
  