diff options
Diffstat (limited to 'lib/kernel/test')
-rw-r--r-- | lib/kernel/test/erl_prim_loader_SUITE.erl | 24 | ||||
-rw-r--r-- | lib/kernel/test/init_SUITE.erl | 18 |
2 files changed, 35 insertions, 7 deletions
diff --git a/lib/kernel/test/erl_prim_loader_SUITE.erl b/lib/kernel/test/erl_prim_loader_SUITE.erl index 4f3881d27e..b6417210b9 100644 --- a/lib/kernel/test/erl_prim_loader_SUITE.erl +++ b/lib/kernel/test/erl_prim_loader_SUITE.erl @@ -108,13 +108,18 @@ get_file(Config) when is_list(Config) -> error = erl_prim_loader:get_file({dummy}), ok. -get_modules(_Config) -> +get_modules(Config) -> case test_server:is_cover() of - false -> do_get_modules(); + false -> do_get_modules(Config); true -> {skip,"Cover"} end. -do_get_modules() -> +do_get_modules(Config) -> + PrivDir = proplists:get_value(priv_dir, Config), + NotADir = atom_to_list(?FUNCTION_NAME) ++ "_not_a_dir", + ok = file:write_file(filename:join(PrivDir, NotADir), <<>>), + ok = file:set_cwd(PrivDir), + MsGood = lists:sort([lists,gen_server,gb_trees,code_server]), Ms = [certainly_not_existing|MsGood], SuccExp = [begin @@ -129,8 +134,10 @@ do_get_modules() -> Path = code:get_path(), Process = fun(_, F, Code) -> {ok,{F,erlang:md5(Code)}} end, - {ok,{Succ,FailExp}} = erl_prim_loader:get_modules(Ms, Process, Path), - SuccExp = lists:sort(Succ), + {ok,{SuccExp,FailExp}} = get_modules_sorted(Ms, Process, Path), + + %% Test that an 'enotdir' error can be handled. + {ok,{SuccExp,FailExp}} = get_modules_sorted(Ms, Process, [NotADir|Path]), Name = inet_get_modules, {ok, Node, BootPid} = complete_start_node(Name), @@ -147,6 +154,13 @@ do_get_modules() -> ok. +get_modules_sorted(Ms, Process, Path) -> + case erl_prim_loader:get_modules(Ms, Process, Path) of + {ok,{Succ,FailExp}} -> + {ok,{lists:sort(Succ),lists:sort(FailExp)}}; + Other -> + Other + end. normalize_and_backslash(Config) -> %% Test OTP-11170 diff --git a/lib/kernel/test/init_SUITE.erl b/lib/kernel/test/init_SUITE.erl index e7b44a714c..a332e7966b 100644 --- a/lib/kernel/test/init_SUITE.erl +++ b/lib/kernel/test/init_SUITE.erl @@ -27,7 +27,7 @@ -export([get_arguments/1, get_argument/1, boot_var/1, restart/1, many_restarts/0, many_restarts/1, get_plain_arguments/1, - reboot/1, stop/1, get_status/1, script_id/1]). + reboot/1, stop_status/1, stop/1, get_status/1, script_id/1]). -export([boot1/1, boot2/1]). -export([init_per_testcase/2, end_per_testcase/2]). @@ -48,7 +48,7 @@ suite() -> all() -> [get_arguments, get_argument, boot_var, many_restarts, - get_plain_arguments, restart, get_status, script_id, + get_plain_arguments, restart, stop_status, get_status, script_id, {group, boot}]. groups() -> @@ -465,6 +465,20 @@ reboot(Config) when is_list(Config) -> %% ------------------------------------------------ %% %% ------------------------------------------------ +stop_status(Config) when is_list(Config) -> + badarg = catch_stop([65,[66],67]), % flat strings only + badarg = catch_stop([65, 666, 67]), % only bytes in string + badarg = catch_stop(abort), % 'abort' not allowed + badarg = catch_stop(true), % other atoms not allowed + badarg = catch_stop(-1), % no negative statuses + ok. + +catch_stop(Status) -> + try init:stop(Status) catch error:badarg -> badarg end. + +%% ------------------------------------------------ +%% +%% ------------------------------------------------ stop(Config) when is_list(Config) -> Args = args(), {ok, Node} = start_node(init_test, Args), |