anchor.diff:  timeout(normal) ->
       10000 * test_server:timetrap_scale_factor().
   
  -
  -%% start_noshell_node(Name) ->
  -%%     PADir =  filename:dirname(code:which(?MODULE)),
  -%%     {ok, Node} = test_server:start_node(Name,slave,[{args," -noshell -pa "++
  -%% 						     PADir++" "}]),
  -%%     Node.
  -%% stop_noshell_node(Node) ->
  -%%     test_server:stop_node(Node).
  -
  --ifndef(debug).
  -rm_rf(Dir) ->
  -    try
  -	{ok,List} = file:list_dir(Dir),
  -	Files = [filename:join([Dir,X]) || X <- List],
  -	[case file:list_dir(Y) of
  -	     {error, enotdir} ->
  -		 ok = file:delete(Y);
  -	     _ ->
  -		 ok = rm_rf(Y)
  -	 end || Y <- Files],
  -	ok = file:del_dir(Dir),
  -	ok
  -    catch
  -	_:Exception -> {error, {Exception,Dir}}
  -    end.
  --endif.       
  -
  -get_and_put(_CPid,[],_) ->
  -    ok;
  -get_and_put(CPid, [{sleep, X}|T],N) ->
  +send_commands(CPid, [{sleep, X}|T], N) ->
       ?dbg({sleep, X}),
       receive
       after X ->
  -	    get_and_put(CPid,T,N+1)
  +	    send_commands(CPid, T, N+1)
       end;
  -get_and_put(CPid, [{getline_pred,Pred,Msg}|T]=T0, N)
  -  when is_function(Pred) ->
  -    ?dbg({getline, Match}),
  -    CPid ! {self(), {get_line, timeout(normal)}},
  +send_commands(CPid, [{expect, Expect}|T], N) when is_list(Expect) ->
  +    ?dbg({expect, Expect}),
  +    case command(CPid, {expect, [Expect], timeout(normal)}) of
  +        ok ->
  +            send_commands(CPid, T, N + 1);
  +        {expect_timeout, Got} ->
  +            ct:pal("expect timed out waiting for ~p\ngot: ~p\n", [Expect,Got]),
  +            {error, timeout};
  +        Other ->
  +            Other
  +    end;
  +send_commands(CPid, [{putline, Line}|T], N) ->
  +    send_commands(CPid, [{putdata, Line ++ "\n"}|T], N);
  +send_commands(CPid, [{putdata, Data}|T], N) ->
  +    ?dbg({putdata, Data}),
  +    case command(CPid, {send_data, Data}) of
  +        ok ->
  +	    send_commands(CPid, T, N+1);
  +        Error ->
  +            Error
  +    end;
  +send_commands(_CPid, [], _) ->
  +    ok.
  +
  +command(Pid, Req) ->
  +    Timeout = timeout(longest),
  +    Ref = erlang:monitor(process, Pid),
  +    Pid ! {self(), Ref, Req},
       receive
  -	{get_line, timeout} ->
  -	    error_logger:error_msg("~p: getline timeout waiting for \"~s\" "
  -				   "(command number ~p, skipped: ~p)~n",
  -				   [?MODULE,Msg,N,get(getline_skipped)]),
  -	    {error, timeout};
  -	{get_line, Data} ->
  -	    ?dbg({data,Data}),
  -	    case Pred(Data) of
  -		yes ->
  -		    put(getline_skipped, []),
  -		    get_and_put(CPid, T,N+1);
  -		no ->
  -		    error_logger:error_msg("~p: getline match failure "
  -					   "\"~s\" "
  -					   "(command number ~p)\n",
  -					   [?MODULE,Msg,N]),
  -		    {error, no_match};
  -		'maybe' ->
  -		    List = get(getline_skipped),
  -		    put(getline_skipped, List ++ [Data]),
  -		    get_and_put(CPid, T0, N)
  -	    end
  -    end;
  -get_and_put(CPid, [{getline, Match}|T],N) ->
  -    ?dbg({getline, Match}),
  -    F = fun(Data) ->
  -		case lists:prefix(Match, Data) of
  -		    true -> yes;
  -		    false -> 'maybe'
  -		end
  -	end,
  -    get_and_put(CPid, [{getline_pred,F,Match}|T], N);
  -get_and_put(CPid, [{getline_re, Match}|T],N) ->
  -    F = fun(Data) ->
  -		case re:run(Data, Match, [{capture,none}]) of
  -		    match -> yes;
  -		    _ -> 'maybe'
  -		end
  -	end,
  -    get_and_put(CPid, [{getline_pred,F,Match}|T], N);
  -get_and_put(CPid, [{putline_raw, Line}|T],N) ->
  -    ?dbg({putline_raw, Line}),
  -    CPid ! {self(), {send_line, Line}},
  -    Timeout = timeout(normal),
  -    receive
  -	{send_line, ok} ->
  -	    get_and_put(CPid, T,N+1)
  +        {Ref, Reply} ->
  +            erlang:demonitor(Ref, [flush]),
  +            Reply;
  +        {'DOWN', Ref, _, _, Reason} ->
  +            {error, Reason}
       after Timeout ->
  -	    error_logger:error_msg("~p: putline_raw timeout (~p) sending "
  -				   "\"~s\" (command number ~p)~n",
  -				   [?MODULE, Timeout, Line, N]),
  -	    {error, timeout}
  -    end;
  -
  -get_and_put(CPid, [{putline, Line}|T],N) ->
  -    ?dbg({putline, Line}),
  -    CPid ! {self(), {send_line, Line}},
  -    Timeout = timeout(normal),
  -    receive
  -	{send_line, ok} ->
  -	    get_and_put(CPid, [{getline, []}|T],N)
  -    after Timeout ->
  -	    error_logger:error_msg("~p: putline timeout (~p) sending "
  -				   "\"~s\" (command number ~p)~n[~p]~n",
  -				   [?MODULE, Timeout, Line, N,get()]),
  -	    {error, timeout}
  +            io:format("timeout while executing ~p\n", [Req]),
  +            {error, timeout}
       end.
   
   wait_for_runerl_server(SPid) ->
  -    Ref = erlang:monitor(process, SPid), 
  +    Ref = erlang:monitor(process, SPid),
       Timeout = timeout(long),
       receive
  -	{'DOWN', Ref, process, SPid, _} ->
  +	{'DOWN', Ref, process, SPid, _Reason} ->
   	    ok
       after Timeout ->
  -	    {error, timeout}
  -    end.
  -
  -
  +	    {error, runerl_server_timeout}
  +    end.
   
   stop_runerl_node(CPid) ->
       Ref = erlang:monitor(process, CPid),
       CPid ! {self(), kill_emulator},
  -    Timeout = timeout(long),
  +    Timeout = timeout(longest),
       receive
   	{'DOWN', Ref, process, CPid, noproc} ->
   	    ok;
  
positive.code:     TestDataLine1BinUtf = unicode:characters_to_binary(TestDataLine1),
      TestDataLine1BinLatin = list_to_binary(TestDataLine1),
  
      {ok,N2List} = create_nodename(),
      MyNodeList = atom2list(node()),
      register(io_proto_suite,self()),
      AM1 = spawn(?MODULE,Machine,
  
negative.code:     TestDataUtf = binary_to_list(unicode:characters_to_binary(TestDataLine1)),
      rtnode([{putline,""},
  	    {putline, "2."},
  	    {expect, "2"},
  	    {putline, "{"++OthReg++","++OthNode++"} ! group_leader()."},
  	    {expect, ".*<[0-9].*"},
  	    %% get_line
  	    {expect, ".*Prompt"},
  	    {putline, "Hej"},
  	    {expect, ".*Okej"},
  	    {expect, ".*Prompt"},
  	    {putline, "Hej"},
  	    {expect, ".*Okej"},
  	    {expect, ".*Prompt"},
  	    {putline, TestDataLine1},
  	    {expect, ".*Okej"},
  	    {expect, ".*Prompt"},
  	    {putline, TestDataLine1},
  	    {expect, ".*Okej"},
  	    {expect, ".*Prompt"},
  	    {putline, TestDataUtf},
  	    {expect, ".*Okej"},
  	    {expect, ".*Prompt"},
  	    {putline, TestDataUtf},
  	    {expect, ".*Okej"},
  	    %% get_chars
  	    {expect, ".*Prompt"},
  	    {putline, "Hej"},
  	    {expect, ".*Okej"},
  	    {expect, ".*Prompt"},
  	    {putline, "Hej"},
  	    {expect, ".*Okej"},
  	    {expect, ".*Prompt"},
  	    {putline, TestDataLine1},
  	    {expect, ".*Okej"},
  	    {expect, ".*Prompt"},
  	    {putline, TestDataLine1},
  	    {expect, ".*Okej"},
  	    {expect, ".*Prompt"},
  	    {putline, TestDataUtf},
  	    {expect, ".*Okej"},
  	    {expect, ".*Prompt"},
  	    {putline, TestDataUtf},
  	    {expect, ".*Okej"},
  	    %% fread
  	    {expect, ".*Prompt"},
  	    {putline, "Hej"},
  	    {expect, ".*Okej"},
  	    {expect, ".*Prompt"},
  	    {putline, "Hej"},
  	    {expect, ".*Okej"},
  	    {expect, ".*Prompt"},
  	    {putline, TestDataLine1},
  	    {expect, ".*Okej"},
  	    {expect, ".*Prompt"},
  	    {putline, TestDataLine1},
  	    {expect, ".*Okej"},
  	    {expect, ".*Prompt"},
  	    {putline, TestDataUtf},
  	    {expect, ".*Okej"},
  	    {expect, ".*Prompt"},
  	    {putline, TestDataUtf},
  	    {expect, ".*Okej"}
  
  	   ],Me,"",["-oldshell","-env","LC_ALL",get_lc_ctype()]),
      O = list_to_atom(OthReg),
      O ! {self(),done},
      ok.
  