diff options
author | Micael Karlberg <[email protected]> | 2019-07-22 14:49:00 +0200 |
---|---|---|
committer | Micael Karlberg <[email protected]> | 2019-07-22 14:49:00 +0200 |
commit | 9295544658711636e21fd11e41d3d23169248c7d (patch) | |
tree | 85a3dff2d23ef5de177c388abc837abae5f9c8a1 | |
parent | cfb78031058227e44c666f7ae1afdb035cf6b1cb (diff) | |
download | otp-9295544658711636e21fd11e41d3d23169248c7d.tar.gz otp-9295544658711636e21fd11e41d3d23169248c7d.tar.bz2 otp-9295544658711636e21fd11e41d3d23169248c7d.zip |
[megaco|test] Failure to start config should result in skip
It seems that the megaco_config process did not start (for
an unknown reason) and that resulted in a failed test case.
But starting the config process was not what the test case
was for, so it should have resulted in a skip.
Also, since we did not check the result of the config start,
we don't know why it failed.
So, move the start and stop of the megaco_config process
to the [init|end]_per_testcase function(s). If we fail to
start, then we skip (with a useful reason).
-rw-r--r-- | lib/megaco/test/megaco_config_test.erl | 28 | ||||
-rw-r--r-- | lib/megaco/test/megaco_test_lib.hrl | 4 |
2 files changed, 20 insertions, 12 deletions
diff --git a/lib/megaco/test/megaco_config_test.erl b/lib/megaco/test/megaco_config_test.erl index 07c3579dc2..d46806927a 100644 --- a/lib/megaco/test/megaco_config_test.erl +++ b/lib/megaco/test/megaco_config_test.erl @@ -54,6 +54,19 @@ t(Case) -> megaco_test_lib:t({?MODULE, Case}). min(M) -> timer:minutes(M). %% Test server callbacks +init_per_testcase(Case, Config) when (Case =:= otp_7216) orelse + (Case =:= otp_8167) orelse + (Case =:= otp_8183) -> + i("try starting megaco_config"), + case megaco_config:start_link() of + {ok, _} -> + C = lists:keydelete(tc_timeout, 1, Config), + do_init_per_testcase(Case, [{tc_timeout, min(3)}|C]); + {error, Reason} -> + i("Failed starting megaco_config: " + "~n ~p", [Reason]), + {skip, ?F("Failed starting config: ~p", [Reason])} + end; init_per_testcase(Case, Config) -> C = lists:keydelete(tc_timeout, 1, Config), do_init_per_testcase(Case, [{tc_timeout, min(3)}|C]). @@ -62,6 +75,12 @@ do_init_per_testcase(Case, Config) -> process_flag(trap_exit, true), megaco_test_lib:init_per_testcase(Case, Config). +end_per_testcase(Case, Config) when (Case =:= otp_7216) orelse + (Case =:= otp_8167) orelse + (Case =:= otp_8183) -> + (catch megaco_config:stop()), + process_flag(trap_exit, false), + megaco_test_lib:end_per_testcase(Case, Config); end_per_testcase(Case, Config) -> process_flag(trap_exit, false), megaco_test_lib:end_per_testcase(Case, Config). @@ -769,9 +788,6 @@ otp_7216(Config) when is_list(Config) -> put(tc, otp_7216), p("start"), - p("start the megaco config process"), - megaco_config:start_link(), - LocalMid1 = {deviceName, "local-mid-1"}, %% LocalMid2 = {deviceName, "local-mid-2"}, RemoteMid1 = {deviceName, "remote-mid-1"}, @@ -892,9 +908,6 @@ otp_8167(Config) when is_list(Config) -> put(tc, otp8167), p("start"), - p("start the megaco config process"), - megaco_config:start_link(), - LocalMid1 = {deviceName, "local-mid-1"}, LocalMid2 = {deviceName, "local-mid-2"}, RemoteMid1 = {deviceName, "remote-mid-1"}, @@ -1014,9 +1027,6 @@ otp_8183(Config) when is_list(Config) -> put(tc, otp8183), p("start"), - p("start the megaco config process"), - megaco_config:start_link(), - LocalMid1 = {deviceName, "local-mid-1"}, LocalMid2 = {deviceName, "local-mid-2"}, RemoteMid1 = {deviceName, "remote-mid-1"}, diff --git a/lib/megaco/test/megaco_test_lib.hrl b/lib/megaco/test/megaco_test_lib.hrl index b759c9bc75..35dcda42b6 100644 --- a/lib/megaco/test/megaco_test_lib.hrl +++ b/lib/megaco/test/megaco_test_lib.hrl @@ -32,8 +32,6 @@ -define(ERROR(Reason), megaco_test_lib:error(Reason, ?MODULE, ?LINE)). --define(F(FMT, ARGS), lists:flatten(io_lib:format(FMT, ARGS))). - -define(OS_BASED_SKIP(Skippable), megaco_test_lib:os_based_skip(Skippable)). @@ -87,4 +85,4 @@ -define(SECONDS(T), megaco_test_lib:seconds(T)). -define(FTS(), megaco:format_timestamp(erlang:timestamp())). -define(FTS(TS), megaco:format_timestamp(TS)). - +-define(F(F,A), lists:flatten(io_lib:format(F, A))). |