1: %%
    2: %% %CopyrightBegin%
    3: %%
    4: %% Copyright Ericsson AB 2002-2013. All Rights Reserved.
    5: %%
    6: %% The contents of this file are subject to the Erlang Public License,
    7: %% Version 1.1, (the "License"); you may not use this file except in
    8: %% compliance with the License. You should have received a copy of the
    9: %% Erlang Public License along with this software. If not, it can be
   10: %% retrieved online at http://www.erlang.org/.
   11: %%
   12: %% Software distributed under the License is distributed on an "AS IS"
   13: %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
   14: %% the License for the specific language governing rights and limitations
   15: %% under the License.
   16: %%
   17: %% %CopyrightEnd%
   18: %%
   19: 
   20: -module(etop_SUITE).
   21: 
   22: %% Test functions
   23: -export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1, 
   24: 	 init_per_group/2,end_per_group/2]).
   25: -export([text/1,text/2,text_tracing_off/1,text_tracing_off/2]).
   26: -export([init_per_testcase/2, end_per_testcase/2]).
   27: 
   28: -include_lib("test_server/include/test_server.hrl").
   29: 
   30: -define(default_timeout, ?t:minutes(1)).
   31: 
   32: init_per_testcase(_Case, Config) ->
   33:     ?line Dog=test_server:timetrap(?default_timeout),
   34:     [{watchdog, Dog}|Config].
   35: end_per_testcase(Case, Config) ->
   36:     try apply(?MODULE,Case,[cleanup,Config])
   37:     catch error:undef -> ok
   38:     end,
   39:     Dog=?config(watchdog, Config),
   40:     ?t:timetrap_cancel(Dog),
   41:     ok.
   42: 
   43: suite() -> [{ct_hooks,[ts_install_cth]}].
   44: 
   45: all() -> 
   46:     [text, text_tracing_off].
   47: 
   48: groups() -> 
   49:     [].
   50: 
   51: init_per_suite(Config) ->
   52:     Config.
   53: 
   54: end_per_suite(_Config) ->
   55:     ok.
   56: 
   57: init_per_group(_GroupName, Config) ->
   58:     Config.
   59: 
   60: end_per_group(_GroupName, Config) ->
   61:     Config.
   62: 
   63: 
   64: %% Start etop with text presentation
   65: text(_) ->
   66:     case test_server:is_native(lists) of
   67: 	true -> {skip,"Native libs -- tracing does not work"};
   68: 	false -> text()
   69:     end.
   70: 
   71: text() ->
   72:     ?line {ok,Node} = ?t:start_node(node2,peer,[]),
   73: 
   74:     %% Must spawn this process, else the test case will never end.
   75:     ?line spawn_link(etop,start,[[{node,Node},{output,text},{interval,3}]]),
   76:     ?line timer:sleep(4000),
   77:     ?line etop:config(interval,2),
   78:     ?line timer:sleep(3000),
   79:     ?line etop:config(lines,5),
   80:     ?line timer:sleep(3000),
   81:     ?line etop:config(accumulate,true),
   82:     ?line timer:sleep(3000),
   83:     ?line etop:config(sort,reductions),
   84:     ?line timer:sleep(3000),
   85:     ?line etop:config(sort,memory),
   86:     ?line timer:sleep(3000),
   87:     ?line etop:config(sort,msg_q),
   88:     ?line timer:sleep(3000),
   89:     ok.
   90: text(cleanup,_Config) ->
   91:     etop:stop(),
   92:     {ok,Host} = inet:gethostname(),
   93:     Node = list_to_atom("node2@"++Host),
   94:     ?t:stop_node(Node).
   95: 
   96: text_tracing_off(suite) ->
   97:     [];
   98: text_tracing_off(doc) ->
   99:     ["Start etop with text presentation, and tracing turned off"];
  100: text_tracing_off(Config) when is_list(Config) ->
  101:     ?line {ok,Node} = ?t:start_node(node2,peer,[]),
  102: 
  103:     %% Must spawn this process, else the test case will never end.
  104:     ?line spawn_link(etop,start,[[{node,Node},
  105: 				  {output,text},
  106: 				  {interval,3},
  107: 				  {tracing,off}]]),
  108:     ?line timer:sleep(4000),
  109:     ?line etop:config(interval,2),
  110:     ?line timer:sleep(3000),
  111:     ?line etop:config(lines,5),
  112:     ?line timer:sleep(3000),
  113:     ?line etop:config(accumulate,true),
  114:     ?line timer:sleep(3000),
  115:     ?line etop:config(sort,memory),
  116:     ?line timer:sleep(3000),
  117:     ?line etop:config(sort,msg_q),
  118:     ?line timer:sleep(3000),
  119:     ?line etop:config(sort,runtime), % this should not crash, but has no effect
  120:     ?line timer:sleep(3000),
  121:     ok.
  122: text_tracing_off(cleanup,_Config) ->
  123:     etop:stop(),
  124:     {ok,Host} = inet:gethostname(),
  125:     Node = list_to_atom("node2@"++Host),
  126:     ?t:stop_node(Node).
  127: