aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2016-03-31 10:11:42 +0200
committerBjörn Gustavsson <[email protected]>2016-03-31 10:11:42 +0200
commite9929ee372001f6ce44697c0e71b93fc6db61f9c (patch)
tree9d954b15f4b76501187d79202748eda4bb84c441
parentdedbb2e6fc619a76407871c6880cd82d85962117 (diff)
parentf08b32f64559c7c7ca7b245b67cd5dfe7e9064c9 (diff)
downloadotp-e9929ee372001f6ce44697c0e71b93fc6db61f9c.tar.gz
otp-e9929ee372001f6ce44697c0e71b93fc6db61f9c.tar.bz2
otp-e9929ee372001f6ce44697c0e71b93fc6db61f9c.zip
Merge branch 'bjorn/optimize-start-up/OTP-13368'
* bjorn/optimize-start-up/OTP-13368: reltool_server_SUITE: Correct diffing of start scripts
-rw-r--r--lib/reltool/test/reltool_server_SUITE.erl47
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]),