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(register_SUITE).
   21: 
   22: 
   23: %-define(line_trace, 1).
   24: 
   25: -include_lib("test_server/include/test_server.hrl").
   26: 
   27: %-compile(export_all).
   28: -export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1, 
   29: 	 init_per_group/2,end_per_group/2, 
   30: 	 init_per_testcase/2, end_per_testcase/2]).
   31: 
   32: -export([otp_8099/1]).
   33: 
   34: -define(DEFAULT_TIMEOUT, ?t:minutes(2)).
   35: 
   36: suite() -> [{ct_hooks,[ts_install_cth]}].
   37: 
   38: all() -> 
   39:     [otp_8099].
   40: 
   41: groups() -> 
   42:     [].
   43: 
   44: init_per_suite(Config) ->
   45:     Config.
   46: 
   47: end_per_suite(_Config) ->
   48:     ok.
   49: 
   50: init_per_group(_GroupName, Config) ->
   51:     Config.
   52: 
   53: end_per_group(_GroupName, Config) ->
   54:     Config.
   55: 
   56: 
   57: init_per_testcase(Case, Config) when is_list(Config) ->
   58:     Dog = ?t:timetrap(?DEFAULT_TIMEOUT),
   59:     [{watchdog, Dog}, {testcase, Case} | Config].
   60: 
   61: end_per_testcase(_Case, Config) when is_list(Config) ->
   62:     Dog = ?config(watchdog, Config),
   63:     ?t:timetrap_cancel(Dog),
   64:     ok.
   65: 
   66: %%
   67: %% Test cases
   68: %%
   69: 
   70: -define(OTP_8099_NAME, otp_8099_reg_proc).
   71: 
   72: otp_8099(Config) when is_list(Config) ->
   73:     case catch erlang:system_info(lock_counting) of
   74: 	true -> {skipped,
   75: 		 "Lock counting enabled. Current lock counting "
   76: 		 "implementation cannot handle this many "
   77: 		 "processes."};
   78: 	_ ->
   79: 	    otp_8099_test(1000000)
   80:     end.
   81: 
   82: otp_8099_test(0) ->
   83:     ok;
   84: otp_8099_test(N) ->
   85:     ?line P = spawn(fun () -> otp_8099_proc() end),
   86:     ?line case catch register(?OTP_8099_NAME, P) of
   87: 	      true ->
   88: 		  ?line ok;
   89: 	      _ ->
   90: 		  ?line OP = whereis(?OTP_8099_NAME),
   91: 		  ?line (catch unregister(?OTP_8099_NAME)),
   92: 		  ?line (catch exit(OP, kill)),
   93: 		  ?line true = (catch register(?OTP_8099_NAME, P))
   94: 	  end,
   95:     ?line P = whereis(?OTP_8099_NAME),
   96:     ?line exit(P, kill),
   97:     ?line otp_8099_test(N-1).
   98: 
   99: otp_8099_proc() ->
  100:     receive _ -> ok end,
  101:     otp_8099_proc().
  102: 
  103: %%
  104: %% Utils
  105: %%
  106: