1: %% 2: %% %CopyrightBegin% 3: %% 4: %% Copyright Ericsson AB 1999-2012. 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: %% 21: -module(int_break_SUITE). 22: 23: %% Test break points. 24: 25: -include_lib("test_server/include/test_server.hrl"). 26: 27: -export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1, 28: init_per_group/2,end_per_group/2, 29: init_per_testcase/2,end_per_testcase/2, 30: basic/1,cleanup/1]). 31: 32: -export([auto_attach/1]). 33: 34: suite() -> [{ct_hooks,[ts_install_cth]}]. 35: 36: all() -> 37: [basic, cleanup]. 38: 39: groups() -> 40: []. 41: 42: init_per_suite(Config) -> 43: Config. 44: 45: end_per_suite(_Config) -> 46: ok. 47: 48: init_per_group(_GroupName, Config) -> 49: Config. 50: 51: end_per_group(_GroupName, Config) -> 52: Config. 53: 54: 55: init_per_testcase(_Case, Config) -> 56: ?line DataDir = ?config(data_dir, Config), 57: ?line Mod = ordsets1, 58: ?line {module,Mod} = int:i(filename:join(DataDir, Mod)), 59: ?line ok = io:format("Interpreted modules: ~p", [int:interpreted()]), 60: ?line Dog = test_server:timetrap(?t:minutes(0.5)), 61: [{watchdog,Dog}|Config]. 62: 63: end_per_testcase(_Case, Config) -> 64: ?line ok = io:format("Interpreted modules: ~p", [int:interpreted()]), 65: ?line Dog = ?config(watchdog, Config), 66: ?t:timetrap_cancel(Dog), 67: ok. 68: 69: basic(doc) -> "Tests setting a few break points."; 70: basic(suite) -> []; 71: basic(Config) when list(Config) -> 72: ?line int:auto_attach([init], {?MODULE,auto_attach}), 73: ?line S1 = [] = ordsets1:new_set(), 74: ?line ok = i:ib(ordsets1, 86), 75: ?line S2 = [xxx] = ordsets1:add_element(xxx, S1), 76: ?line S3 = [xxx,y] = ordsets1:add_element(y, S2), 77: ?line ok = i:ib(ordsets1, union, 2), 78: ?line [xxx,y,z] = ordsets1:union(S3, [z]), 79: All = [{{ordsets1,86}, _}, {{ordsets1,_},_}|_] = lists:sort(int:all_breaks()), 80: [] = lists:sort(int:all_breaks(foobar)), 81: All = lists:sort(int:all_breaks(ordsets1)), 82: ok. 83: 84: cleanup(doc) -> "Make sure that the auto-attach flag is turned off."; 85: cleanup(suite) -> []; 86: cleanup(Config) when list(Config) -> 87: ?line int:auto_attach(false), 88: ok. 89: 90: auto_attach(Pid) -> 91: {ok, Meta} = int:attached(Pid), 92: io:format("Pid = ~p; Meta = ~p", [Pid,Meta]), 93: link(Meta), 94: attach_loop(Pid, Meta). 95: 96: attach_loop(Pid, Meta) -> 97: receive 98: Msg -> 99: io:format("attached: ~p", [Msg]), 100: attach_cmd(Msg, Pid, Meta), 101: attach_loop(Pid, Meta) 102: end. 103: 104: attach_cmd({Meta,{break_at,ordsets1,36,2}}, _Pid, Meta) -> 105: int:meta(Meta, continue); 106: attach_cmd({Meta,{break_at,ordsets1,87,_}}, _Pid, Meta) -> 107: int:meta(Meta, continue); 108: attach_cmd({Meta,{break_at,ordsets1,89,_}}, _Pid, Meta) -> 109: int:meta(Meta, continue); 110: attach_cmd({Meta,{break_at,ordsets1,Line,_}}, _Pid, Meta) when 107 =< Line, Line =< 115 -> 111: int:meta(Meta, finish); 112: attach_cmd({Meta,{break_at,_Mod,_Line,_Other}}=Cmd, _Pid, Meta) -> 113: io:format("attached: no action for ~p", [Cmd]); 114: attach_cmd(_, _Pid, _Meta) -> 115: ok.