diff options
author | Siri Hansen <[email protected]> | 2014-01-28 15:58:11 +0100 |
---|---|---|
committer | Siri Hansen <[email protected]> | 2014-01-28 15:58:11 +0100 |
commit | f834be38b9ac7c07ec2c19ff42a23103cd1d8c5c (patch) | |
tree | 14e1f0b3a1e413dcedac3bc934e28ca98ee64416 | |
parent | 3c112fbde20a21db0cafc140aa72346f60315b90 (diff) | |
parent | 0e2415e88f494a03ce4e643c134c8378882fbcb1 (diff) | |
download | otp-f834be38b9ac7c07ec2c19ff42a23103cd1d8c5c.tar.gz otp-f834be38b9ac7c07ec2c19ff42a23103cd1d8c5c.tar.bz2 otp-f834be38b9ac7c07ec2c19ff42a23103cd1d8c5c.zip |
Merge branch 'siri/appup_tests_17/OTP-11534'
* siri/appup_tests_17/OTP-11534:
Update sasl appup test to work for OTP release 17
Update stdlib appup test to work for OTP release 17
Update kernel appup test to work for OTP release 17
-rw-r--r-- | lib/kernel/test/kernel_SUITE.erl | 80 | ||||
-rw-r--r-- | lib/sasl/test/sasl_SUITE.erl | 93 | ||||
-rw-r--r-- | lib/stdlib/test/stdlib_SUITE.erl | 80 |
3 files changed, 135 insertions, 118 deletions
diff --git a/lib/kernel/test/kernel_SUITE.erl b/lib/kernel/test/kernel_SUITE.erl index 0f29d895e5..75f51eb076 100644 --- a/lib/kernel/test/kernel_SUITE.erl +++ b/lib/kernel/test/kernel_SUITE.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1997-2011. All Rights Reserved. +%% Copyright Ericsson AB 1997-2014. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -81,53 +81,59 @@ app_test(Config) when is_list(Config) -> %% Test that appup allows upgrade from/downgrade to a maximum of two %% major releases back. appup_test(_Config) -> + do_appup_tests(create_test_vsns()). + +do_appup_tests({[],[]}) -> + {skip,"no previous releases available"}; +do_appup_tests({OkVsns,NokVsns}) -> application:load(kernel), {_,_,Vsn} = lists:keyfind(kernel,1,application:loaded_applications()), AppupFile = filename:join([code:lib_dir(kernel),ebin,"kernel.appup"]), {ok,[{Vsn,UpFrom,DownTo}=AppupScript]} = file:consult(AppupFile), ct:log("~p~n",[AppupScript]), - {OkVsns,NokVsns} = create_test_vsns(Vsn), + ct:log("Testing ok versions: ~p~n",[OkVsns]), check_appup(OkVsns,UpFrom,{ok,[restart_new_emulator]}), check_appup(OkVsns,DownTo,{ok,[restart_new_emulator]}), + ct:log("Testing not ok versions: ~p~n",[NokVsns]), check_appup(NokVsns,UpFrom,error), check_appup(NokVsns,DownTo,error), ok. -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). +create_test_vsns() -> + This = erlang:system_info(otp_release), + FirstMajor = previous_major(This), + SecondMajor = previous_major(FirstMajor), + ThirdMajor = previous_major(SecondMajor), + Ok = kernel_vsn([FirstMajor,SecondMajor]), + Nok0 = kernel_vsn([ThirdMajor]), + Nok = case Ok of + [Ok1|_] -> + [Ok1 ++ ",1" | Nok0]; % illegal + _ -> + Nok0 + end, + {Ok,Nok}. + +previous_major("17") -> + "r16"; +previous_major("r"++Rel) -> + "r"++previous_major(Rel); +previous_major(Rel) -> + integer_to_list(list_to_integer(Rel)-1). + +kernel_vsn([R|Rs]) -> + case test_server:is_release_available(R) of + true -> + {ok,N} = test_server:start_node(prevrel,peer,[{erl,[{release,R}]}]), + As = rpc:call(N,application,which_applications,[]), + {_,_,KV} = lists:keyfind(kernel,1,As), + test_server:stop_node(N), + [KV|kernel_vsn(Rs)]; + false -> + kernel_vsn(Rs) + end; +kernel_vsn([]) -> + []. check_appup([Vsn|Vsns],Instrs,Expected) -> case systools_relup:appup_search_for_version(Vsn, Instrs) of diff --git a/lib/sasl/test/sasl_SUITE.erl b/lib/sasl/test/sasl_SUITE.erl index e8f6a4a2eb..e799230338 100644 --- a/lib/sasl/test/sasl_SUITE.erl +++ b/lib/sasl/test/sasl_SUITE.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2011-2013. All Rights Reserved. +%% Copyright Ericsson AB 2011-2014. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -34,7 +34,7 @@ log_mf_h_env/1]). all() -> - [app_test, appup_test, log_mf_h_env]. + [log_mf_h_env, app_test, appup_test]. groups() -> []. @@ -61,54 +61,60 @@ app_test(Config) when is_list(Config) -> %% Test that appup allows upgrade from/downgrade to a maximum of two %% major releases back. appup_test(_Config) -> + do_appup_tests(create_test_vsns()). + +do_appup_tests({[],[]}) -> + {skip,"no previous releases available"}; +do_appup_tests({OkVsns,NokVsns}) -> 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]), - {OkVsns,NokVsns} = create_test_vsns(SaslVsn), + {_,_,Vsn} = lists:keyfind(sasl,1,application:loaded_applications()), + AppupFile = filename:join([code:lib_dir(sasl),ebin,"sasl.appup"]), + {ok,[{Vsn,UpFrom,DownTo}=AppupScript]} = file:consult(AppupFile), + ct:log("~p~n",[AppupScript]), + ct:log("Testing ok versions: ~p~n",[OkVsns]), check_appup(OkVsns,UpFrom,{ok,[restart_new_emulator]}), check_appup(OkVsns,DownTo,{ok,[restart_new_emulator]}), + ct:log("Testing not ok versions: ~p~n",[NokVsns]), check_appup(NokVsns,UpFrom,error), check_appup(NokVsns,DownTo,error), ok. -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). +create_test_vsns() -> + This = erlang:system_info(otp_release), + FirstMajor = previous_major(This), + SecondMajor = previous_major(FirstMajor), + ThirdMajor = previous_major(SecondMajor), + Ok = sasl_vsn([FirstMajor,SecondMajor]), + Nok0 = sasl_vsn([ThirdMajor]), + Nok = case Ok of + [Ok1|_] -> + [Ok1 ++ ",1" | Nok0]; % illegal + _ -> + Nok0 + end, + {Ok,Nok}. + +previous_major("17") -> + "r16"; +previous_major("r"++Rel) -> + "r"++previous_major(Rel); +previous_major(Rel) -> + integer_to_list(list_to_integer(Rel)-1). + +sasl_vsn([R|Rs]) -> + case test_server:is_release_available(R) of + true -> + {ok,N} = test_server:start_node(prevrel,peer,[{erl,[{release,R}]}]), + _ = rpc:call(N,application,load,[sasl]), + As = rpc:call(N,application,loaded_applications,[]), + {_,_,V} = lists:keyfind(sasl,1,As), + test_server:stop_node(N), + [V|sasl_vsn(Rs)]; + false -> + sasl_vsn(Rs) + end; +sasl_vsn([]) -> + []. check_appup([Vsn|Vsns],Instrs,Expected) -> case systools_relup:appup_search_for_version(Vsn, Instrs) of @@ -119,7 +125,6 @@ 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) -> diff --git a/lib/stdlib/test/stdlib_SUITE.erl b/lib/stdlib/test/stdlib_SUITE.erl index 8a2cb5ea6b..8fff5e2e05 100644 --- a/lib/stdlib/test/stdlib_SUITE.erl +++ b/lib/stdlib/test/stdlib_SUITE.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1997-2011. All Rights Reserved. +%% Copyright Ericsson AB 1997-2014. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -81,53 +81,59 @@ app_test(Config) when is_list(Config) -> %% Test that appup allows upgrade from/downgrade to a maximum of two %% major releases back. appup_test(_Config) -> + do_appup_tests(create_test_vsns()). + +do_appup_tests({[],[]}) -> + {skip,"no previous releases available"}; +do_appup_tests({OkVsns,NokVsns}) -> application:load(stdlib), {_,_,Vsn} = lists:keyfind(stdlib,1,application:loaded_applications()), AppupFile = filename:join([code:lib_dir(stdlib),ebin,"stdlib.appup"]), {ok,[{Vsn,UpFrom,DownTo}=AppupScript]} = file:consult(AppupFile), ct:log("~p~n",[AppupScript]), - {OkVsns,NokVsns} = create_test_vsns(Vsn), + ct:log("Testing ok versions: ~p~n",[OkVsns]), check_appup(OkVsns,UpFrom,{ok,[restart_new_emulator]}), check_appup(OkVsns,DownTo,{ok,[restart_new_emulator]}), + ct:log("Testing not ok versions: ~p~n",[NokVsns]), check_appup(NokVsns,UpFrom,error), check_appup(NokVsns,DownTo,error), ok. -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). +create_test_vsns() -> + This = erlang:system_info(otp_release), + FirstMajor = previous_major(This), + SecondMajor = previous_major(FirstMajor), + ThirdMajor = previous_major(SecondMajor), + Ok = stdlib_vsn([FirstMajor,SecondMajor]), + Nok0 = stdlib_vsn([ThirdMajor]), + Nok = case Ok of + [Ok1|_] -> + [Ok1 ++ ",1" | Nok0]; % illegal + _ -> + Nok0 + end, + {Ok,Nok}. + +previous_major("17") -> + "r16"; +previous_major("r"++Rel) -> + "r"++previous_major(Rel); +previous_major(Rel) -> + integer_to_list(list_to_integer(Rel)-1). + +stdlib_vsn([R|Rs]) -> + case test_server:is_release_available(R) of + true -> + {ok,N} = test_server:start_node(prevrel,peer,[{erl,[{release,R}]}]), + As = rpc:call(N,application,which_applications,[]), + {_,_,KV} = lists:keyfind(stdlib,1,As), + test_server:stop_node(N), + [KV|stdlib_vsn(Rs)]; + false -> + stdlib_vsn(Rs) + end; +stdlib_vsn([]) -> + []. check_appup([Vsn|Vsns],Instrs,Expected) -> case systools_relup:appup_search_for_version(Vsn, Instrs) of |