aboutsummaryrefslogtreecommitdiffstats
path: root/lib/sasl
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sasl')
-rw-r--r--lib/sasl/src/systools_relup.erl22
-rw-r--r--lib/sasl/test/systools_SUITE.erl72
-rw-r--r--lib/sasl/test/systools_SUITE_data/d_regexp_appup/lib/fe-2.1.1/ebin/fe.app8
-rw-r--r--lib/sasl/test/systools_SUITE_data/d_regexp_appup/lib/fe-2.1/ebin/fe.app8
-rw-r--r--lib/sasl/test/systools_SUITE_data/d_regexp_appup/lib/fe-3.1/ebin/fe.app7
-rw-r--r--lib/sasl/test/systools_SUITE_data/d_regexp_appup/lib/fe-3.1/ebin/fe.appup28
6 files changed, 140 insertions, 5 deletions
diff --git a/lib/sasl/src/systools_relup.erl b/lib/sasl/src/systools_relup.erl
index 682f5f5cc9..5cfbc3aadf 100644
--- a/lib/sasl/src/systools_relup.erl
+++ b/lib/sasl/src/systools_relup.erl
@@ -451,13 +451,29 @@ get_script_from_appup(Mode, TopApp, BaseVsn, Ws, RUs) ->
%% XXX Why is this a warning only?
[{bad_vsn, {TopVsn, TopApp#application.vsn}}| Ws]
end,
- case lists:keysearch(BaseVsn, 1, VsnRUs) of
- {value, {_, RU}} ->
+ case search_for_version(BaseVsn, length(BaseVsn), VsnRUs) of
+ {ok, RU} ->
{RUs ++ [RU], Ws1};
- _ ->
+ error ->
throw({error, ?MODULE, {no_relup, FName, TopApp, BaseVsn}})
end.
+search_for_version(BaseVsn,_,[{BaseVsn,RU}|_]) ->
+ {ok,RU};
+search_for_version(BaseVsn,Size,[{Vsn,RU}|VsnRUs]) when is_binary(Vsn) ->
+ case re:run(BaseVsn,Vsn,[unicode,{capture,first,index}]) of
+ {match,[{0,Size}]} ->
+ {ok, RU};
+ _ ->
+ search_for_version(BaseVsn,Size,VsnRUs)
+ end;
+search_for_version(BaseVsn,Size,[_|VsnRUs]) ->
+ search_for_version(BaseVsn,Size,VsnRUs);
+search_for_version(_,_,[]) ->
+ error.
+
+
+
%% Primitives for the "lists of release names" that we upgrade from
%% and to.
diff --git a/lib/sasl/test/systools_SUITE.erl b/lib/sasl/test/systools_SUITE.erl
index a3e97c4543..960ba3cc21 100644
--- a/lib/sasl/test/systools_SUITE.erl
+++ b/lib/sasl/test/systools_SUITE.erl
@@ -50,7 +50,7 @@
src_tests_tar/1, shadow_tar/1, var_tar/1,
exref_tar/1, link_tar/1, otp_9507/1]).
-export([ normal_relup/1, abnormal_relup/1, no_appup_relup/1,
- bad_appup_relup/1, app_start_type_relup/1, otp_3065/1]).
+ bad_appup_relup/1, app_start_type_relup/1, regexp_relup/1, otp_3065/1]).
-export([otp_6226/1]).
-export([normal_hybrid/1,hybrid_no_old_sasl/1,hybrid_no_new_sasl/1]).
-export([init_per_suite/1, end_per_suite/1,
@@ -84,7 +84,8 @@ groups() ->
exref_tar, link_tar, otp_9507]},
{relup, [],
[normal_relup, abnormal_relup, no_appup_relup,
- bad_appup_relup, app_start_type_relup]},
+ bad_appup_relup, app_start_type_relup, regexp_relup
+ ]},
{hybrid, [], [normal_hybrid,hybrid_no_old_sasl,hybrid_no_new_sasl]},
{tickets, [], [otp_6226]}].
@@ -1244,12 +1245,26 @@ check_relup(UpVsnL, DnVsnL) ->
[{App, Vsn} || {load_object_code,{App,Vsn,_}} <- Dn]),
ok.
+check_relup_up_only(UpVsnL) ->
+ {ok, [{_V1, [{_, _, Up}], []}]} = file:consult(relup),
+ [] = foldl(fun(X, Acc) ->
+ true = lists:member(X, Acc),
+ lists:delete(X, Acc) end,
+ UpVsnL,
+ [{App, Vsn} || {load_object_code,{App,Vsn,_}} <- Up]),
+ ok.
+
check_restart_emulator() ->
{ok, [{_V1, [{_, _, Up}], [{_, _, Dn}]}]} = file:consult(relup),
restart_new_emulator = lists:last(Up),
restart_new_emulator = lists:last(Dn),
ok.
+check_restart_emulator_up_only() ->
+ {ok, [{_V1, [{_, _, Up}], []}]} = file:consult(relup),
+ restart_new_emulator = lists:last(Up),
+ ok.
+
check_restart_emulator_diff_erts() ->
{ok, [{_V1, [{_, _, Up}], [{_, _, Dn}]}]} = file:consult(relup),
[restart_new_emulator|_] = Up,
@@ -1405,6 +1420,47 @@ app_start_type_relup(Config) when is_list(Config) ->
ok.
+%% regexp_relup
+regexp_relup(Config) ->
+ ?line {ok, OldDir} = file:get_cwd(),
+
+ ?line {LatestDir,LatestName} = create_script(latest_small,Config),
+ ?line {_LatestDir0,LatestName0} = create_script(latest_small0,Config),
+ ?line {_LatestDir1,LatestName1} = create_script(latest_small2,Config),
+
+ ?line DataDir = filename:absname(?copydir),
+ ?line P = [fname([DataDir, d_regexp_appup, lib, '*', ebin]),
+ fname([DataDir, lib, kernel, ebin]),
+ fname([DataDir, lib, stdlib, ebin])],
+
+ ?line ok = file:set_cwd(LatestDir),
+
+ %% Upgrade fe 2.1 -> 3.1, and downgrade 2.1 -> 3.1
+ %% Shall match the first entry if fe-3.1 appup.
+ ?line {ok, _, _, []} =
+ systools:make_relup(LatestName, [LatestName0], [LatestName0],
+ [{path, P}, silent]),
+ ?line ok = check_relup([{fe, "3.1"}], [{fe, "2.1"}]),
+
+ %% Upgrade fe 2.1.1 -> 3.1
+ %% Shall match the second entry in fe-3.1 appup. Have added a
+ %% restart_new_emulator instruction there to distinguish it from
+ %% the first entry...
+ ?line {ok, _, _, []} =
+ systools:make_relup(LatestName, [LatestName1], [], [{path, P}, silent]),
+ ?line ok = check_relup_up_only([{fe, "3.1"}]),
+ ?line ok = check_restart_emulator_up_only(),
+
+ %% Attempt downgrade fe 3.1 -> 2.1.1
+ %% Shall not match any entry!!
+ ?line {error,systools_relup,{no_relup,_,_,_}} =
+ systools:make_relup(LatestName, [], [LatestName1], [{path, P}, silent]),
+
+ ?line ok = file:set_cwd(OldDir),
+
+ ok.
+
+
%% For upgrade of erts - create a boot file which is a hybrid between
%% old and new release - i.e. starts erts, kernel, stdlib, sasl from
%% new release, all other apps from old release.
@@ -1983,6 +2039,18 @@ create_script(latest_small1,Config) ->
[]),
?line ok = file:close(Fd),
{filename:dirname(Name), filename:basename(Name)};
+create_script(latest_small2,Config) ->
+ ?line PrivDir = ?privdir,
+ ?line Name = fname(PrivDir, 'latest-small2'),
+ ?line {ok,Fd} = file:open(Name++".rel",write),
+ ?line io:format(Fd,
+ "{release, {\"Test release 2\", \"LATEST_SMALL2\"}, \n"
+ " {erts, \"4.4\"}, \n"
+ " [{kernel, \"1.0\"}, {stdlib, \"1.0\"}, \n"
+ " {fe, \"2.1.1\"}]}.\n",
+ []),
+ ?line ok = file:close(Fd),
+ {filename:dirname(Name), filename:basename(Name)};
create_script(latest_nokernel,Config) ->
?line PrivDir = ?privdir,
?line Name = fname(PrivDir, 'latest-nokernel'),
diff --git a/lib/sasl/test/systools_SUITE_data/d_regexp_appup/lib/fe-2.1.1/ebin/fe.app b/lib/sasl/test/systools_SUITE_data/d_regexp_appup/lib/fe-2.1.1/ebin/fe.app
new file mode 100644
index 0000000000..c7ba1dfe91
--- /dev/null
+++ b/lib/sasl/test/systools_SUITE_data/d_regexp_appup/lib/fe-2.1.1/ebin/fe.app
@@ -0,0 +1,8 @@
+{application, fe,
+ [{description, "ERICSSON NR FOR FE"},
+ {vsn, "2.1.1"},
+ {modules, [{fe1, "1.0"}, {fe2, "1.0"}, {fe3, "2.0"}]},
+ {registered, []},
+ {applications, []},
+ {env, []},
+ {start, {fe2, start, []}}]}.
diff --git a/lib/sasl/test/systools_SUITE_data/d_regexp_appup/lib/fe-2.1/ebin/fe.app b/lib/sasl/test/systools_SUITE_data/d_regexp_appup/lib/fe-2.1/ebin/fe.app
new file mode 100644
index 0000000000..47ea248720
--- /dev/null
+++ b/lib/sasl/test/systools_SUITE_data/d_regexp_appup/lib/fe-2.1/ebin/fe.app
@@ -0,0 +1,8 @@
+{application, fe,
+ [{description, "ERICSSON NR FOR FE"},
+ {vsn, "2.1"},
+ {modules, [{fe1, "1.0"}, {fe2, "1.0"}, {fe3, "2.0"}]},
+ {registered, []},
+ {applications, []},
+ {env, []},
+ {start, {fe2, start, []}}]}.
diff --git a/lib/sasl/test/systools_SUITE_data/d_regexp_appup/lib/fe-3.1/ebin/fe.app b/lib/sasl/test/systools_SUITE_data/d_regexp_appup/lib/fe-3.1/ebin/fe.app
new file mode 100644
index 0000000000..0696e2494c
--- /dev/null
+++ b/lib/sasl/test/systools_SUITE_data/d_regexp_appup/lib/fe-3.1/ebin/fe.app
@@ -0,0 +1,7 @@
+{application, fe,
+ [{description, "ERICSSON NR FOR FE"},
+ {vsn, "3.1"},
+ {modules, [{fe1, "1.0"}, {fe2, "1.0"}, {fe3, "2.0"}]},
+ {registered, []},
+ {applications, []},
+ {mod, {fe1, []}}]}.
diff --git a/lib/sasl/test/systools_SUITE_data/d_regexp_appup/lib/fe-3.1/ebin/fe.appup b/lib/sasl/test/systools_SUITE_data/d_regexp_appup/lib/fe-3.1/ebin/fe.appup
new file mode 100644
index 0000000000..53d54735e5
--- /dev/null
+++ b/lib/sasl/test/systools_SUITE_data/d_regexp_appup/lib/fe-3.1/ebin/fe.appup
@@ -0,0 +1,28 @@
+%% -*- erlang -*-
+%% Release upgrade script for fe (front end)
+%%
+
+{
+ "3.1",
+ %% Upgrade from:
+ [
+ {<<"2\\.[0-9]+">>, % matches 2.X in full length and 2.X.Y... only partly
+ [{update, fe1, soft, soft_purge, soft_purge, []},
+ {update, fe2, soft, soft_purge, soft_purge, [fe1]},
+ {update, fe3, {advanced, extra}, soft_purge, soft_purge, [fe1, fe2]}
+ ]},
+ {<<"2(\\.[0-9]+)+">>, % matches 2.X.Y... in full length
+ [{update, fe1, soft, soft_purge, soft_purge, []},
+ {update, fe2, soft, soft_purge, soft_purge, [fe1]},
+ {update, fe3, {advanced, extra}, soft_purge, soft_purge,[fe1, fe2]},
+ restart_new_emulator]}
+ ],
+
+ %% Downgrade to:
+ [
+ {<<"2\\.[0-9]+">>, % matches 2.X in full length and 2.X.Y... only partly
+ [{update, fe2, soft, soft_purge, soft_purge, []},
+ {update, fe3, {advanced, extra}, soft_purge, soft_purge, [fe2]}
+ ]}
+ ]
+}.