diff options
author | Siri Hansen <[email protected]> | 2011-10-10 11:30:17 +0200 |
---|---|---|
committer | Siri Hansen <[email protected]> | 2011-11-17 16:47:28 +0100 |
commit | 8a013f1f16fd4730c24839127afdf46f96a45b0b (patch) | |
tree | c5292d1a21ddd714ceb26593e7d8c8895a1b7d39 /lib/sasl/test/systools_SUITE.erl | |
parent | 19a46c5c9f4ed3f0f2bfb149fc1feb0b93d55379 (diff) | |
download | otp-8a013f1f16fd4730c24839127afdf46f96a45b0b.tar.gz otp-8a013f1f16fd4730c24839127afdf46f96a45b0b.tar.bz2 otp-8a013f1f16fd4730c24839127afdf46f96a45b0b.zip |
Allow regexp for version in .appup
In order to avoid duplication of upgrade instructions in .appup files,
we now allow regular expressions to specify the UpFrom and DownTo
versions. To be considered a regular expression, the version
identifier must be specified as a binary, e.g.
<<"2\\.1\\.[0-9]+">> will match versions 2.1.x, where x is any number.
Diffstat (limited to 'lib/sasl/test/systools_SUITE.erl')
-rw-r--r-- | lib/sasl/test/systools_SUITE.erl | 72 |
1 files changed, 70 insertions, 2 deletions
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'), |