1: %%
    2: %% %CopyrightBegin%
    3: %%
    4: %% Copyright Ericsson AB 2010-2011. 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(lcnt_SUITE).
   21: -include_lib("test_server/include/test_server.hrl").
   22: 
   23: %% Test server specific exports
   24: -export([all/0, suite/0,groups/0,init_per_group/2,end_per_group/2]).
   25: -export([init_per_suite/1, end_per_suite/1]).
   26: -export([init_per_testcase/2, end_per_testcase/2]).
   27: 
   28: %% Test cases
   29: -export([
   30: 	load_v1/1,
   31: 	conflicts/1,
   32: 	locations/1,
   33: 	swap_keys/1
   34: 	]).
   35: 
   36: %% Default timetrap timeout (set in init_per_testcase)
   37: -define(default_timeout, ?t:minutes(4)).
   38: 
   39: init_per_suite(Config) when is_list(Config) ->
   40:     Config.
   41: 
   42: end_per_suite(Config) when is_list(Config) ->
   43:     Config.
   44: 
   45: init_per_testcase(_Case, Config) ->
   46:     Dog = ?t:timetrap(?default_timeout),
   47:     [{watchdog,Dog} | Config].
   48: 
   49: end_per_testcase(_Case, Config) ->
   50:     Dog = ?config(watchdog, Config),
   51:     ?t:timetrap_cancel(Dog),
   52:     catch lcnt:stop(),
   53:     ok.
   54: 
   55: suite() -> [{ct_hooks,[ts_install_cth]}].
   56: 
   57: all() -> 
   58:     [load_v1, conflicts, locations, swap_keys].
   59: 
   60: groups() -> 
   61:     [].
   62: 
   63: init_per_group(_GroupName, Config) ->
   64:     Config.
   65: 
   66: end_per_group(_GroupName, Config) ->
   67:     Config.
   68: 
   69: 
   70: %%----------------------------------------------------------------------
   71: %% Tests
   72: %%----------------------------------------------------------------------
   73: 
   74: load_v1(suite) ->
   75:     [];
   76: load_v1(doc) ->
   77:     ["Load data from file."];
   78: load_v1(Config) when is_list(Config) ->
   79:     ?line {ok, _} = lcnt:start(),
   80:     ?line Path = ?config(data_dir, Config),
   81:     ?line File = filename:join([Path,"big_bang_40.lcnt"]),
   82:     ?line ok = lcnt:load(File),
   83:     ?line ok = lcnt:stop(),
   84:     ok.
   85: 
   86: conflicts(suite) ->
   87:     [];
   88: conflicts(doc) ->
   89:     ["API: conflicts"];
   90: conflicts(Config) when is_list(Config) ->
   91:     ?line {ok, _} = lcnt:start(),
   92:     ?line Path = ?config(data_dir, Config),
   93:     ?line File = filename:join([Path,"big_bang_40.lcnt"]),
   94:     ?line ok = lcnt:load(File),
   95:     ?line ok = lcnt:conflicts(),
   96:     THs      = [-1, 0, 100, 1000],
   97:     Print    = [name , id , type , entry , tries , colls , ratio , time , duration],
   98:     Opts     = [
   99: 	[{sort, Sort}, {reverse, Rev}, {max_locks, ML}, {combine, Combine}, {thresholds, [TH]}, {print, [Print]}] ||
  100: 	    Sort    <- [name , id , type , tries , colls , ratio , time , entry],
  101: 	    ML      <- [none, 1 , 32,  4096],
  102: 	    Combine <- [true, false],
  103: 	    TH      <- [{tries, Tries} || Tries <- THs] ++ [{colls, Colls} || Colls <- THs] ++ [{time, Time} || Time <- THs],
  104: 	    Rev     <- [true, false]
  105: 	],
  106:     ?line ok = test_conflicts_opts(Opts),
  107:     ?line ok = lcnt:stop(),
  108:     ok.
  109: 
  110: test_conflicts_opts([]) -> ok;
  111: test_conflicts_opts([Opt|Opts]) ->
  112:     ?line ok = lcnt:conflicts(Opt),
  113:     test_conflicts_opts(Opts).
  114: 
  115: locations(suite) ->
  116:     [];
  117: locations(doc) ->
  118:     ["API: locations"];
  119: locations(Config) when is_list(Config) ->
  120:     ?line {ok, _} = lcnt:start(),
  121:     ?line Path = ?config(data_dir, Config),
  122:     ?line File = filename:join([Path,"big_bang_40.lcnt"]),
  123:     ?line ok = lcnt:load(File),
  124:     ?line ok = lcnt:locations(),
  125:     THs      = [-1, 0, 100, 1000],
  126:     Print    = [name , id , type , entry , tries , colls , ratio , time , duration],
  127:     Opts     = [
  128: 	[{full_id, Id}, {sort, Sort}, {max_locks, ML}, {combine, Combine}, {thresholds, [TH]}, {print, Print}] ||
  129: 	    Sort    <- [name , id , type , tries , colls , ratio , time , entry],
  130: 	    ML      <- [none, 1 , 64],
  131: 	    Combine <- [true, false],
  132: 	    TH      <- [{tries, Tries} || Tries <- THs] ++ [{colls, Colls} || Colls <- THs] ++ [{time, Time} || Time <- THs],
  133: 	    Id      <- [true, false]
  134: 	],
  135:     ?line ok = test_locations_opts(Opts),
  136:     ?line ok = lcnt:stop(),
  137:     ok.
  138: 
  139: test_locations_opts([]) -> ok;
  140: test_locations_opts([Opt|Opts]) ->
  141:     ?line ok = lcnt:locations(Opt),
  142:     test_locations_opts(Opts).
  143: 
  144: swap_keys(suite) ->
  145:     [];
  146: swap_keys(doc) ->
  147:     ["Test interchanging port/process id with class"];
  148: swap_keys(Config) when is_list(Config) ->
  149:     ?line {ok, _} = lcnt:start(),
  150:     ?line Path = ?config(data_dir, Config),
  151:     ?line File = filename:join([Path,"big_bang_40.lcnt"]),
  152:     ?line ok = lcnt:load(File),
  153:     ?line ok = lcnt:conflicts(),
  154:     ?line ok = lcnt:swap_pid_keys(),
  155:     ?line ok = lcnt:conflicts(),
  156:     ?line ok = lcnt:stop(),
  157:     ok.
  158: 
  159: 
  160: %%----------------------------------------------------------------------
  161: %% Auxiliary tests
  162: %%----------------------------------------------------------------------
  163: 
  164: %%----------------------------------------------------------------------
  165: %% Auxiliary
  166: %%----------------------------------------------------------------------