anchor.diff:      TestDataLine1BinUtf = unicode:characters_to_binary(TestDataLine1),
       TestDataLine1BinLatin = list_to_binary(TestDataLine1),
   
  -    {ok,N2List} = create_nodename(),
  +    N2List = peer:random_name(?FUNCTION_NAME),
       MyNodeList = atom2list(node()),
       register(io_proto_suite,self()),
       AM1 = spawn(?MODULE,Machine,
  
positive.code: 				   true -> Nodename
  				end)++
  		       " -setcookie "++atom_to_list(erlang:get_cookie())
  	   end,
      XXArg = case Extra of
  		[] ->
  		    [];
  		_ ->
  		    " "++Extra
  	    end,
      spawn(fun() ->
  		  ?dbg("\""++RunErl++"\" "++Tempdir++"/ "++Tempdir++
  			   " \""++Erl++XArg++XXArg++"\""),
  		  os:cmd("\""++RunErl++"\" "++Tempdir++"/ "++Tempdir++
  			     " \""++Erl++XArg++XXArg++"\"")
  	  end).
  
  start_toerl_server(ToErl,Tempdir) ->
      Pid = spawn(?MODULE,toerl_server,[self(),ToErl,Tempdir]),
      receive
  	{Pid,started} ->
  	    Pid;
  
negative.code: 	    exit(Reason)
      end.
  
  toerl_loop(#{port := Port} = State0) ->
      ?dbg({toerl_loop, Port, map_get(acc, State0),
            maps:get(match, State0, nomatch)}),
  
      State = handle_expect(State0),
  
      receive
  	{Port,{data,Data}} when is_port(Port) ->
  	    ?dbg({?LINE,Port,{data,Data}}),
              toerl_loop(State#{acc => map_get(acc, State) ++ Data});
          {Pid, Ref, {expect, Expect, Timeout}} ->
              toerl_loop(init_expect(Pid, Ref, Expect, Timeout, State));
          {Pid, Ref, {send_data, Data}} ->
  	    ?dbg({?LINE,Port,{send_data,Data}}),
              Port ! {self(), {command, Data}},
  	    Pid ! {Ref, ok},
  	    toerl_loop(State);
  	{_Pid, kill_emulator} ->
              kill_emulator(State);
          {timeout,Timer,expect_timeout} ->
              toerl_loop(handle_expect_timeout(Timer, State));
  	{Port, eof} ->
  	    {error, unexpected_eof};
  	Other ->
  	    {error, {unexpected, Other}}
      end.
  
  kill_emulator(#{spid := SPid, port := Port}) when is_pid(SPid) ->
      catch peer:stop(SPid),
      wait_for_eof(Port);
  kill_emulator(#{port := Port}) ->
      %% If the line happens to end in a ".", issuing "init:stop()."
      %% will result in a syntax error.  To avoid that, issue a "\n"
      %% before "init:stop().".
      Port ! {self(),{command, "\ninit:stop().\n"}},
      wait_for_eof(Port).
  
  wait_for_eof(Port) ->
      receive
          {Port,eof} ->
              normal;
          _Other ->
              wait_for_eof(Port)
      after
          timeout(long) ->
              {error, kill_timeout}
      end.
  
  init_expect(Pid, Ref, ExpectList, Timeout, State) ->
      try compile_expect(ExpectList) of
          Expect ->
              Exp = #{expect => Expect,
                      ref => Ref,
                      source => ExpectList,
                      timer => erlang:start_timer(Timeout, self(), expect_timeout),
                      from => Pid},
              State#{expect => Exp}
      catch
          Class:Reason:Stk ->
              io:put_chars("Compilation of expect pattern failed:"),
              io:format("~p\n", [ExpectList]),
              io:put_chars(erl_error:format_exception(Class, Reason, Stk)),
              exit(expect_pattern_error)
      end.
  
  handle_expect(#{acc := Acc, expect := Exp} = State) ->
      #{expect := Expect, from := Pid, ref := Ref} = Exp,
      case Expect(Acc) of
          nomatch ->
              State;
          {matched, Eaten, Result} ->
              Pid ! {Ref, Result},
              finish_expect(Eaten, State)
      end;
  handle_expect(State) ->
      State.
  
  handle_expect_timeout(Timer, State) ->
      #{acc := Acc, expect := Exp} = State,
      #{expect := Expect, timer := Timer, from := Pid, ref := Ref} = Exp,
      case Expect({timeout, Acc}) of
          nomatch ->
              Result = {expect_timeout, Acc},
              Pid ! {Ref, Result},
              finish_expect(0, State);
          {matched, Eaten, Result} ->
              Pid ! {Ref, Result},
              finish_expect(Eaten, State)
      end.
  
  finish_expect(Eaten, #{acc := Acc0,
                         expect := #{timer := Timer}}=State) ->
      erlang:cancel_timer(Timer),
      receive
          {timeout,Timer,timeout} ->
              ok
      after 0 ->
              ok
      end,
      Acc = lists:nthtail(Eaten, Acc0),
      maps:remove(expect, State#{acc := Acc}).
  
  compile_expect([{timeout,Action}|T]) when is_function(Action, 1) ->
      Next = compile_expect(T),
      fun({timeout, _}=Tm) ->
              {matched, 0, Action(Tm)};
         (Subject) ->
              Next(Subject)
      end;
  compile_expect([{{re,RE0},Action}|T]) when is_binary(RE0), is_function(Action, 1) ->
      {ok, RE} = re:compile(RE0),
      Next = compile_expect(T),
      fun({timeout, _}=Subject) ->
              Next(Subject);
         (Subject) ->
              case re:run(Subject, RE, [{capture,first,index}]) of
                  nomatch ->
                      Next(Subject);
                  {match, [{Pos,Len}]} ->
                      Matched = binary:part(list_to_binary(Subject), Pos, Len),
                      {matched, Pos+Len, Action(Matched)}
              end
      end;
  compile_expect([RE|T]) when is_list(RE) ->
      Ok = fun(_) -> ok end,
      compile_expect([{{re,list_to_binary(RE)},Ok}|T]);
  compile_expect([]) ->
      fun(_) ->
              nomatch
      end.
  
  rtnode_check_logs(Logname, Pattern, Logs) ->
  rtnode_check_logs(Logname, Pattern, true, Logs).
  rtnode_check_logs(Logname, Pattern, Match, Logs) ->
          case re:run(maps:get(Logname, Logs), Pattern) of
              {match, [_]} when Match ->
                  ok;
              nomatch when not Match ->
                  ok;
              _ ->
                  rtnode_dump_logs(Logs),
                  ct:fail("~p not found in log ~ts",[Pattern, Logname])
          end.
  
  rtnode_dump_logs(Logs) ->
      maps:foreach(
        fun(File, Data) ->
                ct:pal("~ts: ~ts",[File, Data])
        end, Logs).
  
  rtnode_read_logs(Tempdir) ->
      {ok, LogFiles0} = file:list_dir(Tempdir),
  
      %% Make sure that we only read log files and not any named pipes.
      LogFiles = [F || F <- LogFiles0,
                       case F of
                           "erlang.log" ++ _ -> true;
                           _ -> false
                       end],
  
      lists:foldl(
        fun(File, Acc) ->
                case file:read_file(filename:join(Tempdir, File)) of
                    {ok, Data} ->
                        Acc#{ File => Data };
                    _ ->
                        Acc
                end
        end, #{}, LogFiles).
  
  get_default_shell() ->
      try
          rtnode([{putline,""},
                  {putline, "is_pid(whereis(user_drv))."},
                  {expect, "true\r\n"}]),
          new
      catch _E:_R ->
              ?dbg({_E,_R}),
              old
      end.
  
  %%
  