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 --- erts/emulator/test/hibernate_SUITE.erl | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'erts/emulator/test/hibernate_SUITE.erl') diff --git a/erts/emulator/test/hibernate_SUITE.erl b/erts/emulator/test/hibernate_SUITE.erl index 31938e6c65..4ac8c272db 100644 --- a/erts/emulator/test/hibernate_SUITE.erl +++ b/erts/emulator/test/hibernate_SUITE.erl @@ -3,16 +3,17 @@ %% %% Copyright Ericsson AB 2003-2012. 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. --- erts/emulator/test/hibernate_SUITE.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'erts/emulator/test/hibernate_SUITE.erl') diff --git a/erts/emulator/test/hibernate_SUITE.erl b/erts/emulator/test/hibernate_SUITE.erl index 4ac8c272db..5138a6ee05 100644 --- a/erts/emulator/test/hibernate_SUITE.erl +++ b/erts/emulator/test/hibernate_SUITE.erl @@ -20,7 +20,7 @@ -module(hibernate_SUITE). --include_lib("test_server/include/test_server.hrl"). +-include_lib("common_test/include/ct.hrl"). -export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1, init_per_group/2,end_per_group/2, -- cgit v1.2.3 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/hibernate_SUITE.erl | 38 +++++++--------------------------- 1 file changed, 8 insertions(+), 30 deletions(-) (limited to 'erts/emulator/test/hibernate_SUITE.erl') diff --git a/erts/emulator/test/hibernate_SUITE.erl b/erts/emulator/test/hibernate_SUITE.erl index 5138a6ee05..ea4cc79701 100644 --- a/erts/emulator/test/hibernate_SUITE.erl +++ b/erts/emulator/test/hibernate_SUITE.erl @@ -22,45 +22,23 @@ -include_lib("common_test/include/ct.hrl"). --export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1, - init_per_group/2,end_per_group/2, - init_per_testcase/2,end_per_testcase/2, +-export([all/0, suite/0, basic/1,dynamic_call/1,min_heap_size/1,bad_args/1, - messages_in_queue/1,undefined_mfa/1,no_heap/1,wake_up_and_bif_trap/1]). + messages_in_queue/1,undefined_mfa/1,no_heap/1, + wake_up_and_bif_trap/1]). %% Used by test cases. --export([basic_hibernator/1,dynamic_call_hibernator/2,messages_in_queue_restart/2, no_heap_loop/0,characters_to_list_trap/1]). +-export([basic_hibernator/1,dynamic_call_hibernator/2,messages_in_queue_restart/2, + no_heap_loop/0,characters_to_list_trap/1]). -suite() -> [{ct_hooks,[ts_install_cth]}]. +suite() -> + [{ct_hooks,[ts_install_cth]}, + {timetrap, {minutes, 3}}]. all() -> [basic, dynamic_call, min_heap_size, bad_args, messages_in_queue, undefined_mfa, no_heap, wake_up_and_bif_trap]. -groups() -> - []. - -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). - %%% %%% Testing the basic functionality of erlang:hibernate/3. %%% -- 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/hibernate_SUITE.erl | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'erts/emulator/test/hibernate_SUITE.erl') diff --git a/erts/emulator/test/hibernate_SUITE.erl b/erts/emulator/test/hibernate_SUITE.erl index ea4cc79701..177468fdfd 100644 --- a/erts/emulator/test/hibernate_SUITE.erl +++ b/erts/emulator/test/hibernate_SUITE.erl @@ -84,13 +84,13 @@ hibernate_wake_up(N, ExpectedHeapSz, Child) -> if size(Bin) > 1000 -> io:format("~s\n", [binary_to_list(Bin)]), - ?line ?t:fail(stack_is_growing); + ?line ct:fail(stack_is_growing); true -> hibernate_wake_up(N-1, ExpectedHeapSz, Child) end; Other -> ?line io:format("~p\n", [Other]), - ?line ?t:fail(unexpected_message) + ?line ct:fail(unexpected_message) end. basic_hibernator(Info) -> @@ -199,8 +199,7 @@ min_heap_size_1(Config) when is_list(Config) -> AfterSize >= 15000 -> ok end; Other -> - io:format("Unexpected: ~p\n", [Other]), - ?line ?t:fail() + ct:fail("Unexpected: ~p\n", [Other]) end. min_hibernator({Parent,_Ref}) -> @@ -244,7 +243,7 @@ bad_args(Mod, Name, Args) -> io:format("erlang:hibernate(~p, ~p, ~p) -> ~p\n", [Mod,Name,Args,Res]); Other -> io:format("erlang:hibernate(~p, ~p, ~p) -> ~p\n", [Mod,Name,Args,Res]), - ?t:fail({bad_result,Other}) + ct:fail({bad_result,Other}) end. @@ -262,7 +261,7 @@ messages_in_queue(Config) when is_list(Config) -> done -> ok; Other -> ?line io:format("~p\n", [Other]), - ?line ?t:fail(unexpected_message) + ?line ct:fail(unexpected_message) end. messages_in_queue_1(Parent, ExpectedMsg) -> @@ -279,7 +278,7 @@ messages_in_queue_restart(Parent, ExpectedMessage) -> Parent ! done; Other -> io:format("~p\n", [Other]), - ?t:fail(unexpected_message) + ct:fail(unexpected_message) end, ok. @@ -301,7 +300,7 @@ undefined_mfa(Config) when is_list(Config) -> ok; Other -> ?line io:format("~p\n", [Other]), - ?line ?t:fail(unexpected_message) + ?line ct:fail(unexpected_message) end, undefined_mfa_1(). @@ -319,7 +318,7 @@ undefined_mfa_1() -> ok; Other -> ?line io:format("~p\n", [Other]), - ?line ?t:fail(unexpected_message) + ?line ct:fail(unexpected_message) end, ok. @@ -369,7 +368,7 @@ wake_up_and_bif_trap(Config) when is_list(Config) -> ?line receive {ok, Pid0} when Pid0 =:= Pid -> ok after 5000 -> - ?line ?t:fail(process_blocked) + ?line ct:fail(process_blocked) end, ?line unlink(Pid), ?line exit(Pid, bye). -- 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/hibernate_SUITE.erl | 4 ---- 1 file changed, 4 deletions(-) (limited to 'erts/emulator/test/hibernate_SUITE.erl') diff --git a/erts/emulator/test/hibernate_SUITE.erl b/erts/emulator/test/hibernate_SUITE.erl index 177468fdfd..1d3d8a69de 100644 --- a/erts/emulator/test/hibernate_SUITE.erl +++ b/erts/emulator/test/hibernate_SUITE.erl @@ -329,8 +329,6 @@ bar() -> %% No heap %% -no_heap(doc) -> []; -no_heap(suite) -> []; no_heap(Config) when is_list(Config) -> ?line H = spawn_link(fun () -> clean_dict(), no_heap_loop() end), ?line lists:foreach(fun (_) -> @@ -359,8 +357,6 @@ clean_dict() -> %% Wake up and then immediatly bif trap with a lengthy computation. %% -wake_up_and_bif_trap(doc) -> []; -wake_up_and_bif_trap(suite) -> []; wake_up_and_bif_trap(Config) when is_list(Config) -> ?line Self = self(), ?line Pid = spawn_link(fun() -> erlang:hibernate(?MODULE, characters_to_list_trap, [Self]) end), -- 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/hibernate_SUITE.erl | 207 ++++++++++++++++----------------- 1 file changed, 101 insertions(+), 106 deletions(-) (limited to 'erts/emulator/test/hibernate_SUITE.erl') diff --git a/erts/emulator/test/hibernate_SUITE.erl b/erts/emulator/test/hibernate_SUITE.erl index 1d3d8a69de..45f0bdc4da 100644 --- a/erts/emulator/test/hibernate_SUITE.erl +++ b/erts/emulator/test/hibernate_SUITE.erl @@ -47,9 +47,9 @@ basic(Config) when is_list(Config) -> Ref = make_ref(), Info = {self(),Ref}, ExpectedHeapSz = erts_debug:size([Info]), - ?line Child = spawn_link(fun() -> basic_hibernator(Info) end), - ?line hibernate_wake_up(100, ExpectedHeapSz, Child), - ?line Child ! please_quit_now, + Child = spawn_link(fun() -> basic_hibernator(Info) end), + hibernate_wake_up(100, ExpectedHeapSz, Child), + Child ! please_quit_now, ok. hibernate_wake_up(0, _, _) -> ok; @@ -63,35 +63,35 @@ hibernate_wake_up(N, ExpectedHeapSz, Child) -> end; 1 -> ok end, - ?line Child ! {hibernate,self()}, - ?line wait_until(fun () -> + Child ! {hibernate,self()}, + wait_until(fun () -> {current_function,{erlang,hibernate,3}} == process_info(Child, current_function) end), - ?line {message_queue_len,0} = process_info(Child, message_queue_len), - ?line {status,waiting} = process_info(Child, status), - ?line {heap_size,ExpectedHeapSz} = process_info(Child, heap_size), + {message_queue_len,0} = process_info(Child, message_queue_len), + {status,waiting} = process_info(Child, status), + {heap_size,ExpectedHeapSz} = process_info(Child, heap_size), io:format("Before hibernation: ~p After hibernation: ~p\n", [Before,ExpectedHeapSz]), - ?line Child ! {whats_up,self()}, - ?line receive - {all_fine,X,Child,_Ref} -> - if - N =:= 1 -> io:format("~p\n", [X]); - true -> ok - end, - {backtrace,Bin} = process_info(Child, backtrace), - if - size(Bin) > 1000 -> - io:format("~s\n", [binary_to_list(Bin)]), - ?line ct:fail(stack_is_growing); - true -> - hibernate_wake_up(N-1, ExpectedHeapSz, Child) - end; - Other -> - ?line io:format("~p\n", [Other]), - ?line ct:fail(unexpected_message) - end. + Child ! {whats_up,self()}, + receive + {all_fine,X,Child,_Ref} -> + if + N =:= 1 -> io:format("~p\n", [X]); + true -> ok + end, + {backtrace,Bin} = process_info(Child, backtrace), + if + size(Bin) > 1000 -> + io:format("~s\n", [binary_to_list(Bin)]), + ct:fail(stack_is_growing); + true -> + hibernate_wake_up(N-1, ExpectedHeapSz, Child) + end; + Other -> + io:format("~p\n", [Other]), + ct:fail(unexpected_message) + end. basic_hibernator(Info) -> {catchlevel,0} = process_info(self(), catchlevel), @@ -143,9 +143,9 @@ dynamic_call(Config) when is_list(Config) -> Ref = make_ref(), Info = {self(),Ref}, ExpectedHeapSz = erts_debug:size([Info]), - ?line Child = spawn_link(fun() -> ?MODULE:dynamic_call_hibernator(Info, hibernate) end), - ?line hibernate_wake_up(100, ExpectedHeapSz, Child), - ?line Child ! please_quit_now, + Child = spawn_link(fun() -> ?MODULE:dynamic_call_hibernator(Info, hibernate) end), + hibernate_wake_up(100, ExpectedHeapSz, Child), + Child ! please_quit_now, ok. dynamic_call_hibernator(Info, Function) -> @@ -173,31 +173,30 @@ min_heap_size(Config) when is_list(Config) -> end. min_heap_size_1(Config) when is_list(Config) -> - ?line erlang:trace(new, true, [call]), + erlang:trace(new, true, [call]), MFA = {?MODULE,min_hibernator,1}, - ?line 1 = erlang:trace_pattern(MFA, true, [local]), + 1 = erlang:trace_pattern(MFA, true, [local]), Ref = make_ref(), Info = {self(),Ref}, - ?line Child = spawn_opt(fun() -> min_hibernator(Info) end, + Child = spawn_opt(fun() -> min_hibernator(Info) end, [{min_heap_size,15000},link]), receive - {trace,Child,call,{?MODULE,min_hibernator,_}} -> - ?line 1 = erlang:trace_pattern(MFA, false, [local]), - ?line erlang:trace(new, false, [call]) + {trace,Child,call,{?MODULE,min_hibernator,_}} -> + 1 = erlang:trace_pattern(MFA, false, [local]), + erlang:trace(new, false, [call]) end, {heap_size,HeapSz} = process_info(Child, heap_size), io:format("Heap size: ~p\n", [HeapSz]), - ?line if - HeapSz < 20 -> ok - end, - ?line Child ! wake_up, + if + HeapSz < 20 -> ok + end, + Child ! wake_up, receive {heap_size,AfterSize} -> io:format("Heap size after wakeup: ~p\n", [AfterSize]), - ?line - if - AfterSize >= 15000 -> ok - end; + if + AfterSize >= 15000 -> ok + end; Other -> ct:fail("Unexpected: ~p\n", [Other]) end. @@ -216,23 +215,23 @@ min_hibernator_recv(Parent) -> %%% bad_args(Config) when is_list(Config) -> - ?line bad_args(?MODULE, {name,glurf}, [0]), - ?line {'EXIT',{system_limit,_}} = + bad_args(?MODULE, {name,glurf}, [0]), + {'EXIT',{system_limit,_}} = (catch erlang:hibernate(x, y, lists:duplicate(5122, xxx))), - ?line bad_args(42, name, [0]), - ?line bad_args(xx, 42, [1]), - ?line bad_args(xx, 42, glurf), - ?line bad_args(xx, 42, {}), - ?line bad_args({}, name, [2]), - ?line bad_args({1}, name, [3]), - ?line bad_args({1,2,3}, name, [4]), - ?line bad_args({1,2,3}, name, [5]), - ?line bad_args({1,2,3,4}, name, [6]), - ?line bad_args({1,2,3,4,5,6}, name,[7]), - ?line bad_args({1,2,3,4,5}, name, [8]), - ?line bad_args({1,2}, name, [9]), - ?line bad_args([1,2], name, [9]), - ?line bad_args(55.0, name, [9]), + bad_args(42, name, [0]), + bad_args(xx, 42, [1]), + bad_args(xx, 42, glurf), + bad_args(xx, 42, {}), + bad_args({}, name, [2]), + bad_args({1}, name, [3]), + bad_args({1,2,3}, name, [4]), + bad_args({1,2,3}, name, [5]), + bad_args({1,2,3,4}, name, [6]), + bad_args({1,2,3,4,5,6}, name,[7]), + bad_args({1,2,3,4,5}, name, [8]), + bad_args({1,2}, name, [9]), + bad_args([1,2], name, [9]), + bad_args(55.0, name, [9]), ok. bad_args(Mod, Name, Args) -> @@ -260,8 +259,8 @@ messages_in_queue(Config) when is_list(Config) -> receive done -> ok; Other -> - ?line io:format("~p\n", [Other]), - ?line ct:fail(unexpected_message) + io:format("~p\n", [Other]), + ct:fail(unexpected_message) end. messages_in_queue_1(Parent, ExpectedMsg) -> @@ -273,13 +272,13 @@ messages_in_queue_1(Parent, ExpectedMsg) -> [Parent,ExpectedMsg]). messages_in_queue_restart(Parent, ExpectedMessage) -> - ?line receive - ExpectedMessage -> - Parent ! done; - Other -> - io:format("~p\n", [Other]), - ct:fail(unexpected_message) - end, + receive + ExpectedMessage -> + Parent ! done; + Other -> + io:format("~p\n", [Other]), + ct:fail(unexpected_message) + end, ok. @@ -289,36 +288,36 @@ messages_in_queue_restart(Parent, ExpectedMessage) -> %%% undefined_mfa(Config) when is_list(Config) -> - ?line process_flag(trap_exit, true), - ?line Pid = spawn_link(fun() -> + process_flag(trap_exit, true), + Pid = spawn_link(fun() -> %% Will be a call_only instruction. erlang:hibernate(?MODULE, blarf, []) end), - ?line Pid ! {a,message}, - ?line receive - {'EXIT',Pid,{undef,Undef}} -> - io:format("~p\n", [Undef]), - ok; - Other -> - ?line io:format("~p\n", [Other]), - ?line ct:fail(unexpected_message) - end, + Pid ! {a,message}, + receive + {'EXIT',Pid,{undef,Undef}} -> + io:format("~p\n", [Undef]), + ok; + Other -> + io:format("~p\n", [Other]), + ct:fail(unexpected_message) + end, undefined_mfa_1(). undefined_mfa_1() -> - ?line Pid = spawn_link(fun() -> + Pid = spawn_link(fun() -> %% Force a call_last instruction by calling bar() %% (if that is not obvious). bar(), erlang:hibernate(?MODULE, blarf, []) end), - ?line Pid ! {another,message}, - ?line receive + Pid ! {another,message}, + receive {'EXIT',Pid,{undef,Undef}} -> io:format("~p\n", [Undef]), ok; Other -> - ?line io:format("~p\n", [Other]), - ?line ct:fail(unexpected_message) + io:format("~p\n", [Other]), + ct:fail(unexpected_message) end, ok. @@ -330,20 +329,16 @@ bar() -> %% no_heap(Config) when is_list(Config) -> - ?line H = spawn_link(fun () -> clean_dict(), no_heap_loop() end), - ?line lists:foreach(fun (_) -> - wait_until(fun () -> is_hibernated(H) end), - ?line [{heap_size,1}, - {total_heap_size,1}] - = process_info(H, - [heap_size, - total_heap_size]), - receive after 10 -> ok end, - H ! again - end, - lists:seq(1, 100)), - ?line unlink(H), - ?line exit(H, bye). + H = spawn_link(fun () -> clean_dict(), no_heap_loop() end), + lists:foreach(fun (_) -> + wait_until(fun () -> is_hibernated(H) end), + [{heap_size,1}, {total_heap_size,1}] + = process_info(H, [heap_size, total_heap_size]), + receive after 10 -> ok end, + H ! again + end, lists:seq(1, 100)), + unlink(H), + exit(H, bye). no_heap_loop() -> flush(), @@ -358,16 +353,16 @@ clean_dict() -> %% wake_up_and_bif_trap(Config) when is_list(Config) -> - ?line Self = self(), - ?line Pid = spawn_link(fun() -> erlang:hibernate(?MODULE, characters_to_list_trap, [Self]) end), - ?line Pid ! wakeup, - ?line receive + Self = self(), + Pid = spawn_link(fun() -> erlang:hibernate(?MODULE, characters_to_list_trap, [Self]) end), + Pid ! wakeup, + receive {ok, Pid0} when Pid0 =:= Pid -> ok after 5000 -> - ?line ct:fail(process_blocked) + ct:fail(process_blocked) end, - ?line unlink(Pid), - ?line exit(Pid, bye). + unlink(Pid), + exit(Pid, bye). %% Lengthy computation that traps (in characters_to_list_trap_3). characters_to_list_trap(Parent) -> -- 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 --- erts/emulator/test/hibernate_SUITE.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'erts/emulator/test/hibernate_SUITE.erl') diff --git a/erts/emulator/test/hibernate_SUITE.erl b/erts/emulator/test/hibernate_SUITE.erl index 45f0bdc4da..6f8ce02266 100644 --- a/erts/emulator/test/hibernate_SUITE.erl +++ b/erts/emulator/test/hibernate_SUITE.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2003-2012. All Rights Reserved. +%% Copyright Ericsson AB 2003-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