anchor.diff:      end.
       
   
  -    
  +    ts_extra_flatform_label() ->
  +    case os:getenv("TS_EXTRA_PLATFORM_LABEL") of
  +        false -> "-";
  +        Val   -> Val
  +    end.
  +
  +simplify_label("Systemtap" ++ _) ->
  +    {host, systemtap};
  +simplify_label("Meamax" ++ _) ->
  +    {host, meamax};
  +simplify_label("Cover" ++ _) ->
  +    {host, cover};
  +simplify_label(Label) ->
  +    case string:find(string:to_lower(Label), "docker") of
  +        "docker" ++ _ ->
  +            docker;
  +        _ ->
  +            {host, undefined}
  +    end.
  +
  +label2factor(docker) ->
  +    4;
  +label2factor({host, meamax}) ->
  +    2;
  +label2factor({host, cover}) ->
  +    6;
  +label2factor({host, _}) ->
  +    0.
  +
   linux_which_distro(Version) ->
  -    try do_linux_which_distro(Version)
  +    Label = ts_extra_flatform_label(),
  +    Checks =
  +        [fun() -> do_linux_which_distro_os_release(Version,     Label) end,
  +         fun() -> do_linux_which_distro_suse_release(Version,   Label) end,
  +         fun() -> do_linux_which_distro_fedora_release(Version, Label) end,
  +         fun() -> do_linux_which_distro_issue(Version,          Label) end],
  +    try linux_which_distro("", Version, Label, Checks)
       catch
           throw:{distro, Distro} ->
               Distro
       end.
   
  -do_linux_which_distro(Version) ->
  -    %% There are a bunch of info file to check:
  -    %% /etc/os-release     (openSUSE, ...)
  -    %% /etc/issue          (debian, ...)
  -    %% /etc/fedora-release (Fedora)
  -    %% /etc/SuSE-release   (SLES/SLED and old openSUSE)
  -    %% We try them, one at a time. If they get info, they throw
  -    %% {distro, <distro tag>}, otherwise {error, <someting>},
  -    %% and we continue until the end, when we return with 'other'.
  -    retry = try_distro_file("os-release",
  -			    fun() -> do_linux_which_distro_os_release(Version) end),
  -    retry = try_distro_file("suse-release",
  -			    fun() -> do_linux_which_distro_suse_release(Version) end),
  -    retry = try_distro_file("fedora-release",
  -			    fun() -> do_linux_which_distro_fedora_release(Version) end),
  -    retry = try_distro_file("issue",
  -			    fun() -> do_linux_which_distro_issue(Version) end),
  +linux_which_distro("", Version, Label, []) ->
       io:format("Linux: ~s"
  -              "~n", [Version]),
  -    other.
  -
  -try_distro_file(_File, F) ->
  -    %% io:format("try distro file ~s~n", [_File]),
  -    try F()
  +              "~n   Label:        ~s"
  +              "~n   Product Name: ~s"
  +              "~n", [Version, Label,
  +                     linux_product_name()]),    
  +    {other, simplify_label(Label)};
  +linux_which_distro(DestroStr, Version, Label, []) ->
  +    io:format("Linux: ~s"
  +              "~n   Distro:       ~s"
  +              "~n   Label:        ~s"
  +              "~n   Product Name: ~s"
  +              "~n", [Version, DestroStr, Label,
  +                     linux_product_name()]),    
  +    {other, simplify_label(Label)};
  +linux_which_distro(Default, Version, Label, [Check|Checks]) ->
  +    try Check() of
  +        DistroStr when is_list(DistroStr) ->
  +            linux_which_distro(DistroStr, Version, Label, Checks);
  +        retry ->
  +            linux_which_distro(Default, Version, Label, Checks);
  +        {error, _Reason} ->
  +            linux_which_distro(Default, Version, Label, Checks)
       catch
  -	throw:{error,  _Reason} ->
  -	    retry
  -    end.
  -
  -do_linux_which_distro_os_release(Version) ->
  +        throw:{error, _Reason} ->
  +	    linux_which_distro(Default, Version, Label, Checks)
  +    end.
  +       
  +
  +do_linux_which_distro_os_release(Version, Label) ->
       case file:read_file_info("/etc/os-release") of
   	{ok, _} ->
  -	    %% The lines in this file are like this:
  -	    %%   NAME="openSUSE Leap"
  -	    %% So, this fun splits each line into
  -	    %%   {NAME, Value}
  -	    Split =
  -		fun(S) ->
  -			case string:tokens(S, [$=]) of
  -			    [Token, Value] ->
  -				{Token, string:strip(Value, both, $")};
  -
  -			    %% We keep these for debugging
  -			    [Token | Values] ->
  -				{bad_format, {Token, Values}};
  -			    _ ->
  -				{bad_format, S}
  -			end
  -		end,
  -	    Info =
  -		[Split(S) ||
  -		    S <- string:tokens(os:cmd("cat /etc/os-release"), [$\n])],
  -	    DistroStr =
  -		case lists:keysearch("NAME", 1, Info) of
  -		    {value, {_, DValue}} ->
  -			DValue;
  -		    false ->
  -			throw({error, no_distro})
  -		end,
  -	    DistroVersion =
  -		case lists:keysearch("VERSION", 1, Info) of
  -		    {value, {_, DVValue}} ->
  -			DVValue;
  -		    false ->
  -			throw({error, no_distro_version})
  -		end,
  -	    case DistroStr of
  -		"openSUSE" ++ _ ->
  +            %% We want to 'catch' if our processing is wrong,
  +            %% that's why we catch and re-throw the distro.
  +            %% Actual errors will be returned as 'ignore'.
  +            try
  +                begin
  +                    Info = linux_process_os_release(),
  +                    {value, {_, DistroStr}} = lists:keysearch(name, 1, Info),
  +                    {value, {_, VersionNo}} = lists:keysearch(version, 1, Info),
                       io:format("Linux: ~s"
  -                              "~n   Distro:         ~s"
  -                              "~n   Distro Version: ~s"
  +                              "~n   Distro:                  ~s"
  +                              "~n   Distro Version:          ~s"
  +                              "~n   TS Extra Platform Label: ~s"
  +                              "~n   Product Name:            ~s"
                                 "~n",
  -                              [Version, DistroStr, DistroVersion]),
  -		    throw({distro, opensuse});
  -		"SLES" ++ _ ->
  -                    io:format("Linux: ~s"
  -                              "~n   Distro:         ~s"
  -                              "~n   Distro Version: ~s"
  -                              "~n",
  -                              [Version, DistroStr, DistroVersion]),
  -		    throw({distro, sles});
  -		"Fedora" ++ _ ->
  -                    io:format("Linux: ~s"
  -                              "~n   Distro:         ~s"
  -                              "~n   Distro Version: ~s"
  -                              "~n",
  -                              [Version, DistroStr, DistroVersion]),
  -		    throw({distro, fedora});
  -		"Linux Mint" ++ _ ->
  -                    io:format("Linux: ~s"
  -                              "~n   Distro:         ~s"
  -                              "~n   Distro Version: ~s"
  -                              "~n",
  -                              [Version, DistroStr, DistroVersion]),
  -		    throw({distro, linuxmint});
  -		"Ubuntu" ++ _ ->
  -                    io:format("Linux: ~s"
  -                              "~n   Distro:         ~s"
  -                              "~n   Distro Version: ~s"
  -                              "~n",
  -                              [Version, DistroStr, DistroVersion]),
  -		    throw({distro, ubuntu});
  -		_Unknown ->
  -		    throw({error, unknown_distro})
  -	    end;
  -	_X ->
  -	    throw({error, not_found})
  +                              [Version, DistroStr, VersionNo, Label,
  +                               linux_product_name()]),
  +                    throw({distro,
  +                           {linux_distro_str_to_distro_id(DistroStr),
  +                            simplify_label(Label)}})
  +                end
  +            catch
  +                throw:{distro, _} = DISTRO ->
  +                    throw(DISTRO);
  +                _:_ ->
  +                    retry
  +            end;
  +        _ ->
  +            retry
       end.
   	    
   
  -do_linux_which_distro_fedora_release(Version) ->
  +linux_process_os_release() ->
  +    %% Read the "raw" file
  +    Raw = os:cmd("cat /etc/os-release"),
  +    %% Split it into lines
  +    Lines1 = string:tokens(Raw, [$\n]),
  +    %% Just in case, skip any lines starting with '#'.
  +    Lines2 = linux_process_os_release1(Lines1),
  +    %% Each (remaining) line *should* be: <TAG>=<VALUE>
  +    %% Both sides will be strings, the value side will be a quoted string...
  +    %% Convert those into a 2-tuple list: [{Tag, Value}]
  +    linux_process_os_release2(Lines2).
  +
  +linux_process_os_release1(Lines) ->
  +    linux_process_os_release1(Lines, []).
  +
  +linux_process_os_release1([], Acc) ->
  +    lists:reverse(Acc);
  +linux_process_os_release1([H|T], Acc) ->
  +    case H of
  +        "#" ++ _ ->
  +            linux_process_os_release1(T, Acc);
  +        _ ->
  +            linux_process_os_release1(T, [H|Acc])
  +    end.
  +
  +linux_process_os_release2(Lines) ->
  +    linux_process_os_release2(Lines, []).
  +
  +linux_process_os_release2([], Acc) ->
  +    lists:reverse(Acc);
  +linux_process_os_release2([H|T], Acc) ->
  +    case linux_process_os_release3(H) of
  +        {value, Value} ->
  +            linux_process_os_release2(T, [Value|Acc]);
  +        false ->
  +            linux_process_os_release2(T, Acc)
  +    end.
  +
  +linux_process_os_release3(H) ->
  +    case [string:strip(S) || S <- string:tokens(H, [$=])] of
  +        [Tag, Value] ->
  +            Tag2   = list_to_atom(string:to_lower(Tag)),
  +            Value2 = string:strip(Value, both, $"),
  +            linux_process_os_release4(Tag2, Value2);
  +        _ ->
  +            false
  +    end.
  +
  +linux_process_os_release4(name = Tag, Value) ->
  +    {value, {Tag, Value}};
  +linux_process_os_release4(version = Tag, Value) ->
  +    {value, {Tag, Value}};
  +linux_process_os_release4(version_id = Tag, Value) ->
  +    {value, {Tag, Value}};
  +linux_process_os_release4(id = Tag, Value) ->
  +    {value, {Tag, Value}};
  +linux_process_os_release4(pretty_name = Tag, Value) ->
  +    {value, {Tag, Value}};
  +linux_process_os_release4(_Tag, _Value) ->
  +    false.
  +
  +linux_distro_str_to_distro_id("Debian" ++ _) ->
  +    debian;
  +linux_distro_str_to_distro_id("Fedora" ++ _) ->
  +    fedora;
  +linux_distro_str_to_distro_id("Linux Mint" ++ _) ->
  +    linux_mint;
  +linux_distro_str_to_distro_id("MontaVista" ++ _) ->
  +    montavista;
  +linux_distro_str_to_distro_id("openSUSE" ++ _) ->
  +    suse;
  +linux_distro_str_to_distro_id("SLES" ++ _) ->
  +    sles;
  +linux_distro_str_to_distro_id("Ubuntu" ++ _) ->
  +    ubuntu;
  +linux_distro_str_to_distro_id("Wind River Linux" ++ _) ->
  +    wind_river;
  +linux_distro_str_to_distro_id("Yellow Dog" ++ _) ->
  +    yellow_dog;
  +linux_distro_str_to_distro_id(X) ->
  +    X.
  +
  +
  +do_linux_which_distro_fedora_release(Version, Label) ->
       %% Check if fedora
       case file:read_file_info("/etc/fedora-release") of
           {ok, _} ->
  
positive.code:                 if
                      (BogoMIPS > 50000) ->
                          1;
                      (BogoMIPS > 30000) ->
                          2;
                      (BogoMIPS > 10000) ->
                          3;
                      (BogoMIPS > 5000) ->
                          5;
                      (BogoMIPS > 3000) ->
                          8;
                      true ->
                          10
                  end;
  
negative.code:          init_per_testcase/2, end_per_testcase/2]).
  
  -export([proxy_init/2]).
  
  %% Convenient exports...
  -export([analyze_and_print_host_info/0]).
  
  -include("megaco_test_lib.hrl").
  
  