1: %% 2: %% %CopyrightBegin% 3: %% 4: %% Copyright Ericsson AB 1997-2011. All Rights Reserved. 5: %% 6: %% The contents of this file are subject to the Erlang Public License, 7: %% Version 1.1, (the "License"); you may not use this file except in 8: %% compliance with the License. You should have received a copy of the 9: %% Erlang Public License along with this software. If not, it can be 10: %% retrieved online at http://www.erlang.org/. 11: %% 12: %% Software distributed under the License is distributed on an "AS IS" 13: %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14: %% the License for the specific language governing rights and limitations 15: %% under the License. 16: %% 17: %% %CopyrightEnd% 18: %% 19: %%%---------------------------------------------------------------- 20: %%% Purpose:Stdlib application test suite. 21: %%%----------------------------------------------------------------- 22: -module(stdlib_SUITE). 23: -include_lib("test_server/include/test_server.hrl"). 24: 25: 26: % Default timetrap timeout (set in init_per_testcase). 27: -define(default_timeout, ?t:minutes(1)). 28: -define(application, stdlib). 29: 30: % Test server specific exports 31: -export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1, 32: init_per_group/2,end_per_group/2]). 33: -export([init_per_testcase/2, end_per_testcase/2]). 34: 35: % Test cases must be exported. 36: -export([app_test/1, appup_test/1]). 37: 38: %% 39: %% all/1 40: %% 41: suite() -> [{ct_hooks,[ts_install_cth]}]. 42: 43: all() -> 44: [app_test, appup_test]. 45: 46: groups() -> 47: []. 48: 49: init_per_suite(Config) -> 50: Config. 51: 52: end_per_suite(_Config) -> 53: ok. 54: 55: init_per_group(_GroupName, Config) -> 56: Config. 57: 58: end_per_group(_GroupName, Config) -> 59: Config. 60: 61: 62: init_per_testcase(_Case, Config) -> 63: ?line Dog=test_server:timetrap(?default_timeout), 64: [{watchdog, Dog}|Config]. 65: end_per_testcase(_Case, Config) -> 66: Dog=?config(watchdog, Config), 67: test_server:timetrap_cancel(Dog), 68: ok. 69: 70: % 71: % Test cases starts here. 72: % 73: app_test(suite) -> 74: []; 75: app_test(doc) -> 76: ["Application consistency test."]; 77: app_test(Config) when is_list(Config) -> 78: ?t:app_test(stdlib), 79: ok. 80: 81: %% Test that appup allows upgrade from/downgrade to a maximum of two 82: %% major releases back. 83: appup_test(_Config) -> 84: application:load(stdlib), 85: {_,_,Vsn} = lists:keyfind(stdlib,1,application:loaded_applications()), 86: AppupFile = filename:join([code:lib_dir(stdlib),ebin,"stdlib.appup"]), 87: {ok,[{Vsn,UpFrom,DownTo}=AppupScript]} = file:consult(AppupFile), 88: ct:log("~p~n",[AppupScript]), 89: {OkVsns,NokVsns} = create_test_vsns(Vsn), 90: check_appup(OkVsns,UpFrom,{ok,[restart_new_emulator]}), 91: check_appup(OkVsns,DownTo,{ok,[restart_new_emulator]}), 92: check_appup(NokVsns,UpFrom,error), 93: check_appup(NokVsns,DownTo,error), 94: ok. 95: 96: create_test_vsns(Current) -> 97: [XStr,YStr|Rest] = string:tokens(Current,"."), 98: X = list_to_integer(XStr), 99: Y = list_to_integer(YStr), 100: SecondMajor = vsn(X,Y-2), 101: SecondMinor = SecondMajor ++ ".1.3", 102: FirstMajor = vsn(X,Y-1), 103: FirstMinor = FirstMajor ++ ".57", 104: ThisMajor = vsn(X,Y), 105: This = 106: case Rest of 107: [] -> 108: []; 109: ["1"] -> 110: [ThisMajor]; 111: _ -> 112: ThisMinor = ThisMajor ++ ".1", 113: [ThisMajor,ThisMinor] 114: end, 115: OkVsns = This ++ [FirstMajor, FirstMinor, SecondMajor, SecondMinor], 116: 117: ThirdMajor = vsn(X,Y-3), 118: ThirdMinor = ThirdMajor ++ ".10.12", 119: Illegal = ThisMajor ++ ",1", 120: Newer1Major = vsn(X,Y+1), 121: Newer1Minor = Newer1Major ++ ".1", 122: Newer2Major = ThisMajor ++ "1", 123: NokVsns = [ThirdMajor,ThirdMinor, 124: Illegal, 125: Newer1Major,Newer1Minor, 126: Newer2Major], 127: {OkVsns,NokVsns}. 128: 129: vsn(X,Y) -> 130: integer_to_list(X) ++ "." ++ integer_to_list(Y). 131: 132: check_appup([Vsn|Vsns],Instrs,Expected) -> 133: case systools_relup:appup_search_for_version(Vsn, Instrs) of 134: Expected -> check_appup(Vsns,Instrs,Expected); 135: Other -> ct:fail({unexpected_result_for_vsn,Vsn,Other}) 136: end; 137: check_appup([],_,_) -> 138: ok.