diff options
Diffstat (limited to 'lib/sasl/test/systools_SUITE.erl')
-rw-r--r-- | lib/sasl/test/systools_SUITE.erl | 249 |
1 files changed, 241 insertions, 8 deletions
diff --git a/lib/sasl/test/systools_SUITE.erl b/lib/sasl/test/systools_SUITE.erl index 6c913850b9..4b67d406a6 100644 --- a/lib/sasl/test/systools_SUITE.erl +++ b/lib/sasl/test/systools_SUITE.erl @@ -57,7 +57,7 @@ all() -> groups() -> [{script, [], - [script_options, normal_script, unicode_script, no_mod_vsn_script, + [script_options, normal_script, start_script, unicode_script, no_mod_vsn_script, wildcard_script, variable_script, abnormal_script, no_sasl_script, no_dot_erlang_script, src_tests_script, crazy_script, @@ -66,13 +66,14 @@ groups() -> duplicate_modules_script, otp_3065_circular_dependenies, included_and_used_sort_script]}, {tar, [], - [tar_options, normal_tar, no_mod_vsn_tar, system_files_tar, + [tar_options, relname_tar, normal_tar, no_mod_vsn_tar, system_files_tar, system_src_file_tar, invalid_system_files_tar, variable_tar, src_tests_tar, var_tar, exref_tar, link_tar, no_sasl_tar, - otp_9507_path_ebin]}, + otp_9507_path_ebin, additional_files_tar, erts_tar]}, {relup, [], [normal_relup, restart_relup, abnormal_relup, no_sasl_relup, - no_appup_relup, bad_appup_relup, app_start_type_relup, regexp_relup + no_appup_relup, bad_appup_relup, app_start_type_relup, regexp_relup, + replace_app_relup ]}, {hybrid, [], [normal_hybrid,hybrid_no_old_sasl,hybrid_no_new_sasl]}, {options, [], [otp_6226_outdir,app_file_defaults]}]. @@ -235,6 +236,29 @@ normal_script(Config) when is_list(Config) -> code:set_path(PSAVE), % Restore path ok. +%% make_script: Check that script can be named start.script +start_script(Config) when is_list(Config) -> + {ok, OldDir} = file:get_cwd(), + PSAVE = code:get_path(), % Save path + + {LatestDir, LatestName} = create_script(latest,Config), + + DataDir = filename:absname(?copydir), + LibDir = fname([DataDir, d_normal, lib]), + P1 = fname([LibDir, 'db-2.1', ebin]), + P2 = fname([LibDir, 'fe-3.1', ebin]), + + true = code:add_patha(P1), + true = code:add_patha(P2), + + ok = file:set_cwd(LatestDir), + + ok = systools:make_script(filename:basename(LatestName), [{script_name, "start"}]), + {ok, _} = read_script_file("start"), % Check readabillity + + ok = file:set_cwd(OldDir), + code:set_path(PSAVE), % Restore path + ok. %% make_script: Test make_script with unicode .app file unicode_script(Config) when is_list(Config) -> @@ -869,7 +893,7 @@ tar_options(Config) when is_list(Config) -> ok. -%% make_tar: Check normal case +%% make_tar: Check case of start.boot normal_tar(Config) when is_list(Config) -> {ok, OldDir} = file:get_cwd(), @@ -882,7 +906,29 @@ normal_tar(Config) when is_list(Config) -> ok = file:set_cwd(LatestDir), - {ok, _, []} = systools:make_script(LatestName, [silent, {path, P}]), + {ok, _, []} = systools:make_script(LatestName, [silent, {path, P}, {script_name, "start"}]), + ok = systools:make_tar(LatestName, [{path, P}]), + ok = check_tar(fname([lib,'db-2.1',ebin,'db.app']), LatestName), + {ok, _, []} = systools:make_tar(LatestName, [{path, P}, silent]), + ok = check_tar(fname([lib,'fe-3.1',ebin,'fe.app']), LatestName), + + ok = file:set_cwd(OldDir), + ok. + +%% make_tar: Check case of relname.boot +relname_tar(Config) when is_list(Config) -> + {ok, OldDir} = file:get_cwd(), + + {LatestDir, LatestName} = create_script(latest,Config), + + DataDir = filename:absname(?copydir), + LibDir = fname([DataDir, d_normal, lib]), + P = [fname([LibDir, 'db-2.1', ebin]), + fname([LibDir, 'fe-3.1', ebin])], + + ok = file:set_cwd(LatestDir), + + {ok, _, []} = systools:make_script(LatestName, [silent, {path, P}, {script_name, LatestName}]), ok = systools:make_tar(LatestName, [{path, P}]), ok = check_tar(fname([lib,'db-2.1',ebin,'db.app']), LatestName), {ok, _, []} = systools:make_tar(LatestName, [{path, P}, silent]), @@ -945,6 +991,56 @@ system_files_tar(Config) -> ok. +%% make_tar: Check that extra_files are included in the tarball +additional_files_tar(Config) -> + {ok, OldDir} = file:get_cwd(), + + {LatestDir, LatestName} = create_script(latest,Config), + + DataDir = filename:absname(?copydir), + LibDir = fname([DataDir, d_normal, lib]), + P = [fname([LibDir, 'db-2.1', ebin]), + fname([LibDir, 'fe-3.1', ebin])], + + ok = file:set_cwd(LatestDir), + + %% Add dummy relup and sys.config + ok = file:write_file("sys.config","[].\n"), + ok = file:write_file("relup","{\"LATEST\",[],[]}.\n"), + + %% unrelated files that must be included explicitly + RandomFile = "somefile", + ok = file:write_file(RandomFile,"hello\n"), + + TopLevelDir = "some_dir", + TopLevelFile = filename:join(TopLevelDir, "top_level_file"), + + filelib:ensure_dir(TopLevelFile), + ok = file:write_file(TopLevelFile, "hello there\n"), + + {ok, _, []} = systools:make_script(LatestName, [silent, {path, P}]), + ok = systools:make_tar(LatestName, [{path, P}]), + ok = check_tar(fname(["releases","LATEST","sys.config"]), LatestName), + ok = check_tar(fname(["releases","LATEST","relup"]), LatestName), + %% random file should not be in this tarball + {error, _} = check_tar(fname(["releases","LATEST",RandomFile]), LatestName), + + RandomFilePathInTar = filename:join(["releases", "LATEST", RandomFile]), + + {ok, _, []} = systools:make_tar(LatestName, + [{path, P}, silent, + {extra_files, [{RandomFile, RandomFilePathInTar}, + {TopLevelDir, TopLevelDir}]}]), + ok = check_tar(fname(["releases","LATEST","sys.config"]), LatestName), + ok = check_tar(fname(["releases","LATEST","relup"]), LatestName), + + %% random file and dir should be in this tarball + ok = check_tar(fname(["releases","LATEST",RandomFile]), LatestName), + ok = check_tar(fname([TopLevelFile]), LatestName), + + ok = file:set_cwd(OldDir), + + ok. system_files_tar(cleanup,Config) -> Dir = ?privdir, @@ -952,6 +1048,84 @@ system_files_tar(cleanup,Config) -> file:delete(filename:join(Dir,"relup")), ok. +erts_tar(Config) -> + + {ok, OldDir} = file:get_cwd(), + + {LatestDir, LatestName} = create_script(current_all,Config), + + ERTS_VSN = erlang:system_info(version), + ERTS_DIR = fname(["erts-" ++ ERTS_VSN,bin]), + + %% List of all expected executable files in erts/bin + %% This list needs to be kept up to date whenever a file is + %% added or removed. + {Default, Ignored} = + case os:type() of + {unix,_} -> + {["beam.smp","dyn_erl","epmd","erl","erl_call","erl_child_setup", + "erlexec","erl.src","escript","heart","inet_gethost","run_erl", + "start","start_erl.src","start.src","to_erl"], + ["ct_run","dialyzer","erlc","typer","yielding_c_fun"]}; + {win32, _} -> + {["beam.smp.pdb","erl.exe", + "erl.pdb","erl_log.exe","erlexec.dll","erlsrv.exe","heart.exe", + "start_erl.exe","werl.exe","beam.smp.dll", + "epmd.exe","erl.ini","erl_call.exe", + "erlexec.pdb","escript.exe","inet_gethost.exe","werl.pdb"], + ["dialyzer.exe","erlc.exe","yielding_c_fun.exe","ct_run.exe","typer.exe"]} + end, + + ErtsTarContent = + fun(TarName) -> + lists:sort( + [filename:basename(File) + || File <- tar_contents(TarName), + string:equal(filename:dirname(File),ERTS_DIR), + %% Filter out beam.*.smp.* + re:run(filename:basename(File), "beam\\.[^\\.]+\\.smp(\\.dll)?") == nomatch, + %% Filter out any erl_child_setup.* + re:run(filename:basename(File), "erl_child_setup\\..*") == nomatch + ]) + end, + + DataDir = filename:absname(?copydir), + LibDir = fname([DataDir, d_normal, lib]), + P = [fname([LibDir, 'db-2.1', ebin])], + + ok = file:set_cwd(LatestDir), + + {ok, _, []} = systools:make_script(LatestName, [silent, {path, P}, {script_name, "start"}]), + ok = systools:make_tar(LatestName, [{path, P}, {erts, code:root_dir()}]), + ErtsContent = ErtsTarContent(LatestName), + + case lists:sort(Default) of + ErtsContent -> + ok; + Expected -> + ct:pal("Content: ~p",[ErtsContent]), + ct:pal("Expected: ~p",[Expected]), + ct:fail("Incorrect erts bin content") + end, + + ok = systools:make_tar(LatestName, [{path, P}, + {erts, code:root_dir()}, + erts_all]), + ErtsAllContent = ErtsTarContent(LatestName), + + case lists:sort(Default ++ Ignored) of + ErtsAllContent -> + ok; + ExpectedIgn -> + ct:pal("Content: ~p",[ErtsAllContent]), + ct:pal("Expected: ~p",[ExpectedIgn]), + ct:fail("Incorrect erts bin content") + end, + + ok = file:set_cwd(OldDir), + ok. + + %% make_tar: Check that sys.config.src and not sys.config is included system_src_file_tar(Config) -> {ok, OldDir} = file:get_cwd(), @@ -1769,6 +1943,59 @@ regexp_relup(Config) -> ok. +%% make_relup: Replace an application dependency with another +%% The key part here is that the new application should be +%% started before the old one is stopped. +replace_app_relup(Config) when is_list(Config) -> + {ok, OldDir} = file:get_cwd(), + + {LatestDir,LatestName} = create_script(replace_app0,Config), + {_LatestDir1,LatestName1} = create_script(replace_app1,Config), + + DataDir = filename:absname(?copydir), + LibDir = [fname([DataDir, d_replace_app, lib])], + P = [fname([LibDir, '*', ebin]), + fname([DataDir, lib, kernel, ebin]), + fname([DataDir, lib, stdlib, ebin]), + fname([DataDir, lib, sasl, ebin])], + + ok = file:set_cwd(LatestDir), + + ok = systools:make_relup(LatestName, [LatestName1], [LatestName1], + [{path, P}]), + + check_start_stop_order([{start,gh},{stop,fe}], [{start,fe},{stop,gh}]), + + ok = file:set_cwd(OldDir), + ok. + + +check_start_stop_order(UpOrder, DownOrder) -> + + {ok, [{_V0, [{_V1, [], Up}], + [{_V1, [], Down}] + }]} = file:consult(relup), + + GetAppStartStop = fun(Instr) -> + [{Action,App} || {apply,{application,Action,[App|_]}} <- Instr, + lists:member(Action,[start,stop])] + end, + + case GetAppStartStop(Up) of + UpOrder -> ok; + ActualUpOrder -> + ct:fail("Incorrect upgrade order.~nExpected: ~p~nGot:~p", + [UpOrder,ActualUpOrder]) + end, + + case GetAppStartStop(Down) of + DownOrder -> ok; + ActualDownOrder -> + ct:fail("Incorrect down order.~nExpected: ~p~nGot:~p", + [DownOrder,ActualDownOrder]) + end, + + ok. %% make_hybrid_boot: Normal case. %% For upgrade of erts - create a boot file which is a hybrid between @@ -2246,7 +2473,7 @@ delete_tree(Dir) -> end. tar_contents(Name) -> - {ok, Cont} = erl_tar:table(Name ++ ".tar.gz", [compressed]), + {ok, Cont} = erl_tar:table(tar_name(Name), [compressed]), Cont. tar_name(Name) -> @@ -2324,7 +2551,13 @@ create_script({unicode,RelVsn},Config) -> do_create_script(unicode,RelVsn,Config,current,Apps); create_script(duplicate_modules,Config) -> Apps = core_apps(current) ++ [{app1,"1.0"},{app2,"1.0"}], - do_create_script(duplicate_modules,Config,current,Apps). + do_create_script(duplicate_modules,Config,current,Apps); +create_script(replace_app0,Config) -> + Apps = core_apps(current) ++ [{db,"1.1"},{gh,"1.0"}], + do_create_script(repace_app0,Config,current,Apps); +create_script(replace_app1,Config) -> + Apps = core_apps(current) ++ [{db,"1.0"},{fe,"2.1"}], + do_create_script(repace_app1,Config,current,Apps). do_create_script(Id,Config,ErtsVsn,AppVsns) -> |