From e13c6510763f24dec76b1ce66b86ebbf7a84816d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Thu, 26 Mar 2015 15:32:26 +0100 Subject: Eliminate use of deprecated now/0 for random number generation Use erlang:timestamp/0 instead now/0 when seeding the random number generator. --- lib/stdlib/test/random_SUITE.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/stdlib/test/random_SUITE.erl') diff --git a/lib/stdlib/test/random_SUITE.erl b/lib/stdlib/test/random_SUITE.erl index ac9d1a6c06..22c0900651 100644 --- a/lib/stdlib/test/random_SUITE.erl +++ b/lib/stdlib/test/random_SUITE.erl @@ -82,7 +82,7 @@ seed(suite) -> []; seed(Config) when is_list(Config) -> ?line Self = self(), - ?line Seed = {S1, S2, S3} = now(), + Seed = {S1, S2, S3} = erlang:timestamp(), ?line _ = spawn(fun() -> random:seed(S1,S2,S3), Rands = lists:foldl(fun -- cgit v1.2.3 From 738c34d4bb8f1a3811acd00af8c6c12107f8315b Mon Sep 17 00:00:00 2001 From: Bruce Yinhe Date: Thu, 18 Jun 2015 11:31:02 +0200 Subject: Change license text to APLv2 --- lib/stdlib/test/random_SUITE.erl | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'lib/stdlib/test/random_SUITE.erl') diff --git a/lib/stdlib/test/random_SUITE.erl b/lib/stdlib/test/random_SUITE.erl index 22c0900651..738f73ae15 100644 --- a/lib/stdlib/test/random_SUITE.erl +++ b/lib/stdlib/test/random_SUITE.erl @@ -3,16 +3,17 @@ %% %% Copyright Ericsson AB 2000-2011. All Rights Reserved. %% -%% The contents of this file are subject to the Erlang Public License, -%% Version 1.1, (the "License"); you may not use this file except in -%% compliance with the License. You should have received a copy of the -%% Erlang Public License along with this software. If not, it can be -%% retrieved online at http://www.erlang.org/. -%% -%% Software distributed under the License is distributed on an "AS IS" -%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See -%% the License for the specific language governing rights and limitations -%% under the License. +%% Licensed under the Apache License, Version 2.0 (the "License"); +%% you may not use this file except in compliance with the License. +%% You may obtain a copy of the License at +%% +%% http://www.apache.org/licenses/LICENSE-2.0 +%% +%% Unless required by applicable law or agreed to in writing, software +%% distributed under the License is distributed on an "AS IS" BASIS, +%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +%% See the License for the specific language governing permissions and +%% limitations under the License. %% %% %CopyrightEnd% -- cgit v1.2.3 From 03fcb7dabf8861e60ffab4121a909b347bccfec9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Mon, 15 Feb 2016 15:33:12 +0100 Subject: Eliminate use of test_server.hrl and test_server_line.hrl As a first step to removing the test_server application as as its own separate application, change the inclusion of test_server.hrl to an inclusion of ct.hrl and remove the inclusion of test_server_line.hrl. --- lib/stdlib/test/random_SUITE.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/stdlib/test/random_SUITE.erl') diff --git a/lib/stdlib/test/random_SUITE.erl b/lib/stdlib/test/random_SUITE.erl index 738f73ae15..701a3e3f33 100644 --- a/lib/stdlib/test/random_SUITE.erl +++ b/lib/stdlib/test/random_SUITE.erl @@ -25,7 +25,7 @@ -export([init_per_testcase/2, end_per_testcase/2]). --include_lib("test_server/include/test_server.hrl"). +-include_lib("common_test/include/ct.hrl"). % Default timetrap timeout (set in init_per_testcase). -define(default_timeout, ?t:minutes(1)). -- cgit v1.2.3 From db87ef023f4660fd2129f30dbbff05e73bff3dd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Fri, 26 Feb 2016 06:47:38 +0100 Subject: Modernize use of timetraps Either rely on the default 30 minutes timetrap, or set the timeout using the supported methods in common_test. --- lib/stdlib/test/random_SUITE.erl | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'lib/stdlib/test/random_SUITE.erl') diff --git a/lib/stdlib/test/random_SUITE.erl b/lib/stdlib/test/random_SUITE.erl index 701a3e3f33..fe7189d91a 100644 --- a/lib/stdlib/test/random_SUITE.erl +++ b/lib/stdlib/test/random_SUITE.erl @@ -19,26 +19,23 @@ -module(random_SUITE). -export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1, + init_per_testcase/2, end_per_testcase/2, init_per_group/2,end_per_group/2]). -export([interval_1/1, seed0/1, seed/1]). --export([init_per_testcase/2, end_per_testcase/2]). -include_lib("common_test/include/ct.hrl"). -% Default timetrap timeout (set in init_per_testcase). --define(default_timeout, ?t:minutes(1)). - init_per_testcase(_Case, Config) -> - ?line Dog = ?t:timetrap(?default_timeout), - [{watchdog, Dog} | Config]. -end_per_testcase(_Case, Config) -> - Dog = ?config(watchdog, Config), - test_server:timetrap_cancel(Dog), + Config. + +end_per_testcase(_Case, _Config) -> ok. -suite() -> [{ct_hooks,[ts_install_cth]}]. +suite() -> + [{ct_hooks,[ts_install_cth]}, + {timetrap,{minutes,1}}]. all() -> [interval_1, seed0, seed]. -- cgit v1.2.3 From ec35c6439d3707801c7527dd2ea01ef0aa0421ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Thu, 25 Feb 2016 15:28:25 +0100 Subject: Eliminate use of test_server:fail/0,1 --- lib/stdlib/test/random_SUITE.erl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/stdlib/test/random_SUITE.erl') diff --git a/lib/stdlib/test/random_SUITE.erl b/lib/stdlib/test/random_SUITE.erl index fe7189d91a..02c2754a44 100644 --- a/lib/stdlib/test/random_SUITE.erl +++ b/lib/stdlib/test/random_SUITE.erl @@ -116,9 +116,9 @@ check_interval(N, Top) -> X = random:uniform(Top), if X < 1 -> - test_server:fail(too_small); + ct:fail(too_small); X > Top -> - test_server:fail(too_large); + ct:fail(too_large); true -> ok end, -- cgit v1.2.3 From 03ec5bc984264feee907408e720015e2bd9b6108 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Sun, 28 Feb 2016 14:10:25 +0100 Subject: Eliminate 'suite' and 'doc' clauses --- lib/stdlib/test/random_SUITE.erl | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'lib/stdlib/test/random_SUITE.erl') diff --git a/lib/stdlib/test/random_SUITE.erl b/lib/stdlib/test/random_SUITE.erl index 02c2754a44..d261b92514 100644 --- a/lib/stdlib/test/random_SUITE.erl +++ b/lib/stdlib/test/random_SUITE.erl @@ -56,10 +56,7 @@ end_per_group(_GroupName, Config) -> Config. -seed0(doc) -> - ["Test that seed is set implicitly, and always the same."]; -seed0(suite) -> - []; +%% Test that seed is set implicitly, and always the same. seed0(Config) when is_list(Config) -> ?line Self = self(), ?line _ = spawn(fun() -> Self ! random:uniform() end), @@ -74,10 +71,7 @@ seed0(Config) when is_list(Config) -> ?line F1 = F2, ok. -seed(doc) -> - ["Test that seed/1 and seed/3 is equivalent."]; -seed(suite) -> - []; +%% Test that seed/1 and seed/3 are equivalent. seed(Config) when is_list(Config) -> ?line Self = self(), Seed = {S1, S2, S3} = erlang:timestamp(), @@ -101,10 +95,7 @@ seed(Config) when is_list(Config) -> ok. -interval_1(doc) -> - ["Check that uniform/1 returns values within the proper interval."]; -interval_1(suite) -> - []; +%% Check that uniform/1 returns values within the proper interval. interval_1(Config) when is_list(Config) -> ?line Top = 7, ?line N = 10, -- cgit v1.2.3 From 33b414783b37dc0c242c729fa3fa843cd648e3e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Wed, 2 Mar 2016 06:50:54 +0100 Subject: Remove ?line macros While we are it, also re-ident the files. --- lib/stdlib/test/random_SUITE.erl | 64 ++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 32 deletions(-) (limited to 'lib/stdlib/test/random_SUITE.erl') diff --git a/lib/stdlib/test/random_SUITE.erl b/lib/stdlib/test/random_SUITE.erl index d261b92514..34b350e132 100644 --- a/lib/stdlib/test/random_SUITE.erl +++ b/lib/stdlib/test/random_SUITE.erl @@ -58,48 +58,48 @@ end_per_group(_GroupName, Config) -> %% Test that seed is set implicitly, and always the same. seed0(Config) when is_list(Config) -> - ?line Self = self(), - ?line _ = spawn(fun() -> Self ! random:uniform() end), - ?line F1 = receive - Fa -> Fa - end, - ?line _ = spawn(fun() -> random:seed(), - Self ! random:uniform() end), - ?line F2 = receive - Fb -> Fb - end, - ?line F1 = F2, + Self = self(), + _ = spawn(fun() -> Self ! random:uniform() end), + F1 = receive + Fa -> Fa + end, + _ = spawn(fun() -> random:seed(), + Self ! random:uniform() end), + F2 = receive + Fb -> Fb + end, + F1 = F2, ok. %% Test that seed/1 and seed/3 are equivalent. seed(Config) when is_list(Config) -> - ?line Self = self(), + Self = self(), Seed = {S1, S2, S3} = erlang:timestamp(), - ?line _ = spawn(fun() -> - random:seed(S1,S2,S3), - Rands = lists:foldl(fun - (_, Out) -> [random:uniform(10000)|Out] - end, [], lists:seq(1,100)), - Self ! {seed_test, Rands} - end), - ?line Rands1 = receive {seed_test, R1s} -> R1s end, - ?line _ = spawn(fun() -> - random:seed(Seed), - Rands = lists:foldl(fun - (_, Out) -> [random:uniform(10000)|Out] - end, [], lists:seq(1,100)), - Self ! {seed_test, Rands} - end), - ?line Rands2 = receive {seed_test, R2s} -> R2s end, - ?line Rands1 = Rands2, + _ = spawn(fun() -> + random:seed(S1,S2,S3), + Rands = lists:foldl(fun + (_, Out) -> [random:uniform(10000)|Out] + end, [], lists:seq(1,100)), + Self ! {seed_test, Rands} + end), + Rands1 = receive {seed_test, R1s} -> R1s end, + _ = spawn(fun() -> + random:seed(Seed), + Rands = lists:foldl(fun + (_, Out) -> [random:uniform(10000)|Out] + end, [], lists:seq(1,100)), + Self ! {seed_test, Rands} + end), + Rands2 = receive {seed_test, R2s} -> R2s end, + Rands1 = Rands2, ok. %% Check that uniform/1 returns values within the proper interval. interval_1(Config) when is_list(Config) -> - ?line Top = 7, - ?line N = 10, - ?line check_interval(N, Top), + Top = 7, + N = 10, + check_interval(N, Top), ok. check_interval(0, _) -> ok; -- cgit v1.2.3 From 6664eed554974336909d3ffe03f20349cc4c38fd Mon Sep 17 00:00:00 2001 From: Henrik Nord Date: Tue, 15 Mar 2016 15:19:56 +0100 Subject: update copyright-year --- lib/stdlib/test/random_SUITE.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/stdlib/test/random_SUITE.erl') diff --git a/lib/stdlib/test/random_SUITE.erl b/lib/stdlib/test/random_SUITE.erl index 34b350e132..e9aa00dac8 100644 --- a/lib/stdlib/test/random_SUITE.erl +++ b/lib/stdlib/test/random_SUITE.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2000-2011. All Rights Reserved. +%% Copyright Ericsson AB 2000-2016. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. -- cgit v1.2.3