diff options
author | Björn Gustavsson <[email protected]> | 2015-12-04 12:15:40 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2015-12-11 14:37:46 +0100 |
commit | 80757f9491c72ee262a5910e0b3b02e95b1e5f2a (patch) | |
tree | 1019a6da73ac28571a0b51727ed6fa33daf11522 /lib/test_server | |
parent | dee396ffd32dcd68c47cab983c75ba32f921b9db (diff) | |
download | otp-80757f9491c72ee262a5910e0b3b02e95b1e5f2a.tar.gz otp-80757f9491c72ee262a5910e0b3b02e95b1e5f2a.tar.bz2 otp-80757f9491c72ee262a5910e0b3b02e95b1e5f2a.zip |
Use 'rand' instead of the obsolete 'random' module
In most cases, we don't have to seed the random number generator,
as the rand:uniform/1 takes care about that itself.
Diffstat (limited to 'lib/test_server')
-rw-r--r-- | lib/test_server/src/test_server_ctrl.erl | 14 | ||||
-rw-r--r-- | lib/test_server/src/test_server_node.erl | 3 |
2 files changed, 11 insertions, 6 deletions
diff --git a/lib/test_server/src/test_server_ctrl.erl b/lib/test_server/src/test_server_ctrl.erl index 0be6e0b4e4..34681876f3 100644 --- a/lib/test_server/src/test_server_ctrl.erl +++ b/lib/test_server/src/test_server_ctrl.erl @@ -3163,11 +3163,17 @@ delete_prop([], Props) -> %% Shuffles the order of Cases. shuffle_cases(Ref, Cases, undefined) -> - shuffle_cases(Ref, Cases, ?now); + shuffle_cases(Ref, Cases, rand:seed_s(exsplus)); -shuffle_cases(Ref, [{conf,Ref,_,_}=Start | Cases], Seed) -> +shuffle_cases(Ref, [{conf,Ref,_,_}=Start | Cases], Seed0) -> {N,CasesToShuffle,Rest} = cases_to_shuffle(Ref, Cases), - ShuffledCases = random_order(N, random:uniform_s(N, Seed), CasesToShuffle, []), + Seed = case Seed0 of + {X,Y,Z} when is_integer(X+Y+Z) -> + rand:seed(exsplus, Seed0); + _ -> + Seed0 + end, + ShuffledCases = random_order(N, rand:uniform_s(N, Seed), CasesToShuffle, []), [Start|ShuffledCases] ++ Rest. cases_to_shuffle(Ref, Cases) -> @@ -3201,7 +3207,7 @@ random_order(1, {_Pos,Seed}, [{_Ix,CaseOrGroup}], Shuffled) -> Shuffled++CaseOrGroup; random_order(N, {Pos,NewSeed}, IxCases, Shuffled) -> {First,[{_Ix,CaseOrGroup}|Rest]} = lists:split(Pos-1, IxCases), - random_order(N-1, random:uniform_s(N-1, NewSeed), + random_order(N-1, rand:uniform_s(N-1, NewSeed), First++Rest, Shuffled++CaseOrGroup). diff --git a/lib/test_server/src/test_server_node.erl b/lib/test_server/src/test_server_node.erl index 4e6839fc6b..3419f3f5d0 100644 --- a/lib/test_server/src/test_server_node.erl +++ b/lib/test_server/src/test_server_node.erl @@ -619,8 +619,7 @@ do_quote_progname([Prog,Arg|Args]) -> end. random_element(L) -> - random:seed(os:timestamp()), - lists:nth(random:uniform(length(L)), L). + lists:nth(rand:uniform(length(L)), L). find_release(latest) -> "/usr/local/otp/releases/latest/bin/erl"; |