From 40014d4b190c86044df5f1aa70dad7138d531b7b Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Wed, 4 Jan 2012 16:09:01 +0100 Subject: [reltool] Add more test cases and fix bugs OTP-9794 The following test cases are added for the inteface from GUI to reltool_server: * get_config * get_apps * set_app_and_undo * set_apps_and_undo * load_config_and_undo * reset_config_and_undo * save_config The following bugs were found and corrected: * If set_apps failed, then the state of reltool_server would not be reset to how it was before the failing operation - and every operation done afterwards would also (seem to) fail. * undo_config did not work after reset_config - since faulty #sys record was stored as old_sys. * undo_config did not work after set_app (used when changing the content of an application from the GUI) - since old_sys was not set. Also old_status was not set causing possible warnings to disappear. * undo_config did not work after set_apps (used e.g. when excluding or including an application from the GUI) - since old_sys was not set. Also old_status was not set causing possible warnings to disappear. --- lib/reltool/test/reltool_server_SUITE.erl | 391 ++++++++++++++++++++- .../faulty_app_file/a-1.0/ebin/a.app | 1 + .../faulty_app_file/a-1.0/src/a.erl | 49 +++ .../faulty_app_file/a-1.0/src/a_sup.erl | 37 ++ 4 files changed, 473 insertions(+), 5 deletions(-) create mode 100644 lib/reltool/test/reltool_server_SUITE_data/faulty_app_file/a-1.0/ebin/a.app create mode 100644 lib/reltool/test/reltool_server_SUITE_data/faulty_app_file/a-1.0/src/a.erl create mode 100644 lib/reltool/test/reltool_server_SUITE_data/faulty_app_file/a-1.0/src/a_sup.erl (limited to 'lib/reltool/test') diff --git a/lib/reltool/test/reltool_server_SUITE.erl b/lib/reltool/test/reltool_server_SUITE.erl index 9ed79e8c95..588db837e4 100644 --- a/lib/reltool/test/reltool_server_SUITE.erl +++ b/lib/reltool/test/reltool_server_SUITE.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2009-2011. All Rights Reserved. +%% Copyright Ericsson AB 2009-2012. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -24,6 +24,7 @@ -compile(export_all). +-include_lib("reltool/src/reltool.hrl"). -include("reltool_test_lib.hrl"). -include_lib("common_test/include/ct.hrl"). @@ -51,10 +52,12 @@ end_per_testcase(Func,Config) -> suite() -> [{ct_hooks,[ts_install_cth]}]. all() -> - [start_server, set_config, create_release, + [start_server, set_config, get_config, create_release, create_script, create_target, create_embedded, create_standalone, create_old_target, - otp_9135, otp_9229_exclude_app, otp_9229_exclude_mod]. + otp_9135, otp_9229_exclude_app, otp_9229_exclude_mod, + get_apps, set_app_and_undo, set_apps_and_undo, + load_config_and_undo, reset_config_and_undo, save_config]. groups() -> []. @@ -111,6 +114,83 @@ set_config(_Config) -> ?m(ok, reltool:stop(Pid)), ok. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Check that get_config returns the expected derivates and defaults +%% as specified +get_config(_Config) -> + Sys = {sys,[{incl_cond, exclude}, + {app,kernel,[{incl_cond,include}]}, + {app,sasl,[{incl_cond,include}]}, + {app,stdlib,[{incl_cond,include}]}]}, + {ok, Pid} = ?msym({ok, _}, reltool:start_server([{config, Sys}])), + ?m({ok, Sys}, reltool:get_config(Pid)), + ?m({ok, Sys}, reltool:get_config(Pid,false,false)), + + ?msym({ok,{sys,[{incl_cond, exclude}, + {erts,[]}, + {app,kernel,[{incl_cond,include},{mod,_,[]}|_]}, + {app,sasl,[{incl_cond,include},{mod,_,[]}|_]}, + {app,stdlib,[{incl_cond,include},{mod,_,[]}|_]}]}}, + reltool:get_config(Pid,false,true)), + + ?msym({ok,{sys,[{root_dir,_}, + {lib_dirs,_}, + {mod_cond,all}, + {incl_cond,exclude}, + {app,kernel,[{incl_cond,include},{vsn,undefined}]}, + {app,sasl,[{incl_cond,include},{vsn,undefined}]}, + {app,stdlib,[{incl_cond,include},{vsn,undefined}]}, + {boot_rel,"start_clean"}, + {rel,"start_clean","1.0",[]}, + {rel,"start_sasl","1.0",[sasl]}, + {emu_name,"beam"}, + {relocatable,true}, + {profile,development}, + {incl_sys_filters,[".*"]}, + {excl_sys_filters,[]}, + {incl_app_filters,[".*"]}, + {excl_app_filters,[]}, + {incl_archive_filters,[".*"]}, + {excl_archive_filters,["^include$","^priv$"]}, + {archive_opts,[]}, + {rel_app_type,permanent}, + {app_file,keep}, + {debug_info,keep}]}}, + reltool:get_config(Pid,true,false)), + + KVsn = latest(kernel), + StdVsn = latest(stdlib), + + ?msym({ok,{sys,[{root_dir,_}, + {lib_dirs,_}, + {mod_cond,all}, + {incl_cond,exclude}, + {erts,[]}, + {app,kernel,[{incl_cond,include},{vsn,KVsn},{mod,_,[]}|_]}, + {app,sasl,[{incl_cond,include},{vsn,_},{mod,_,[]}|_]}, + {app,stdlib,[{incl_cond,include},{vsn,StdVsn},{mod,_,[]}|_]}, + {boot_rel,"start_clean"}, + {rel,"start_clean","1.0",[]}, + {rel,"start_sasl","1.0",[sasl]}, + {emu_name,"beam"}, + {relocatable,true}, + {profile,development}, + {incl_sys_filters,[".*"]}, + {excl_sys_filters,[]}, + {incl_app_filters,[".*"]}, + {excl_app_filters,[]}, + {incl_archive_filters,[".*"]}, + {excl_archive_filters,["^include$","^priv$"]}, + {archive_opts,[]}, + {rel_app_type,permanent}, + {app_file,keep}, + {debug_info,keep}]}}, + reltool:get_config(Pid,true,true)), + + ?m(ok, reltool:stop(Pid)), + ok. + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% OTP-9135, test that app_file option can be set to all | keep | strip @@ -389,7 +469,7 @@ otp_9229_exclude_app(Config) -> ?m(ok, reltool_utils:recursive_delete(TargetDir)), ?m(ok, file:make_dir(TargetDir)), ?log("SPEC: ~p\n", [reltool:get_target_spec([{config, ExclApp}])]), - {ok,["Module mylib exists in applications x and y. Using module from application x."]} = reltool:get_status([{config, ExclApp}]), + ?m({ok,["Module mylib exists in applications x and y. Using module from application x."]}, reltool:get_status([{config, ExclApp}])), ?m(ok, reltool:create_target([{config, ExclApp}], TargetDir)), Erl = filename:join([TargetDir, "bin", "erl"]), @@ -436,7 +516,7 @@ otp_9229_exclude_mod(Config) -> ?m(ok, reltool_utils:recursive_delete(TargetDir)), ?m(ok, file:make_dir(TargetDir)), ?log("SPEC: ~p\n", [reltool:get_target_spec([{config, ExclMod}])]), - {ok,["Module mylib exists in applications x and y. Using module from application x."]} = reltool:get_status([{config, ExclMod}]), + ?m({ok,["Module mylib exists in applications x and y. Using module from application x."]}, reltool:get_status([{config, ExclMod}])), ?m(ok, reltool:create_target([{config, ExclMod}], TargetDir)), Erl = filename:join([TargetDir, "bin", "erl"]), @@ -466,7 +546,296 @@ otp_9229_exclude_mod(Config) -> ok. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Test the interface used by the GUI: +%% get_app +%% get_apps +%% set_app +%% set_apps +%% load_config +%% reset_config +%% +%% Also, for each operation which manipulates the config test +%% undo_config - that it is properly undone, and that warnings are +%% re-displayed. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +get_apps(_Config) -> + Sys = {sys,[{app,kernel,[{incl_cond,include}]}, + {app,sasl,[{incl_cond,include}]}, + {app,stdlib,[{incl_cond,include}]}, + {app,tools,[{incl_cond,derived}]}, + {app,runtime_tools,[{incl_cond,exclude}]}]}, + {ok, Pid} = ?msym({ok, _}, reltool:start_server([{config, Sys}])), + + {ok,Sasl} = ?msym({ok,#app{name=sasl}}, reltool_server:get_app(Pid,sasl)), + {ok,[#app{name=kernel}, + #app{name=sasl}=Sasl, + #app{name=stdlib}] = White} = + ?msym({ok,_}, reltool_server:get_apps(Pid,whitelist)), + {ok,[#app{name=runtime_tools}] = Black} = + ?msym({ok,_}, reltool_server:get_apps(Pid,blacklist)), + + {ok,Derived} = ?msym({ok,_}, reltool_server:get_apps(Pid,derived)), + true = lists:keymember(tools,#app.name,Derived), + + {ok,Source} = ?msym({ok,_}, reltool_server:get_apps(Pid,source)), + true = lists:keymember(common_test,#app.name,Source), + + %% Check that the four lists are disjoint + Number = length(White) + length(Black) + length(Derived) + length(Source), + WN = lists:usort([N || #app{name=N} <- White]), + BN = lists:usort([N || #app{name=N} <- Black]), + DN = lists:usort([N || #app{name=N} <- Derived]), + SN = lists:usort([N || #app{name=N} <- Source]), + AllN = lists:umerge([WN,BN,DN,SN]), + ?m(Number,length(AllN)), + + ?m(ok, reltool:stop(Pid)), + + ok. + +set_app_and_undo(Config) -> + Sys = {sys,[{lib_dirs,[filename:join(datadir(Config),"faulty_app_file")]}, + {incl_cond, exclude}, + {app,a,[{incl_cond,include}]}, + {app,kernel,[{incl_cond,include}]}, + {app,sasl,[{incl_cond,include}]}, + {app,stdlib,[{incl_cond,include}]}, + {app,tools,[{incl_cond,include}]}]}, + {ok, Pid} = ?msym({ok, _}, reltool:start_server([{config, Sys}])), + ?m({ok, Sys}, reltool:get_config(Pid)), + + %% Exclude one module with set_app + {ok,Tools} = ?msym({ok,_}, reltool_server:get_app(Pid,tools)), + Mods = Tools#app.mods, + Cover = lists:keyfind(cover,#mod.name,Mods), + ExclCover = Cover#mod{incl_cond=exclude}, + Tools1 = Tools#app{mods = lists:keyreplace(cover,#mod.name,Mods,ExclCover)}, + {ok,ToolsNoCover,[]} = ?msym({ok,_,[]}, reltool_server:set_app(Pid,Tools1)), + ?m({ok,ToolsNoCover}, reltool_server:get_app(Pid,tools)), + + %% Undo + ?m(ok, reltool_server:undo_config(Pid)), + ?m({ok,Tools}, reltool_server:get_app(Pid,tools)), + %%! warning can come twice here... :( + ?msym({ok,["a: Cannot parse app file"++_|_]}, reltool:get_status(Pid)), + + %% Undo again, to check that it toggles + ?m(ok, reltool_server:undo_config(Pid)), + ?m({ok,ToolsNoCover}, reltool_server:get_app(Pid,tools)), + ?m({ok,[]}, reltool:get_status(Pid)), + + ?m(ok, reltool:stop(Pid)), + ok. + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +set_apps_and_undo(Config) -> + Sys = {sys,[{lib_dirs,[filename:join(datadir(Config),"faulty_app_file")]}, + {incl_cond, exclude}, + {app,kernel,[{incl_cond,include}]}, + {app,sasl,[{incl_cond,include}]}, + {app,stdlib,[{incl_cond,include}]}, + {app,tools,[{incl_cond,include}]}]}, + {ok, Pid} = ?msym({ok, _}, reltool:start_server([{config, Sys}])), + ?m({ok, Sys}, reltool:get_config(Pid)), + + %% Exclude one application with set_apps + {ok,Tools} = ?msym({ok,_}, reltool_server:get_app(Pid,tools)), + ExclTools = Tools#app{incl_cond=exclude}, + ?m({ok,[]}, reltool_server:set_apps(Pid,[ExclTools])), + {ok,NoTools} = ?msym({ok,_}, reltool_server:get_app(Pid,tools)), + ?m(false, NoTools#app.is_pre_included), + ?m(false, NoTools#app.is_included), + + %% Undo + ?m(ok, reltool_server:undo_config(Pid)), + ?m({ok,Tools}, reltool_server:get_app(Pid,tools)), + %%! warning can come twice here... :( + ?msym({ok,["a: Cannot parse app file"++_|_]}, reltool:get_status(Pid)), + + %% Undo again, to check that it toggles + ?m(ok, reltool_server:undo_config(Pid)), + ?m({ok,NoTools}, reltool_server:get_app(Pid,tools)), + ?m({ok,[]}, reltool:get_status(Pid)), + + ?m(ok, reltool:stop(Pid)), + ok. + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +load_config_and_undo(Config) -> + Sys1 = {sys,[{incl_cond, exclude}, + {app,kernel,[{incl_cond,include}]}, + {app,sasl,[{incl_cond,include}]}, + {app,stdlib,[{incl_cond,include}]}, + {app,tools,[{incl_cond,include}]}]}, + {ok, Pid} = ?msym({ok, _}, reltool:start_server([{config, Sys1}])), + ?m({ok, Sys1}, reltool:get_config(Pid)), + + %% Check that tools is included + {ok,Tools1} = ?msym({ok,_}, reltool_server:get_app(Pid,tools)), + ?m(true, Tools1#app.is_pre_included), + ?m(true, Tools1#app.is_included), + + %% Exclude one application with set_apps + Sys2 = {sys,[{lib_dirs,[filename:join(datadir(Config),"faulty_app_file")]}, + {incl_cond, exclude}, + {app,kernel,[{incl_cond,include}]}, + {app,sasl,[{incl_cond,include}]}, + {app,stdlib,[{incl_cond,include}]}, + {app,tools,[{incl_cond,derived}]}, + {app,a,[{incl_cond,include}]}]}, + ?msym({ok,["a: Cannot parse app file"++_]}, + reltool_server:load_config(Pid,Sys2)), + + %% Check that tools is included (since it is used by sasl) but not + %% pre-included (neither included or excluded => undefined) + {ok,Tools2} = ?msym({ok,_}, reltool_server:get_app(Pid,tools)), + ?m(undefined, Tools2#app.is_pre_included), + ?m(true, Tools2#app.is_included), + + %% Undo + ?m(ok, reltool_server:undo_config(Pid)), + ?m({ok,Tools1}, reltool_server:get_app(Pid,tools)), + ?m({ok,[]}, reltool:get_status(Pid)), + + %% Undo again, to check that it toggles + ?m(ok, reltool_server:undo_config(Pid)), + ?m({ok,Tools2}, reltool_server:get_app(Pid,tools)), + ?msym({ok,["a: Cannot parse app file"++_]}, reltool:get_status(Pid)), + ?m(ok, reltool:stop(Pid)), + ok. + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +reset_config_and_undo(Config) -> + Sys1 = {sys,[{lib_dirs,[filename:join(datadir(Config),"faulty_app_file")]}, + {incl_cond, exclude}, + {app,a,[{incl_cond,include}]}, + {app,kernel,[{incl_cond,include}]}, + {app,sasl,[{incl_cond,include}]}, + {app,stdlib,[{incl_cond,include}]}, + {app,tools,[{incl_cond,include}]}]}, + {ok, Pid} = ?msym({ok, _}, reltool:start_server([{config, Sys1}])), + ?m({ok, Sys1}, reltool:get_config(Pid)), + + %% Check that tools is included + {ok,Tools1} = ?msym({ok,_}, reltool_server:get_app(Pid,tools)), + ?m(true, Tools1#app.is_pre_included), + ?m(true, Tools1#app.is_included), + + %% Exclude one application with set_apps + Sys2 = {sys,[{incl_cond, exclude}, + {app,kernel,[{incl_cond,include}]}, + {app,sasl,[{incl_cond,include}]}, + {app,stdlib,[{incl_cond,include}]}, + {app,tools,[{incl_cond,exclude}]}]}, + ?m({ok,[]}, reltool_server:load_config(Pid,Sys2)), + + %% Check that tools is excluded + {ok,Tools2} = ?msym({ok,_}, reltool_server:get_app(Pid,tools)), + ?m(false, Tools2#app.is_pre_included), + ?m(false, Tools2#app.is_included), + + %% Reset + %%! warning can come twice here... :( + ?msym({ok,["a: Cannot parse app file"++_|_]}, + reltool_server:reset_config(Pid)), + ?m({ok,Tools1}, reltool_server:get_app(Pid,tools)), + + %% Undo again, to check that it toggles + ?m(ok, reltool_server:undo_config(Pid)), + ?m({ok,Tools2}, reltool_server:get_app(Pid,tools)), + ?m({ok,[]}, reltool:get_status(Pid)), + + ?m(ok, reltool:stop(Pid)), + ok. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +save_config(Config) -> + PrivDir = ?config(priv_dir,Config), + Sys = {sys,[{incl_cond, exclude}, + {app,kernel,[{incl_cond,include}]}, + {app,sasl,[{incl_cond,include}]}, + {app,stdlib,[{incl_cond,include}]}]}, + {ok, Pid} = ?msym({ok, _}, reltool:start_server([{config, Sys}])), + ?m({ok, Sys}, reltool:get_config(Pid)), + + Simple = filename:join(PrivDir,"save_simple.reltool"), + ?m(ok, reltool_server:save_config(Pid,Simple,false,false)), + ?m({ok,[Sys]}, file:consult(Simple)), + + Derivates = filename:join(PrivDir,"save_derivates.reltool"), + ?m(ok, reltool_server:save_config(Pid,Derivates,false,true)), + ?msym({ok,[{sys,[{incl_cond, exclude}, + {erts,[]}, + {app,kernel,[{incl_cond,include},{mod,_,[]}|_]}, + {app,sasl,[{incl_cond,include},{mod,_,[]}|_]}, + {app,stdlib,[{incl_cond,include},{mod,_,[]}|_]}]}]}, + file:consult(Derivates)), + + Defaults = filename:join(PrivDir,"save_defaults.reltool"), + ?m(ok, reltool_server:save_config(Pid,Defaults,true,false)), + ?msym({ok,[{sys,[{root_dir,_}, + {lib_dirs,_}, + {mod_cond,all}, + {incl_cond,exclude}, + {app,kernel,[{incl_cond,include},{vsn,undefined}]}, + {app,sasl,[{incl_cond,include},{vsn,undefined}]}, + {app,stdlib,[{incl_cond,include},{vsn,undefined}]}, + {boot_rel,"start_clean"}, + {rel,"start_clean","1.0",[]}, + {rel,"start_sasl","1.0",[sasl]}, + {emu_name,"beam"}, + {relocatable,true}, + {profile,development}, + {incl_sys_filters,[".*"]}, + {excl_sys_filters,[]}, + {incl_app_filters,[".*"]}, + {excl_app_filters,[]}, + {incl_archive_filters,[".*"]}, + {excl_archive_filters,["^include$","^priv$"]}, + {archive_opts,[]}, + {rel_app_type,permanent}, + {app_file,keep}, + {debug_info,keep}]}]}, + file:consult(Defaults)), + + KVsn = latest(kernel), + StdVsn = latest(stdlib), + + All = filename:join(PrivDir,"save_all.reltool"), + ?m(ok, reltool_server:save_config(Pid,All,true,true)), + ?msym({ok,[{sys,[{root_dir,_}, + {lib_dirs,_}, + {mod_cond,all}, + {incl_cond,exclude}, + {erts,[]}, + {app,kernel,[{incl_cond,include},{vsn,KVsn},{mod,_,[]}|_]}, + {app,sasl,[{incl_cond,include},{vsn,_},{mod,_,[]}|_]}, + {app,stdlib,[{incl_cond,include},{vsn,StdVsn},{mod,_,[]}|_]}, + {boot_rel,"start_clean"}, + {rel,"start_clean","1.0",[]}, + {rel,"start_sasl","1.0",[sasl]}, + {emu_name,"beam"}, + {relocatable,true}, + {profile,development}, + {incl_sys_filters,[".*"]}, + {excl_sys_filters,[]}, + {incl_app_filters,[".*"]}, + {excl_app_filters,[]}, + {incl_archive_filters,[".*"]}, + {excl_archive_filters,["^include$","^priv$"]}, + {archive_opts,[]}, + {rel_app_type,permanent}, + {app_file,keep}, + {debug_info,keep}]}]}, + file:consult(All)), + + ?m(ok, reltool:stop(Pid)), + ok. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -478,6 +847,18 @@ erl_libs() -> LibStr -> string:tokens(LibStr, ":;") end. +datadir(Config) -> + %% Removes the trailing slash... + filename:nativename(?config(data_dir,Config)). + +latest(App) -> + AppStr = atom_to_list(App), + AppDirs = filelib:wildcard(filename:join(code:lib_dir(),AppStr++"-*")), + [LatestAppDir|_] = lists:reverse(AppDirs), + [_,Vsn] = string:tokens(filename:basename(LatestAppDir),"-"), + Vsn. + + diff_script(Script, Script) -> equal; diff_script({script, Rel, Commands1}, {script, Rel, Commands2}) -> diff --git a/lib/reltool/test/reltool_server_SUITE_data/faulty_app_file/a-1.0/ebin/a.app b/lib/reltool/test/reltool_server_SUITE_data/faulty_app_file/a-1.0/ebin/a.app new file mode 100644 index 0000000000..ea77103598 --- /dev/null +++ b/lib/reltool/test/reltool_server_SUITE_data/faulty_app_file/a-1.0/ebin/a.app @@ -0,0 +1 @@ +faulty app file diff --git a/lib/reltool/test/reltool_server_SUITE_data/faulty_app_file/a-1.0/src/a.erl b/lib/reltool/test/reltool_server_SUITE_data/faulty_app_file/a-1.0/src/a.erl new file mode 100644 index 0000000000..bb500bed69 --- /dev/null +++ b/lib/reltool/test/reltool_server_SUITE_data/faulty_app_file/a-1.0/src/a.erl @@ -0,0 +1,49 @@ +%% ``The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved via the world wide web at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% The Initial Developer of the Original Code is Ericsson Utvecklings AB. +%% Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings +%% AB. All Rights Reserved.'' +%% +%% $Id$ +%% +-module(a). + + +-behaviour(gen_server). + +-vsn(1). + +%% External exports +-export([start_link/0, a/0]). +%% Internal exports +-export([init/1, handle_call/3, handle_info/2, terminate/2]). + +start_link() -> gen_server:start_link({local, aa}, a, [], []). + +a() -> gen_server:call(aa, a). + +%%----------------------------------------------------------------- +%% Callback functions from gen_server +%%----------------------------------------------------------------- +init([]) -> + process_flag(trap_exit, true), + {ok, state}. + +handle_call(a, _From, State) -> + X = application:get_all_env(a), + {reply, X, State}. + +handle_info(_, State) -> + {noreply, State}. + +terminate(_Reason, _State) -> + ok. diff --git a/lib/reltool/test/reltool_server_SUITE_data/faulty_app_file/a-1.0/src/a_sup.erl b/lib/reltool/test/reltool_server_SUITE_data/faulty_app_file/a-1.0/src/a_sup.erl new file mode 100644 index 0000000000..a141c1767b --- /dev/null +++ b/lib/reltool/test/reltool_server_SUITE_data/faulty_app_file/a-1.0/src/a_sup.erl @@ -0,0 +1,37 @@ +%% ``The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved via the world wide web at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% The Initial Developer of the Original Code is Ericsson Utvecklings AB. +%% Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings +%% AB. All Rights Reserved.'' +%% +%% $Id$ +%% +-module(a_sup). + + +-behaviour(supervisor). + +%% External exports +-export([start/2]). + +%% Internal exports +-export([init/1]). + +start(_, _) -> + supervisor:start_link({local, a_sup}, a_sup, []). + +init([]) -> + SupFlags = {one_for_one, 4, 3600}, + Config = {a, + {a, start_link, []}, + permanent, 2000, worker, [a]}, + {ok, {SupFlags, [Config]}}. -- cgit v1.2.3 From e610c1e38219b7038f2e42b233ef226508535a90 Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Mon, 9 Jan 2012 15:42:29 +0100 Subject: [reltool] Add test of dependencies derived through calls to external apps OTP-9794 This is a test of the mechanism with which reltool_server decides which applications to include and not, based on function calls between applications. This is also the mechanism which forms the base for the application- and module dependency graphs. --- lib/reltool/test/reltool_server_SUITE.erl | 142 ++++++++++++++++++++- .../test/reltool_server_SUITE_data/Makefile.src | 23 +++- .../dependencies/x-1.0/ebin/x.app | 7 + .../dependencies/x-1.0/src/x1.erl | 5 + .../dependencies/x-1.0/src/x2.erl | 5 + .../dependencies/x-1.0/src/x3.erl | 5 + .../dependencies/y-1.0/ebin/y.app | 7 + .../dependencies/y-1.0/src/y1.erl | 5 + .../dependencies/y-1.0/src/y2.erl | 5 + .../dependencies/z-1.0/ebin/z.app | 7 + .../dependencies/z-1.0/src/z1.erl | 5 + 11 files changed, 214 insertions(+), 2 deletions(-) create mode 100644 lib/reltool/test/reltool_server_SUITE_data/dependencies/x-1.0/ebin/x.app create mode 100644 lib/reltool/test/reltool_server_SUITE_data/dependencies/x-1.0/src/x1.erl create mode 100644 lib/reltool/test/reltool_server_SUITE_data/dependencies/x-1.0/src/x2.erl create mode 100644 lib/reltool/test/reltool_server_SUITE_data/dependencies/x-1.0/src/x3.erl create mode 100644 lib/reltool/test/reltool_server_SUITE_data/dependencies/y-1.0/ebin/y.app create mode 100644 lib/reltool/test/reltool_server_SUITE_data/dependencies/y-1.0/src/y1.erl create mode 100644 lib/reltool/test/reltool_server_SUITE_data/dependencies/y-1.0/src/y2.erl create mode 100644 lib/reltool/test/reltool_server_SUITE_data/dependencies/z-1.0/ebin/z.app create mode 100644 lib/reltool/test/reltool_server_SUITE_data/dependencies/z-1.0/src/z1.erl (limited to 'lib/reltool/test') diff --git a/lib/reltool/test/reltool_server_SUITE.erl b/lib/reltool/test/reltool_server_SUITE.erl index 588db837e4..90288020f1 100644 --- a/lib/reltool/test/reltool_server_SUITE.erl +++ b/lib/reltool/test/reltool_server_SUITE.erl @@ -57,7 +57,8 @@ all() -> create_standalone, create_old_target, otp_9135, otp_9229_exclude_app, otp_9229_exclude_mod, get_apps, set_app_and_undo, set_apps_and_undo, - load_config_and_undo, reset_config_and_undo, save_config]. + load_config_and_undo, reset_config_and_undo, save_config, + dependencies]. groups() -> []. @@ -837,6 +838,143 @@ save_config(Config) -> ?m(ok, reltool:stop(Pid)), ok. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Test calculation of dependencies +%% The following test applications are used +%% +%% x-1.0: x1.erl x2.erl x3.erl +%% \ / (x2 calls y1, x3 calls y2) +%% y-1.0: y1.erl y2.erl +%% \ (y1 calls z1) +%% z-1.0 z1.erl +%% +%% Test includes x and derives y and z. +%% +dependencies(Config) -> + PrivDir = ?config(priv_dir,Config), + + %% Default: all modules included => y and z are included (derived) + Sys = {sys,[{lib_dirs,[filename:join(datadir(Config),"dependencies")]}, + {incl_cond, exclude}, + {app,kernel,[{incl_cond,include}]}, + {app,sasl,[{incl_cond,include}]}, + {app,stdlib,[{incl_cond,include}]}, + {app,x,[{incl_cond,include}]}, + {app,y,[{incl_cond,derived}]}, + {app,z,[{incl_cond,derived}]}]}, + {ok, Pid} = ?msym({ok, _}, reltool:start_server([{config, Sys}])), + + ?msym({ok,[#app{name=kernel}, + #app{name=sasl}, + #app{name=stdlib}, + #app{name=x,uses_apps=[y]}]}, + reltool_server:get_apps(Pid,whitelist)), + {ok, Der} = ?msym({ok,_}, + reltool_server:get_apps(Pid,derived)), + ?msym([#app{name=y,uses_apps=[z]}, + #app{name=z}], + rm_missing_app(Der)), + ?msym({ok,[]}, + reltool_server:get_apps(Pid,source)), + + %% Excluding x2 => y still included since y2 is used by x3 + %% z still included since z1 is used by y1 + Sys2 = {sys,[{lib_dirs,[filename:join(datadir(Config),"dependencies")]}, + {incl_cond, exclude}, + {app,kernel,[{incl_cond,include}]}, + {app,sasl,[{incl_cond,include}]}, + {app,stdlib,[{incl_cond,include}]}, + {app,x,[{incl_cond,include},{mod,x2,[{incl_cond,exclude}]}]}, + {app,y,[{incl_cond,derived}]}, + {app,z,[{incl_cond,derived}]}]}, + ?m({ok,[]}, reltool_server:load_config(Pid,Sys2)), + ?msym({ok,[#app{name=kernel}, + #app{name=sasl}, + #app{name=stdlib}, + #app{name=x,uses_apps=[y]}]}, + reltool_server:get_apps(Pid,whitelist)), + {ok, Der2} = ?msym({ok,_}, + reltool_server:get_apps(Pid,derived)), + ?msym([#app{name=y,uses_apps=[z]}, + #app{name=z}], + rm_missing_app(Der2)), + ?msym({ok,[]}, + reltool_server:get_apps(Pid,source)), + + %% Excluding x3 => y still included since y1 is used by x2 + %% z still included since z1 is used by y1 + Sys3 = {sys,[{lib_dirs,[filename:join(datadir(Config),"dependencies")]}, + {incl_cond, exclude}, + {app,kernel,[{incl_cond,include}]}, + {app,sasl,[{incl_cond,include}]}, + {app,stdlib,[{incl_cond,include}]}, + {app,x,[{incl_cond,include},{mod,x3,[{incl_cond,exclude}]}]}, + {app,y,[{incl_cond,derived}]}, + {app,z,[{incl_cond,derived}]}]}, + ?m({ok,[]}, reltool_server:load_config(Pid,Sys3)), + ?msym({ok,[#app{name=kernel}, + #app{name=sasl}, + #app{name=stdlib}, + #app{name=x,uses_apps=[y]}]}, + reltool_server:get_apps(Pid,whitelist)), + {ok, Der3} = ?msym({ok,_}, + reltool_server:get_apps(Pid,derived)), + ?msym([#app{name=y,uses_apps=[z]}, + #app{name=z}], + rm_missing_app(Der3)), + ?msym({ok,[]}, + reltool_server:get_apps(Pid,source)), + + %% Excluding x2 and x3 => y and z excluded + Sys4 = {sys,[{lib_dirs,[filename:join(datadir(Config),"dependencies")]}, + {incl_cond, exclude}, + {app,kernel,[{incl_cond,include}]}, + {app,sasl,[{incl_cond,include}]}, + {app,stdlib,[{incl_cond,include}]}, + {app,x,[{incl_cond,include}, + {mod,x2,[{incl_cond,exclude}]}, + {mod,x3,[{incl_cond,exclude}]}]}, + {app,y,[{incl_cond,derived}]}, + {app,z,[{incl_cond,derived}]}]}, + ?m({ok,[]}, reltool_server:load_config(Pid,Sys4)), + ?msym({ok,[#app{name=kernel}, + #app{name=sasl}, + #app{name=stdlib}, + #app{name=x,uses_apps=[]}]}, + reltool_server:get_apps(Pid,whitelist)), + {ok, Der4} = ?msym({ok,_}, + reltool_server:get_apps(Pid,derived)), + ?msym([], rm_missing_app(Der4)), + ?msym({ok,[#app{name=y}, + #app{name=z}]}, + reltool_server:get_apps(Pid,source)), + + %% Excluding y1 => y still included since y2 is used by x3 + %% z excluded since not used by any other than y1 + Sys5 = {sys,[{lib_dirs,[filename:join(datadir(Config),"dependencies")]}, + {incl_cond, exclude}, + {app,kernel,[{incl_cond,include}]}, + {app,sasl,[{incl_cond,include}]}, + {app,stdlib,[{incl_cond,include}]}, + {app,x,[{incl_cond,include}]}, + {app,y,[{incl_cond,derived}, + {mod,y1,[{incl_cond,exclude}]}]}, + {app,z,[{incl_cond,derived}]}]}, + ?m({ok,[]}, reltool_server:load_config(Pid,Sys5)), + ?msym({ok,[#app{name=kernel}, + #app{name=sasl}, + #app{name=stdlib}, + #app{name=x,uses_apps=[y]}]}, + reltool_server:get_apps(Pid,whitelist)), + {ok, Der5} = ?msym({ok,_}, + reltool_server:get_apps(Pid,derived)), + ?msym([#app{name=y,uses_apps=[]}], rm_missing_app(Der5)), + ?msym({ok,[#app{name=z}]}, + reltool_server:get_apps(Pid,source)), + + ?m(ok, reltool:stop(Pid)), + ok. + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Library functions @@ -858,6 +996,8 @@ latest(App) -> [_,Vsn] = string:tokens(filename:basename(LatestAppDir),"-"), Vsn. +rm_missing_app(Apps) -> + lists:keydelete(?MISSING_APP_NAME,#app.name,Apps). diff_script(Script, Script) -> equal; diff --git a/lib/reltool/test/reltool_server_SUITE_data/Makefile.src b/lib/reltool/test/reltool_server_SUITE_data/Makefile.src index 049e8dd6cc..35a239bfe2 100644 --- a/lib/reltool/test/reltool_server_SUITE_data/Makefile.src +++ b/lib/reltool/test/reltool_server_SUITE_data/Makefile.src @@ -6,8 +6,16 @@ OTP9229= \ otp_9229/y-1.0/ebin/y.@EMULATOR@ \ otp_9229/y-1.0/ebin/mylib.@EMULATOR@ +DEPENDENCIES= \ + dependencies/x-1.0/ebin/x1.@EMULATOR@ \ + dependencies/x-1.0/ebin/x2.@EMULATOR@ \ + dependencies/x-1.0/ebin/x3.@EMULATOR@ \ + dependencies/y-1.0/ebin/y1.@EMULATOR@ \ + dependencies/y-1.0/ebin/y2.@EMULATOR@ \ + dependencies/z-1.0/ebin/z1.@EMULATOR@ -all: $(OTP9229) + +all: $(OTP9229) $(DEPENDENCIES) otp_9229/x-1.0/ebin/x.@EMULATOR@: otp_9229/x-1.0/src/x.erl erlc $(EFLAGS) -ootp_9229/x-1.0/ebin otp_9229/x-1.0/src/x.erl @@ -17,3 +25,16 @@ otp_9229/y-1.0/ebin/y.@EMULATOR@: otp_9229/y-1.0/src/y.erl erlc $(EFLAGS) -ootp_9229/y-1.0/ebin otp_9229/y-1.0/src/y.erl otp_9229/y-1.0/ebin/mylib.@EMULATOR@: otp_9229/y-1.0/src/mylib.erl erlc $(EFLAGS) -ootp_9229/y-1.0/ebin otp_9229/y-1.0/src/mylib.erl + +dependencies/x-1.0/ebin/x1.@EMULATOR@: dependencies/x-1.0/src/x1.erl + erlc $(EFLAGS) -odependencies/x-1.0/ebin dependencies/x-1.0/src/x1.erl +dependencies/x-1.0/ebin/x2.@EMULATOR@: dependencies/x-1.0/src/x2.erl + erlc $(EFLAGS) -odependencies/x-1.0/ebin dependencies/x-1.0/src/x2.erl +dependencies/x-1.0/ebin/x3.@EMULATOR@: dependencies/x-1.0/src/x3.erl + erlc $(EFLAGS) -odependencies/x-1.0/ebin dependencies/x-1.0/src/x3.erl +dependencies/y-1.0/ebin/y1.@EMULATOR@: dependencies/y-1.0/src/y1.erl + erlc $(EFLAGS) -odependencies/y-1.0/ebin dependencies/y-1.0/src/y1.erl +dependencies/y-1.0/ebin/y2.@EMULATOR@: dependencies/y-1.0/src/y2.erl + erlc $(EFLAGS) -odependencies/y-1.0/ebin dependencies/y-1.0/src/y2.erl +dependencies/z-1.0/ebin/z1.@EMULATOR@: dependencies/z-1.0/src/z1.erl + erlc $(EFLAGS) -odependencies/z-1.0/ebin dependencies/z-1.0/src/z1.erl diff --git a/lib/reltool/test/reltool_server_SUITE_data/dependencies/x-1.0/ebin/x.app b/lib/reltool/test/reltool_server_SUITE_data/dependencies/x-1.0/ebin/x.app new file mode 100644 index 0000000000..ccaab8a8c7 --- /dev/null +++ b/lib/reltool/test/reltool_server_SUITE_data/dependencies/x-1.0/ebin/x.app @@ -0,0 +1,7 @@ +% -*-erlang-*- +{application, x, + [{description, "Main application in reltool dependency test"}, + {vsn, "1.0"}, + {modules, [x1,x2,x3]}, + {registered, []}, + {applications, [kernel, stdlib]}]}. diff --git a/lib/reltool/test/reltool_server_SUITE_data/dependencies/x-1.0/src/x1.erl b/lib/reltool/test/reltool_server_SUITE_data/dependencies/x-1.0/src/x1.erl new file mode 100644 index 0000000000..bf1e7f9279 --- /dev/null +++ b/lib/reltool/test/reltool_server_SUITE_data/dependencies/x-1.0/src/x1.erl @@ -0,0 +1,5 @@ +-module(x1). +-compile(export_all). + +f() -> + ok. diff --git a/lib/reltool/test/reltool_server_SUITE_data/dependencies/x-1.0/src/x2.erl b/lib/reltool/test/reltool_server_SUITE_data/dependencies/x-1.0/src/x2.erl new file mode 100644 index 0000000000..82191ba278 --- /dev/null +++ b/lib/reltool/test/reltool_server_SUITE_data/dependencies/x-1.0/src/x2.erl @@ -0,0 +1,5 @@ +-module(x2). +-compile(export_all). + +f() -> + y1:f(). diff --git a/lib/reltool/test/reltool_server_SUITE_data/dependencies/x-1.0/src/x3.erl b/lib/reltool/test/reltool_server_SUITE_data/dependencies/x-1.0/src/x3.erl new file mode 100644 index 0000000000..618c75c9a7 --- /dev/null +++ b/lib/reltool/test/reltool_server_SUITE_data/dependencies/x-1.0/src/x3.erl @@ -0,0 +1,5 @@ +-module(x3). +-compile(export_all). + +f() -> + y2:f(). diff --git a/lib/reltool/test/reltool_server_SUITE_data/dependencies/y-1.0/ebin/y.app b/lib/reltool/test/reltool_server_SUITE_data/dependencies/y-1.0/ebin/y.app new file mode 100644 index 0000000000..d9dac371d7 --- /dev/null +++ b/lib/reltool/test/reltool_server_SUITE_data/dependencies/y-1.0/ebin/y.app @@ -0,0 +1,7 @@ +% -*-erlang-*- +{application, y, + [{description, "Library application in reltool dependency test"}, + {vsn, "1.0"}, + {modules, [y1,y2]}, + {registered, []}, + {applications, [kernel, stdlib]}]}. diff --git a/lib/reltool/test/reltool_server_SUITE_data/dependencies/y-1.0/src/y1.erl b/lib/reltool/test/reltool_server_SUITE_data/dependencies/y-1.0/src/y1.erl new file mode 100644 index 0000000000..dd21b33292 --- /dev/null +++ b/lib/reltool/test/reltool_server_SUITE_data/dependencies/y-1.0/src/y1.erl @@ -0,0 +1,5 @@ +-module(y1). +-compile(export_all). + +f() -> + z1:f(). diff --git a/lib/reltool/test/reltool_server_SUITE_data/dependencies/y-1.0/src/y2.erl b/lib/reltool/test/reltool_server_SUITE_data/dependencies/y-1.0/src/y2.erl new file mode 100644 index 0000000000..bf8ddf6080 --- /dev/null +++ b/lib/reltool/test/reltool_server_SUITE_data/dependencies/y-1.0/src/y2.erl @@ -0,0 +1,5 @@ +-module(y2). +-compile(export_all). + +f() -> + ok. diff --git a/lib/reltool/test/reltool_server_SUITE_data/dependencies/z-1.0/ebin/z.app b/lib/reltool/test/reltool_server_SUITE_data/dependencies/z-1.0/ebin/z.app new file mode 100644 index 0000000000..437a0968e9 --- /dev/null +++ b/lib/reltool/test/reltool_server_SUITE_data/dependencies/z-1.0/ebin/z.app @@ -0,0 +1,7 @@ +% -*-erlang-*- +{application, z, + [{description, "Library application in reltool dependency test"}, + {vsn, "1.0"}, + {modules, [z1]}, + {registered, []}, + {applications, [kernel, stdlib]}]}. diff --git a/lib/reltool/test/reltool_server_SUITE_data/dependencies/z-1.0/src/z1.erl b/lib/reltool/test/reltool_server_SUITE_data/dependencies/z-1.0/src/z1.erl new file mode 100644 index 0000000000..97ef90b87f --- /dev/null +++ b/lib/reltool/test/reltool_server_SUITE_data/dependencies/z-1.0/src/z1.erl @@ -0,0 +1,5 @@ +-module(z1). +-compile(export_all). + +f() -> + ok. -- cgit v1.2.3 From 06ea8c9f62e265bc045eb92d522e84a5f208f8cd Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Fri, 13 Jan 2012 14:54:50 +0100 Subject: [reltool] Ensure that tests do not try to start node if target was not created OTP-9794 Some test cases in reltool_server_SUITE tried to create a target system and then start a node running this system. If creation of the target system failed, an attempt would still be made to start the node. This has been corrected so the test is immediately terminated if the target system could not be created. --- lib/reltool/test/reltool_server_SUITE.erl | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'lib/reltool/test') diff --git a/lib/reltool/test/reltool_server_SUITE.erl b/lib/reltool/test/reltool_server_SUITE.erl index 90288020f1..086ada41e0 100644 --- a/lib/reltool/test/reltool_server_SUITE.erl +++ b/lib/reltool/test/reltool_server_SUITE.erl @@ -324,7 +324,7 @@ create_target(_Config) -> ?m(ok, reltool_utils:recursive_delete(TargetDir)), ?m(ok, file:make_dir(TargetDir)), ?log("SPEC: ~p\n", [reltool:get_target_spec([{config, Config}])]), - ?m(ok, reltool:create_target([{config, Config}], TargetDir)), + ok = ?m(ok, reltool:create_target([{config, Config}], TargetDir)), Erl = filename:join([TargetDir, "bin", "erl"]), {ok, Node} = ?msym({ok, _}, start_node(?NODE_NAME, Erl)), @@ -357,7 +357,7 @@ create_embedded(_Config) -> TargetDir = filename:join([?WORK_DIR, "target_embedded"]), ?m(ok, reltool_utils:recursive_delete(TargetDir)), ?m(ok, file:make_dir(TargetDir)), - ?m(ok, reltool:create_target([{config, Config}], TargetDir)), + ok = ?m(ok, reltool:create_target([{config, Config}], TargetDir)), Erl = filename:join([TargetDir, "bin", "erl"]), {ok, Node} = ?msym({ok, _}, start_node(?NODE_NAME, Erl)), @@ -387,7 +387,7 @@ create_standalone(_Config) -> TargetDir = filename:join([?WORK_DIR, "target_standalone"]), ?m(ok, reltool_utils:recursive_delete(TargetDir)), ?m(ok, file:make_dir(TargetDir)), - ?m(ok, reltool:create_target([{config, Config}], TargetDir)), + ok = ?m(ok, reltool:create_target([{config, Config}], TargetDir)), BinDir = filename:join([TargetDir, "bin"]), Erl = filename:join([BinDir, "erl"]), @@ -431,10 +431,10 @@ create_old_target(_Config) -> TargetDir = filename:join([?WORK_DIR, "target_old_style"]), ?m(ok, reltool_utils:recursive_delete(TargetDir)), ?m(ok, file:make_dir(TargetDir)), - ?m(ok, reltool:create_target([{config, Config}], TargetDir)), + ok = ?m(ok, reltool:create_target([{config, Config}], TargetDir)), %% io:format("Will fail on Windows (should patch erl.ini)\n", []), - ?m(ok, reltool:install(RelName2, TargetDir)), + ok = ?m(ok, reltool:install(RelName2, TargetDir)), Erl = filename:join([TargetDir, "bin", "erl"]), {ok, Node} = ?msym({ok, _}, start_node(?NODE_NAME, Erl)), @@ -471,7 +471,7 @@ otp_9229_exclude_app(Config) -> ?m(ok, file:make_dir(TargetDir)), ?log("SPEC: ~p\n", [reltool:get_target_spec([{config, ExclApp}])]), ?m({ok,["Module mylib exists in applications x and y. Using module from application x."]}, reltool:get_status([{config, ExclApp}])), - ?m(ok, reltool:create_target([{config, ExclApp}], TargetDir)), + ok = ?m(ok, reltool:create_target([{config, ExclApp}], TargetDir)), Erl = filename:join([TargetDir, "bin", "erl"]), {ok, Node} = ?msym({ok, _}, start_node(?NODE_NAME, Erl)), @@ -518,7 +518,7 @@ otp_9229_exclude_mod(Config) -> ?m(ok, file:make_dir(TargetDir)), ?log("SPEC: ~p\n", [reltool:get_target_spec([{config, ExclMod}])]), ?m({ok,["Module mylib exists in applications x and y. Using module from application x."]}, reltool:get_status([{config, ExclMod}])), - ?m(ok, reltool:create_target([{config, ExclMod}], TargetDir)), + ok = ?m(ok, reltool:create_target([{config, ExclMod}], TargetDir)), Erl = filename:join([TargetDir, "bin", "erl"]), {ok, Node} = ?msym({ok, _}, start_node(?NODE_NAME, Erl)), -- cgit v1.2.3 From 610280492bca33c851eabda0a2daf5cf141ea090 Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Fri, 20 Jan 2012 17:10:31 +0100 Subject: [reltool] Add test case for reltool_server:get_mod OTP-9794 This test case revealed a bug that occurs when calling reltool_server:get_mod after reltool_server:undo_config. get_mod reads from the module table (ets) and not from the reltool_server state, while undo_config only changes the state. This bug has been corrected, so undo_config now updates both state and tables (it does the same as set_sys). --- lib/reltool/test/reltool_server_SUITE.erl | 116 ++++++++++++++++++++++-------- 1 file changed, 88 insertions(+), 28 deletions(-) (limited to 'lib/reltool/test') diff --git a/lib/reltool/test/reltool_server_SUITE.erl b/lib/reltool/test/reltool_server_SUITE.erl index 086ada41e0..79c6854465 100644 --- a/lib/reltool/test/reltool_server_SUITE.erl +++ b/lib/reltool/test/reltool_server_SUITE.erl @@ -56,7 +56,7 @@ all() -> create_script, create_target, create_embedded, create_standalone, create_old_target, otp_9135, otp_9229_exclude_app, otp_9229_exclude_mod, - get_apps, set_app_and_undo, set_apps_and_undo, + get_apps, get_mod, set_app_and_undo, set_apps_and_undo, load_config_and_undo, reset_config_and_undo, save_config, dependencies]. @@ -595,6 +595,29 @@ get_apps(_Config) -> ok. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +get_mod(_Config) -> + Sys = {sys,[{app,kernel,[{incl_cond,include}]}, + {app,sasl,[{incl_cond,include}]}, + {app,stdlib,[{incl_cond,include}]}, + {app,tools,[{incl_cond,derived}]}, + {app,runtime_tools,[{incl_cond,exclude}]}]}, + {ok, Pid} = ?msym({ok, _}, reltool:start_server([{config, Sys}])), + + %% Read app and get a module from the #app record + {ok,Tools} = ?msym({ok,#app{name=tools}}, reltool_server:get_app(Pid,tools)), + Cover = lists:keyfind(cover,#mod.name,Tools#app.mods), + + %% get_mod - and check that it is equal to the one in #app.mods + ?m({ok,Cover}, reltool_server:get_mod(Pid,cover)), + + ?m(ok, reltool:stop(Pid)), + + ok. + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% set_app_and_undo(Config) -> Sys = {sys,[{lib_dirs,[filename:join(datadir(Config),"faulty_app_file")]}, {incl_cond, exclude}, @@ -606,25 +629,32 @@ set_app_and_undo(Config) -> {ok, Pid} = ?msym({ok, _}, reltool:start_server([{config, Sys}])), ?m({ok, Sys}, reltool:get_config(Pid)), - %% Exclude one module with set_app + %% Get app and mod {ok,Tools} = ?msym({ok,_}, reltool_server:get_app(Pid,tools)), - Mods = Tools#app.mods, - Cover = lists:keyfind(cover,#mod.name,Mods), + {ok,Cover} = ?msym({ok,#mod{name=cover, is_included=true}}, + reltool_server:get_mod(Pid,cover)), + + %% Exclude one module with set_app ExclCover = Cover#mod{incl_cond=exclude}, + Mods = Tools#app.mods, Tools1 = Tools#app{mods = lists:keyreplace(cover,#mod.name,Mods,ExclCover)}, {ok,ToolsNoCover,[]} = ?msym({ok,_,[]}, reltool_server:set_app(Pid,Tools1)), + + %% Check that the module is no longer included ?m({ok,ToolsNoCover}, reltool_server:get_app(Pid,tools)), + {ok,NoIncludeCover} = ?msym({ok,#mod{name=cover, is_included=false}}, + reltool_server:get_mod(Pid,cover)), %% Undo - ?m(ok, reltool_server:undo_config(Pid)), - ?m({ok,Tools}, reltool_server:get_app(Pid,tools)), %%! warning can come twice here... :( - ?msym({ok,["a: Cannot parse app file"++_|_]}, reltool:get_status(Pid)), + ?msym({ok,["a: Cannot parse app file"++_|_]},reltool_server:undo_config(Pid)), + ?m({ok,Tools}, reltool_server:get_app(Pid,tools)), + ?m({ok,Cover}, reltool_server:get_mod(Pid,cover)), %% Undo again, to check that it toggles - ?m(ok, reltool_server:undo_config(Pid)), + ?m({ok,[]}, reltool_server:undo_config(Pid)), ?m({ok,ToolsNoCover}, reltool_server:get_app(Pid,tools)), - ?m({ok,[]}, reltool:get_status(Pid)), + ?m({ok,NoIncludeCover}, reltool_server:get_mod(Pid,cover)), ?m(ok, reltool:stop(Pid)), ok. @@ -641,24 +671,34 @@ set_apps_and_undo(Config) -> {ok, Pid} = ?msym({ok, _}, reltool:start_server([{config, Sys}])), ?m({ok, Sys}, reltool:get_config(Pid)), - %% Exclude one application with set_apps + %% Get app and mod {ok,Tools} = ?msym({ok,_}, reltool_server:get_app(Pid,tools)), + ?m(true, Tools#app.is_pre_included), + ?m(true, Tools#app.is_included), + {ok,Cover} = ?msym({ok,#mod{name=cover, is_included=true}}, + reltool_server:get_mod(Pid,cover)), + + %% Exclude one application with set_apps ExclTools = Tools#app{incl_cond=exclude}, ?m({ok,[]}, reltool_server:set_apps(Pid,[ExclTools])), + + %% Check that the app and its modules (one of them) are no longer included {ok,NoTools} = ?msym({ok,_}, reltool_server:get_app(Pid,tools)), ?m(false, NoTools#app.is_pre_included), ?m(false, NoTools#app.is_included), + {ok,NoIncludeCover} = ?msym({ok,#mod{name=cover, is_included=false}}, + reltool_server:get_mod(Pid,cover)), %% Undo - ?m(ok, reltool_server:undo_config(Pid)), - ?m({ok,Tools}, reltool_server:get_app(Pid,tools)), %%! warning can come twice here... :( - ?msym({ok,["a: Cannot parse app file"++_|_]}, reltool:get_status(Pid)), + ?msym({ok,["a: Cannot parse app file"++_|_]},reltool_server:undo_config(Pid)), + ?m({ok,Tools}, reltool_server:get_app(Pid,tools)), + ?m({ok,Cover}, reltool_server:get_mod(Pid,cover)), %% Undo again, to check that it toggles - ?m(ok, reltool_server:undo_config(Pid)), + ?m({ok,[]}, reltool_server:undo_config(Pid)), ?m({ok,NoTools}, reltool_server:get_app(Pid,tools)), - ?m({ok,[]}, reltool:get_status(Pid)), + ?m({ok,NoIncludeCover}, reltool_server:get_mod(Pid,cover)), ?m(ok, reltool:stop(Pid)), ok. @@ -674,12 +714,16 @@ load_config_and_undo(Config) -> {ok, Pid} = ?msym({ok, _}, reltool:start_server([{config, Sys1}])), ?m({ok, Sys1}, reltool:get_config(Pid)), - %% Check that tools is included + %% Get app and mod {ok,Tools1} = ?msym({ok,_}, reltool_server:get_app(Pid,tools)), ?m(true, Tools1#app.is_pre_included), ?m(true, Tools1#app.is_included), + {ok,Cover1} = ?msym({ok,#mod{name=cover, + is_included=true, + is_pre_included=true}}, + reltool_server:get_mod(Pid,cover)), - %% Exclude one application with set_apps + %% Change tools from include to derived by loading new config Sys2 = {sys,[{lib_dirs,[filename:join(datadir(Config),"faulty_app_file")]}, {incl_cond, exclude}, {app,kernel,[{incl_cond,include}]}, @@ -695,16 +739,20 @@ load_config_and_undo(Config) -> {ok,Tools2} = ?msym({ok,_}, reltool_server:get_app(Pid,tools)), ?m(undefined, Tools2#app.is_pre_included), ?m(true, Tools2#app.is_included), + {ok,Cover2} = ?msym({ok,#mod{name=cover, + is_included=true, + is_pre_included=undefined}}, + reltool_server:get_mod(Pid,cover)), %% Undo - ?m(ok, reltool_server:undo_config(Pid)), + ?m({ok,[]}, reltool_server:undo_config(Pid)), ?m({ok,Tools1}, reltool_server:get_app(Pid,tools)), - ?m({ok,[]}, reltool:get_status(Pid)), + ?m({ok,Cover1}, reltool_server:get_mod(Pid,cover)), %% Undo again, to check that it toggles - ?m(ok, reltool_server:undo_config(Pid)), + ?msym({ok,["a: Cannot parse app file"++_|_]},reltool_server:undo_config(Pid)), ?m({ok,Tools2}, reltool_server:get_app(Pid,tools)), - ?msym({ok,["a: Cannot parse app file"++_]}, reltool:get_status(Pid)), + ?m({ok,Cover2}, reltool_server:get_mod(Pid,cover)), ?m(ok, reltool:stop(Pid)), ok. @@ -722,12 +770,16 @@ reset_config_and_undo(Config) -> {ok, Pid} = ?msym({ok, _}, reltool:start_server([{config, Sys1}])), ?m({ok, Sys1}, reltool:get_config(Pid)), - %% Check that tools is included + %% Get app and mod {ok,Tools1} = ?msym({ok,_}, reltool_server:get_app(Pid,tools)), ?m(true, Tools1#app.is_pre_included), ?m(true, Tools1#app.is_included), + {ok,Cover1} = ?msym({ok,#mod{name=cover, + is_included=true, + is_pre_included=true}}, + reltool_server:get_mod(Pid,cover)), - %% Exclude one application with set_apps + %% Exclude tools by loading new config Sys2 = {sys,[{incl_cond, exclude}, {app,kernel,[{incl_cond,include}]}, {app,sasl,[{incl_cond,include}]}, @@ -739,17 +791,27 @@ reset_config_and_undo(Config) -> {ok,Tools2} = ?msym({ok,_}, reltool_server:get_app(Pid,tools)), ?m(false, Tools2#app.is_pre_included), ?m(false, Tools2#app.is_included), + {ok,Cover2} = ?msym({ok,#mod{name=cover, + is_included=false, + is_pre_included=false}}, + reltool_server:get_mod(Pid,cover)), %% Reset %%! warning can come twice here... :( ?msym({ok,["a: Cannot parse app file"++_|_]}, reltool_server:reset_config(Pid)), ?m({ok,Tools1}, reltool_server:get_app(Pid,tools)), + ?m({ok,Cover1}, reltool_server:get_mod(Pid,cover)), - %% Undo again, to check that it toggles - ?m(ok, reltool_server:undo_config(Pid)), + %% Undo + ?m({ok,[]}, reltool_server:undo_config(Pid)), ?m({ok,Tools2}, reltool_server:get_app(Pid,tools)), - ?m({ok,[]}, reltool:get_status(Pid)), + ?m({ok,Cover2}, reltool_server:get_mod(Pid,cover)), + + %% Undo again, to check that it toggles + ?msym({ok,["a: Cannot parse app file"++_|_]},reltool_server:undo_config(Pid)), + ?m({ok,Tools1}, reltool_server:get_app(Pid,tools)), + ?m({ok,Cover1}, reltool_server:get_mod(Pid,cover)), ?m(ok, reltool:stop(Pid)), ok. @@ -851,8 +913,6 @@ save_config(Config) -> %% Test includes x and derives y and z. %% dependencies(Config) -> - PrivDir = ?config(priv_dir,Config), - %% Default: all modules included => y and z are included (derived) Sys = {sys,[{lib_dirs,[filename:join(datadir(Config),"dependencies")]}, {incl_cond, exclude}, -- cgit v1.2.3 From f515a08b3a57c854ee547e6c84c39e2fd14a27da Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Tue, 24 Jan 2012 15:46:31 +0100 Subject: [reltool] Add more tests OTP-9794 Test cases are added for the following functions: * reltool_server:get_sys * reltool_server:set_sys * reltool_server:get_status * reltool_server:gen_rel_files * reltool:eval_target_spec * reltool:get_server --- lib/reltool/test/reltool_server_SUITE.erl | 156 +++++++++++++++++++++++++++--- lib/reltool/test/reltool_wx_SUITE.erl | 8 +- 2 files changed, 151 insertions(+), 13 deletions(-) (limited to 'lib/reltool/test') diff --git a/lib/reltool/test/reltool_server_SUITE.erl b/lib/reltool/test/reltool_server_SUITE.erl index 79c6854465..fc2d844d07 100644 --- a/lib/reltool/test/reltool_server_SUITE.erl +++ b/lib/reltool/test/reltool_server_SUITE.erl @@ -54,11 +54,11 @@ suite() -> [{ct_hooks,[ts_install_cth]}]. all() -> [start_server, set_config, get_config, create_release, create_script, create_target, create_embedded, - create_standalone, create_old_target, + create_standalone, create_old_target, eval_target_spec, otp_9135, otp_9229_exclude_app, otp_9229_exclude_mod, - get_apps, get_mod, set_app_and_undo, set_apps_and_undo, - load_config_and_undo, reset_config_and_undo, save_config, - dependencies]. + get_apps, get_mod, get_sys, set_app_and_undo, set_apps_and_undo, + set_sys_and_undo, load_config_and_undo, reset_config_and_undo, + gen_rel_files, save_config, dependencies]. groups() -> []. @@ -442,6 +442,38 @@ create_old_target(_Config) -> ok. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Generate target system with eval_target_spec/3 + +eval_target_spec(_Config) -> + %% Configure the server + RelName1 = "Just testing", + RelName2 = "Just testing with SASL", + RelVsn = "1.0", + Config = + {sys, + [ + {root_dir, code:root_dir()}, + {lib_dirs, []}, + {boot_rel, RelName2}, + {rel, RelName1, RelVsn, [stdlib, kernel]}, + {rel, RelName2, RelVsn, [sasl, stdlib, kernel]}, + {app, sasl, [{incl_cond, include}]} + ]}, + + %% Generate target file + TargetDir = filename:join([?WORK_DIR, "eval_target_spec"]), + ?m(ok, reltool_utils:recursive_delete(TargetDir)), + ?m(ok, file:make_dir(TargetDir)), + {ok, Spec} = ?msym({ok,_}, reltool:get_target_spec([{config, Config}])), + ok = ?m(ok, reltool:eval_target_spec(Spec, code:root_dir(), TargetDir)), + + Erl = filename:join([TargetDir, "bin", "erl"]), + {ok, Node} = ?msym({ok, _}, start_node(?NODE_NAME, Erl)), + ?msym(ok, stop_node(Node)), + + ok. + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% OTP-9229 - handle duplicated module names, i.e. same module name %% exists in two applications. @@ -556,9 +588,8 @@ otp_9229_exclude_mod(Config) -> %% load_config %% reset_config %% -%% Also, for each operation which manipulates the config test -%% undo_config - that it is properly undone, and that warnings are -%% re-displayed. +%% Also, for each operation which manipulates the config, test +%% get_status and undo_config. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% get_apps(_Config) -> Sys = {sys,[{app,kernel,[{incl_cond,include}]}, @@ -592,7 +623,6 @@ get_apps(_Config) -> ?m(Number,length(AllN)), ?m(ok, reltool:stop(Pid)), - ok. @@ -613,10 +643,24 @@ get_mod(_Config) -> ?m({ok,Cover}, reltool_server:get_mod(Pid,cover)), ?m(ok, reltool:stop(Pid)), - ok. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +get_sys(_Config) -> + Sys = {sys,[{app,kernel,[{incl_cond,include}]}, + {app,sasl,[{incl_cond,include}]}, + {app,stdlib,[{incl_cond,include}]}, + {app,tools,[{incl_cond,derived}]}, + {app,runtime_tools,[{incl_cond,exclude}]}]}, + {ok, Pid} = ?msym({ok, _}, reltool:start_server([{config, Sys}])), + + RootDir = code:root_dir(), + ?msym({ok,#sys{root_dir=RootDir,apps=undefined}},reltool_server:get_sys(Pid)), + + ?m(ok, reltool:stop(Pid)), + ok. + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% set_app_and_undo(Config) -> Sys = {sys,[{lib_dirs,[filename:join(datadir(Config),"faulty_app_file")]}, @@ -628,6 +672,7 @@ set_app_and_undo(Config) -> {app,tools,[{incl_cond,include}]}]}, {ok, Pid} = ?msym({ok, _}, reltool:start_server([{config, Sys}])), ?m({ok, Sys}, reltool:get_config(Pid)), + ?msym({ok,["a: Cannot parse app file"++_|_]},reltool_server:get_status(Pid)), %% Get app and mod {ok,Tools} = ?msym({ok,_}, reltool_server:get_app(Pid,tools)), @@ -639,6 +684,7 @@ set_app_and_undo(Config) -> Mods = Tools#app.mods, Tools1 = Tools#app{mods = lists:keyreplace(cover,#mod.name,Mods,ExclCover)}, {ok,ToolsNoCover,[]} = ?msym({ok,_,[]}, reltool_server:set_app(Pid,Tools1)), + ?m({ok,[]}, reltool_server:get_status(Pid)), %% Check that the module is no longer included ?m({ok,ToolsNoCover}, reltool_server:get_app(Pid,tools)), @@ -650,11 +696,13 @@ set_app_and_undo(Config) -> ?msym({ok,["a: Cannot parse app file"++_|_]},reltool_server:undo_config(Pid)), ?m({ok,Tools}, reltool_server:get_app(Pid,tools)), ?m({ok,Cover}, reltool_server:get_mod(Pid,cover)), + ?msym({ok,["a: Cannot parse app file"++_|_]},reltool_server:get_status(Pid)), %% Undo again, to check that it toggles ?m({ok,[]}, reltool_server:undo_config(Pid)), ?m({ok,ToolsNoCover}, reltool_server:get_app(Pid,tools)), ?m({ok,NoIncludeCover}, reltool_server:get_mod(Pid,cover)), + ?m({ok,[]}, reltool_server:get_status(Pid)), ?m(ok, reltool:stop(Pid)), ok. @@ -670,6 +718,7 @@ set_apps_and_undo(Config) -> {app,tools,[{incl_cond,include}]}]}, {ok, Pid} = ?msym({ok, _}, reltool:start_server([{config, Sys}])), ?m({ok, Sys}, reltool:get_config(Pid)), + ?msym({ok,["a: Cannot parse app file"++_|_]},reltool_server:get_status(Pid)), %% Get app and mod {ok,Tools} = ?msym({ok,_}, reltool_server:get_app(Pid,tools)), @@ -681,6 +730,7 @@ set_apps_and_undo(Config) -> %% Exclude one application with set_apps ExclTools = Tools#app{incl_cond=exclude}, ?m({ok,[]}, reltool_server:set_apps(Pid,[ExclTools])), + ?m({ok,[]}, reltool_server:get_status(Pid)), %% Check that the app and its modules (one of them) are no longer included {ok,NoTools} = ?msym({ok,_}, reltool_server:get_app(Pid,tools)), @@ -694,16 +744,53 @@ set_apps_and_undo(Config) -> ?msym({ok,["a: Cannot parse app file"++_|_]},reltool_server:undo_config(Pid)), ?m({ok,Tools}, reltool_server:get_app(Pid,tools)), ?m({ok,Cover}, reltool_server:get_mod(Pid,cover)), + ?msym({ok,["a: Cannot parse app file"++_|_]},reltool_server:get_status(Pid)), %% Undo again, to check that it toggles ?m({ok,[]}, reltool_server:undo_config(Pid)), ?m({ok,NoTools}, reltool_server:get_app(Pid,tools)), ?m({ok,NoIncludeCover}, reltool_server:get_mod(Pid,cover)), + ?m({ok,[]}, reltool_server:get_status(Pid)), ?m(ok, reltool:stop(Pid)), ok. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +set_sys_and_undo(Config) -> + Sys1 = {sys,[{incl_cond, exclude}, + {app,kernel,[{incl_cond,include}]}, + {app,sasl,[{incl_cond,include}]}, + {app,stdlib,[{incl_cond,include}]}, + {app,tools,[{incl_cond,include}]}]}, + {ok, Pid} = ?msym({ok, _}, reltool:start_server([{config, Sys1}])), + ?m({ok,[]}, reltool_server:get_status(Pid)), + + %% Read sys record + {ok, SysRec} = reltool_server:get_sys(Pid), + + %% Set lib dirs by call to set_sys + NewLib = filename:join(datadir(Config),"faulty_app_file"), + NewLibDirs = [NewLib | SysRec#sys.lib_dirs], + NewSysRec = SysRec#sys{lib_dirs=NewLibDirs}, + ?msym({ok,["a: Cannot parse app file"++_|_]}, + reltool_server:set_sys(Pid, NewSysRec)), + ?m({ok,NewSysRec}, reltool_server:get_sys(Pid)), + ?msym({ok,["a: Cannot parse app file"++_|_]},reltool_server:get_status(Pid)), + + %% Undo + ?m({ok,[]}, reltool_server:undo_config(Pid)), + ?m({ok,SysRec}, reltool_server:get_sys(Pid)), + ?m({ok,[]}, reltool_server:get_status(Pid)), + + %% Undo again, to check that it toggles + ?msym({ok,["a: Cannot parse app file"++_|_]},reltool_server:undo_config(Pid)), + ?m({ok,NewSysRec}, reltool_server:get_sys(Pid)), + ?msym({ok,["a: Cannot parse app file"++_|_]},reltool_server:get_status(Pid)), + + ?m(ok, reltool:stop(Pid)), + ok. + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% load_config_and_undo(Config) -> Sys1 = {sys,[{incl_cond, exclude}, @@ -713,6 +800,7 @@ load_config_and_undo(Config) -> {app,tools,[{incl_cond,include}]}]}, {ok, Pid} = ?msym({ok, _}, reltool:start_server([{config, Sys1}])), ?m({ok, Sys1}, reltool:get_config(Pid)), + ?m({ok,[]}, reltool_server:get_status(Pid)), %% Get app and mod {ok,Tools1} = ?msym({ok,_}, reltool_server:get_app(Pid,tools)), @@ -725,14 +813,17 @@ load_config_and_undo(Config) -> %% Change tools from include to derived by loading new config Sys2 = {sys,[{lib_dirs,[filename:join(datadir(Config),"faulty_app_file")]}, - {incl_cond, exclude}, + {app,a,[{incl_cond,include}]}, {app,kernel,[{incl_cond,include}]}, {app,sasl,[{incl_cond,include}]}, {app,stdlib,[{incl_cond,include}]}, - {app,tools,[{incl_cond,derived}]}, - {app,a,[{incl_cond,include}]}]}, + {app,tools,[{incl_cond,derived}]}]}, ?msym({ok,["a: Cannot parse app file"++_]}, reltool_server:load_config(Pid,Sys2)), +%%% OTP-0702, 15) ?m({ok, Sys2}, reltool:get_config(Pid)), +%%% Note that {incl_cond,exclude} is removed compared to Sys1 - +%%% config is merged, not overwritten - is this correct??? + ?msym({ok,["a: Cannot parse app file"++_|_]},reltool_server:get_status(Pid)), %% Check that tools is included (since it is used by sasl) but not %% pre-included (neither included or excluded => undefined) @@ -748,11 +839,13 @@ load_config_and_undo(Config) -> ?m({ok,[]}, reltool_server:undo_config(Pid)), ?m({ok,Tools1}, reltool_server:get_app(Pid,tools)), ?m({ok,Cover1}, reltool_server:get_mod(Pid,cover)), + ?m({ok,[]}, reltool_server:get_status(Pid)), %% Undo again, to check that it toggles ?msym({ok,["a: Cannot parse app file"++_|_]},reltool_server:undo_config(Pid)), ?m({ok,Tools2}, reltool_server:get_app(Pid,tools)), ?m({ok,Cover2}, reltool_server:get_mod(Pid,cover)), + ?msym({ok,["a: Cannot parse app file"++_|_]},reltool_server:get_status(Pid)), ?m(ok, reltool:stop(Pid)), ok. @@ -769,6 +862,7 @@ reset_config_and_undo(Config) -> {app,tools,[{incl_cond,include}]}]}, {ok, Pid} = ?msym({ok, _}, reltool:start_server([{config, Sys1}])), ?m({ok, Sys1}, reltool:get_config(Pid)), + ?msym({ok,["a: Cannot parse app file"++_|_]},reltool_server:get_status(Pid)), %% Get app and mod {ok,Tools1} = ?msym({ok,_}, reltool_server:get_app(Pid,tools)), @@ -786,6 +880,7 @@ reset_config_and_undo(Config) -> {app,stdlib,[{incl_cond,include}]}, {app,tools,[{incl_cond,exclude}]}]}, ?m({ok,[]}, reltool_server:load_config(Pid,Sys2)), + ?m({ok,[]}, reltool_server:get_status(Pid)), %% Check that tools is excluded {ok,Tools2} = ?msym({ok,_}, reltool_server:get_app(Pid,tools)), @@ -802,16 +897,53 @@ reset_config_and_undo(Config) -> reltool_server:reset_config(Pid)), ?m({ok,Tools1}, reltool_server:get_app(Pid,tools)), ?m({ok,Cover1}, reltool_server:get_mod(Pid,cover)), + ?msym({ok,["a: Cannot parse app file"++_|_]},reltool_server:get_status(Pid)), %% Undo ?m({ok,[]}, reltool_server:undo_config(Pid)), ?m({ok,Tools2}, reltool_server:get_app(Pid,tools)), ?m({ok,Cover2}, reltool_server:get_mod(Pid,cover)), + ?m({ok,[]}, reltool_server:get_status(Pid)), %% Undo again, to check that it toggles ?msym({ok,["a: Cannot parse app file"++_|_]},reltool_server:undo_config(Pid)), ?m({ok,Tools1}, reltool_server:get_app(Pid,tools)), ?m({ok,Cover1}, reltool_server:get_mod(Pid,cover)), + ?msym({ok,["a: Cannot parse app file"++_|_]},reltool_server:get_status(Pid)), + + ?m(ok, reltool:stop(Pid)), + ok. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +gen_rel_files(_Config) -> + %% Configure the server + RelName = "gen_fel_files_test", + RelVsn = "1.0", + Sys = + {sys, + [ + {lib_dirs, []}, + {boot_rel, RelName}, + {rel, RelName, RelVsn, [kernel, stdlib]} + ]}, + {ok, Pid} = ?msym({ok, _}, reltool:start_server([{config, Sys}])), + + %% Generate .rel, .script and .boot + Dir = filename:join(?WORK_DIR,"gen_rel_files"), + ok = file:make_dir(Dir), + ?m({ok,[]}, reltool_server:gen_rel_files(Pid,Dir)), + + Script = RelName ++ ".script", + Rel = RelName ++ ".rel", + Boot = RelName ++ ".boot", + {ok,Files} = ?msym({ok,_}, file:list_dir(Dir)), + [Boot,Rel,Script] = lists:sort(Files), + + %% Check that contents is reasonable + {ok,[S]} = ?msym({ok,[{script,_,_}]},file:consult(filename:join(Dir,Script))), + ?msym({ok,[{release,_,_,_}]}, file:consult(filename:join(Dir,Rel))), + {ok,Bin} = ?msym({ok,_}, file:read_file(filename:join(Dir,Boot))), + ?m(S,binary_to_term(Bin)), ?m(ok, reltool:stop(Pid)), ok. diff --git a/lib/reltool/test/reltool_wx_SUITE.erl b/lib/reltool/test/reltool_wx_SUITE.erl index 424bc7d189..51f433f206 100644 --- a/lib/reltool/test/reltool_wx_SUITE.erl +++ b/lib/reltool/test/reltool_wx_SUITE.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2009-2011. All Rights Reserved. +%% Copyright Ericsson AB 2009-2012. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -63,6 +63,12 @@ start_all_windows(_Config) -> {ok, SysPid} = ?msym({ok, _}, reltool:start([{trap_exit, false}])), {ok, AppPid} = ?msym({ok, _}, reltool_sys_win:open_app(SysPid, stdlib)), ?msym({ok, _}, reltool_app_win:open_mod(AppPid, escript)), + + %% Test that server pid can be fetched, and that server is alive + {ok, Server} = ?msym({ok,_}, reltool:get_server(SysPid)), + ?m(true, erlang:is_process_alive(Server)), + ?m({ok,{sys,[]}}, reltool:get_config(Server)), + timer:sleep(timer:seconds(10)), ?m(ok, reltool:stop(SysPid)), -- cgit v1.2.3 From 3fef8ee7031a16a038c9f87dc8cf8ea44064e6ed Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Wed, 25 Jan 2012 16:24:35 +0100 Subject: [reltool] Add more GUI tests OTP-9794 This commit adds a test suite for manual testing of the reltool GUI. By use of test_server:break/1 function, it guides the user through a set of tests in the GUI. Some minor checks are also added to the automatic GUI test, reltool_wx_SUITE. --- lib/reltool/test/Makefile | 3 +- lib/reltool/test/reltool.spec | 1 + lib/reltool/test/reltool_manual_gui_SUITE.erl | 247 +++++++++++++++++++++ .../reltool_manual_gui_SUITE_data/Makefile.src | 28 +++ .../dependencies/x-1.0/ebin/x.app | 7 + .../dependencies/x-1.0/src/x1.erl | 5 + .../dependencies/x-1.0/src/x2.erl | 5 + .../dependencies/x-1.0/src/x3.erl | 5 + .../dependencies/y-1.0/ebin/y.app | 7 + .../dependencies/y-1.0/src/y1.erl | 5 + .../dependencies/y-1.0/src/y2.erl | 5 + .../dependencies/y-1.0/src/y3.erl | 5 + .../dependencies/z-1.0/ebin/z.app | 7 + .../dependencies/z-1.0/src/z1.erl | 5 + .../faulty_app_file/a-1.0/ebin/a.app | 1 + .../faulty_app_file/a-1.0/src/a.erl | 49 ++++ .../faulty_app_file/a-1.0/src/a_sup.erl | 37 +++ lib/reltool/test/reltool_wx_SUITE.erl | 37 ++- 18 files changed, 455 insertions(+), 4 deletions(-) create mode 100644 lib/reltool/test/reltool_manual_gui_SUITE.erl create mode 100644 lib/reltool/test/reltool_manual_gui_SUITE_data/Makefile.src create mode 100644 lib/reltool/test/reltool_manual_gui_SUITE_data/dependencies/x-1.0/ebin/x.app create mode 100644 lib/reltool/test/reltool_manual_gui_SUITE_data/dependencies/x-1.0/src/x1.erl create mode 100644 lib/reltool/test/reltool_manual_gui_SUITE_data/dependencies/x-1.0/src/x2.erl create mode 100644 lib/reltool/test/reltool_manual_gui_SUITE_data/dependencies/x-1.0/src/x3.erl create mode 100644 lib/reltool/test/reltool_manual_gui_SUITE_data/dependencies/y-1.0/ebin/y.app create mode 100644 lib/reltool/test/reltool_manual_gui_SUITE_data/dependencies/y-1.0/src/y1.erl create mode 100644 lib/reltool/test/reltool_manual_gui_SUITE_data/dependencies/y-1.0/src/y2.erl create mode 100644 lib/reltool/test/reltool_manual_gui_SUITE_data/dependencies/y-1.0/src/y3.erl create mode 100644 lib/reltool/test/reltool_manual_gui_SUITE_data/dependencies/z-1.0/ebin/z.app create mode 100644 lib/reltool/test/reltool_manual_gui_SUITE_data/dependencies/z-1.0/src/z1.erl create mode 100644 lib/reltool/test/reltool_manual_gui_SUITE_data/faulty_app_file/a-1.0/ebin/a.app create mode 100644 lib/reltool/test/reltool_manual_gui_SUITE_data/faulty_app_file/a-1.0/src/a.erl create mode 100644 lib/reltool/test/reltool_manual_gui_SUITE_data/faulty_app_file/a-1.0/src/a_sup.erl (limited to 'lib/reltool/test') diff --git a/lib/reltool/test/Makefile b/lib/reltool/test/Makefile index 767454b66a..d8a7adb837 100644 --- a/lib/reltool/test/Makefile +++ b/lib/reltool/test/Makefile @@ -1,7 +1,7 @@ # # %CopyrightBegin% # -# Copyright Ericsson AB 2009-2011. All Rights Reserved. +# Copyright Ericsson AB 2009-2012. All Rights Reserved. # # The contents of this file are subject to the Erlang Public License, # Version 1.1, (the "License"); you may not use this file except in @@ -28,6 +28,7 @@ MODULES= \ reltool_app_SUITE \ reltool_wx_SUITE \ reltool_server_SUITE \ + reltool_manual_gui_SUITE \ reltool_test_lib diff --git a/lib/reltool/test/reltool.spec b/lib/reltool/test/reltool.spec index 2995720105..2501a7a203 100644 --- a/lib/reltool/test/reltool.spec +++ b/lib/reltool/test/reltool.spec @@ -1 +1,2 @@ {suites,"../reltool_test",all}. +{skip_suites,"../reltool_test",[reltool_manual_gui_SUITE],"Manual only"}. diff --git a/lib/reltool/test/reltool_manual_gui_SUITE.erl b/lib/reltool/test/reltool_manual_gui_SUITE.erl new file mode 100644 index 0000000000..c6b1d56988 --- /dev/null +++ b/lib/reltool/test/reltool_manual_gui_SUITE.erl @@ -0,0 +1,247 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2012. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% + +-module(reltool_manual_gui_SUITE). + +-export([all/0, suite/0,groups/0,init_per_group/2,end_per_group/2, + init_per_suite/1, end_per_suite/1, + init_per_testcase/2, end_per_testcase/2]). + +-compile(export_all). + +-include_lib("common_test/include/ct.hrl"). +-include("reltool_test_lib.hrl"). + +%% Initialization functions. +init_per_suite(Config) -> + reltool_test_lib:wx_init_per_suite(Config). + +end_per_suite(Config) -> + reltool_test_lib:wx_end_per_suite(Config). + +init_per_testcase(Func,Config) -> + reltool_test_lib:init_per_testcase(Func,Config). +end_per_testcase(Func,Config) -> + reltool_test_lib:end_per_testcase(Func,Config). + +%% SUITE specification +suite() -> [{ct_hooks,[ts_install_cth]}]. + +all() -> + [config, depgraphs]. + +groups() -> + []. + +init_per_group(_GroupName, Config) -> + Config. + +end_per_group(_GroupName, Config) -> + Config. + + +%% The test cases + +%% Semi-automatic walkthrough of the GUI +config(Config) -> + DataDir = ?config(data_dir,Config), + PrivDir = ?config(priv_dir,Config), + {ok, SysPid} = ?msym({ok, _}, reltool:start([])), + link(SysPid), + + SimpleConfigFile = create_simple_config(PrivDir), + WarningConfigFile = create_warning_config(PrivDir,DataDir), + + break("there are no modules in the 'Included' and 'Excluded' columns", + {"load configuration ~p",[SimpleConfigFile]}), + break("kernel, stdlib and sasl are included and all other are excluded", + "undo"), + break("we are back to default - no included and no excluded applications", + "undo again"), + break("kernel, stdlib and sasl are included and all other are excluded", + {"load configuration ~p, but click 'cancel' in the warning dialog", + [WarningConfigFile]}), + break("no change is done", + "load same configuration again and this time click 'ok' in the dialog"), + break("application a is added in the 'Included' column", + "reset configuration"), + break("we are back to default - no included and no excluded applications", + "undo"), + break("a warning dialog is displayed, with only an ok button", + "click ok"), + break("a, kernel, stdlib and sasl are included and all other are excluded", + "select application a from 'Included' column and click red cross to " + "exclude it"), + break("application a is moved to 'Excluded' column", + "select application tools from 'Excluded' column and click green V to " + "include it"), + break("application tools is moved to 'Included' column", + "select application runtime-tools from 'Excluded' column and click " + "green V to include it"), + break("application runtime-tools is moved to 'Included' column", + "undo"), + + ExplicitConfig = filename:join(PrivDir,"explicit.config"), + break("application runtime-tools is moved back to 'Excluded' column", + {"save configuration as 'explicit' to ~p",[ExplicitConfig]}), + ExpectedExplicitConfig = + {sys,[{lib_dirs,[filename:join(DataDir,"faulty_app_file")]}, + {incl_cond,exclude}, + {app,a,[{incl_cond,exclude}]}, + {app,kernel,[{incl_cond,include}]}, + {app,sasl,[{incl_cond,include}]}, + {app,stdlib,[{incl_cond,include}]}, + {app,tools,[{incl_cond,include}]}]}, + check_config(ExpectedExplicitConfig,ExplicitConfig), + + break("The saved configuration file is checked and is ok.\n" + "Now go to the 'Libraries' tab and change the root directory to " + "some invalid directory."), + break("an error dialog occurs saying that there is no lib dir", + {"add library directory ~p, and click 'ok' in warning dialog", + [filename:join(DataDir,"dependencies")]}), + break("applications x, y and z are added to the 'Excluded' column in " + "'Applications' tab", + "go to the 'System settings' tab and set application inclusion policy " + "to 'derived'"), + break("a is excluded, kernel, stdlib, sasl and tools are included and " + "x, y and z are available in the 'Applications' tab", + "undo, and click ok in the warning dialog"), + break("all non included application are moved to the 'Excluded' column " + "and that 'Application inclusion policy' under 'System settings' " + "tab is set back to 'exclude'", + "undo again"), + break("applications x, y and z are in the 'Available' column", + "open application x, go to the 'Application settings' tab and set " + "'Application inclusion policy' to 'Use application specific config' " + "and 'include'. Close the window"), + break("application x is moved to the 'Included' column and z and y are moved " + "to the 'Derived' column in the system window", + "open application y"), + break("modules y1, y2 and y3 are in the 'Derived' column", + "go to 'Application dependencies' tab"), + break("application y is used by x, requires kernel and stdlib, and uses z", + "go to 'Module dependencies' tab"), + break("y is used by x2 and x3, and uses z1", + "got to 'Application settings' tab and select " + "'Source selection policy' 'Use selected version'"), + break("'Directories' frame becomes enabled (clickable)", + "select 'Module inclusion policy' 'Use application specific config' " + "and select 'app file + derived'"), + break("module y3 is moved to the 'Available' column in the 'Modules' tab", + "open module y1"), + break("module y1 is used by x2 and uses z1", + "go to the 'Code' tab and double click the line with call to z1:f()"), + break("new tab is opened with module z1", + "find something"), + break("it is found", + "goto some line"), + break("the cursor is moved to that line", + "click the 'Back' button"), + break("the cursor is moved back to the line of your previous 'find'", + "terminate the application window (but keep the module window)."), + + {ok,ServerPid} = reltool:get_server(SysPid), + unlink(SysPid), + break("the system window is still alive", + "terminate reltool by hitting 'Ctrl-q' when system window is active"), + false = erlang:is_process_alive(SysPid), + false = erlang:is_process_alive(ServerPid), + + break("Check that both module window and system window are terminated"), + + ok. + + +depgraphs(Config) -> + PrivDir = ?config(priv_dir,Config), + SimpleConfigFile = create_simple_config(PrivDir), + {ok, SysPid} = ?msym({ok, _}, reltool:start([{config,SimpleConfigFile}])), + link(SysPid), + + break("Open the application dependency graph and \n\n" + "*move the complete graph by left clicking somewhere over it and drag\n" + "*move one node left clicking the node and drag\n" + "*lock node to position by holding down shift while releasing\n" + "*select several nodes with ctrl and left mouse button\n" + "*lock/unlock selected nodes with suitable buttons\n" + "*freeze\n" + "*reset\n" + "*left slider: push nodes apart\n" + "*right slider: pull nodes together\n" + "*middle slider: adjust length of links\n" + "*select node and delete\n"), + break("Open the module dependency graph and meditate over it... "), + + unlink(SysPid), + break("Terminate reltool from the file menu in the system window"), + false = erlang:is_process_alive(SysPid), + + break("Check that system window and graphs are terminated"), + + ok. + + + + +%%%----------------------------------------------------------------- +%%% Internal functions +break(CheckStr,DoStr) when is_list(CheckStr), is_list(DoStr) -> + Str = io_lib:format("Check that ~s.~n~nThen ~s.",[CheckStr,DoStr]), + break(Str); +break(Check,Do) -> + CheckStr = + case Check of + {CheckFormat,CheckArgs} -> io_lib:format(CheckFormat,CheckArgs); + _ -> Check + end, + DoStr = + case Do of + {DoFormat,DoArgs} -> io_lib:format(DoFormat,DoArgs); + _ -> Do + end, + break(CheckStr,DoStr). + +break(Str) -> + test_server:break(Str). + +check_config(Expected,File) -> + {ok,[Config]} = file:consult(File), + ?m(Expected,Config). + +create_simple_config(PrivDir) -> + SimpleConfigFile = filename:join(PrivDir,"simple.config"), + SimpleConfig = {sys,[{incl_cond,exclude}, + {app,kernel,[{incl_cond,include}]}, + {app,stdlib,[{incl_cond,include}]}, + {app,sasl,[{incl_cond,include}]}]}, + ok=file:write_file(SimpleConfigFile,io_lib:format("~p.~n",[SimpleConfig])), + SimpleConfigFile. + +create_warning_config(PrivDir,DataDir) -> + WarningConfigFile = filename:join(PrivDir,"warning.config"), + FaultyAppFileDir = filename:join(DataDir,"faulty_app_file"), + WarningConfig = {sys,[{lib_dirs,[FaultyAppFileDir]}, + {incl_cond,exclude}, + {app,kernel,[{incl_cond,include}]}, + {app,sasl,[{incl_cond,include}]}, + {app,stdlib,[{incl_cond,include}]}, + {app,a,[{incl_cond,include}]} + ]}, + ok=file:write_file(WarningConfigFile,io_lib:format("~p.~n",[WarningConfig])), + WarningConfigFile. diff --git a/lib/reltool/test/reltool_manual_gui_SUITE_data/Makefile.src b/lib/reltool/test/reltool_manual_gui_SUITE_data/Makefile.src new file mode 100644 index 0000000000..9a340274ad --- /dev/null +++ b/lib/reltool/test/reltool_manual_gui_SUITE_data/Makefile.src @@ -0,0 +1,28 @@ +EFLAGS=+debug_info + +DEPENDENCIES= \ + dependencies/x-1.0/ebin/x1.@EMULATOR@ \ + dependencies/x-1.0/ebin/x2.@EMULATOR@ \ + dependencies/x-1.0/ebin/x3.@EMULATOR@ \ + dependencies/y-1.0/ebin/y1.@EMULATOR@ \ + dependencies/y-1.0/ebin/y2.@EMULATOR@ \ + dependencies/y-1.0/ebin/y3.@EMULATOR@ \ + dependencies/z-1.0/ebin/z1.@EMULATOR@ + + +all: $(DEPENDENCIES) + +dependencies/x-1.0/ebin/x1.@EMULATOR@: dependencies/x-1.0/src/x1.erl + erlc $(EFLAGS) -odependencies/x-1.0/ebin dependencies/x-1.0/src/x1.erl +dependencies/x-1.0/ebin/x2.@EMULATOR@: dependencies/x-1.0/src/x2.erl + erlc $(EFLAGS) -odependencies/x-1.0/ebin dependencies/x-1.0/src/x2.erl +dependencies/x-1.0/ebin/x3.@EMULATOR@: dependencies/x-1.0/src/x3.erl + erlc $(EFLAGS) -odependencies/x-1.0/ebin dependencies/x-1.0/src/x3.erl +dependencies/y-1.0/ebin/y1.@EMULATOR@: dependencies/y-1.0/src/y1.erl + erlc $(EFLAGS) -odependencies/y-1.0/ebin dependencies/y-1.0/src/y1.erl +dependencies/y-1.0/ebin/y2.@EMULATOR@: dependencies/y-1.0/src/y2.erl + erlc $(EFLAGS) -odependencies/y-1.0/ebin dependencies/y-1.0/src/y2.erl +dependencies/y-1.0/ebin/y3.@EMULATOR@: dependencies/y-1.0/src/y3.erl + erlc $(EFLAGS) -odependencies/y-1.0/ebin dependencies/y-1.0/src/y3.erl +dependencies/z-1.0/ebin/z1.@EMULATOR@: dependencies/z-1.0/src/z1.erl + erlc $(EFLAGS) -odependencies/z-1.0/ebin dependencies/z-1.0/src/z1.erl diff --git a/lib/reltool/test/reltool_manual_gui_SUITE_data/dependencies/x-1.0/ebin/x.app b/lib/reltool/test/reltool_manual_gui_SUITE_data/dependencies/x-1.0/ebin/x.app new file mode 100644 index 0000000000..ccaab8a8c7 --- /dev/null +++ b/lib/reltool/test/reltool_manual_gui_SUITE_data/dependencies/x-1.0/ebin/x.app @@ -0,0 +1,7 @@ +% -*-erlang-*- +{application, x, + [{description, "Main application in reltool dependency test"}, + {vsn, "1.0"}, + {modules, [x1,x2,x3]}, + {registered, []}, + {applications, [kernel, stdlib]}]}. diff --git a/lib/reltool/test/reltool_manual_gui_SUITE_data/dependencies/x-1.0/src/x1.erl b/lib/reltool/test/reltool_manual_gui_SUITE_data/dependencies/x-1.0/src/x1.erl new file mode 100644 index 0000000000..bf1e7f9279 --- /dev/null +++ b/lib/reltool/test/reltool_manual_gui_SUITE_data/dependencies/x-1.0/src/x1.erl @@ -0,0 +1,5 @@ +-module(x1). +-compile(export_all). + +f() -> + ok. diff --git a/lib/reltool/test/reltool_manual_gui_SUITE_data/dependencies/x-1.0/src/x2.erl b/lib/reltool/test/reltool_manual_gui_SUITE_data/dependencies/x-1.0/src/x2.erl new file mode 100644 index 0000000000..82191ba278 --- /dev/null +++ b/lib/reltool/test/reltool_manual_gui_SUITE_data/dependencies/x-1.0/src/x2.erl @@ -0,0 +1,5 @@ +-module(x2). +-compile(export_all). + +f() -> + y1:f(). diff --git a/lib/reltool/test/reltool_manual_gui_SUITE_data/dependencies/x-1.0/src/x3.erl b/lib/reltool/test/reltool_manual_gui_SUITE_data/dependencies/x-1.0/src/x3.erl new file mode 100644 index 0000000000..618c75c9a7 --- /dev/null +++ b/lib/reltool/test/reltool_manual_gui_SUITE_data/dependencies/x-1.0/src/x3.erl @@ -0,0 +1,5 @@ +-module(x3). +-compile(export_all). + +f() -> + y2:f(). diff --git a/lib/reltool/test/reltool_manual_gui_SUITE_data/dependencies/y-1.0/ebin/y.app b/lib/reltool/test/reltool_manual_gui_SUITE_data/dependencies/y-1.0/ebin/y.app new file mode 100644 index 0000000000..4f9b610b69 --- /dev/null +++ b/lib/reltool/test/reltool_manual_gui_SUITE_data/dependencies/y-1.0/ebin/y.app @@ -0,0 +1,7 @@ +% -*-erlang-*- +{application, y, + [{description, "Library application in reltool dependency test"}, + {vsn, "1.0"}, + {modules, [y1,y2]}, % y3 is skipped on purpose - to test module inclusion policy + {registered, []}, + {applications, [kernel, stdlib]}]}. diff --git a/lib/reltool/test/reltool_manual_gui_SUITE_data/dependencies/y-1.0/src/y1.erl b/lib/reltool/test/reltool_manual_gui_SUITE_data/dependencies/y-1.0/src/y1.erl new file mode 100644 index 0000000000..dd21b33292 --- /dev/null +++ b/lib/reltool/test/reltool_manual_gui_SUITE_data/dependencies/y-1.0/src/y1.erl @@ -0,0 +1,5 @@ +-module(y1). +-compile(export_all). + +f() -> + z1:f(). diff --git a/lib/reltool/test/reltool_manual_gui_SUITE_data/dependencies/y-1.0/src/y2.erl b/lib/reltool/test/reltool_manual_gui_SUITE_data/dependencies/y-1.0/src/y2.erl new file mode 100644 index 0000000000..bf8ddf6080 --- /dev/null +++ b/lib/reltool/test/reltool_manual_gui_SUITE_data/dependencies/y-1.0/src/y2.erl @@ -0,0 +1,5 @@ +-module(y2). +-compile(export_all). + +f() -> + ok. diff --git a/lib/reltool/test/reltool_manual_gui_SUITE_data/dependencies/y-1.0/src/y3.erl b/lib/reltool/test/reltool_manual_gui_SUITE_data/dependencies/y-1.0/src/y3.erl new file mode 100644 index 0000000000..915d64d5b9 --- /dev/null +++ b/lib/reltool/test/reltool_manual_gui_SUITE_data/dependencies/y-1.0/src/y3.erl @@ -0,0 +1,5 @@ +-module(y3). +-compile(export_all). + +f() -> + ok. diff --git a/lib/reltool/test/reltool_manual_gui_SUITE_data/dependencies/z-1.0/ebin/z.app b/lib/reltool/test/reltool_manual_gui_SUITE_data/dependencies/z-1.0/ebin/z.app new file mode 100644 index 0000000000..437a0968e9 --- /dev/null +++ b/lib/reltool/test/reltool_manual_gui_SUITE_data/dependencies/z-1.0/ebin/z.app @@ -0,0 +1,7 @@ +% -*-erlang-*- +{application, z, + [{description, "Library application in reltool dependency test"}, + {vsn, "1.0"}, + {modules, [z1]}, + {registered, []}, + {applications, [kernel, stdlib]}]}. diff --git a/lib/reltool/test/reltool_manual_gui_SUITE_data/dependencies/z-1.0/src/z1.erl b/lib/reltool/test/reltool_manual_gui_SUITE_data/dependencies/z-1.0/src/z1.erl new file mode 100644 index 0000000000..97ef90b87f --- /dev/null +++ b/lib/reltool/test/reltool_manual_gui_SUITE_data/dependencies/z-1.0/src/z1.erl @@ -0,0 +1,5 @@ +-module(z1). +-compile(export_all). + +f() -> + ok. diff --git a/lib/reltool/test/reltool_manual_gui_SUITE_data/faulty_app_file/a-1.0/ebin/a.app b/lib/reltool/test/reltool_manual_gui_SUITE_data/faulty_app_file/a-1.0/ebin/a.app new file mode 100644 index 0000000000..ea77103598 --- /dev/null +++ b/lib/reltool/test/reltool_manual_gui_SUITE_data/faulty_app_file/a-1.0/ebin/a.app @@ -0,0 +1 @@ +faulty app file diff --git a/lib/reltool/test/reltool_manual_gui_SUITE_data/faulty_app_file/a-1.0/src/a.erl b/lib/reltool/test/reltool_manual_gui_SUITE_data/faulty_app_file/a-1.0/src/a.erl new file mode 100644 index 0000000000..bb500bed69 --- /dev/null +++ b/lib/reltool/test/reltool_manual_gui_SUITE_data/faulty_app_file/a-1.0/src/a.erl @@ -0,0 +1,49 @@ +%% ``The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved via the world wide web at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% The Initial Developer of the Original Code is Ericsson Utvecklings AB. +%% Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings +%% AB. All Rights Reserved.'' +%% +%% $Id$ +%% +-module(a). + + +-behaviour(gen_server). + +-vsn(1). + +%% External exports +-export([start_link/0, a/0]). +%% Internal exports +-export([init/1, handle_call/3, handle_info/2, terminate/2]). + +start_link() -> gen_server:start_link({local, aa}, a, [], []). + +a() -> gen_server:call(aa, a). + +%%----------------------------------------------------------------- +%% Callback functions from gen_server +%%----------------------------------------------------------------- +init([]) -> + process_flag(trap_exit, true), + {ok, state}. + +handle_call(a, _From, State) -> + X = application:get_all_env(a), + {reply, X, State}. + +handle_info(_, State) -> + {noreply, State}. + +terminate(_Reason, _State) -> + ok. diff --git a/lib/reltool/test/reltool_manual_gui_SUITE_data/faulty_app_file/a-1.0/src/a_sup.erl b/lib/reltool/test/reltool_manual_gui_SUITE_data/faulty_app_file/a-1.0/src/a_sup.erl new file mode 100644 index 0000000000..a141c1767b --- /dev/null +++ b/lib/reltool/test/reltool_manual_gui_SUITE_data/faulty_app_file/a-1.0/src/a_sup.erl @@ -0,0 +1,37 @@ +%% ``The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved via the world wide web at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% The Initial Developer of the Original Code is Ericsson Utvecklings AB. +%% Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings +%% AB. All Rights Reserved.'' +%% +%% $Id$ +%% +-module(a_sup). + + +-behaviour(supervisor). + +%% External exports +-export([start/2]). + +%% Internal exports +-export([init/1]). + +start(_, _) -> + supervisor:start_link({local, a_sup}, a_sup, []). + +init([]) -> + SupFlags = {one_for_one, 4, 3600}, + Config = {a, + {a, start_link, []}, + permanent, 2000, worker, [a]}, + {ok, {SupFlags, [Config]}}. diff --git a/lib/reltool/test/reltool_wx_SUITE.erl b/lib/reltool/test/reltool_wx_SUITE.erl index 51f433f206..13d71f4fd6 100644 --- a/lib/reltool/test/reltool_wx_SUITE.erl +++ b/lib/reltool/test/reltool_wx_SUITE.erl @@ -61,15 +61,46 @@ start_all_windows(TestInfo) when is_atom(TestInfo) -> reltool_test_lib:tc_info(TestInfo); start_all_windows(_Config) -> {ok, SysPid} = ?msym({ok, _}, reltool:start([{trap_exit, false}])), + erlang:monitor(process,SysPid), {ok, AppPid} = ?msym({ok, _}, reltool_sys_win:open_app(SysPid, stdlib)), - ?msym({ok, _}, reltool_app_win:open_mod(AppPid, escript)), + erlang:monitor(process,AppPid), + {ok, ModPid} = ?msym({ok, _}, reltool_app_win:open_mod(AppPid, escript)), + erlang:monitor(process,ModPid), + + %% Let all windows get started + timer:sleep(timer:seconds(10)), %% Test that server pid can be fetched, and that server is alive {ok, Server} = ?msym({ok,_}, reltool:get_server(SysPid)), ?m(true, erlang:is_process_alive(Server)), ?m({ok,{sys,[]}}, reltool:get_config(Server)), - timer:sleep(timer:seconds(10)), + %% Terminate + check_no_win_crash(), ?m(ok, reltool:stop(SysPid)), - + wait_terminate([{sys,SysPid},{app,AppPid},{mod,ModPid}]), + ok. + + +%%%----------------------------------------------------------------- +%%% Internal functions +check_no_win_crash() -> + receive {'DOWN',_,_,_,_} = Down -> + ct:log("Unexpected termination of window:~n~p",[Down]), + ct:fail("window crashed") + after 0 -> + ok + end. + +wait_terminate([]) -> + ok; +wait_terminate([{Win,P}|Rest]) -> + receive + {'DOWN',_,process,P,shutdown} -> + wait_terminate(Rest); + {'DOWN',_,process,P,Reason} -> + ct:log("~p window terminated with unexpected reason:~n~p", + [Win,Reason]), + ct:fail("unexpected exit reason from window") + end. -- cgit v1.2.3 From 523573110b7afc1491c1e67865303da2468bcf0f Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Mon, 30 Jan 2012 14:43:06 +0100 Subject: [reltool] Add tests for sorting of applications in .rel and .script files OTP-9794 Test cases create_release_sort and create_script_sort are added. The test are temporarily skipped since they detected quite a few bugs that will be corrected with OTP-9792. The following bug is corrected in this commit:' reltool_server did not recognize {App,InclApps} inside a 'rel' specification in the reltool config, e.g. {rel, "myrel", "1.0", [{myapp,[app2]}]}. --- lib/reltool/test/reltool_server_SUITE.erl | 345 ++++++++++++++++++++- .../sort_apps/x-1.0/ebin/x.app | 7 + .../sort_apps/y-1.0/ebin/y.app | 7 + .../sort_apps/z-1.0/ebin/z.app | 8 + 4 files changed, 360 insertions(+), 7 deletions(-) create mode 100644 lib/reltool/test/reltool_server_SUITE_data/sort_apps/x-1.0/ebin/x.app create mode 100644 lib/reltool/test/reltool_server_SUITE_data/sort_apps/y-1.0/ebin/y.app create mode 100644 lib/reltool/test/reltool_server_SUITE_data/sort_apps/z-1.0/ebin/z.app (limited to 'lib/reltool/test') diff --git a/lib/reltool/test/reltool_server_SUITE.erl b/lib/reltool/test/reltool_server_SUITE.erl index fc2d844d07..0aca242d4e 100644 --- a/lib/reltool/test/reltool_server_SUITE.erl +++ b/lib/reltool/test/reltool_server_SUITE.erl @@ -52,13 +52,32 @@ end_per_testcase(Func,Config) -> suite() -> [{ct_hooks,[ts_install_cth]}]. all() -> - [start_server, set_config, get_config, create_release, - create_script, create_target, create_embedded, - create_standalone, create_old_target, eval_target_spec, - otp_9135, otp_9229_exclude_app, otp_9229_exclude_mod, - get_apps, get_mod, get_sys, set_app_and_undo, set_apps_and_undo, - set_sys_and_undo, load_config_and_undo, reset_config_and_undo, - gen_rel_files, save_config, dependencies]. + [start_server, + set_config, + get_config, + create_release, + create_release_sort, + create_script, + create_script_sort, + create_target, + create_embedded, + create_standalone, + create_old_target, + eval_target_spec, + otp_9135, + otp_9229_exclude_app, + otp_9229_exclude_mod, + get_apps, + get_mod, + get_sys, + set_app_and_undo, + set_apps_and_undo, + set_sys_and_undo, + load_config_and_undo, + reset_config_and_undo, + gen_rel_files, + save_config, + dependencies]. groups() -> []. @@ -250,6 +269,121 @@ create_release(_Config) -> ?m({ok, Rel}, reltool:get_rel([{config, Config}], RelName)), ok. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Generate releases and make sure order of applications specified in +%% 'rel' parameter is preserved and that included applications are +%% started before the including application. +%% Circular dependencies shall also be detected and cause error. + +create_release_sort(_Config) -> {skip, "Multiple known problems - see OTP-9792"}; +create_release_sort(Config) -> + DataDir = ?config(data_dir,Config), + %% Configure the server + RelName1 = "MnesiaFirst", + RelName2 = "SaslFirst", + RelName3 = "Include-both", + RelName4 = "Include-only-app", + RelName5 = "Include-only-rel", + RelName6 = "Include-missing-app", + RelName7 = "Circular", + RelName8 = "Include-both-missing-app", + RelName9 = "Include-overwrite", + RelVsn = "1.0", + Sys = + {sys, + [ + {lib_dirs, [filename:join(DataDir,"sort_apps")]}, + {boot_rel, RelName1}, + {rel, RelName1, RelVsn, [stdlib, kernel, mnesia, sasl]}, + {rel, RelName2, RelVsn, [stdlib, kernel, sasl, mnesia]}, + {rel, RelName3, RelVsn, [stdlib, kernel, {z,[tools]}, tools]}, + {rel, RelName4, RelVsn, [stdlib, kernel, z, tools]}, + {rel, RelName5, RelVsn, [stdlib, kernel, {sasl,[tools]}]}, + {rel, RelName6, RelVsn, [stdlib, kernel, z]}, %z includes tools in .app + {rel, RelName7, RelVsn, [stdlib, kernel, mnesia, y, sasl, x]}, + {rel, RelName8, RelVsn, [stdlib, kernel, {z,[tools]}]}, + {rel, RelName9, RelVsn, [stdlib, kernel, {z,[]}]}, + {incl_cond,exclude}, + {mod_cond,app}, + {app,kernel,[{incl_cond,include}]}, + {app,stdlib,[{incl_cond,include}]}, + {app,mnesia,[{incl_cond,include}]}, + {app,sasl,[{incl_cond,include}]}, + {app,x,[{incl_cond,include}]}, + {app,y,[{incl_cond,include}]}, + {app,z,[{incl_cond,include}]}, + {app,tools,[{mod_cond,app},{incl_cond,include}]} + ]}, + %% Generate release + + %% BUG: reltool reverses the list of applications after kernel and stdlib + ?msym({ok, {release, {RelName1, RelVsn}, + {erts, _}, + [{kernel, _}, + {stdlib, _}, + {mnesia, _}, + {sasl, _}]}}, + reltool:get_rel([{config, Sys}], RelName1)), + + %% BUG: reltool reverses the list of applications after kernel and stdlib + ?msym({ok, {release, {RelName2, RelVsn}, + {erts, _}, + [{kernel, _}, + {stdlib, _}, + {sasl, _}, + {mnesia, _}]}}, + reltool:get_rel([{config, Sys}], RelName2)), + + ?msym({ok, {release, {RelName3, RelVsn}, + {erts, _}, + [{kernel, _}, + {stdlib, _}, + {tools, _}, + {z, _, [tools]}]}}, + reltool:get_rel([{config, Sys}], RelName3)), + + %% BUG: reltool does not honor included applications in .app files + %% unless they are also mentioned in the 'rel' specification in + %% the reltool config. + %% => order of tools and z does not become correct in rel (tools + %% should be first since it is included in z) + ?msym({ok, {release, {RelName4, RelVsn}, + {erts, _}, + [{kernel, _}, + {stdlib, _}, + {tools, _}, + {z, _}]}}, + reltool:get_rel([{config, Sys}], RelName4)), + + ?m({error,"sasl: These applications are used by release " + "Include-only-rel but are missing as included_applications " + "in the app file: [tools]"}, + reltool:get_rel([{config, Sys}], RelName5)), + + %% BUG: reltool does not honor included applications in .app files + %% unless they are also mentioned in the 'rel' specification in + %% the reltool config. + %% => does not detect that tools (included in z) is missing + ?m({error, "Undefined applications: [tools]"}, + reltool:get_rel([{config, Sys}], RelName6)), + + ?m({error,"Circular dependencies: [x,y]"}, + reltool:get_rel([{config, Sys}], RelName7)), + + ?m({error,"Undefined applications: [tools]"}, + reltool:get_rel([{config, Sys}], RelName8)), + + %% BUG: Reltool looses the empty include list for z, which should + %% overwrite included_applications statement from the .app file. + ?msym({ok,{release,{RelName9,RelVsn}, + {erts,_}, + [{kernel,_}, + {stdlib,_}, + {z,_,[]}]}}, + reltool:get_rel([{config, Sys}], RelName9)), + + ok. + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Generate boot scripts @@ -298,6 +432,203 @@ create_script(_Config) -> ?m(ok, reltool:stop(Pid)), ok. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Test creation of .script with different sorting of applications and +%% included applications. +%% Test that result is equal to what systools produces +create_script_sort(_Config) -> {skip, "Multiple known problems - see OTP-9792"}; +create_script_sort(Config) -> + DataDir = ?config(data_dir,Config), + %% Configure the server + RelName1 = "MnesiaFirst", + RelName2 = "SaslFirst", + RelName3 = "Include-both", + RelName4 = "Include-only-app", + RelName5 = "Include-only-rel", + RelName6 = "Include-missing-app", + RelName7 = "Circular", + RelName8 = "Include-both-missing-app", + RelName9 = "Include-overwrite", + RelVsn = "1.0", + LibDir = filename:join(DataDir,"sort_apps"), + Sys = + {sys, + [ + {lib_dirs, [LibDir]}, + {boot_rel, RelName1}, + {rel, RelName1, RelVsn, [stdlib, kernel, mnesia, sasl]}, + {rel, RelName2, RelVsn, [stdlib, kernel, sasl, mnesia]}, + {rel, RelName3, RelVsn, [stdlib, kernel, {z,[tools]}, tools]}, + {rel, RelName4, RelVsn, [stdlib, kernel, z, tools]}, + {rel, RelName5, RelVsn, [stdlib, kernel, {sasl,[tools]}]}, + {rel, RelName6, RelVsn, [stdlib, kernel, z]}, %z includes tools in .app + {rel, RelName7, RelVsn, [stdlib, kernel, mnesia, y, sasl, x]}, + {rel, RelName8, RelVsn, [stdlib, kernel, {z,[tools]}]}, + {rel, RelName9, RelVsn, [stdlib, kernel, {z,[]}]}, + {incl_cond,exclude}, + {mod_cond,app}, + {app,kernel,[{incl_cond,include}]}, + {app,stdlib,[{incl_cond,include}]}, + {app,mnesia,[{incl_cond,include}]}, + {app,sasl,[{incl_cond,include}]}, + {app,x,[{incl_cond,include}]}, + {app,y,[{incl_cond,include}]}, + {app,z,[{incl_cond,include}]}, + {app,tools,[{mod_cond,app},{incl_cond,include}]} + ]}, + + {ok, Pid} = ?msym({ok, _}, reltool:start_server([{config, Sys}])), + + %% Generate release files + application:load(sasl), + application:load(mnesia), + application:load(tools), + {ok,KernelVsn} = application:get_key(kernel,vsn), + {ok,StdlibVsn} = application:get_key(stdlib,vsn), + {ok,SaslVsn} = application:get_key(sasl,vsn), + {ok,MnesiaVsn} = application:get_key(mnesia,vsn), + {ok,ToolsVsn} = application:get_key(tools,vsn), + ErtsVsn = erlang:system_info(version), + + Rel1 = {release, {RelName1,RelVsn}, {erts,ErtsVsn}, + [{kernel,KernelVsn}, + {stdlib,StdlibVsn}, + {mnesia,MnesiaVsn}, + {sasl,SaslVsn}]}, + FullName1 = filename:join(?WORK_DIR,RelName1), + ?m(ok, file:write_file(FullName1 ++ ".rel", io_lib:format("~p.\n", [Rel1]))), + Rel2 = {release, {RelName2,RelVsn}, {erts,ErtsVsn}, + [{kernel,KernelVsn}, + {stdlib,StdlibVsn}, + {sasl,SaslVsn}, + {mnesia,MnesiaVsn}]}, + FullName2 = filename:join(?WORK_DIR,RelName2), + ?m(ok, file:write_file(FullName2 ++ ".rel", io_lib:format("~p.\n", [Rel2]))), + Rel3 = {release, {RelName3,RelVsn}, {erts,ErtsVsn}, + [{kernel,KernelVsn}, + {stdlib,StdlibVsn}, + {z,"1.0",[tools]}, + {tools,ToolsVsn}]}, + FullName3 = filename:join(?WORK_DIR,RelName3), + ?m(ok, file:write_file(FullName3 ++ ".rel", io_lib:format("~p.\n", [Rel3]))), + Rel4 = {release, {RelName4,RelVsn}, {erts,ErtsVsn}, + [{kernel,KernelVsn}, + {stdlib,StdlibVsn}, + {z,"1.0"}, + {tools,ToolsVsn}]}, + FullName4 = filename:join(?WORK_DIR,RelName4), + ?m(ok, file:write_file(FullName4 ++ ".rel", io_lib:format("~p.\n", [Rel4]))), + Rel5 = {release, {RelName5,RelVsn}, {erts,ErtsVsn}, + [{kernel,KernelVsn}, + {stdlib,StdlibVsn}, + {sasl,SaslVsn,[tools]}, + {tools,ToolsVsn}]}, + FullName5 = filename:join(?WORK_DIR,RelName5), + ?m(ok, file:write_file(FullName5 ++ ".rel", io_lib:format("~p.\n", [Rel5]))), + Rel6 = {release, {RelName6,RelVsn}, {erts,ErtsVsn}, + [{kernel,KernelVsn}, + {stdlib,StdlibVsn}, + {z,"1.0"}]}, + FullName6 = filename:join(?WORK_DIR,RelName6), + ?m(ok, file:write_file(FullName6 ++ ".rel", io_lib:format("~p.\n", [Rel6]))), + Rel7 = {release, {RelName7,RelVsn}, {erts,ErtsVsn}, + [{kernel,KernelVsn}, + {stdlib,StdlibVsn}, + {mnesia,MnesiaVsn}, + {y,"1.0"}, + {sasl,SaslVsn}, + {x,"1.0"}]}, + FullName7 = filename:join(?WORK_DIR,RelName7), + ?m(ok, file:write_file(FullName7 ++ ".rel", io_lib:format("~p.\n", [Rel7]))), + Rel8 = {release, {RelName8,RelVsn}, {erts,ErtsVsn}, + [{kernel,KernelVsn}, + {stdlib,StdlibVsn}, + {z,"1.0",[tools]}]}, + FullName8 = filename:join(?WORK_DIR,RelName8), + ?m(ok, file:write_file(FullName8 ++ ".rel", io_lib:format("~p.\n", [Rel8]))), + Rel9 = {release, {RelName9,RelVsn}, {erts,ErtsVsn}, + [{kernel,KernelVsn}, + {stdlib,StdlibVsn}, + {z,"1.0",[]}]}, + FullName9 = filename:join(?WORK_DIR,RelName9), + ?m(ok, file:write_file(FullName9 ++ ".rel", io_lib:format("~p.\n", [Rel9]))), + + %% Generate script files with systools and reltool and compare + ZPath = filename:join([LibDir,"*",ebin]), + + %% BUG: reltool reverses the list of applications after kernel and stdlib + %% => mnesia and sasl are reverted + ?msym({ok,_,_}, systools_make_script(FullName1,ZPath)), + {ok, [SystoolsScript1]} = ?msym({ok,[_]}, file:consult(FullName1++".script")), + {ok, Script1} = ?msym({ok, _}, reltool:get_script(Pid, RelName1)), + ?m(equal, diff_script(SystoolsScript1, Script1)), + + %% BUG: reltool reverses the list of applications after kernel and stdlib + %% => mnesia and sasl are reverted + ?msym({ok,_,_}, systools_make_script(FullName2,ZPath)), + {ok, [SystoolsScript2]} = ?msym({ok,[_]}, file:consult(FullName2++".script")), + {ok, Script2} = ?msym({ok, _}, reltool:get_script(Pid, RelName2)), + ?m(equal, diff_script(SystoolsScript2, Script2)), + + %% BUG1: reltool loads all modules in the ebin dir of an application, + %% even if mod_cond is set to 'app'. + %% BUG2: reltool shall not start included applications!! + ?msym({ok,_,_}, systools_make_script(FullName3,ZPath)), + {ok, [SystoolsScript3]} = ?msym({ok,[_]}, file:consult(FullName3++".script")), + {ok, Script3} = ?msym({ok, _}, reltool:get_script(Pid, RelName3)), + ?m(equal, diff_script(SystoolsScript3, Script3)), + + %% BUG1: reltool loads all modules in the ebin dir of an application, + %% even if mod_cond is set to 'app'. + %% BUG2: reltool does not honor included applications in .app files + %% unless they are also mentioned in the 'rel' specification in + %% the reltool config. + %% => faulty order of load instructions for tools and z. tools + %% should be first since it is included in z. + ?msym({ok,_,_}, systools_make_script(FullName4,ZPath)), + {ok, [SystoolsScript4]} = ?msym({ok,[_]}, file:consult(FullName4++".script")), + {ok, Script4} = ?msym({ok, _}, reltool:get_script(Pid, RelName4)), + ?m(equal, diff_script(SystoolsScript4, Script4)), + + ?msym({error,_,[{error_reading,{sasl,{override_include,_}}}]}, + systools_make_script(FullName5,ZPath)), + ?m({error,"sasl: These applications are used by release " + "Include-only-rel but are missing as included_applications " + "in the app file: [tools]"}, + reltool:get_script(Pid, RelName5)), + + %% BUG: reltool does not honor included applications in .app files + %% unless they are also mentioned in the 'rel' specification in + %% the reltool config. + %% => does not detect that tools (included in z) is missing + ?msym({error,_,{undefined_applications,_}}, + systools_make_script(FullName6,ZPath)), + ?m({error, "Undefined applications: [tools]"}, + reltool:get_script(Pid, RelName6)), + + ?msym({error,_,{circular_dependencies,_}}, + systools_make_script(FullName7,ZPath)), + ?m({error,"Circular dependencies: [x,y]"}, + reltool:get_script(Pid, RelName7)), + + ?msym({error,_,{undefined_applications,_}}, + systools_make_script(FullName8,ZPath)), + ?m({error, "Undefined applications: [tools]"}, + reltool:get_script(Pid, RelName8)), + + ?msym({ok,_,_}, systools_make_script(FullName9,ZPath)), + {ok, [SystoolsScript9]} = ?msym({ok,[_]}, file:consult(FullName9++".script")), + {ok, Script9} = ?msym({ok, _}, reltool:get_script(Pid, RelName9)), + ?m(equal, diff_script(SystoolsScript9, Script9)), + + %% Stop server + ?m(ok, reltool:stop(Pid)), + ok. + + +systools_make_script(Name,Path) -> + systools:make_script(Name,[{path,[Path]},{outdir,?WORK_DIR},silent]). + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Generate target system diff --git a/lib/reltool/test/reltool_server_SUITE_data/sort_apps/x-1.0/ebin/x.app b/lib/reltool/test/reltool_server_SUITE_data/sort_apps/x-1.0/ebin/x.app new file mode 100644 index 0000000000..5fa2a92969 --- /dev/null +++ b/lib/reltool/test/reltool_server_SUITE_data/sort_apps/x-1.0/ebin/x.app @@ -0,0 +1,7 @@ +% -*-erlang-*- +{application, x, + [{description, "Application in reltool sort app test - circular dependency"}, + {vsn, "1.0"}, + {modules,[]}, + {registered, []}, + {applications, [kernel, stdlib, y]}]}. diff --git a/lib/reltool/test/reltool_server_SUITE_data/sort_apps/y-1.0/ebin/y.app b/lib/reltool/test/reltool_server_SUITE_data/sort_apps/y-1.0/ebin/y.app new file mode 100644 index 0000000000..c4bc62f55f --- /dev/null +++ b/lib/reltool/test/reltool_server_SUITE_data/sort_apps/y-1.0/ebin/y.app @@ -0,0 +1,7 @@ +% -*-erlang-*- +{application, y, + [{description, "Application in reltool sort app test - circular dependency"}, + {vsn, "1.0"}, + {modules,[]}, + {registered, []}, + {applications, [kernel, stdlib, x]}]}. diff --git a/lib/reltool/test/reltool_server_SUITE_data/sort_apps/z-1.0/ebin/z.app b/lib/reltool/test/reltool_server_SUITE_data/sort_apps/z-1.0/ebin/z.app new file mode 100644 index 0000000000..1622975bf6 --- /dev/null +++ b/lib/reltool/test/reltool_server_SUITE_data/sort_apps/z-1.0/ebin/z.app @@ -0,0 +1,8 @@ +% -*-erlang-*- +{application, z, + [{description, "Application in reltool sort app test - included applications"}, + {vsn, "1.0"}, + {modules,[]}, + {registered, []}, + {applications, [kernel, stdlib]}, + {included_applications, [tools]}]}. -- cgit v1.2.3 From e3bb31270b1cc43a72a2c3942f496e5c8f93155b Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Mon, 13 Feb 2012 16:57:51 +0100 Subject: [reltool] Add test cases for handling of escripts OTP-9794 OTP-9968 The following test cases are added: * create_standalone_beam * create_standalone_app * create_multiple_standalone * load_config_escript_path * load_config_same_escript_source * load_config_same_escript_beam * load_config_add_escript Most of them are temporarily skipped since they re-produce known problems that will be corrected in a later commit. --- lib/reltool/test/reltool_server_SUITE.erl | 365 ++++++++++++++++++++- .../test/reltool_server_SUITE_data/Makefile.src | 8 +- .../escript/someapp-1.0/ebin/someapp.app | 6 + .../escript/someapp-1.0/src/mymod.erl | 26 ++ 4 files changed, 394 insertions(+), 11 deletions(-) create mode 100644 lib/reltool/test/reltool_server_SUITE_data/escript/someapp-1.0/ebin/someapp.app create mode 100644 lib/reltool/test/reltool_server_SUITE_data/escript/someapp-1.0/src/mymod.erl (limited to 'lib/reltool/test') diff --git a/lib/reltool/test/reltool_server_SUITE.erl b/lib/reltool/test/reltool_server_SUITE.erl index 0aca242d4e..56c9cb5ed1 100644 --- a/lib/reltool/test/reltool_server_SUITE.erl +++ b/lib/reltool/test/reltool_server_SUITE.erl @@ -62,6 +62,9 @@ all() -> create_target, create_embedded, create_standalone, + create_standalone_beam, + create_standalone_app, + create_multiple_standalone, create_old_target, eval_target_spec, otp_9135, @@ -74,6 +77,10 @@ all() -> set_apps_and_undo, set_sys_and_undo, load_config_and_undo, + load_config_escript_path, + load_config_same_escript_source, + load_config_same_escript_beam, + load_config_add_escript, reset_config_and_undo, gen_rel_files, save_config, @@ -138,27 +145,34 @@ set_config(_Config) -> %% Check that get_config returns the expected derivates and defaults %% as specified get_config(_Config) -> + + KVsn = latest(kernel), + StdVsn = latest(stdlib), + SaslVsn = latest(sasl), + Sys = {sys,[{incl_cond, exclude}, {app,kernel,[{incl_cond,include}]}, - {app,sasl,[{incl_cond,include}]}, + {app,sasl,[{incl_cond,include},{vsn,SaslVsn}]}, {app,stdlib,[{incl_cond,include}]}]}, {ok, Pid} = ?msym({ok, _}, reltool:start_server([{config, Sys}])), ?m({ok, Sys}, reltool:get_config(Pid)), ?m({ok, Sys}, reltool:get_config(Pid,false,false)), + %% Include derived info ?msym({ok,{sys,[{incl_cond, exclude}, {erts,[]}, {app,kernel,[{incl_cond,include},{mod,_,[]}|_]}, - {app,sasl,[{incl_cond,include},{mod,_,[]}|_]}, + {app,sasl,[{incl_cond,include},{vsn,SaslVsn},{mod,_,[]}|_]}, {app,stdlib,[{incl_cond,include},{mod,_,[]}|_]}]}}, reltool:get_config(Pid,false,true)), + %% Include defaults ?msym({ok,{sys,[{root_dir,_}, {lib_dirs,_}, {mod_cond,all}, {incl_cond,exclude}, {app,kernel,[{incl_cond,include},{vsn,undefined}]}, - {app,sasl,[{incl_cond,include},{vsn,undefined}]}, + {app,sasl,[{incl_cond,include},{vsn,SaslVsn}]}, {app,stdlib,[{incl_cond,include},{vsn,undefined}]}, {boot_rel,"start_clean"}, {rel,"start_clean","1.0",[]}, @@ -178,16 +192,14 @@ get_config(_Config) -> {debug_info,keep}]}}, reltool:get_config(Pid,true,false)), - KVsn = latest(kernel), - StdVsn = latest(stdlib), - + %% Include both defaults and derived info ?msym({ok,{sys,[{root_dir,_}, {lib_dirs,_}, {mod_cond,all}, {incl_cond,exclude}, {erts,[]}, {app,kernel,[{incl_cond,include},{vsn,KVsn},{mod,_,[]}|_]}, - {app,sasl,[{incl_cond,include},{vsn,_},{mod,_,[]}|_]}, + {app,sasl,[{incl_cond,include},{vsn,SaslVsn},{mod,_,[]}|_]}, {app,stdlib,[{incl_cond,include},{vsn,StdVsn},{mod,_,[]}|_]}, {boot_rel,"start_clean"}, {rel,"start_clean","1.0",[]}, @@ -720,21 +732,187 @@ create_standalone(_Config) -> ?m(ok, file:make_dir(TargetDir)), ok = ?m(ok, reltool:create_target([{config, Config}], TargetDir)), + %% Start the target system and fetch root dir BinDir = filename:join([TargetDir, "bin"]), Erl = filename:join([BinDir, "erl"]), {ok, Node} = ?msym({ok, _}, start_node(?NODE_NAME, Erl)), RootDir = ?ignore(rpc:call(Node, code, root_dir, [])), ?msym(ok, stop_node(Node)), + %% Execute escript Expected = iolist_to_binary(["Root dir: ", RootDir, "\n" "Script args: [\"-arg1\",\"arg2\",\"arg3\"]\n", "Smp: false\n", "ExitCode:0"]), io:format("Expected: ~s\n", [Expected]), - ?m(Expected, run(BinDir, EscriptName ++ " -arg1 arg2 arg3")), + ?m(Expected, run(BinDir, EscriptName, "-arg1 arg2 arg3")), ok. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Generate standalone system with inlined beam file + +create_standalone_beam(Config) -> + %% Read beam file + DataDir = ?config(data_dir,Config), + BeamFile = filename:join([DataDir,escript,"someapp-1.0",ebin,"mymod.beam"]), + {ok,BeamBin} = file:read_file(BeamFile), + + %% Create the escript + EscriptName = "mymod.escript", + Escript = filename:join(?WORK_DIR,EscriptName), + ok = escript:create(Escript,[shebang,{beam,BeamBin}]), + ok = file:change_mode(Escript,8#00744), + + %% Configure the server + Sys = + {sys, + [ + {lib_dirs, []}, + {escript, Escript, [{incl_cond, include}]}, + {profile, standalone} + ]}, + + %% Generate target file + TargetDir = filename:join([?WORK_DIR, "target_standalone_beam"]), + ?m(ok, reltool_utils:recursive_delete(TargetDir)), + ?m(ok, file:make_dir(TargetDir)), + ok = ?m(ok, reltool:create_target([{config, Sys}], TargetDir)), + + %% Start the target system and fetch root dir + BinDir = filename:join([TargetDir, "bin"]), + Erl = filename:join([BinDir, "erl"]), + {ok, Node} = ?msym({ok, _}, start_node(?NODE_NAME, Erl)), + RootDir = ?ignore(rpc:call(Node, code, root_dir, [])), + ?msym(ok, stop_node(Node)), + + %% Execute escript + Expected = iolist_to_binary(["Root dir: ", RootDir, "\n" + "Script args: [\"-arg1\",\"arg2\",\"arg3\"]\n", + "ExitCode:0"]), + io:format("Expected: ~s\n", [Expected]), + ?m(Expected, run(BinDir, EscriptName, "-arg1 arg2 arg3")), + + ok. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Generate standalone system with inlined archived application + +%% BUG: see OTP-9792, 25) +%% Problem related to change of #app.name from "*escript* someapp" to +%% just "someapp", since there is a someapp.app in the +%% archive. "someapp" does not have an incl_cond=include statement, +%% and it is not derived so the it is not included in the target +%% system. +create_standalone_app(_Config) -> {skip, "Known bug: escript with inlined archive is not handled correctly by reltool"}; +create_standalone_app(Config) -> + %% Create archive + DataDir = ?config(data_dir,Config), + EscriptDir = filename:join(DataDir,escript), + {ok,{_Archive,Bin}} = zip:create("someapp-1.0.ez",["someapp-1.0"], + [memory, + {cwd,EscriptDir}, + {compress,all}, + {uncompress,[".beam",".app"]}]), + + %% Create the escript + EscriptName = "someapp.escript", + Escript = filename:join(?WORK_DIR,EscriptName), + ok = escript:create(Escript,[shebang, + {emu_args,"-escript main mymod"}, + {archive,Bin}]), + ok = file:change_mode(Escript,8#00744), + + %% Configure the server + Sys = + {sys, + [ + {lib_dirs, []}, + {escript, Escript, [{incl_cond, include}]}, + {profile, standalone} + ]}, + + %% Generate target file + TargetDir = filename:join([?WORK_DIR, "target_standalone_app"]), + ?m(ok, reltool_utils:recursive_delete(TargetDir)), + ?m(ok, file:make_dir(TargetDir)), + ok = ?m(ok, reltool:create_target([{config, Sys}], TargetDir)), + + %% Start the target system and fetch root dir + BinDir = filename:join([TargetDir, "bin"]), + Erl = filename:join([BinDir, "erl"]), + {ok, Node} = ?msym({ok, _}, start_node(?NODE_NAME, Erl)), + RootDir = ?ignore(rpc:call(Node, code, root_dir, [])), + ?msym(ok, stop_node(Node)), + + %% Execute escript + Expected = iolist_to_binary(["Root dir: ", RootDir, "\n" + "Script args: [\"-arg1\",\"arg2\",\"arg3\"]\n", + "ExitCode:0"]), + io:format("Expected: ~s\n", [Expected]), + ?m(Expected, run(BinDir, EscriptName, "-arg1 arg2 arg3")), + + ok. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Generate standalone system with multiple escripts + +create_multiple_standalone(Config) -> + %% First escript + ExDir = code:lib_dir(reltool, examples), + EscriptName1 = "display_args", + Escript1 = filename:join([ExDir, EscriptName1]), + + %% Second escript + DataDir = ?config(data_dir,Config), + BeamFile = filename:join([DataDir,escript,"someapp-1.0",ebin,"mymod.beam"]), + {ok,BeamBin} = file:read_file(BeamFile), + EscriptName2 = "mymod.escript", + Escript2 = filename:join(?WORK_DIR,EscriptName2), + ok = escript:create(Escript2,[shebang,{beam,BeamBin}]), + ok = file:change_mode(Escript2,8#00744), + + %% Configure server + Sys = + {sys, + [ + {lib_dirs, []}, + {escript, Escript1, [{incl_cond, include}]}, + {escript, Escript2, [{incl_cond, include}]}, + {profile, standalone} + ]}, + + %% Generate target system + TargetDir = filename:join([?WORK_DIR, "target_multiple_standalone"]), + ?m(ok, reltool_utils:recursive_delete(TargetDir)), + ?m(ok, file:make_dir(TargetDir)), + ok = ?m(ok, reltool:create_target([{config,Sys}], TargetDir)), + + %% Start the target system and fetch root dir + BinDir = filename:join([TargetDir, "bin"]), + Erl = filename:join([BinDir, "erl"]), + {ok, Node} = ?msym({ok, _}, start_node(?NODE_NAME, Erl)), + RootDir = ?ignore(rpc:call(Node, code, root_dir, [])), + ?msym(ok, stop_node(Node)), + + %% Execute escript1 + Expected1 = iolist_to_binary(["Root dir: ", RootDir, "\n" + "Script args: [\"-arg1\",\"arg2\",\"arg3\"]\n", + "Smp: false\n", + "ExitCode:0"]), + io:format("Expected1: ~s\n", [Expected1]), + ?m(Expected1, run(BinDir, EscriptName1, "-arg1 arg2 arg3")), + + + %% Execute escript2 + Expected2 = iolist_to_binary(["Root dir: ", RootDir, "\n" + "Script args: [\"-arg1\",\"arg2\",\"arg3\"]\n", + "ExitCode:0"]), + io:format("Expected2: ~s\n", [Expected2]), + ?m(Expected2, run(BinDir, EscriptName2, "-arg1 arg2 arg3")), + + ok. + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Generate old type of target system @@ -1182,6 +1360,171 @@ load_config_and_undo(Config) -> ok. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Load config with escript + +load_config_escript_path(_Config) -> {skip,"Known bug: loading config with escript at reltool start creates different #app record than loading same config with load_config"}; +load_config_escript_path(Config) -> + %% Create escript + DataDir = ?config(data_dir,Config), + BeamFile = filename:join([DataDir,escript,"someapp-1.0",ebin,"mymod.beam"]), + {ok,BeamBin} = file:read_file(BeamFile), + EscriptName = "mymod.escript", + Escript = filename:join(?WORK_DIR,EscriptName), + ok = escript:create(Escript,[shebang,{beam,BeamBin}]), + ok = file:change_mode(Escript,8#00744), + + %% Start reltool_server with one escript in configuration + EscriptSys = + {sys, + [ + {lib_dirs, []}, + {escript, Escript, [{incl_cond, include}]}, + {profile, standalone} + ]}, + + {ok, Pid1} = ?msym({ok, _}, reltool:start_server([{config, EscriptSys}])), + {ok,[#app{name='*escript* mymod'}=A]} = + ?msym({ok,[_]}, reltool_server:get_apps(Pid1,whitelist)), + ?m(ok, reltool:stop(Pid1)), + + + %% Do same again, but now start reltool first with simple config, + %% then add escript by loading new configuration and check that + %% #app is the same + SimpleSys = + {sys, + [ + {lib_dirs, []} + ]}, + + {ok, Pid2} = ?msym({ok, _}, reltool:start_server([{config, SimpleSys}])), + ?m({ok,[]}, reltool_server:get_apps(Pid2,whitelist)), + ?m({ok,[]}, reltool_server:load_config(Pid2,EscriptSys)), + ?m({ok,[A]}, reltool_server:get_apps(Pid2,whitelist)), + + ?m(ok, reltool:stop(Pid2)), + + ok. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Load config with same (source) escript twice and check that the +%% application information is not changed. + +load_config_same_escript_source(_Config) -> {skip,"Known bug: loading config with same escript (source) twice causes reltool to add same module twice in #app.mods"}; +load_config_same_escript_source(_Config) -> + %% Create escript + ExDir = code:lib_dir(reltool, examples), + EscriptName = "display_args", + Escript = filename:join([ExDir, EscriptName]), + + %% Start reltool_server with one escript in configuration + Sys = + {sys, + [ + {lib_dirs, []}, + {escript, Escript, [{incl_cond, include}]}, + {profile, standalone} + ]}, + + {ok, Pid} = ?msym({ok, _}, reltool:start_server([{config, Sys}])), + {ok,[#app{name='*escript* display_args'}=A]} = + ?msym({ok,[_]}, reltool_server:get_apps(Pid,whitelist)), + + %% Load the same config again, then check that app is not changed + ?m({ok,[]}, reltool_server:load_config(Pid,Sys)), + ?m({ok,[A]}, reltool_server:get_apps(Pid,whitelist)), + + ?m(ok, reltool:stop(Pid)), + + ok. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Load config with same (beam) escript twice and check that the +%% application information is not changed. + +load_config_same_escript_beam(_Config) -> {skip,"Known bug: loading config with same escript (with inlined beam) twice causes reltool to fail and say module is included by two different applications"}; +load_config_same_escript_beam(Config) -> + %% Create escript + DataDir = ?config(data_dir,Config), + BeamFile = filename:join([DataDir,escript,"someapp-1.0",ebin,"mymod.beam"]), + {ok,BeamBin} = file:read_file(BeamFile), + EscriptName = "mymod.escript", + Escript = filename:join(?WORK_DIR,EscriptName), + ok = escript:create(Escript,[shebang,{beam,BeamBin}]), + ok = file:change_mode(Escript,8#00744), + + %% Start reltool_server with one escript in configuration + Sys = + {sys, + [ + {lib_dirs, []}, + {escript, Escript, [{incl_cond, include}]}, + {profile, standalone} + ]}, + + {ok, Pid} = ?msym({ok, _}, reltool:start_server([{config, Sys}])), + {ok,[#app{name='*escript* mymod'}=A]} = + ?msym({ok,[_]}, reltool_server:get_apps(Pid,whitelist)), + + %% Load the same config again, then check that app is not changed + ?m({ok,[]}, reltool_server:load_config(Pid,Sys)), + ?m({ok,[A]}, reltool_server:get_apps(Pid,whitelist)), + + ?m(ok, reltool:stop(Pid)), + + ok. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Load config with escript + +%% BUG: see OTP-9792, 25) +load_config_add_escript(_Config) -> {skip,"Known bug: Can not load_config which in addition to an existing escript also adds another escript for which the name sorts before the existing one"}; +load_config_add_escript(Config) -> + %% First escript + ExDir = code:lib_dir(reltool, examples), + EscriptName1 = "display_args", + Escript1 = filename:join([ExDir, EscriptName1]), + + %% Second escript + DataDir = ?config(data_dir,Config), + BeamFile = filename:join([DataDir,escript,"someapp-1.0",ebin,"mymod.beam"]), + {ok,BeamBin} = file:read_file(BeamFile), + EscriptName2 = "mymod.escript", + Escript2 = filename:join(?WORK_DIR,EscriptName2), + ok = escript:create(Escript2,[shebang,{beam,BeamBin}]), + ok = file:change_mode(Escript2,8#00744), + + %% Start reltool_server with one escript in configuration + Sys1 = + {sys, + [ + {lib_dirs, []}, + {escript, Escript2, [{incl_cond, include}]}, + {profile, standalone} + ]}, + + {ok, Pid} = ?msym({ok, _}, reltool:start_server([{config, Sys1}])), + + %% Add second escript by loading new configuration + Sys2 = + {sys, + [ + {lib_dirs, []}, + {escript, Escript1, [{incl_cond, include}]}, + {escript, Escript2, [{incl_cond, include}]}, + {profile, standalone} + ]}, + + {ok,[]} = ?m({ok,[]}, reltool_server:load_config(Pid,Sys2)), + {ok,[#app{name='*escript* display_args'}, + #app{name='*escript* mymod'}]} = + ?msym({ok,[_,_]}, reltool_server:get_apps(Pid,whitelist)), + + ?m(ok, reltool:stop(Pid)), + + ok. + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% reset_config_and_undo(Config) -> Sys1 = {sys,[{lib_dirs,[filename:join(datadir(Config),"faulty_app_file")]}, @@ -1654,14 +1997,16 @@ wait_for_process(Node, Name, N) when is_integer(N), N > 0 -> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Run escript -run(Dir, Cmd0) -> +run(Dir, Script, Args) -> + Cmd0 = filename:rootname(Script) ++ " " ++ Args, Cmd = case os:type() of {win32,_} -> filename:nativename(Dir) ++ "\\" ++ Cmd0; _ -> Cmd0 end, do_run(Dir, Cmd). -run(Dir, Opts, Cmd0) -> +run(Dir, Opts, Script, Args) -> + Cmd0 = filename:rootname(Script) ++ " " ++ Args, Cmd = case os:type() of {win32,_} -> Opts ++ " " ++ filename:nativename(Dir) ++ "\\" ++ Cmd0; _ -> Opts ++ " " ++ Dir ++ "/" ++ Cmd0 diff --git a/lib/reltool/test/reltool_server_SUITE_data/Makefile.src b/lib/reltool/test/reltool_server_SUITE_data/Makefile.src index 35a239bfe2..8ab077d64b 100644 --- a/lib/reltool/test/reltool_server_SUITE_data/Makefile.src +++ b/lib/reltool/test/reltool_server_SUITE_data/Makefile.src @@ -14,8 +14,11 @@ DEPENDENCIES= \ dependencies/y-1.0/ebin/y2.@EMULATOR@ \ dependencies/z-1.0/ebin/z1.@EMULATOR@ +ESCRIPT= \ + escript/someapp-1.0/ebin/mymod.@EMULATOR@ -all: $(OTP9229) $(DEPENDENCIES) + +all: $(OTP9229) $(DEPENDENCIES) $(ESCRIPT) otp_9229/x-1.0/ebin/x.@EMULATOR@: otp_9229/x-1.0/src/x.erl erlc $(EFLAGS) -ootp_9229/x-1.0/ebin otp_9229/x-1.0/src/x.erl @@ -38,3 +41,6 @@ dependencies/y-1.0/ebin/y2.@EMULATOR@: dependencies/y-1.0/src/y2.erl erlc $(EFLAGS) -odependencies/y-1.0/ebin dependencies/y-1.0/src/y2.erl dependencies/z-1.0/ebin/z1.@EMULATOR@: dependencies/z-1.0/src/z1.erl erlc $(EFLAGS) -odependencies/z-1.0/ebin dependencies/z-1.0/src/z1.erl + +escript/someapp-1.0/ebin/mymod.@EMULATOR@: escript/someapp-1.0/src/mymod.erl + erlc $(EFLAGS) -oescript/someapp-1.0/ebin escript/someapp-1.0/src/mymod.erl diff --git a/lib/reltool/test/reltool_server_SUITE_data/escript/someapp-1.0/ebin/someapp.app b/lib/reltool/test/reltool_server_SUITE_data/escript/someapp-1.0/ebin/someapp.app new file mode 100644 index 0000000000..ea2209941e --- /dev/null +++ b/lib/reltool/test/reltool_server_SUITE_data/escript/someapp-1.0/ebin/someapp.app @@ -0,0 +1,6 @@ +%% -*- erlang -*- +{application, someapp, + [{description, "Some app for reltool test including archives in escripts"}, + {vsn, "1.0"}, + {modules, [someapp]}, + {applications, [kernel, stdlib]}]}. diff --git a/lib/reltool/test/reltool_server_SUITE_data/escript/someapp-1.0/src/mymod.erl b/lib/reltool/test/reltool_server_SUITE_data/escript/someapp-1.0/src/mymod.erl new file mode 100644 index 0000000000..b6c71c666d --- /dev/null +++ b/lib/reltool/test/reltool_server_SUITE_data/escript/someapp-1.0/src/mymod.erl @@ -0,0 +1,26 @@ +%% ``The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved via the world wide web at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% The Initial Developer of the Original Code is Ericsson Utvecklings AB. +%% Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings +%% AB. All Rights Reserved.'' +%% +%% $Id$ +%% +-module(mymod). + +-export([main/1]). + +%%%----------------------------------------------------------------- +%%% escript main function +main(Args) -> + io:format("Root dir: ~s\n", [code:root_dir()]), + io:format("Script args: ~p\n", [Args]). -- cgit v1.2.3 From 6f5e3e16019a3a4f9e9033d185b9c487967ad5fa Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Wed, 15 Feb 2012 16:36:27 +0100 Subject: [reltool] Update state and tables consistently for all types of config changes OTP-9794 OTP-9968 The main idea behind the data structure in reltool_server is that the state shall reflect what is explicitly configured, and the tables shall contain this configuration plus everything that is derived. In some cases, however, this was not the complete truth: * the application table was never read * the module table was never updated on undo * the state contained a lot more than what was explicitly configured This commit re-writes major parts of the reltool_server for the sake of unifying the way the state and tables are updated: * The list of applications in the state now only contains those applications and modules for which there are explicit settings in the configuration (given at startup or changed from the GUI) * When changing any bit of the configuration, the tables are always emptied and every part is derived again from the configuration found in the state * All configuration changes now cause a re-read of the file system, meaning that if something has changed in the file system it will be reflected in the result of the configuration change. This is the case even if no file system related configuration is changed (e.g. root dir or lib dirs) (*POSSIBLE INCOMPATIBILITY*) * Requests for applications and modules from the GUI now always read the tables, not the state * When loading a new configuration file via the GUI, the old configuration is completly scratched, and only the new is valid (*POSSIBLE INCOMPATIBILITY*) * The handling of escripts which include archives of applications is changed to always produce one #app record for the escript in addition to one for each inlined application. All modules are listed as parts of the inlined application where it belongs and not as part of the escript's #app record. This is a temporary solution which will be modified and improved. The following bugs are corrected by this commit: * Loading a config which contains an escript via the GUI menu did not produce the same #app record as when loading the same configuration at reltool start. Paths, version and label could differ. * Loading config with same escript (source) twice caused reltool to add same module twice in #app.mods * Loading config with same escript (inlined beam) twice caused reltool to fail saying module is included by two different applications * Loading config which in addition to an existing escript also adds another escript for which the name sorts before the existing one would cause reltool to fail saying "Application name clash" --- lib/reltool/test/reltool_server_SUITE.erl | 37 ++++++++++++++----------------- 1 file changed, 17 insertions(+), 20 deletions(-) (limited to 'lib/reltool/test') diff --git a/lib/reltool/test/reltool_server_SUITE.erl b/lib/reltool/test/reltool_server_SUITE.erl index 56c9cb5ed1..f2b63f78f0 100644 --- a/lib/reltool/test/reltool_server_SUITE.erl +++ b/lib/reltool/test/reltool_server_SUITE.erl @@ -1192,8 +1192,10 @@ set_app_and_undo(Config) -> ExclCover = Cover#mod{incl_cond=exclude}, Mods = Tools#app.mods, Tools1 = Tools#app{mods = lists:keyreplace(cover,#mod.name,Mods,ExclCover)}, - {ok,ToolsNoCover,[]} = ?msym({ok,_,[]}, reltool_server:set_app(Pid,Tools1)), - ?m({ok,[]}, reltool_server:get_status(Pid)), + {ok,ToolsNoCover,["a: Cannot parse app file"++_|_]} = + ?msym({ok,_,["a: Cannot parse app file"++_|_]}, + reltool_server:set_app(Pid,Tools1)), + ?msym({ok,["a: Cannot parse app file"++_|_]}, reltool_server:get_status(Pid)), %% Check that the module is no longer included ?m({ok,ToolsNoCover}, reltool_server:get_app(Pid,tools)), @@ -1201,17 +1203,16 @@ set_app_and_undo(Config) -> reltool_server:get_mod(Pid,cover)), %% Undo - %%! warning can come twice here... :( ?msym({ok,["a: Cannot parse app file"++_|_]},reltool_server:undo_config(Pid)), ?m({ok,Tools}, reltool_server:get_app(Pid,tools)), ?m({ok,Cover}, reltool_server:get_mod(Pid,cover)), ?msym({ok,["a: Cannot parse app file"++_|_]},reltool_server:get_status(Pid)), %% Undo again, to check that it toggles - ?m({ok,[]}, reltool_server:undo_config(Pid)), + ?msym({ok,["a: Cannot parse app file"++_|_]}, reltool_server:undo_config(Pid)), ?m({ok,ToolsNoCover}, reltool_server:get_app(Pid,tools)), ?m({ok,NoIncludeCover}, reltool_server:get_mod(Pid,cover)), - ?m({ok,[]}, reltool_server:get_status(Pid)), + ?msym({ok,["a: Cannot parse app file"++_|_]}, reltool_server:get_status(Pid)), ?m(ok, reltool:stop(Pid)), ok. @@ -1238,8 +1239,9 @@ set_apps_and_undo(Config) -> %% Exclude one application with set_apps ExclTools = Tools#app{incl_cond=exclude}, - ?m({ok,[]}, reltool_server:set_apps(Pid,[ExclTools])), - ?m({ok,[]}, reltool_server:get_status(Pid)), + ?msym({ok,["a: Cannot parse app file"++_|_]}, + reltool_server:set_apps(Pid,[ExclTools])), + ?msym({ok,["a: Cannot parse app file"++_|_]}, reltool_server:get_status(Pid)), %% Check that the app and its modules (one of them) are no longer included {ok,NoTools} = ?msym({ok,_}, reltool_server:get_app(Pid,tools)), @@ -1249,17 +1251,16 @@ set_apps_and_undo(Config) -> reltool_server:get_mod(Pid,cover)), %% Undo - %%! warning can come twice here... :( ?msym({ok,["a: Cannot parse app file"++_|_]},reltool_server:undo_config(Pid)), ?m({ok,Tools}, reltool_server:get_app(Pid,tools)), ?m({ok,Cover}, reltool_server:get_mod(Pid,cover)), ?msym({ok,["a: Cannot parse app file"++_|_]},reltool_server:get_status(Pid)), %% Undo again, to check that it toggles - ?m({ok,[]}, reltool_server:undo_config(Pid)), + ?msym({ok,["a: Cannot parse app file"++_|_]}, reltool_server:undo_config(Pid)), ?m({ok,NoTools}, reltool_server:get_app(Pid,tools)), ?m({ok,NoIncludeCover}, reltool_server:get_mod(Pid,cover)), - ?m({ok,[]}, reltool_server:get_status(Pid)), + ?msym({ok,["a: Cannot parse app file"++_|_]}, reltool_server:get_status(Pid)), ?m(ok, reltool:stop(Pid)), ok. @@ -1327,7 +1328,7 @@ load_config_and_undo(Config) -> {app,sasl,[{incl_cond,include}]}, {app,stdlib,[{incl_cond,include}]}, {app,tools,[{incl_cond,derived}]}]}, - ?msym({ok,["a: Cannot parse app file"++_]}, + ?msym({ok,["a: Cannot parse app file"++_|_]}, reltool_server:load_config(Pid,Sys2)), %%% OTP-0702, 15) ?m({ok, Sys2}, reltool:get_config(Pid)), %%% Note that {incl_cond,exclude} is removed compared to Sys1 - @@ -1363,7 +1364,6 @@ load_config_and_undo(Config) -> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Load config with escript -load_config_escript_path(_Config) -> {skip,"Known bug: loading config with escript at reltool start creates different #app record than loading same config with load_config"}; load_config_escript_path(Config) -> %% Create escript DataDir = ?config(data_dir,Config), @@ -1411,7 +1411,6 @@ load_config_escript_path(Config) -> %% Load config with same (source) escript twice and check that the %% application information is not changed. -load_config_same_escript_source(_Config) -> {skip,"Known bug: loading config with same escript (source) twice causes reltool to add same module twice in #app.mods"}; load_config_same_escript_source(_Config) -> %% Create escript ExDir = code:lib_dir(reltool, examples), @@ -1428,12 +1427,14 @@ load_config_same_escript_source(_Config) -> ]}, {ok, Pid} = ?msym({ok, _}, reltool:start_server([{config, Sys}])), - {ok,[#app{name='*escript* display_args'}=A]} = - ?msym({ok,[_]}, reltool_server:get_apps(Pid,whitelist)), +% {ok,[#app{name='*escript* display_args'}]} = + ?msym({ok,[#app{name='*escript* display_args',mods=[_]}]}, + reltool_server:get_apps(Pid,whitelist)), %% Load the same config again, then check that app is not changed ?m({ok,[]}, reltool_server:load_config(Pid,Sys)), - ?m({ok,[A]}, reltool_server:get_apps(Pid,whitelist)), + ?msym({ok,[#app{name='*escript* display_args',mods=[_]}]}, + reltool_server:get_apps(Pid,whitelist)), ?m(ok, reltool:stop(Pid)), @@ -1443,7 +1444,6 @@ load_config_same_escript_source(_Config) -> %% Load config with same (beam) escript twice and check that the %% application information is not changed. -load_config_same_escript_beam(_Config) -> {skip,"Known bug: loading config with same escript (with inlined beam) twice causes reltool to fail and say module is included by two different applications"}; load_config_same_escript_beam(Config) -> %% Create escript DataDir = ?config(data_dir,Config), @@ -1478,8 +1478,6 @@ load_config_same_escript_beam(Config) -> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Load config with escript -%% BUG: see OTP-9792, 25) -load_config_add_escript(_Config) -> {skip,"Known bug: Can not load_config which in addition to an existing escript also adds another escript for which the name sorts before the existing one"}; load_config_add_escript(Config) -> %% First escript ExDir = code:lib_dir(reltool, examples), @@ -1566,7 +1564,6 @@ reset_config_and_undo(Config) -> reltool_server:get_mod(Pid,cover)), %% Reset - %%! warning can come twice here... :( ?msym({ok,["a: Cannot parse app file"++_|_]}, reltool_server:reset_config(Pid)), ?m({ok,Tools1}, reltool_server:get_app(Pid,tools)), -- cgit v1.2.3 From a5240467ac0b5428063360fc4a3d67ab9ffa1413 Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Thu, 16 Feb 2012 14:58:57 +0100 Subject: [reltool] Link together escript with inlined application OTP-9968 Make sure that inlined applications in an escript is included/excluded as the escript itself, and forbid explicit configuration of the inlined application. --- lib/reltool/test/reltool_server_SUITE.erl | 116 ++++++++++++++++++++++++++++-- 1 file changed, 109 insertions(+), 7 deletions(-) (limited to 'lib/reltool/test') diff --git a/lib/reltool/test/reltool_server_SUITE.erl b/lib/reltool/test/reltool_server_SUITE.erl index f2b63f78f0..e279be82a8 100644 --- a/lib/reltool/test/reltool_server_SUITE.erl +++ b/lib/reltool/test/reltool_server_SUITE.erl @@ -64,6 +64,7 @@ all() -> create_standalone, create_standalone_beam, create_standalone_app, + create_standalone_app_clash, create_multiple_standalone, create_old_target, eval_target_spec, @@ -75,6 +76,7 @@ all() -> get_sys, set_app_and_undo, set_apps_and_undo, + set_apps_inlined, set_sys_and_undo, load_config_and_undo, load_config_escript_path, @@ -798,13 +800,6 @@ create_standalone_beam(Config) -> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Generate standalone system with inlined archived application -%% BUG: see OTP-9792, 25) -%% Problem related to change of #app.name from "*escript* someapp" to -%% just "someapp", since there is a someapp.app in the -%% archive. "someapp" does not have an incl_cond=include statement, -%% and it is not derived so the it is not included in the target -%% system. -create_standalone_app(_Config) -> {skip, "Known bug: escript with inlined archive is not handled correctly by reltool"}; create_standalone_app(Config) -> %% Create archive DataDir = ?config(data_dir,Config), @@ -854,6 +849,43 @@ create_standalone_app(Config) -> ok. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Generate standalone system with inlined archived application +%% Check that the inlined app can not be explicitly configured + +create_standalone_app_clash(Config) -> + %% Create archive + DataDir = ?config(data_dir,Config), + EscriptDir = filename:join(DataDir,escript), + {ok,{_Archive,Bin}} = zip:create("someapp-1.0.ez",["someapp-1.0"], + [memory, + {cwd,EscriptDir}, + {compress,all}, + {uncompress,[".beam",".app"]}]), + + %% Create the escript + EscriptName = "someapp.escript", + Escript = filename:join(?WORK_DIR,EscriptName), + ok = escript:create(Escript,[shebang, + {emu_args,"-escript main mymod"}, + {archive,Bin}]), + ok = file:change_mode(Escript,8#00744), + + %% Configure the server + Sys = + {sys, + [ + {lib_dirs, []}, + {escript, Escript, [{incl_cond, include}]}, + {profile, standalone}, + {app, someapp, [{incl_cond,include}]} + ]}, + + ?msym({error,"someapp: Application name clash. Escript "++_}, + reltool:get_target_spec([{config,Sys}])), + + ok. + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Generate standalone system with multiple escripts @@ -1266,6 +1298,76 @@ set_apps_and_undo(Config) -> ok. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Test that escript can be configured, but not its inlined applications +set_apps_inlined(Config) -> + %% Create archive + DataDir = ?config(data_dir,Config), + EscriptDir = filename:join(DataDir,escript), + {ok,{_Archive,Bin}} = zip:create("someapp-1.0.ez",["someapp-1.0"], + [memory, + {cwd,EscriptDir}, + {compress,all}, + {uncompress,[".beam",".app"]}]), + + %% Create the escript + EscriptName = "someapp.escript", + Escript = filename:join(?WORK_DIR,EscriptName), + ok = escript:create(Escript,[shebang, + {emu_args,"-escript main mymod"}, + {archive,Bin}]), + ok = file:change_mode(Escript,8#00744), + + %% Configure the server + Sys = {sys,[{incl_cond, exclude}, + {escript,Escript,[]}, + {app,kernel,[{incl_cond,include}]}, + {app,sasl,[{incl_cond,include}]}, + {app,stdlib,[{incl_cond,include}]}]}, + {ok, Pid} = ?msym({ok, _}, reltool:start_server([{config, Sys}])), + ?msym({ok,[]},reltool_server:get_status(Pid)), + + %% Get app and mod + {ok,EApp} = ?msym({ok,_}, reltool_server:get_app(Pid,'*escript* someapp')), + {ok,Someapp} = ?msym({ok,_}, reltool_server:get_app(Pid,someapp)), + ?m(undefined, EApp#app.incl_cond), + ?m(undefined, Someapp#app.incl_cond), + ?m(false, Someapp#app.is_included), + ?m(false, Someapp#app.is_pre_included), + + %% Include escript + EApp1 = EApp#app{incl_cond=include}, + ?m({ok,[]}, reltool_server:set_apps(Pid,[EApp1])), + ExpectedEApp = EApp1#app{is_included=true,is_pre_included=true}, + ?m({ok,ExpectedEApp}, reltool_server:get_app(Pid,'*escript* someapp')), + {ok,Someapp1} = ?msym({ok,_}, reltool_server:get_app(Pid,someapp)), + ?m(include, Someapp1#app.incl_cond), + ?m(true, Someapp1#app.is_included), + ?m(true, Someapp1#app.is_pre_included), + + %% Check that inlined app can not be configured + Someapp2 = Someapp1#app{incl_cond=exclude}, + ?msym({error, + "Application someapp is inlined in '*escript* someapp'. " + "Can not change configuration for an inlined application."}, + reltool_server:set_apps(Pid,[Someapp2])), + ?m({ok,Someapp1}, reltool_server:get_app(Pid,someapp)), + + %% Exclude escript + {ok,EApp2} = ?msym({ok,_}, reltool_server:get_app(Pid,'*escript* someapp')), + EApp3 = EApp2#app{incl_cond=exclude}, + ?m({ok,[]}, reltool_server:set_apps(Pid,[EApp3])), + ExpectedEApp3 = EApp3#app{is_included=false,is_pre_included=false}, + ?m({ok,ExpectedEApp3}, reltool_server:get_app(Pid,'*escript* someapp')), + {ok,Someapp3} = ?msym({ok,_}, reltool_server:get_app(Pid,someapp)), + ?m(exclude, Someapp3#app.incl_cond), + ?m(false, Someapp3#app.is_included), + ?m(false, Someapp3#app.is_pre_included), + + ?m(ok, reltool:stop(Pid)), + ok. + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% set_sys_and_undo(Config) -> Sys1 = {sys,[{incl_cond, exclude}, -- cgit v1.2.3 From c714eff72c1bd15f8831cffe7256f3dfd8faf806 Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Thu, 23 Feb 2012 11:26:27 +0100 Subject: [reltool] Fix rollback and undo OTP-9794 Backup old configuration before starting re-configuration so rollback is possible if configuration fails. Store last configuration including derivates so undo does no longer need to refresh and analyse everything from disk. --- lib/reltool/test/reltool_server_SUITE.erl | 60 +++++++++++++++++++++++++------ 1 file changed, 49 insertions(+), 11 deletions(-) (limited to 'lib/reltool/test') diff --git a/lib/reltool/test/reltool_server_SUITE.erl b/lib/reltool/test/reltool_server_SUITE.erl index e279be82a8..2588c0829f 100644 --- a/lib/reltool/test/reltool_server_SUITE.erl +++ b/lib/reltool/test/reltool_server_SUITE.erl @@ -79,6 +79,7 @@ all() -> set_apps_inlined, set_sys_and_undo, load_config_and_undo, + load_config_fail, load_config_escript_path, load_config_same_escript_source, load_config_same_escript_beam, @@ -1235,13 +1236,13 @@ set_app_and_undo(Config) -> reltool_server:get_mod(Pid,cover)), %% Undo - ?msym({ok,["a: Cannot parse app file"++_|_]},reltool_server:undo_config(Pid)), + ?m(ok, reltool_server:undo_config(Pid)), ?m({ok,Tools}, reltool_server:get_app(Pid,tools)), ?m({ok,Cover}, reltool_server:get_mod(Pid,cover)), - ?msym({ok,["a: Cannot parse app file"++_|_]},reltool_server:get_status(Pid)), + ?msym({ok,["a: Cannot parse app file"++_|_]}, reltool_server:get_status(Pid)), %% Undo again, to check that it toggles - ?msym({ok,["a: Cannot parse app file"++_|_]}, reltool_server:undo_config(Pid)), + ?msym(ok, reltool_server:undo_config(Pid)), ?m({ok,ToolsNoCover}, reltool_server:get_app(Pid,tools)), ?m({ok,NoIncludeCover}, reltool_server:get_mod(Pid,cover)), ?msym({ok,["a: Cannot parse app file"++_|_]}, reltool_server:get_status(Pid)), @@ -1283,13 +1284,13 @@ set_apps_and_undo(Config) -> reltool_server:get_mod(Pid,cover)), %% Undo - ?msym({ok,["a: Cannot parse app file"++_|_]},reltool_server:undo_config(Pid)), + ?m(ok, reltool_server:undo_config(Pid)), ?m({ok,Tools}, reltool_server:get_app(Pid,tools)), ?m({ok,Cover}, reltool_server:get_mod(Pid,cover)), ?msym({ok,["a: Cannot parse app file"++_|_]},reltool_server:get_status(Pid)), %% Undo again, to check that it toggles - ?msym({ok,["a: Cannot parse app file"++_|_]}, reltool_server:undo_config(Pid)), + ?m(ok, reltool_server:undo_config(Pid)), ?m({ok,NoTools}, reltool_server:get_app(Pid,tools)), ?m({ok,NoIncludeCover}, reltool_server:get_mod(Pid,cover)), ?msym({ok,["a: Cannot parse app file"++_|_]}, reltool_server:get_status(Pid)), @@ -1391,12 +1392,12 @@ set_sys_and_undo(Config) -> ?msym({ok,["a: Cannot parse app file"++_|_]},reltool_server:get_status(Pid)), %% Undo - ?m({ok,[]}, reltool_server:undo_config(Pid)), + ?m(ok, reltool_server:undo_config(Pid)), ?m({ok,SysRec}, reltool_server:get_sys(Pid)), ?m({ok,[]}, reltool_server:get_status(Pid)), %% Undo again, to check that it toggles - ?msym({ok,["a: Cannot parse app file"++_|_]},reltool_server:undo_config(Pid)), + ?m(ok,reltool_server:undo_config(Pid)), ?m({ok,NewSysRec}, reltool_server:get_sys(Pid)), ?msym({ok,["a: Cannot parse app file"++_|_]},reltool_server:get_status(Pid)), @@ -1448,13 +1449,13 @@ load_config_and_undo(Config) -> reltool_server:get_mod(Pid,cover)), %% Undo - ?m({ok,[]}, reltool_server:undo_config(Pid)), + ?m(ok, reltool_server:undo_config(Pid)), ?m({ok,Tools1}, reltool_server:get_app(Pid,tools)), ?m({ok,Cover1}, reltool_server:get_mod(Pid,cover)), ?m({ok,[]}, reltool_server:get_status(Pid)), %% Undo again, to check that it toggles - ?msym({ok,["a: Cannot parse app file"++_|_]},reltool_server:undo_config(Pid)), + ?m(ok, reltool_server:undo_config(Pid)), ?m({ok,Tools2}, reltool_server:get_app(Pid,tools)), ?m({ok,Cover2}, reltool_server:get_mod(Pid,cover)), ?msym({ok,["a: Cannot parse app file"++_|_]},reltool_server:get_status(Pid)), @@ -1463,6 +1464,43 @@ load_config_and_undo(Config) -> ok. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Test that load_config is properly rolled back if it fails +load_config_fail(_Config) -> + Sys1 = {sys,[{incl_cond, exclude}, + {app,kernel,[{incl_cond,include}]}, + {app,sasl,[{incl_cond,include}]}, + {app,stdlib,[{incl_cond,include}]}, + {app,tools,[{incl_cond,include}]}]}, + {ok, Pid} = ?msym({ok, _}, reltool:start_server([{config, Sys1}])), + ?m({ok, Sys1}, reltool:get_config(Pid)), + ?m({ok,[]}, reltool_server:get_status(Pid)), + + %% Get app and mod + {ok,Tools} = ?msym({ok,_}, reltool_server:get_app(Pid,tools)), + + %% Try to load a config with a faulty rel statement (includes a + %% non-existing application) + Sys2 = {sys,[{incl_cond, exclude}, + {boot_rel, "faulty_rel"}, + {rel, "faulty_rel", "1.0", [kernel, sasl, stdlib, xxx]}, + {app,kernel,[{incl_cond,include}]}, + {app,sasl,[{incl_cond,include}]}, + {app,stdlib,[{incl_cond,include}]}]}, + ?msym({error,"Release faulty_rel uses non existing application xxx"}, + reltool_server:load_config(Pid,Sys2)), + + %% Check that a rollback is done to the old configuration + ?m({ok, Sys1}, reltool:get_config(Pid,false,false)), + + %% and that tools is not changed (i.e. that the new configuration + %% is not applied) + ?m({ok,Tools}, reltool_server:get_app(Pid,tools)), + + ?m(ok, reltool:stop(Pid)), + ok. + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Load config with escript @@ -1673,13 +1711,13 @@ reset_config_and_undo(Config) -> ?msym({ok,["a: Cannot parse app file"++_|_]},reltool_server:get_status(Pid)), %% Undo - ?m({ok,[]}, reltool_server:undo_config(Pid)), + ?m(ok, reltool_server:undo_config(Pid)), ?m({ok,Tools2}, reltool_server:get_app(Pid,tools)), ?m({ok,Cover2}, reltool_server:get_mod(Pid,cover)), ?m({ok,[]}, reltool_server:get_status(Pid)), %% Undo again, to check that it toggles - ?msym({ok,["a: Cannot parse app file"++_|_]},reltool_server:undo_config(Pid)), + ?m(ok, reltool_server:undo_config(Pid)), ?m({ok,Tools1}, reltool_server:get_app(Pid,tools)), ?m({ok,Cover1}, reltool_server:get_mod(Pid,cover)), ?msym({ok,["a: Cannot parse app file"++_|_]},reltool_server:get_status(Pid)), -- cgit v1.2.3 From 537773c0e6969cb89f92aec0244ba29b07ec66ea Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Fri, 24 Feb 2012 15:52:34 +0100 Subject: [reltool] Improve error handling OTP-9794 Stopping configuration (throw/catch) at first error instead of continuing through all steps and then returning the error at the end. Start of reltool_server will no longer succeed if the configuration causes an error. reltool:get_status can only return {error,Reason} in the case where the reltool_server has terminated. In all other cases it will return {ok,Warnings}. Bug fix in this commit: * warnings are no longer duplicated in pop-up or return from reltool_server --- lib/reltool/test/reltool_server_SUITE.erl | 44 +++++++++++++++---------------- 1 file changed, 21 insertions(+), 23 deletions(-) (limited to 'lib/reltool/test') diff --git a/lib/reltool/test/reltool_server_SUITE.erl b/lib/reltool/test/reltool_server_SUITE.erl index 2588c0829f..5526df5f52 100644 --- a/lib/reltool/test/reltool_server_SUITE.erl +++ b/lib/reltool/test/reltool_server_SUITE.erl @@ -883,8 +883,7 @@ create_standalone_app_clash(Config) -> ]}, ?msym({error,"someapp: Application name clash. Escript "++_}, - reltool:get_target_spec([{config,Sys}])), - + reltool:start_server([{config,Sys}])), ok. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -1214,7 +1213,7 @@ set_app_and_undo(Config) -> {app,tools,[{incl_cond,include}]}]}, {ok, Pid} = ?msym({ok, _}, reltool:start_server([{config, Sys}])), ?m({ok, Sys}, reltool:get_config(Pid)), - ?msym({ok,["a: Cannot parse app file"++_|_]},reltool_server:get_status(Pid)), + ?msym({ok,["a: Cannot parse app file"++_]},reltool_server:get_status(Pid)), %% Get app and mod {ok,Tools} = ?msym({ok,_}, reltool_server:get_app(Pid,tools)), @@ -1228,7 +1227,7 @@ set_app_and_undo(Config) -> {ok,ToolsNoCover,["a: Cannot parse app file"++_|_]} = ?msym({ok,_,["a: Cannot parse app file"++_|_]}, reltool_server:set_app(Pid,Tools1)), - ?msym({ok,["a: Cannot parse app file"++_|_]}, reltool_server:get_status(Pid)), + ?msym({ok,["a: Cannot parse app file"++_]}, reltool_server:get_status(Pid)), %% Check that the module is no longer included ?m({ok,ToolsNoCover}, reltool_server:get_app(Pid,tools)), @@ -1239,13 +1238,13 @@ set_app_and_undo(Config) -> ?m(ok, reltool_server:undo_config(Pid)), ?m({ok,Tools}, reltool_server:get_app(Pid,tools)), ?m({ok,Cover}, reltool_server:get_mod(Pid,cover)), - ?msym({ok,["a: Cannot parse app file"++_|_]}, reltool_server:get_status(Pid)), + ?msym({ok,["a: Cannot parse app file"++_]}, reltool_server:get_status(Pid)), %% Undo again, to check that it toggles ?msym(ok, reltool_server:undo_config(Pid)), ?m({ok,ToolsNoCover}, reltool_server:get_app(Pid,tools)), ?m({ok,NoIncludeCover}, reltool_server:get_mod(Pid,cover)), - ?msym({ok,["a: Cannot parse app file"++_|_]}, reltool_server:get_status(Pid)), + ?msym({ok,["a: Cannot parse app file"++_]}, reltool_server:get_status(Pid)), ?m(ok, reltool:stop(Pid)), ok. @@ -1261,7 +1260,7 @@ set_apps_and_undo(Config) -> {app,tools,[{incl_cond,include}]}]}, {ok, Pid} = ?msym({ok, _}, reltool:start_server([{config, Sys}])), ?m({ok, Sys}, reltool:get_config(Pid)), - ?msym({ok,["a: Cannot parse app file"++_|_]},reltool_server:get_status(Pid)), + ?msym({ok,["a: Cannot parse app file"++_]},reltool_server:get_status(Pid)), %% Get app and mod {ok,Tools} = ?msym({ok,_}, reltool_server:get_app(Pid,tools)), @@ -1272,9 +1271,9 @@ set_apps_and_undo(Config) -> %% Exclude one application with set_apps ExclTools = Tools#app{incl_cond=exclude}, - ?msym({ok,["a: Cannot parse app file"++_|_]}, + ?msym({ok,["a: Cannot parse app file"++_]}, reltool_server:set_apps(Pid,[ExclTools])), - ?msym({ok,["a: Cannot parse app file"++_|_]}, reltool_server:get_status(Pid)), + ?msym({ok,["a: Cannot parse app file"++_]}, reltool_server:get_status(Pid)), %% Check that the app and its modules (one of them) are no longer included {ok,NoTools} = ?msym({ok,_}, reltool_server:get_app(Pid,tools)), @@ -1287,13 +1286,13 @@ set_apps_and_undo(Config) -> ?m(ok, reltool_server:undo_config(Pid)), ?m({ok,Tools}, reltool_server:get_app(Pid,tools)), ?m({ok,Cover}, reltool_server:get_mod(Pid,cover)), - ?msym({ok,["a: Cannot parse app file"++_|_]},reltool_server:get_status(Pid)), + ?msym({ok,["a: Cannot parse app file"++_]},reltool_server:get_status(Pid)), %% Undo again, to check that it toggles ?m(ok, reltool_server:undo_config(Pid)), ?m({ok,NoTools}, reltool_server:get_app(Pid,tools)), ?m({ok,NoIncludeCover}, reltool_server:get_mod(Pid,cover)), - ?msym({ok,["a: Cannot parse app file"++_|_]}, reltool_server:get_status(Pid)), + ?msym({ok,["a: Cannot parse app file"++_]}, reltool_server:get_status(Pid)), ?m(ok, reltool:stop(Pid)), ok. @@ -1386,10 +1385,10 @@ set_sys_and_undo(Config) -> NewLib = filename:join(datadir(Config),"faulty_app_file"), NewLibDirs = [NewLib | SysRec#sys.lib_dirs], NewSysRec = SysRec#sys{lib_dirs=NewLibDirs}, - ?msym({ok,["a: Cannot parse app file"++_|_]}, + ?msym({ok,["a: Cannot parse app file"++_]}, reltool_server:set_sys(Pid, NewSysRec)), ?m({ok,NewSysRec}, reltool_server:get_sys(Pid)), - ?msym({ok,["a: Cannot parse app file"++_|_]},reltool_server:get_status(Pid)), + ?msym({ok,["a: Cannot parse app file"++_]},reltool_server:get_status(Pid)), %% Undo ?m(ok, reltool_server:undo_config(Pid)), @@ -1399,7 +1398,7 @@ set_sys_and_undo(Config) -> %% Undo again, to check that it toggles ?m(ok,reltool_server:undo_config(Pid)), ?m({ok,NewSysRec}, reltool_server:get_sys(Pid)), - ?msym({ok,["a: Cannot parse app file"++_|_]},reltool_server:get_status(Pid)), + ?msym({ok,["a: Cannot parse app file"++_]},reltool_server:get_status(Pid)), ?m(ok, reltool:stop(Pid)), ok. @@ -1431,12 +1430,12 @@ load_config_and_undo(Config) -> {app,sasl,[{incl_cond,include}]}, {app,stdlib,[{incl_cond,include}]}, {app,tools,[{incl_cond,derived}]}]}, - ?msym({ok,["a: Cannot parse app file"++_|_]}, + ?msym({ok,["a: Cannot parse app file"++_]}, reltool_server:load_config(Pid,Sys2)), %%% OTP-0702, 15) ?m({ok, Sys2}, reltool:get_config(Pid)), %%% Note that {incl_cond,exclude} is removed compared to Sys1 - %%% config is merged, not overwritten - is this correct??? - ?msym({ok,["a: Cannot parse app file"++_|_]},reltool_server:get_status(Pid)), + ?msym({ok,["a: Cannot parse app file"++_]},reltool_server:get_status(Pid)), %% Check that tools is included (since it is used by sasl) but not %% pre-included (neither included or excluded => undefined) @@ -1458,7 +1457,7 @@ load_config_and_undo(Config) -> ?m(ok, reltool_server:undo_config(Pid)), ?m({ok,Tools2}, reltool_server:get_app(Pid,tools)), ?m({ok,Cover2}, reltool_server:get_mod(Pid,cover)), - ?msym({ok,["a: Cannot parse app file"++_|_]},reltool_server:get_status(Pid)), + ?msym({ok,["a: Cannot parse app file"++_]},reltool_server:get_status(Pid)), ?m(ok, reltool:stop(Pid)), ok. @@ -1487,7 +1486,7 @@ load_config_fail(_Config) -> {app,kernel,[{incl_cond,include}]}, {app,sasl,[{incl_cond,include}]}, {app,stdlib,[{incl_cond,include}]}]}, - ?msym({error,"Release faulty_rel uses non existing application xxx"}, + ?msym({error,"Release \"faulty_rel\" uses non existing application xxx"}, reltool_server:load_config(Pid,Sys2)), %% Check that a rollback is done to the old configuration @@ -1674,7 +1673,7 @@ reset_config_and_undo(Config) -> {app,tools,[{incl_cond,include}]}]}, {ok, Pid} = ?msym({ok, _}, reltool:start_server([{config, Sys1}])), ?m({ok, Sys1}, reltool:get_config(Pid)), - ?msym({ok,["a: Cannot parse app file"++_|_]},reltool_server:get_status(Pid)), + ?msym({ok,["a: Cannot parse app file"++_]},reltool_server:get_status(Pid)), %% Get app and mod {ok,Tools1} = ?msym({ok,_}, reltool_server:get_app(Pid,tools)), @@ -1704,11 +1703,10 @@ reset_config_and_undo(Config) -> reltool_server:get_mod(Pid,cover)), %% Reset - ?msym({ok,["a: Cannot parse app file"++_|_]}, - reltool_server:reset_config(Pid)), + ?msym({ok,["a: Cannot parse app file"++_]},reltool_server:reset_config(Pid)), ?m({ok,Tools1}, reltool_server:get_app(Pid,tools)), ?m({ok,Cover1}, reltool_server:get_mod(Pid,cover)), - ?msym({ok,["a: Cannot parse app file"++_|_]},reltool_server:get_status(Pid)), + ?msym({ok,["a: Cannot parse app file"++_]},reltool_server:get_status(Pid)), %% Undo ?m(ok, reltool_server:undo_config(Pid)), @@ -1720,7 +1718,7 @@ reset_config_and_undo(Config) -> ?m(ok, reltool_server:undo_config(Pid)), ?m({ok,Tools1}, reltool_server:get_app(Pid,tools)), ?m({ok,Cover1}, reltool_server:get_mod(Pid,cover)), - ?msym({ok,["a: Cannot parse app file"++_|_]},reltool_server:get_status(Pid)), + ?msym({ok,["a: Cannot parse app file"++_]},reltool_server:get_status(Pid)), ?m(ok, reltool:stop(Pid)), ok. -- cgit v1.2.3 From 70b56b16177703c4721f9afbb0329b181af1de3e Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Wed, 29 Feb 2012 11:18:08 +0100 Subject: [reltool] Unset ERL_FLAGS when running escript from reltool_server_SUITE OTP-9794 Some escript tests in reltool_server_SUITE failed if ERL_FLAGS was set to enable smp. The reason is that the test expected smp_support to be false, since the argument "-smp disable" is stated in the %%!-line of the escript. However, ERL_FLAGS will override the arguments in the escript so the result could not be truested. --- lib/reltool/test/reltool_server_SUITE.erl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/reltool/test') diff --git a/lib/reltool/test/reltool_server_SUITE.erl b/lib/reltool/test/reltool_server_SUITE.erl index 5526df5f52..c1d568f019 100644 --- a/lib/reltool/test/reltool_server_SUITE.erl +++ b/lib/reltool/test/reltool_server_SUITE.erl @@ -2150,7 +2150,9 @@ run(Dir, Opts, Script, Args) -> do_run(Dir, Cmd) -> io:format("Run: ~p\n", [Cmd]), - Env = [{"PATH",Dir++":"++os:getenv("PATH")}], + Env = [{"PATH",Dir++":"++os:getenv("PATH")}, + {"ERL_FLAGS",""}, % Make sure no flags are set that can override + {"ERL_ZFLAGS",""}], % any of the flags set in the escript. Port = open_port({spawn,Cmd}, [exit_status,eof,in,{env,Env}]), Res = get_data(Port, []), receive -- cgit v1.2.3 From a3a7c3590f549c609749cff16da7d00af2c114d3 Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Wed, 29 Feb 2012 15:27:34 +0100 Subject: [reltool] Cleanup test code OTP-9794 Remove some unused code from reltool test. --- lib/reltool/test/reltool_server_SUITE.erl | 20 +----------------- lib/reltool/test/reltool_test_lib.erl | 6 +----- lib/reltool/test/reltool_test_lib.hrl | 34 +------------------------------ 3 files changed, 3 insertions(+), 57 deletions(-) (limited to 'lib/reltool/test') diff --git a/lib/reltool/test/reltool_server_SUITE.erl b/lib/reltool/test/reltool_server_SUITE.erl index c1d568f019..4b0511afaf 100644 --- a/lib/reltool/test/reltool_server_SUITE.erl +++ b/lib/reltool/test/reltool_server_SUITE.erl @@ -104,8 +104,6 @@ end_per_group(_GroupName, Config) -> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Start a server process and check that it does not crash -start_server(TestInfo) when is_atom(TestInfo) -> - reltool_test_lib:tc_info(TestInfo); start_server(_Config) -> {ok, Pid} = ?msym({ok, _}, reltool:start_server([])), Libs = lists:sort(erl_libs()), @@ -121,8 +119,6 @@ start_server(_Config) -> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Start a server process and check that it does not crash -set_config(TestInfo) when is_atom(TestInfo) -> - reltool_test_lib:tc_info(TestInfo); set_config(_Config) -> Libs = lists:sort(erl_libs()), Default = @@ -229,8 +225,6 @@ get_config(_Config) -> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% OTP-9135, test that app_file option can be set to all | keep | strip -otp_9135(TestInfo) when is_atom(TestInfo) -> - reltool_test_lib:tc_info(TestInfo); otp_9135(_Config) -> Libs = lists:sort(erl_libs()), StrippedDefaultSys = @@ -260,8 +254,6 @@ otp_9135(_Config) -> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Generate releases -create_release(TestInfo) when is_atom(TestInfo) -> - reltool_test_lib:tc_info(TestInfo); create_release(_Config) -> %% Configure the server RelName = "Just testing...", @@ -402,8 +394,6 @@ create_release_sort(Config) -> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Generate boot scripts -create_script(TestInfo) when is_atom(TestInfo) -> - reltool_test_lib:tc_info(TestInfo); create_script(_Config) -> %% Configure the server RelName = "Just testing", @@ -647,8 +637,6 @@ systools_make_script(Name,Path) -> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Generate target system -create_target(TestInfo) when is_atom(TestInfo) -> - reltool_test_lib:tc_info(TestInfo); create_target(_Config) -> %% Configure the server RelName1 = "Just testing", @@ -681,8 +669,6 @@ create_target(_Config) -> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Generate embedded target system -create_embedded(TestInfo) when is_atom(TestInfo) -> - reltool_test_lib:tc_info(TestInfo); create_embedded(_Config) -> %% Configure the server RelName1 = "Just testing", @@ -714,8 +700,6 @@ create_embedded(_Config) -> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Generate standalone system -create_standalone(TestInfo) when is_atom(TestInfo) -> - reltool_test_lib:tc_info(TestInfo); create_standalone(_Config) -> %% Configure the server ExDir = code:lib_dir(reltool, examples), @@ -948,10 +932,8 @@ create_multiple_standalone(Config) -> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Generate old type of target system -create_old_target(TestInfo) when is_atom(TestInfo) -> - reltool_test_lib:tc_info(TestInfo); +create_old_target(_Config) -> {skip, "Old style of target"}; create_old_target(_Config) -> - ?skip("Old style of target", []), %% Configure the server RelName1 = "Just testing", diff --git a/lib/reltool/test/reltool_test_lib.erl b/lib/reltool/test/reltool_test_lib.erl index b8bcbcd009..61f783190c 100644 --- a/lib/reltool/test/reltool_test_lib.erl +++ b/lib/reltool/test/reltool_test_lib.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2009-2010. All Rights Reserved. +%% Copyright Ericsson AB 2009-2012. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -138,10 +138,6 @@ end_per_testcase(_Func, Config) when is_list(Config) -> reset_kill_timer(Config), Config. -%% Backwards compatible with test_server -tc_info(suite) -> []; -tc_info(doc) -> "". - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Use ?log(Format, Args) as wrapper diff --git a/lib/reltool/test/reltool_test_lib.hrl b/lib/reltool/test/reltool_test_lib.hrl index b592ebb2f0..0dfc08b81c 100644 --- a/lib/reltool/test/reltool_test_lib.hrl +++ b/lib/reltool/test/reltool_test_lib.hrl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2009-2010. All Rights Reserved. +%% Copyright Ericsson AB 2009-2012. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -18,20 +18,10 @@ -include_lib("wx/include/wx.hrl"). --define(flat_format(Format,Args), lists:flatten(io_lib:format(Format,Args))). -define(log(Format,Args), reltool_test_lib:log(Format,Args,?FILE,?LINE)). --define(warning(Format,Args), ?log("\n " ++ Format,Args)). -define(error(Format,Args), reltool_test_lib:error(Format,Args,?FILE,?LINE)). -define(verbose(Format,Args), reltool_test_lib:verbose(Format,Args,?FILE,?LINE)). --define(fatal(Format,Args), - ?error(Format, Args), - exit({test_case_fatal, Format, Args, ?FILE, ?LINE})). - --define(skip(Format,Args), - ?warning(Format, Args), - exit({skipped, ?flat_format(Format, Args)})). - -define(ignore(Expr), fun() -> AcTuAlReS = (catch (Expr)), @@ -68,25 +58,3 @@ AcTuAlReS end end()). - --define(m_receive(ExpectedMsg), - ?m(ExpectedMsg,reltool_test_lib:pick_msg())). - --define(m_multi_receive(ExpectedMsgs), - fun() -> - TmPeXpCtEdMsGs = lists:sort(ExpectedMsgs), - AcTuAlReS = - lists:sort(lists:map(fun(_) -> - reltool_test_lib:pick_msg() - end, TmPeXpCtEdMsGs)), - case AcTuAlReS of - TmPeXpCtEdMsGs -> - ?verbose("ok: ~p\n",[AcTuAlReS]), - AcTuAlReS; - _ -> - reltool_test_lib:error("Not matching actual result was:\n ~p \nExpected ~p\n", - [AcTuAlReS, ExpectedMsgs], - ?FILE, ?LINE), - AcTuAlReS - end - end()). -- cgit v1.2.3 From 2be5415d4a5d024c223d340381ef74e3697fc7ea Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Wed, 29 Feb 2012 16:30:13 +0100 Subject: [reltool] Display warnings continously in GUI OTP-9967 All active warnings are now displayed in a specific warning list at the bottom of the sys windows. Warnings do no longer cause popup dialogs during configuration. The reason for this is to avoid the same warning to pop up many times. This would happen since each configuration change now causes a fresh reading of the file system - and thus each warning would be detected each time the configuration was changed. reltool_manual_gui_SUITE is updated to test the new functionality. --- lib/reltool/test/reltool_manual_gui_SUITE.erl | 48 ++++++++++++++++++--------- 1 file changed, 33 insertions(+), 15 deletions(-) (limited to 'lib/reltool/test') diff --git a/lib/reltool/test/reltool_manual_gui_SUITE.erl b/lib/reltool/test/reltool_manual_gui_SUITE.erl index c6b1d56988..1ebee9fae1 100644 --- a/lib/reltool/test/reltool_manual_gui_SUITE.erl +++ b/lib/reltool/test/reltool_manual_gui_SUITE.erl @@ -67,37 +67,49 @@ config(Config) -> SimpleConfigFile = create_simple_config(PrivDir), WarningConfigFile = create_warning_config(PrivDir,DataDir), - break("there are no modules in the 'Included' and 'Excluded' columns", + break("there are no modules in the 'Included' and 'Excluded' columns, " + "and now warnings are displayed", {"load configuration ~p",[SimpleConfigFile]}), break("kernel, stdlib and sasl are included and all other are excluded", "undo"), break("we are back to default - no included and no excluded applications", "undo again"), break("kernel, stdlib and sasl are included and all other are excluded", - {"load configuration ~p, but click 'cancel' in the warning dialog", + {"load configuration ~p", [WarningConfigFile]}), - break("no change is done", - "load same configuration again and this time click 'ok' in the dialog"), - break("application a is added in the 'Included' column", + break("a warning is displayed in the warning list", + "undo"), + break("no warning is displayed in the warning list", + "load same configuration again"), + break("application a is added in the 'Included' column and " + "one warning is displayed", "reset configuration"), - break("we are back to default - no included and no excluded applications", + break("we are back to default - no included and no excluded applications, " + "and no warnings", "undo"), - break("a warning dialog is displayed, with only an ok button", - "click ok"), - break("a, kernel, stdlib and sasl are included and all other are excluded", + break("a, kernel, stdlib and sasl are included and all other are excluded. " + "One warning should now exist through the rest of this test case", + "double click the warning"), + break("a popup window occurs displaying the warning text", + "close it with the 'Close' button"), + break("it disappears", + "open it again"), + break("the warning text can be marked, copied and pasted", + "close the popup with the close box on the top frame"), + break("it disappears", "select application a from 'Included' column and click red cross to " "exclude it"), break("application a is moved to 'Excluded' column", "select application tools from 'Excluded' column and click green V to " "include it"), break("application tools is moved to 'Included' column", - "select application runtime-tools from 'Excluded' column and click " + "select application runtime_tools from 'Excluded' column and click " "green V to include it"), - break("application runtime-tools is moved to 'Included' column", + break("application runtime_tools is moved to 'Included' column", "undo"), ExplicitConfig = filename:join(PrivDir,"explicit.config"), - break("application runtime-tools is moved back to 'Excluded' column", + break("application runtime_tools is moved back to 'Excluded' column", {"save configuration as 'explicit' to ~p",[ExplicitConfig]}), ExpectedExplicitConfig = {sys,[{lib_dirs,[filename:join(DataDir,"faulty_app_file")]}, @@ -113,7 +125,7 @@ config(Config) -> "Now go to the 'Libraries' tab and change the root directory to " "some invalid directory."), break("an error dialog occurs saying that there is no lib dir", - {"add library directory ~p, and click 'ok' in warning dialog", + {"add library directory ~p", [filename:join(DataDir,"dependencies")]}), break("applications x, y and z are added to the 'Excluded' column in " "'Applications' tab", @@ -121,7 +133,7 @@ config(Config) -> "to 'derived'"), break("a is excluded, kernel, stdlib, sasl and tools are included and " "x, y and z are available in the 'Applications' tab", - "undo, and click ok in the warning dialog"), + "undo"), break("all non included application are moved to the 'Excluded' column " "and that 'Application inclusion policy' under 'System settings' " "tab is set back to 'exclude'", @@ -218,7 +230,13 @@ break(Check,Do) -> break(CheckStr,DoStr). break(Str) -> - test_server:break(Str). + Count = + case get(count) of + undefined -> 1; + C -> C + end, + put(count,Count+1), + test_server:break("Step " ++ integer_to_list(Count) ++ ":\n" ++ Str). check_config(Expected,File) -> {ok,[Config]} = file:consult(File), -- cgit v1.2.3 From dac94945228322ffb9f8dd8495789c0cd64442a3 Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Mon, 12 Mar 2012 17:34:15 +0100 Subject: [reltool] Just warn if same module occurs twice in .app file OTP-9792 Earlier this would cause an error with reason "Module xxx potentially included by two different applications: yyy and yyy." This is now changed so it will only be a warning saying that the module is duplicated in the .app file. --- lib/reltool/test/reltool_server_SUITE.erl | 40 +++++++++++++++++++--- .../dupl_mod/a-1.0/ebin/a.app | 7 ++++ 2 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 lib/reltool/test/reltool_server_SUITE_data/dupl_mod/a-1.0/ebin/a.app (limited to 'lib/reltool/test') diff --git a/lib/reltool/test/reltool_server_SUITE.erl b/lib/reltool/test/reltool_server_SUITE.erl index 4b0511afaf..57b04251d4 100644 --- a/lib/reltool/test/reltool_server_SUITE.erl +++ b/lib/reltool/test/reltool_server_SUITE.erl @@ -69,8 +69,9 @@ all() -> create_old_target, eval_target_spec, otp_9135, - otp_9229_exclude_app, - otp_9229_exclude_mod, + otp_9229_dupl_mod_exclude_app, + otp_9229_dupl_mod_exclude_mod, + dupl_mod_in_app_file, get_apps, get_mod, get_sys, @@ -1002,7 +1003,7 @@ eval_target_spec(_Config) -> %% exists in two applications. %% Include on app, exclude the other -otp_9229_exclude_app(Config) -> +otp_9229_dupl_mod_exclude_app(Config) -> DataDir = ?config(data_dir,Config), LibDir = filename:join(DataDir,"otp_9229"), @@ -1049,7 +1050,7 @@ otp_9229_exclude_app(Config) -> ok. %% Include both apps, but exclude common module from one app -otp_9229_exclude_mod(Config) -> +otp_9229_dupl_mod_exclude_mod(Config) -> DataDir = ?config(data_dir,Config), LibDir = filename:join(DataDir,"otp_9229"), @@ -1102,6 +1103,37 @@ otp_9229_exclude_mod(Config) -> ok. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Test that if a module is duplicated in a .app file, then a warning +%% is produced, but target can still be created. +dupl_mod_in_app_file(Config) -> + DataDir = ?config(data_dir,Config), + LibDir = filename:join(DataDir,"dupl_mod"), + + %% Configure the server + Sys = + {sys, + [ + {lib_dirs, [LibDir]}, + {incl_cond,exclude}, + {app,a,[{incl_cond,include}]}, + {app,kernel,[{incl_cond,include}]}, + {app,stdlib,[{incl_cond,include}]}, + {app,sasl,[{incl_cond,include}]} + ]}, + + %% Generate target file + TargetDir = filename:join([?WORK_DIR, "target_dupl_mod_in_app_file"]), + ?m(ok, reltool_utils:recursive_delete(TargetDir)), + ?m(ok, file:make_dir(TargetDir)), + ?log("SPEC: ~p\n", [reltool:get_target_spec([{config, Sys}])]), + ?m({ok,["Module a duplicated in app file for application a."]}, + reltool:get_status([{config, Sys}])), + + %%! test that only one module installed (in spec) + + ok. + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Test the interface used by the GUI: %% get_app diff --git a/lib/reltool/test/reltool_server_SUITE_data/dupl_mod/a-1.0/ebin/a.app b/lib/reltool/test/reltool_server_SUITE_data/dupl_mod/a-1.0/ebin/a.app new file mode 100644 index 0000000000..fada34847a --- /dev/null +++ b/lib/reltool/test/reltool_server_SUITE_data/dupl_mod/a-1.0/ebin/a.app @@ -0,0 +1,7 @@ +% -*-erlang-*- +{application, a, + [{description, "Application with duplicated module name in .app file"}, + {vsn, "1.0"}, + {modules, [a,a]}, + {registered, []}, + {applications, [kernel, stdlib]}]}. -- cgit v1.2.3 From ba3e53ef71cc127d4df9c53f9f401645814e3fb7 Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Thu, 15 Mar 2012 11:52:41 +0100 Subject: [reltool] Fix problems with sorting of applications OTP-9792 The following problems have been solved: * reltool_target:do_merge_apps - in recursive calls to this function, the accumulator was reverted each time causing the order of applications listed after kernel and stdlib in the rel specification in the configuration to sometimes be messed up. * There are several ways to specify wich applications to include in an application: 1) in the .app file for the including applications 2a) in the .rel file, when listing applications 2b) in the rel specification in the reltool configuration 2a (systools) and 2b (reltool) should have the same effect and overwrite 1. According to the documentation of systools (sasl), the default value in 2a is an empty list. This should mean that if included applications are not mentioned in the .rel file, then any included application listed in the .app file will be disregarded. This is NOT the way systools actually works. The implementation sets the default for the .rel file to the same list as in the .app file. Reltool earlier implemented 2b as described in the systools documentation. However, after some discussion we decided to change this so that reltool handles 2b in the same way as systools handles 2a since this seems more intuitive. The sasl documentation will be altered accordingly (internal ref OTP-9980). * If the rel specification in the reltool configuration explicitly specified included applications to be an empty list, and the .app file had a non-empty list, then the empty list from the rel specification was discarded. This has been corrected so the rel specification now, if set, always overwrites the value of included_applications in the .app file. * reltool would earlier add load instructions in the script/boot files for ALL modules in the ebin directory of an application even if mod_cond was set to app (include only modules listed in the .app file). This has been corrected - now only modules with #mod.is_included==true are loaded. * reltool would earlier add start instructions in the script/boot file for included applications. This has been corrected - included applications shall only be loaded since the including application is responsible for starting them. --- lib/reltool/test/reltool_server_SUITE.erl | 95 ++++++++++++---------- .../sort_apps/z-1.0/ebin/z.app | 4 +- 2 files changed, 52 insertions(+), 47 deletions(-) (limited to 'lib/reltool/test') diff --git a/lib/reltool/test/reltool_server_SUITE.erl b/lib/reltool/test/reltool_server_SUITE.erl index 57b04251d4..122880fca9 100644 --- a/lib/reltool/test/reltool_server_SUITE.erl +++ b/lib/reltool/test/reltool_server_SUITE.erl @@ -283,7 +283,7 @@ create_release(_Config) -> %% started before the including application. %% Circular dependencies shall also be detected and cause error. -create_release_sort(_Config) -> {skip, "Multiple known problems - see OTP-9792"}; +create_release_sort(_Config) -> {skip, "Two bugs related to sorting"}; create_release_sort(Config) -> DataDir = ?config(data_dir,Config), %% Configure the server @@ -296,7 +296,11 @@ create_release_sort(Config) -> RelName7 = "Circular", RelName8 = "Include-both-missing-app", RelName9 = "Include-overwrite", + RelName10= "Uses-order-as-rel", RelVsn = "1.0", + %% Application z (.app file): + %% includes [tools, mnesia] + %% uses [kernel, stdlib, sasl, inets] Sys = {sys, [ @@ -304,19 +308,21 @@ create_release_sort(Config) -> {boot_rel, RelName1}, {rel, RelName1, RelVsn, [stdlib, kernel, mnesia, sasl]}, {rel, RelName2, RelVsn, [stdlib, kernel, sasl, mnesia]}, - {rel, RelName3, RelVsn, [stdlib, kernel, {z,[tools]}, tools]}, - {rel, RelName4, RelVsn, [stdlib, kernel, z, tools]}, + {rel, RelName3, RelVsn, [stdlib, kernel, {z,[tools]}, tools, mnesia]}, + {rel, RelName4, RelVsn, [stdlib, kernel, z, mnesia, tools]}, {rel, RelName5, RelVsn, [stdlib, kernel, {sasl,[tools]}]}, - {rel, RelName6, RelVsn, [stdlib, kernel, z]}, %z includes tools in .app + {rel, RelName6, RelVsn, [stdlib, kernel, z]}, {rel, RelName7, RelVsn, [stdlib, kernel, mnesia, y, sasl, x]}, {rel, RelName8, RelVsn, [stdlib, kernel, {z,[tools]}]}, {rel, RelName9, RelVsn, [stdlib, kernel, {z,[]}]}, + {rel, RelName10, RelVsn, [stdlib, kernel, {z,[]}, inets, sasl]}, {incl_cond,exclude}, {mod_cond,app}, {app,kernel,[{incl_cond,include}]}, {app,stdlib,[{incl_cond,include}]}, {app,mnesia,[{incl_cond,include}]}, {app,sasl,[{incl_cond,include}]}, + {app,inets,[{incl_cond,include}]}, {app,x,[{incl_cond,include}]}, {app,y,[{incl_cond,include}]}, {app,z,[{incl_cond,include}]}, @@ -324,7 +330,6 @@ create_release_sort(Config) -> ]}, %% Generate release - %% BUG: reltool reverses the list of applications after kernel and stdlib ?msym({ok, {release, {RelName1, RelVsn}, {erts, _}, [{kernel, _}, @@ -333,7 +338,6 @@ create_release_sort(Config) -> {sasl, _}]}}, reltool:get_rel([{config, Sys}], RelName1)), - %% BUG: reltool reverses the list of applications after kernel and stdlib ?msym({ok, {release, {RelName2, RelVsn}, {erts, _}, [{kernel, _}, @@ -346,19 +350,21 @@ create_release_sort(Config) -> {erts, _}, [{kernel, _}, {stdlib, _}, + {sasl, _}, + {inets, _}, {tools, _}, - {z, _, [tools]}]}}, + {z, _, [tools]}, + {mnesia, _}]}}, reltool:get_rel([{config, Sys}], RelName3)), - %% BUG: reltool does not honor included applications in .app files - %% unless they are also mentioned in the 'rel' specification in - %% the reltool config. - %% => order of tools and z does not become correct in rel (tools - %% should be first since it is included in z) + %%! BUG: same as OTP-4121, but for reltool???? Or revert tools and mnesia ?msym({ok, {release, {RelName4, RelVsn}, {erts, _}, [{kernel, _}, {stdlib, _}, + {sasl, _}, + {inets, _}, + {mnesia, _}, {tools, _}, {z, _}]}}, reltool:get_rel([{config, Sys}], RelName4)), @@ -368,11 +374,7 @@ create_release_sort(Config) -> "in the app file: [tools]"}, reltool:get_rel([{config, Sys}], RelName5)), - %% BUG: reltool does not honor included applications in .app files - %% unless they are also mentioned in the 'rel' specification in - %% the reltool config. - %% => does not detect that tools (included in z) is missing - ?m({error, "Undefined applications: [tools]"}, + ?m({error, "Undefined applications: [tools,mnesia]"}, reltool:get_rel([{config, Sys}], RelName6)), ?m({error,"Circular dependencies: [x,y]"}, @@ -381,15 +383,25 @@ create_release_sort(Config) -> ?m({error,"Undefined applications: [tools]"}, reltool:get_rel([{config, Sys}], RelName8)), - %% BUG: Reltool looses the empty include list for z, which should - %% overwrite included_applications statement from the .app file. ?msym({ok,{release,{RelName9,RelVsn}, {erts,_}, [{kernel,_}, {stdlib,_}, + {sasl, _}, + {inets, _}, {z,_,[]}]}}, reltool:get_rel([{config, Sys}], RelName9)), + %%! BUG: same as OTP-9984, but for reltool???? Or revert inets and sasl? + ?msym({ok,{release,{RelName10,RelVsn}, + {erts,_}, + [{kernel,_}, + {stdlib,_}, + {inets, _}, + {sasl, _}, + {z,_,[]}]}}, + reltool:get_rel([{config, Sys}], RelName10)), + ok. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -442,7 +454,7 @@ create_script(_Config) -> %% Test creation of .script with different sorting of applications and %% included applications. %% Test that result is equal to what systools produces -create_script_sort(_Config) -> {skip, "Multiple known problems - see OTP-9792"}; +create_script_sort(_Config) -> {skip, "OTP-9984 - stdlib sort problem"}; create_script_sort(Config) -> DataDir = ?config(data_dir,Config), %% Configure the server @@ -464,10 +476,10 @@ create_script_sort(Config) -> {boot_rel, RelName1}, {rel, RelName1, RelVsn, [stdlib, kernel, mnesia, sasl]}, {rel, RelName2, RelVsn, [stdlib, kernel, sasl, mnesia]}, - {rel, RelName3, RelVsn, [stdlib, kernel, {z,[tools]}, tools]}, - {rel, RelName4, RelVsn, [stdlib, kernel, z, tools]}, + {rel, RelName3, RelVsn, [stdlib, kernel, {z,[tools]}, tools, mnesia]}, + {rel, RelName4, RelVsn, [stdlib, kernel, z, mnesia, tools]}, {rel, RelName5, RelVsn, [stdlib, kernel, {sasl,[tools]}]}, - {rel, RelName6, RelVsn, [stdlib, kernel, z]}, %z includes tools in .app + {rel, RelName6, RelVsn, [stdlib, kernel, z]}, {rel, RelName7, RelVsn, [stdlib, kernel, mnesia, y, sasl, x]}, {rel, RelName8, RelVsn, [stdlib, kernel, {z,[tools]}]}, {rel, RelName9, RelVsn, [stdlib, kernel, {z,[]}]}, @@ -477,6 +489,7 @@ create_script_sort(Config) -> {app,stdlib,[{incl_cond,include}]}, {app,mnesia,[{incl_cond,include}]}, {app,sasl,[{incl_cond,include}]}, + {app,inets,[{incl_cond,include}]}, {app,x,[{incl_cond,include}]}, {app,y,[{incl_cond,include}]}, {app,z,[{incl_cond,include}]}, @@ -487,11 +500,13 @@ create_script_sort(Config) -> %% Generate release files application:load(sasl), + application:load(inets), application:load(mnesia), application:load(tools), {ok,KernelVsn} = application:get_key(kernel,vsn), {ok,StdlibVsn} = application:get_key(stdlib,vsn), {ok,SaslVsn} = application:get_key(sasl,vsn), + {ok,InetsVsn} = application:get_key(inets,vsn), {ok,MnesiaVsn} = application:get_key(mnesia,vsn), {ok,ToolsVsn} = application:get_key(tools,vsn), ErtsVsn = erlang:system_info(version), @@ -514,14 +529,20 @@ create_script_sort(Config) -> [{kernel,KernelVsn}, {stdlib,StdlibVsn}, {z,"1.0",[tools]}, - {tools,ToolsVsn}]}, + {tools,ToolsVsn}, + {mnesia,MnesiaVsn}, + {sasl,SaslVsn}, + {inets,InetsVsn}]}, FullName3 = filename:join(?WORK_DIR,RelName3), ?m(ok, file:write_file(FullName3 ++ ".rel", io_lib:format("~p.\n", [Rel3]))), Rel4 = {release, {RelName4,RelVsn}, {erts,ErtsVsn}, [{kernel,KernelVsn}, {stdlib,StdlibVsn}, {z,"1.0"}, - {tools,ToolsVsn}]}, + {tools,ToolsVsn}, + {mnesia,MnesiaVsn}, + {sasl,SaslVsn}, + {inets,InetsVsn}]}, FullName4 = filename:join(?WORK_DIR,RelName4), ?m(ok, file:write_file(FullName4 ++ ".rel", io_lib:format("~p.\n", [Rel4]))), Rel5 = {release, {RelName5,RelVsn}, {erts,ErtsVsn}, @@ -555,42 +576,30 @@ create_script_sort(Config) -> Rel9 = {release, {RelName9,RelVsn}, {erts,ErtsVsn}, [{kernel,KernelVsn}, {stdlib,StdlibVsn}, - {z,"1.0",[]}]}, + {z,"1.0",[]}, + {sasl,SaslVsn}, + {inets,InetsVsn}]}, FullName9 = filename:join(?WORK_DIR,RelName9), ?m(ok, file:write_file(FullName9 ++ ".rel", io_lib:format("~p.\n", [Rel9]))), %% Generate script files with systools and reltool and compare ZPath = filename:join([LibDir,"*",ebin]), - %% BUG: reltool reverses the list of applications after kernel and stdlib - %% => mnesia and sasl are reverted ?msym({ok,_,_}, systools_make_script(FullName1,ZPath)), {ok, [SystoolsScript1]} = ?msym({ok,[_]}, file:consult(FullName1++".script")), {ok, Script1} = ?msym({ok, _}, reltool:get_script(Pid, RelName1)), ?m(equal, diff_script(SystoolsScript1, Script1)), - %% BUG: reltool reverses the list of applications after kernel and stdlib - %% => mnesia and sasl are reverted ?msym({ok,_,_}, systools_make_script(FullName2,ZPath)), {ok, [SystoolsScript2]} = ?msym({ok,[_]}, file:consult(FullName2++".script")), {ok, Script2} = ?msym({ok, _}, reltool:get_script(Pid, RelName2)), ?m(equal, diff_script(SystoolsScript2, Script2)), - %% BUG1: reltool loads all modules in the ebin dir of an application, - %% even if mod_cond is set to 'app'. - %% BUG2: reltool shall not start included applications!! ?msym({ok,_,_}, systools_make_script(FullName3,ZPath)), {ok, [SystoolsScript3]} = ?msym({ok,[_]}, file:consult(FullName3++".script")), {ok, Script3} = ?msym({ok, _}, reltool:get_script(Pid, RelName3)), ?m(equal, diff_script(SystoolsScript3, Script3)), - %% BUG1: reltool loads all modules in the ebin dir of an application, - %% even if mod_cond is set to 'app'. - %% BUG2: reltool does not honor included applications in .app files - %% unless they are also mentioned in the 'rel' specification in - %% the reltool config. - %% => faulty order of load instructions for tools and z. tools - %% should be first since it is included in z. ?msym({ok,_,_}, systools_make_script(FullName4,ZPath)), {ok, [SystoolsScript4]} = ?msym({ok,[_]}, file:consult(FullName4++".script")), {ok, Script4} = ?msym({ok, _}, reltool:get_script(Pid, RelName4)), @@ -603,13 +612,9 @@ create_script_sort(Config) -> "in the app file: [tools]"}, reltool:get_script(Pid, RelName5)), - %% BUG: reltool does not honor included applications in .app files - %% unless they are also mentioned in the 'rel' specification in - %% the reltool config. - %% => does not detect that tools (included in z) is missing ?msym({error,_,{undefined_applications,_}}, systools_make_script(FullName6,ZPath)), - ?m({error, "Undefined applications: [tools]"}, + ?m({error, "Undefined applications: [tools,mnesia]"}, reltool:get_script(Pid, RelName6)), ?msym({error,_,{circular_dependencies,_}}, diff --git a/lib/reltool/test/reltool_server_SUITE_data/sort_apps/z-1.0/ebin/z.app b/lib/reltool/test/reltool_server_SUITE_data/sort_apps/z-1.0/ebin/z.app index 1622975bf6..8608bc554b 100644 --- a/lib/reltool/test/reltool_server_SUITE_data/sort_apps/z-1.0/ebin/z.app +++ b/lib/reltool/test/reltool_server_SUITE_data/sort_apps/z-1.0/ebin/z.app @@ -4,5 +4,5 @@ {vsn, "1.0"}, {modules,[]}, {registered, []}, - {applications, [kernel, stdlib]}, - {included_applications, [tools]}]}. + {applications, [kernel, stdlib, sasl, inets]}, + {included_applications, [tools, mnesia]}]}. -- cgit v1.2.3 From 20ef6a7d381b37d7c620f303a981a3a8b4e227a8 Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Mon, 19 Mar 2012 09:06:38 +0100 Subject: [reltool] Remove skip statement for test that failed due to stdlib error The stdlib error has been corrected in a previous commit so the failing test (reltool_server_SUITE:create_script_sort) can be un-skipped. --- lib/reltool/test/reltool_server_SUITE.erl | 1 - 1 file changed, 1 deletion(-) (limited to 'lib/reltool/test') diff --git a/lib/reltool/test/reltool_server_SUITE.erl b/lib/reltool/test/reltool_server_SUITE.erl index 122880fca9..4e24a2fb55 100644 --- a/lib/reltool/test/reltool_server_SUITE.erl +++ b/lib/reltool/test/reltool_server_SUITE.erl @@ -454,7 +454,6 @@ create_script(_Config) -> %% Test creation of .script with different sorting of applications and %% included applications. %% Test that result is equal to what systools produces -create_script_sort(_Config) -> {skip, "OTP-9984 - stdlib sort problem"}; create_script_sort(Config) -> DataDir = ?config(data_dir,Config), %% Configure the server -- cgit v1.2.3 From 844afaf366ad7a4f668a60e896d0ae3b9e5d850b Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Mon, 19 Mar 2012 15:54:30 +0100 Subject: [reltool] Fix GUI problems on Windows The new warning list did not work on Windows. It could not display tooltips for each warning and the popup window would always disappear behind the main system window. Also, column width did not occur well initially in list controls. --- lib/reltool/test/reltool_manual_gui_SUITE.erl | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'lib/reltool/test') diff --git a/lib/reltool/test/reltool_manual_gui_SUITE.erl b/lib/reltool/test/reltool_manual_gui_SUITE.erl index 1ebee9fae1..0dcc5cbf15 100644 --- a/lib/reltool/test/reltool_manual_gui_SUITE.erl +++ b/lib/reltool/test/reltool_manual_gui_SUITE.erl @@ -97,14 +97,14 @@ config(Config) -> break("the warning text can be marked, copied and pasted", "close the popup with the close box on the top frame"), break("it disappears", - "select application a from 'Included' column and click red cross to " - "exclude it"), + "select application a from 'Included' column and click 'cross'-button " + "with to exclude it"), break("application a is moved to 'Excluded' column", - "select application tools from 'Excluded' column and click green V to " - "include it"), + "select application tools from 'Excluded' column and click " + "'tick'-button to include it"), break("application tools is moved to 'Included' column", "select application runtime_tools from 'Excluded' column and click " - "green V to include it"), + "'tick'-button to include it"), break("application runtime_tools is moved to 'Included' column", "undo"), @@ -171,7 +171,8 @@ config(Config) -> {ok,ServerPid} = reltool:get_server(SysPid), unlink(SysPid), break("the system window is still alive", - "terminate reltool by hitting 'Ctrl-q' when system window is active"), + "terminate reltool by hitting 'Ctrl-q' (linux) or clicking the " + "close box on the top fram when system window is active"), false = erlang:is_process_alive(SysPid), false = erlang:is_process_alive(ServerPid), -- cgit v1.2.3