1%% 2%% %CopyrightBegin% 3%% 4%% Copyright Ericsson AB 2001-2016. All Rights Reserved. 5%% 6%% Licensed under the Apache License, Version 2.0 (the "License"); 7%% you may not use this file except in compliance with the License. 8%% You may obtain a copy of the License at 9%% 10%% http://www.apache.org/licenses/LICENSE-2.0 11%% 12%% Unless required by applicable law or agreed to in writing, software 13%% distributed under the License is distributed on an "AS IS" BASIS, 14%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15%% See the License for the specific language governing permissions and 16%% limitations under the License. 17%% 18%% %CopyrightEnd% 19%% 20 21%% 22-module(debugger_SUITE). 23 24%% Test break points. 25 26-include_lib("common_test/include/ct.hrl"). 27 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 app_test/1,appup_test/1,erts_debug/1,encrypted_debug_info/1, 32 no_abstract_code/1]). 33 34suite() -> 35 [{ct_hooks,[ts_install_cth]}, 36 {timetrap,{minutes,1}}]. 37 38all() -> 39 [app_test, appup_test, erts_debug, no_abstract_code, 40 encrypted_debug_info]. 41 42groups() -> 43 []. 44 45init_per_suite(Config) -> 46 Config. 47 48end_per_suite(_Config) -> 49 ok. 50 51init_per_group(_GroupName, Config) -> 52 Config. 53 54end_per_group(_GroupName, Config) -> 55 Config. 56 57 58init_per_testcase(_Case, Config) -> 59 Config. 60 61end_per_testcase(_Case, _Config) -> 62 ok. 63 64app_test(Config) when is_list(Config) -> 65 test_server:app_test(debugger), 66 ok. 67 68appup_test(Config) when is_list(Config) -> 69 ok = test_server:appup_test(debugger). 70 71erts_debug(Config) when is_list(Config) -> 72 c:l(erts_debug), 73 ok. 74 75no_abstract_code(Config) when is_list(Config) -> 76 PrivDir = proplists:get_value(priv_dir, Config), 77 Simple = filename:join(PrivDir, "simple"), 78 Source = Simple ++ ".erl", 79 BeamFile = Simple ++ ".beam", 80 simple_file(Source), 81 82 %% Compile module without abstract code. 83 CompileFlags = [{outdir,PrivDir}], 84 {ok,_} = compile:file(Source, CompileFlags), 85 error = int:i(Simple), 86 87 %% Cleanup. 88 ok = file:delete(Source), 89 ok = file:delete(BeamFile), 90 91 ok. 92 93encrypted_debug_info(Config) when is_list(Config) -> 94 try begin crypto:start(), crypto:stop(), ok end of 95 ok -> 96 encrypted_debug_info_1(Config) 97 catch 98 error:_ -> 99 {skip,"The crypto application is missing or broken"} 100 end. 101 102encrypted_debug_info_1(Config) -> 103 PrivDir = proplists:get_value(priv_dir, Config), 104 Simple = filename:join(PrivDir, "simple"), 105 Source = Simple ++ ".erl", 106 BeamFile = Simple ++ ".beam", 107 simple_file(Source), 108 109 %% Compile module. 110 Key = "_This a Crypto Key_", 111 CompileFlags = [{outdir,PrivDir},debug_info,{debug_info_key,Key}], 112 {ok,_} = compile:file(Source, CompileFlags), 113 114 %% Interpret module 115 ok = beam_lib:crypto_key_fun(simple_crypto_fun(Key)), 116 {module,simple} = int:i(Simple), 117 118 %% Remove key. 119 {ok,_} = beam_lib:clear_crypto_key_fun(), 120 error = int:i(Simple), 121 122 %% Cleanup. 123 ok = file:delete(Source), 124 ok = file:delete(BeamFile), 125 126 ok. 127 128simple_crypto_fun(Key) -> 129 fun(init) -> ok; 130 ({debug_info, des3_cbc, simple, _}) -> Key 131 end. 132 133 134simple_file(File) -> 135 simple_file(File, simple). 136 137simple_file(File, Module) -> 138 simple_file(File, Module, member). 139 140simple_file(File, Module, F) -> 141 B = list_to_binary(["-module(", atom_to_list(Module), "). " 142 "-export([t/0]). " 143 "t() -> " 144 " t([]). " 145 "t(L) -> " 146 " lists:", 147 atom_to_list(F), "(a, L). "]), 148 ok = file:write_file(File, B). 149