1: %% 2: %% %CopyrightBegin% 3: %% 4: %% Copyright Ericsson AB 1999-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(ref_SUITE). 21: 22: -export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1, 23: init_per_group/2,end_per_group/2, 24: init_per_testcase/2,end_per_testcase/2]). 25: -export([wrap_1/1]). 26: 27: -export([loop_ref/1]). 28: 29: -include_lib("test_server/include/test_server.hrl"). 30: 31: init_per_testcase(_, Config) -> 32: ?line Dog=test_server:timetrap(test_server:minutes(2)), 33: [{watchdog, Dog}|Config]. 34: 35: end_per_testcase(_, Config) -> 36: Dog=?config(watchdog, Config), 37: test_server:timetrap_cancel(Dog), 38: ok. 39: 40: suite() -> [{ct_hooks,[ts_install_cth]}]. 41: 42: all() -> 43: [wrap_1]. 44: 45: groups() -> 46: []. 47: 48: init_per_suite(Config) -> 49: Config. 50: 51: end_per_suite(_Config) -> 52: ok. 53: 54: init_per_group(_GroupName, Config) -> 55: Config. 56: 57: end_per_group(_GroupName, Config) -> 58: Config. 59: 60: 61: wrap_1(doc) -> "Check that refs don't wrap around easily."; 62: wrap_1(Config) when is_list(Config) -> 63: ?line spawn_link(?MODULE, loop_ref, [self()]), 64: ?line receive 65: done -> 66: test_server:fail(wrapfast) 67: after 30000 -> 68: ok 69: end, 70: ok. 71: 72: loop_ref(Parent) -> 73: Ref0 = make_ref(), 74: loop_ref(Ref0, first, 0), 75: Parent ! done. 76: 77: loop_ref(R, R, _) -> ok; 78: loop_ref(R0, _, N) -> 79: loop_ref(R0, make_ref(), N+1).