From c062dfc485ad0d51d648701950f77ef8f51d4f35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn-Egil=20Dahlberg?= Date: Tue, 8 Mar 2016 19:35:31 +0100 Subject: Modernize use of timetraps --- erts/emulator/test/big_SUITE.erl | 30 +++++------------------------- 1 file changed, 5 insertions(+), 25 deletions(-) (limited to 'erts/emulator/test/big_SUITE.erl') diff --git a/erts/emulator/test/big_SUITE.erl b/erts/emulator/test/big_SUITE.erl index bb77235253..9b611a136c 100644 --- a/erts/emulator/test/big_SUITE.erl +++ b/erts/emulator/test/big_SUITE.erl @@ -20,8 +20,8 @@ -module(big_SUITE). --export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1, - init_per_group/2,end_per_group/2]). +-export([all/0, suite/0, groups/0]). + -export([t_div/1, eq_28/1, eq_32/1, eq_big/1, eq_math/1, big_literals/1, borders/1, negative/1, big_float_1/1, big_float_2/1, shift_limit_1/1, powmod/1, system_limit/1, toobig/1, otp_6692/1]). @@ -32,11 +32,12 @@ -export([fac/1, fib/1, pow/2, gcd/2, lcm/2]). --export([init_per_testcase/2, end_per_testcase/2]). -include_lib("common_test/include/ct.hrl"). -suite() -> [{ct_hooks,[ts_install_cth]}]. +suite() -> + [{ct_hooks,[ts_install_cth]}, + {timetrap, {minutes, 3}}]. all() -> [t_div, eq_28, eq_32, eq_big, eq_math, big_literals, @@ -46,27 +47,6 @@ all() -> groups() -> [{big_float, [], [big_float_1, big_float_2]}]. -init_per_suite(Config) -> - Config. - -end_per_suite(_Config) -> - ok. - -init_per_group(_GroupName, Config) -> - Config. - -end_per_group(_GroupName, Config) -> - Config. - - -init_per_testcase(Func, Config) when is_atom(Func), is_list(Config) -> - Dog=?t:timetrap(?t:minutes(3)), - [{watchdog, Dog}|Config]. - -end_per_testcase(_Func, Config) -> - Dog=?config(watchdog, Config), - ?t:timetrap_cancel(Dog). - %% %% Syntax of data files: %% Expr1 = Expr2. -- cgit v1.2.3 From 9b6b82abfaae479849902ba60c4c54a526840a03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn-Egil=20Dahlberg?= Date: Tue, 8 Mar 2016 21:01:40 +0100 Subject: Eliminate use of test_server:fail/0,1 --- erts/emulator/test/big_SUITE.erl | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'erts/emulator/test/big_SUITE.erl') diff --git a/erts/emulator/test/big_SUITE.erl b/erts/emulator/test/big_SUITE.erl index 9b611a136c..37e90df60e 100644 --- a/erts/emulator/test/big_SUITE.erl +++ b/erts/emulator/test/big_SUITE.erl @@ -104,7 +104,7 @@ test(File, Nodes) -> file:close(Fd), case Res of {0,Cases} -> {comment, integer_to_list(Cases) ++ " cases"}; - {_,_} -> test_server:fail() + {_,_} -> ct:fail("failed") end. test(File, Fd, Ns) -> @@ -245,8 +245,7 @@ t_div(Config) when is_list(Config) -> {result, Result} -> 'try'(Iter-1, Fun, Result, [0|Filler]); {result, Other} -> - io:format("Expected ~p; got ~p~n", [Result, Other]), - test_server:fail() + ct:fail("Expected ~p; got ~p~n", [Result, Other]) end. init(ReplyTo, Fun, _Filler) -> -- cgit v1.2.3 From 5611e47606d8d691331f2eb4b7ed87bdd8ba9270 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn-Egil=20Dahlberg?= Date: Wed, 9 Mar 2016 16:52:21 +0100 Subject: Eliminate use of ?config() macro --- erts/emulator/test/big_SUITE.erl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'erts/emulator/test/big_SUITE.erl') diff --git a/erts/emulator/test/big_SUITE.erl b/erts/emulator/test/big_SUITE.erl index 37e90df60e..3cc812784a 100644 --- a/erts/emulator/test/big_SUITE.erl +++ b/erts/emulator/test/big_SUITE.erl @@ -87,7 +87,7 @@ negative(Config) when is_list(Config) -> %% Find test file test_file(Config, Name) -> - DataDir = ?config(data_dir, Config), + DataDir = proplists:get_value(data_dir, Config), filename:join(DataDir, Name). %% @@ -256,7 +256,7 @@ big_literals(doc) -> big_literals(Config) when is_list(Config) -> %% Note: The literal test cannot be compiler on a pre-R4 Beam emulator, %% so we compile it now. - ?line DataDir = ?config(data_dir, Config), + ?line DataDir = proplists:get_value(data_dir, Config), ?line Test = filename:join(DataDir, "literal_test"), ?line {ok, Mod, Bin} = compile:file(Test, [binary]), ?line {module, Mod} = code:load_binary(Mod, Mod, Bin), -- cgit v1.2.3 From 33b0c5f37b7b5baa42d4999d1a2be32470fb1bc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn-Egil=20Dahlberg?= Date: Thu, 10 Mar 2016 17:59:23 +0100 Subject: Eliminate use of doc and suite clauses Those clause are obsolete and never used by common_test. --- erts/emulator/test/big_SUITE.erl | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'erts/emulator/test/big_SUITE.erl') diff --git a/erts/emulator/test/big_SUITE.erl b/erts/emulator/test/big_SUITE.erl index 3cc812784a..57f4e502a5 100644 --- a/erts/emulator/test/big_SUITE.erl +++ b/erts/emulator/test/big_SUITE.erl @@ -75,7 +75,7 @@ eq_math(Config) when is_list(Config) -> test(TestFile). -borders(doc) -> "Tests border cases between small/big."; +%% Tests border cases between small/big. borders(Config) when is_list(Config) -> TestFile = test_file(Config, "borders.dat"), test(TestFile). @@ -251,8 +251,7 @@ t_div(Config) when is_list(Config) -> init(ReplyTo, Fun, _Filler) -> ReplyTo ! {result, Fun()}. -big_literals(doc) -> - "Tests that big-number literals work correctly."; +%% Tests that big-number literals work correctly. big_literals(Config) when is_list(Config) -> %% Note: The literal test cannot be compiler on a pre-R4 Beam emulator, %% so we compile it now. @@ -264,8 +263,7 @@ big_literals(Config) when is_list(Config) -> ok. -big_float_1(doc) -> - ["OTP-2436, part 1"]; +%% OTP-2436, part 1 big_float_1(Config) when is_list(Config) -> %% F is a number very close to a maximum float. ?line F = id(1.7e308), @@ -289,8 +287,7 @@ big_float_1(Config) when is_list(Config) -> ?line true = (F =< I*I), ok. -big_float_2(doc) -> - ["OTP-2436, part 2"]; +%% "OTP-2436, part 2 big_float_2(Config) when is_list(Config) -> ?line F = id(1.7e308), ?line I = trunc(F), @@ -299,8 +296,7 @@ big_float_2(Config) when is_list(Config) -> ?line {'EXIT', _} = (catch 4/(2*I)), ok. -shift_limit_1(doc) -> - ["OTP-3256"]; +%% OTP-3256 shift_limit_1(Config) when is_list(Config) -> ?line case catch (id(1) bsl 100000000) of {'EXIT', {system_limit, _}} -> @@ -360,10 +356,7 @@ toobig() -> <> = A, % should fail ANr band ANr. -otp_6692(suite) -> - []; -otp_6692(doc) -> - ["Tests for DIV/REM bug reported in OTP-6692"]; +%% Tests for DIV/REM bug reported in OTP-6692 otp_6692(Config) when is_list(Config)-> ?line loop1(1,1000). -- cgit v1.2.3 From 20ae6a9238d3fd09587bd3f4179a8ae25f1e3aea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn-Egil=20Dahlberg?= Date: Thu, 10 Mar 2016 18:19:16 +0100 Subject: Remove ?line macros --- erts/emulator/test/big_SUITE.erl | 92 ++++++++++++++++++++-------------------- 1 file changed, 46 insertions(+), 46 deletions(-) (limited to 'erts/emulator/test/big_SUITE.erl') diff --git a/erts/emulator/test/big_SUITE.erl b/erts/emulator/test/big_SUITE.erl index 57f4e502a5..d331083661 100644 --- a/erts/emulator/test/big_SUITE.erl +++ b/erts/emulator/test/big_SUITE.erl @@ -99,7 +99,7 @@ test(File) -> test(File, [node()]). test(File, Nodes) -> - ?line {ok,Fd} = file:open(File, [read]), + {ok,Fd} = file:open(File, [read]), Res = test(File, Fd, Nodes), file:close(Fd), case Res of @@ -136,7 +136,7 @@ multi_match(Ns, Expr) -> multi_match(Ns, Expr, []). multi_match([Node|Ns], Expr, Rs) -> - ?line X = rpc:call(Node, big_SUITE, eval, [Expr]), + X = rpc:call(Node, big_SUITE, eval, [Expr]), if X == 0 -> multi_match(Ns, Expr, Rs); true -> multi_match(Ns, Expr, [{Node,X}|Rs]) end; @@ -228,10 +228,10 @@ lcm(Q, R) -> %% Test case t_div cut in from R2D test suite. t_div(Config) when is_list(Config) -> - ?line 'try'(fun() -> 98765432101234 div 98765432101235 end, 0), + 'try'(fun() -> 98765432101234 div 98765432101235 end, 0), % Big remainder, small quotient. - ?line 'try'(fun() -> 339254531512 div 68719476736 end, 4), + 'try'(fun() -> 339254531512 div 68719476736 end, 4), ok. 'try'(Fun, Result) -> @@ -255,50 +255,50 @@ init(ReplyTo, Fun, _Filler) -> big_literals(Config) when is_list(Config) -> %% Note: The literal test cannot be compiler on a pre-R4 Beam emulator, %% so we compile it now. - ?line DataDir = proplists:get_value(data_dir, Config), - ?line Test = filename:join(DataDir, "literal_test"), - ?line {ok, Mod, Bin} = compile:file(Test, [binary]), - ?line {module, Mod} = code:load_binary(Mod, Mod, Bin), - ?line ok = Mod:t(), + DataDir = proplists:get_value(data_dir, Config), + Test = filename:join(DataDir, "literal_test"), + {ok, Mod, Bin} = compile:file(Test, [binary]), + {module, Mod} = code:load_binary(Mod, Mod, Bin), + ok = Mod:t(), ok. %% OTP-2436, part 1 big_float_1(Config) when is_list(Config) -> %% F is a number very close to a maximum float. - ?line F = id(1.7e308), - ?line I = trunc(F), - ?line true = (I == F), - ?line false = (I /= F), - ?line true = (I > F/2), - ?line false = (I =< F/2), - ?line true = (I*2 >= F), - ?line false = (I*2 < F), - ?line true = (I*I > F), - ?line false = (I*I =< F), - - ?line true = (F == I), - ?line false = (F /= I), - ?line false = (F/2 > I), - ?line true = (F/2 =< I), - ?line false = (F >= I*2), - ?line true = (F < I*2), - ?line false = (F > I*I), - ?line true = (F =< I*I), + F = id(1.7e308), + I = trunc(F), + true = (I == F), + false = (I /= F), + true = (I > F/2), + false = (I =< F/2), + true = (I*2 >= F), + false = (I*2 < F), + true = (I*I > F), + false = (I*I =< F), + + true = (F == I), + false = (F /= I), + false = (F/2 > I), + true = (F/2 =< I), + false = (F >= I*2), + true = (F < I*2), + false = (F > I*I), + true = (F =< I*I), ok. %% "OTP-2436, part 2 big_float_2(Config) when is_list(Config) -> - ?line F = id(1.7e308), - ?line I = trunc(F), - ?line {'EXIT', _} = (catch 1/(2*I)), - ?line _Ignore = 2/I, - ?line {'EXIT', _} = (catch 4/(2*I)), + F = id(1.7e308), + I = trunc(F), + {'EXIT', _} = (catch 1/(2*I)), + _Ignore = 2/I, + {'EXIT', _} = (catch 4/(2*I)), ok. %% OTP-3256 shift_limit_1(Config) when is_list(Config) -> - ?line case catch (id(1) bsl 100000000) of + case catch (id(1) bsl 100000000) of {'EXIT', {system_limit, _}} -> ok end, @@ -327,16 +327,16 @@ powmod(A, B, C) -> end. system_limit(Config) when is_list(Config) -> - ?line Maxbig = maxbig(), - ?line {'EXIT',{system_limit,_}} = (catch Maxbig+1), - ?line {'EXIT',{system_limit,_}} = (catch -Maxbig-1), - ?line {'EXIT',{system_limit,_}} = (catch 2*Maxbig), - ?line {'EXIT',{system_limit,_}} = (catch bnot Maxbig), - ?line {'EXIT',{system_limit,_}} = (catch apply(erlang, id('bnot'), [Maxbig])), - ?line {'EXIT',{system_limit,_}} = (catch Maxbig bsl 2), - ?line {'EXIT',{system_limit,_}} = (catch apply(erlang, id('bsl'), [Maxbig,2])), - ?line {'EXIT',{system_limit,_}} = (catch id(1) bsl (1 bsl 45)), - ?line {'EXIT',{system_limit,_}} = (catch id(1) bsl (1 bsl 69)), + Maxbig = maxbig(), + {'EXIT',{system_limit,_}} = (catch Maxbig+1), + {'EXIT',{system_limit,_}} = (catch -Maxbig-1), + {'EXIT',{system_limit,_}} = (catch 2*Maxbig), + {'EXIT',{system_limit,_}} = (catch bnot Maxbig), + {'EXIT',{system_limit,_}} = (catch apply(erlang, id('bnot'), [Maxbig])), + {'EXIT',{system_limit,_}} = (catch Maxbig bsl 2), + {'EXIT',{system_limit,_}} = (catch apply(erlang, id('bsl'), [Maxbig,2])), + {'EXIT',{system_limit,_}} = (catch id(1) bsl (1 bsl 45)), + {'EXIT',{system_limit,_}} = (catch id(1) bsl (1 bsl 69)), ok. maxbig() -> @@ -347,7 +347,7 @@ maxbig() -> id(I) -> I. toobig(Config) when is_list(Config) -> - ?line {'EXIT',{{badmatch,_},_}} = (catch toobig()), + {'EXIT',{{badmatch,_},_}} = (catch toobig()), ok. toobig() -> @@ -358,7 +358,7 @@ toobig() -> %% Tests for DIV/REM bug reported in OTP-6692 otp_6692(Config) when is_list(Config)-> - ?line loop1(1,1000). + loop1(1,1000). fact(N) -> fact(N,1). -- cgit v1.2.3