2
%% <year>2002-2008</year>
3
%% <holder>Ericsson AB, All Rights Reserved</holder>
6
%% ``The contents of this file are subject to the Erlang Public License,
4
%% Copyright Ericsson AB 2002-2009. All Rights Reserved.
6
%% The contents of this file are subject to the Erlang Public License,
7
7
%% Version 1.1, (the "License"); you may not use this file except in
8
8
%% compliance with the License. You should have received a copy of the
9
9
%% Erlang Public License along with this software. If not, it can be
10
10
%% retrieved online at http://www.erlang.org/.
12
12
%% Software distributed under the License is distributed on an "AS IS"
13
13
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14
14
%% the License for the specific language governing rights and limitations
15
15
%% under the License.
17
%% The Initial Developer of the Original Code is Ericsson AB.
20
19
-module(test_server_node).
24
%%% This code must be possible to load in both R10B and R11B.
25
%%% To make that possible:
27
%%% 1) No arithmetic instructions must be used. Use (id(erlang)):'+'/2
29
%%% 2) No bit syntax must be used.
23
%%% The same compiled code for this module must be possible to load
24
%%% in R11B, R12B and later. To make that possible no bit syntax
379
378
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
380
379
%%% Start slave/peer nodes (initiated by test_server:start_node/5)
382
start_node(SlaveName, slave, Options, From, TI) when list(SlaveName) ->
381
start_node(SlaveName, slave, Options, From, TI) when is_list(SlaveName) ->
383
382
start_node_slave(list_to_atom(SlaveName), Options, From, TI);
384
383
start_node(SlaveName, slave, Options, From, TI) ->
385
384
start_node_slave(SlaveName, Options, From, TI);
386
start_node(SlaveName, peer, Options, From, TI) when atom(SlaveName) ->
385
start_node(SlaveName, peer, Options, From, TI) when is_atom(SlaveName) ->
387
386
start_node_peer(atom_to_list(SlaveName), Options, From, TI);
388
387
start_node(SlaveName, peer, Options, From, TI) ->
389
388
start_node_peer(SlaveName, Options, From, TI);
886
885
random_element(L) ->
888
E = (id(erlang)):'rem'(lists:sum([A,B,C]), length(L)),
889
lists:nth((id(erlang)):'+'(E, 1), L).
887
E = lists:sum([A,B,C]) rem length(L),
891
890
find_release(latest) ->
892
891
"/usr/local/otp/releases/latest/bin/erl";
893
892
find_release(previous) ->
895
894
find_release(Rel) ->
897
"/usr/local/otp/releases/otp_beam_" ++ os(Rel) ++ "_" ++ Rel ++ "/bin/erl".
899
os(Rel) when Rel=="r5b01_patched";
903
Rel=="r7b01_patched";
910
Rel=="r9b_patched" ->
895
find_release(os:type(), Rel).
897
find_release({unix,sunos}, Rel) ->
898
case os:cmd("uname -p") of
900
"/usr/local/otp/releases/otp_beam_solaris8_" ++ Rel ++ "/bin/erl";
904
find_release({unix,linux}, Rel) ->
905
Candidates = find_rel_linux(Rel),
906
case lists:dropwhile(fun(N) ->
907
not filelib:is_regular(N)
912
find_release(_, _) -> none.
914
find_rel_linux(Rel) ->
915
case suse_release() of
917
SuseRel -> find_rel_suse(Rel, SuseRel)
920
find_rel_suse(Rel, SuseRel) ->
921
Root = "/usr/local/otp/releases/otp_beam_linux_sles",
924
%% Try both SuSE 11, SuSE 10 and SuSe 9 in that order.
925
find_rel_suse_1(Rel, Root++"11") ++
926
find_rel_suse_1(Rel, Root++"10") ++
927
find_rel_suse_1(Rel, Root++"9");
929
%% Try both SuSE 10 and SuSe 9 in that order.
930
find_rel_suse_1(Rel, Root++"10") ++
931
find_rel_suse_1(Rel, Root++"9");
933
find_rel_suse_1(Rel, Root++"9");
938
find_rel_suse_1(Rel, RootWc) ->
939
case erlang:system_info(wordsize) of
941
find_rel_suse_2(Rel, RootWc++"_i386");
943
find_rel_suse_2(Rel, RootWc++"_x64") ++
944
find_rel_suse_2(Rel, RootWc++"_i386")
947
find_rel_suse_2(Rel, RootWc) ->
948
Wc = RootWc ++ "_" ++ Rel,
949
case filelib:wildcard(Wc) of
953
[filename:join([R,"bin","erl"])]
956
%% suse_release() -> VersionString | none.
957
%% Return the major SuSE version number for this platform or
958
%% 'none' if this is not a SuSE platform.
960
case file:open("/etc/SuSE-release", [read]) of
971
case io:get_line(Fd, '') of
973
Line when is_list(Line) ->
974
case re:run(Line, "^VERSION\\s*=\\s*(\\d+)\s*",
975
[{capture,all_but_first,list}]) of
916
984
{One,Term} = split_binary(Bin, 1),