diff options
author | Björn Gustavsson <[email protected]> | 2016-03-24 12:56:40 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2016-03-31 10:11:04 +0200 |
commit | f08b32f64559c7c7ca7b245b67cd5dfe7e9064c9 (patch) | |
tree | 682b9bf815a3f65328e38c9e85afad15dc8b823f /lib/reltool/test | |
parent | ab418313123e98d5de15e2e71ac169afdad8d3f8 (diff) | |
download | otp-f08b32f64559c7c7ca7b245b67cd5dfe7e9064c9.tar.gz otp-f08b32f64559c7c7ca7b245b67cd5dfe7e9064c9.tar.bz2 otp-f08b32f64559c7c7ca7b245b67cd5dfe7e9064c9.zip |
reltool_server_SUITE: Correct diffing of start scripts
In c3c6182, systools was updated to add more modules to be pre-loaded
along with error_handler. That is a pure optimization.
Because of the extra modules, test cases that compared the start
scripts generated by SASL with the ones generated by Reltool
would fail.
We must implement a more elaborate way to diff the scripts.
Diffstat (limited to 'lib/reltool/test')
-rw-r--r-- | lib/reltool/test/reltool_server_SUITE.erl | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/lib/reltool/test/reltool_server_SUITE.erl b/lib/reltool/test/reltool_server_SUITE.erl index 6a487a1ddb..624a3536c0 100644 --- a/lib/reltool/test/reltool_server_SUITE.erl +++ b/lib/reltool/test/reltool_server_SUITE.erl @@ -2530,13 +2530,54 @@ latest(App) -> rm_missing_app(Apps) -> lists:keydelete(?MISSING_APP_NAME,#app.name,Apps). +%% We will compare the script generated by systools with +%% the script generated by Reltool. +%% +%% The systools script may include additional modules in +%% the first primLoad command (as a pure optimization). +%% Therefore, we cannot compare the primLoad commands +%% directly. Instead we will collect all modules from +%% all primLoad commands in each script. The same +%% modules must be loaded by both scripts. In addition, +%% the error_handler module must be included in the +%% first primLoad in each script. + diff_script(Script, Script) -> equal; diff_script({script, Rel, Commands1}, {script, Rel, Commands2}) -> - diff_cmds(Commands1, Commands2); + case diff_cmds(Commands1, Commands2) of + equal -> + Loaded = diff_get_prim_load(Commands1), + case diff_get_prim_load(Commands2) of + Loaded -> + equal; + Other -> + io:format("Only loaded by systools: ~p", + [Loaded--Other]), + io:format("Only loaded by reltool: ~p", + [Other--Loaded]), + ct:fail(different_prim_loads) + end; + Error -> + Error + end; diff_script({script, Rel1, _}, {script, Rel2, _}) -> {error, {Rel1, Rel2}}. +diff_cmds([{primLoad, Ms1}=Cmd1 | Commands1], + [{primLoad, Ms2}=Cmd2 | Commands2]) -> + case lists:member(error_handler, Ms1) xor + lists:member(error_handler, Ms2) of + false -> + %% error_handler either present in both or + %% absent in both. + diff_cmds(Commands1, Commands2); + true -> + %% error_handler only present in one primLoad. + %% Not OK. + {diff, missing_error_handler, + {expected, Cmd1}, {actual, Cmd2}} + end; diff_cmds([Cmd | Commands1], [Cmd | Commands2]) -> diff_cmds(Commands1, Commands2); diff_cmds([Cmd1 | _Commands1], [Cmd2 | _Commands2]) -> @@ -2544,6 +2585,10 @@ diff_cmds([Cmd1 | _Commands1], [Cmd2 | _Commands2]) -> diff_cmds([], []) -> equal. +diff_get_prim_load(Cmds) -> + L = [Ms || {primLoad, Ms} <- Cmds], + lists:sort(lists:flatten(L)). + os_cmd(Cmd) when is_list(Cmd) -> %% Call the plain os:cmd with an echo command appended to print command status %% io:format("os:cmd(~p).\n", [Cmd]), |