diff options
author | Siri Hansen <[email protected]> | 2011-10-14 12:34:08 +0200 |
---|---|---|
committer | Siri Hansen <[email protected]> | 2011-11-17 16:47:28 +0100 |
commit | d221b34133a8da8d62bdc57ebb724f86d7cd2fc0 (patch) | |
tree | e61faa27add14bf9c743e87ab4d5f3d00e428c32 /lib/sasl/test/sasl_SUITE.erl | |
parent | be04ed7beceeb4bcf5db7807e86df87e28c9f4b9 (diff) | |
download | otp-d221b34133a8da8d62bdc57ebb724f86d7cd2fc0.tar.gz otp-d221b34133a8da8d62bdc57ebb724f86d7cd2fc0.tar.bz2 otp-d221b34133a8da8d62bdc57ebb724f86d7cd2fc0.zip |
Add restart_new_emulator instruction to kernel, stdlib and sasl appups
The appup files for kernel, stdlib and sasl did not contain any
UpFromVsn and DownToVsn. This means that it was not possible to create
a relup file with systool:make_relup if any of these applications had
changed.
This commit adds entries in the appup files for a maximum of two major
releases back - all with only one upgrade instruction:
restart_new_emulator. The point is to allow relups to be generated,
but ensure that no soft upgrade is done for these three applications -
i.e. they will always cause a restart of the emulator prior to all
other upgrade instructions from other applications.
Test cases (appup_test) are added to kernel_SUITE, stdlib_SUITE and
sasl_SUITE. These all check that expected versions are matched in the
appups, and illegal versions (older than two major releases, or in any
other way illegal) do not match. The test is written in a general way
where it is assumed that the version of these applications are stepped
according the the rule that major releases step the second number,
maintenance releases step the third number and patches step the fourth
number.
Diffstat (limited to 'lib/sasl/test/sasl_SUITE.erl')
-rw-r--r-- | lib/sasl/test/sasl_SUITE.erl | 99 |
1 files changed, 98 insertions, 1 deletions
diff --git a/lib/sasl/test/sasl_SUITE.erl b/lib/sasl/test/sasl_SUITE.erl index 454095db6a..195324daa0 100644 --- a/lib/sasl/test/sasl_SUITE.erl +++ b/lib/sasl/test/sasl_SUITE.erl @@ -30,10 +30,11 @@ % Test cases must be exported. -export([app_test/1, + appup_test/1, log_mf_h_env/1]). all() -> - [app_test, log_mf_h_env]. + [app_test, appup_test, log_mf_h_env]. groups() -> []. @@ -57,6 +58,102 @@ app_test(Config) when is_list(Config) -> ?line ?t:app_test(sasl, allow), ok. +%% Test that appup allows upgrade from/downgrade to a maximum of two +%% major releases back. +appup_test(_Config) -> + application:load(sasl), + {sasl,_,SaslVsn} = lists:keyfind(sasl,1,application:loaded_applications()), + Ebin = filename:join(code:lib_dir(sasl),ebin), + {ok,[{SaslVsn,UpFrom,DownTo}=Appup]} = + file:consult(filename:join(Ebin,"sasl.appup")), + ct:log("~p~n",[Appup]), + ?line {OkVsns,NokVsns} = create_test_vsns(SaslVsn), + ?line check_appup(OkVsns,UpFrom,{ok,[restart_new_emulator]}), + ?line check_appup(OkVsns,DownTo,{ok,[restart_new_emulator]}), + ?line check_appup(NokVsns,UpFrom,error), + ?line check_appup(NokVsns,DownTo,error), + ok. + + +%% For sasl, the versions up to R14B03 were not according to the rule +%% used for other core applications - i.e. to change the second number +%% at major releases, the third at maintenance releases and the fourth +%% for patches - therefore test versions up to and including R16 are +%% hardcoded. +%% (All versions below are not necessarily existing.) +-define(r12_vsns,["2.1.5"]). +-define(r13_vsns,["2.1.6","2.1.7.1","2.1.9","2.1.9.1.2"]). +-define(r14_vsns,["2.1.9.2","2.1.9.2.20","2.1.9.4","2.1.10"]). +-define(r15_major,"2.2"). +-define(r16_major,"2.3"). +-define(r17_major,"2.4"). +create_test_vsns(?r15_major ++ Rest) -> + R15Vsns = + case string:tokens(Rest,".") of + [] -> []; + ["1"] -> [?r15_major]; + _ -> [?r15_major,?r15_major++".1"] + end, + OkVsns = ?r13_vsns ++ ?r14_vsns ++ R15Vsns, + NokVsns = ?r12_vsns ++ [?r15_major++",1", ?r16_major], + {OkVsns,NokVsns}; +create_test_vsns(?r16_major ++ Rest) -> + R16Vsns = + case string:tokens(Rest,".") of + [] -> []; + ["1"] -> [?r16_major]; + _ -> [?r16_major,?r16_major++".1"] + end, + OkVsns = ?r14_vsns ++ [?r15_major, ?r15_major ++ ".1.4"] ++ R16Vsns, + NokVsns = ?r13_vsns ++ [?r16_major++",1", ?r17_major], + {OkVsns,NokVsns}; +%% Normal erts case - i.e. for versions that comply to the erts standard +create_test_vsns(Current) -> + [XStr,YStr|Rest] = string:tokens(Current,"."), + X = list_to_integer(XStr), + Y = list_to_integer(YStr), + SecondMajor = vsn(X,Y-2), + SecondMinor = SecondMajor ++ ".1.3", + FirstMajor = vsn(X,Y-1), + FirstMinor = FirstMajor ++ ".57", + ThisMajor = vsn(X,Y), + This = + case Rest of + [] -> + []; + ["1"] -> + [ThisMajor]; + _ -> + ThisMinor = ThisMajor ++ ".1", + [ThisMajor,ThisMinor] + end, + OkVsns = This ++ [FirstMajor, FirstMinor, SecondMajor, SecondMinor], + + ThirdMajor = vsn(X,Y-3), + ThirdMinor = ThirdMajor ++ ".10.12", + Illegal = ThisMajor ++ ",1", + Newer1Major = vsn(X,Y+1), + Newer1Minor = Newer1Major ++ ".1", + Newer2Major = ThisMajor ++ "1", + NokVsns = [ThirdMajor,ThirdMinor, + Illegal, + Newer1Major,Newer1Minor, + Newer2Major], + {OkVsns,NokVsns}. + +vsn(X,Y) -> + integer_to_list(X) ++ "." ++ integer_to_list(Y). + +check_appup([Vsn|Vsns],Instrs,Expected) -> + case systools_relup:appup_search_for_version(Vsn, Instrs) of + Expected -> check_appup(Vsns,Instrs,Expected); + Other -> ct:fail({unexpected_result_for_vsn,Vsn,Other}) + end; +check_appup([],_,_) -> + ok. + + + %% OTP-9185 - fail sasl start if some but not all log_mf_h env vars %% are given. log_mf_h_env(Config) -> |