summaryrefslogtreecommitdiff
path: root/lib/megaco
diff options
context:
space:
mode:
Diffstat (limited to 'lib/megaco')
-rw-r--r--lib/megaco/test/megaco_mess_SUITE.erl47
-rw-r--r--lib/megaco/test/megaco_test_lib.erl55
-rw-r--r--lib/megaco/test/megaco_test_lib.hrl3
3 files changed, 60 insertions, 45 deletions
diff --git a/lib/megaco/test/megaco_mess_SUITE.erl b/lib/megaco/test/megaco_mess_SUITE.erl
index 36cbb1d6d2..b2f52f65c8 100644
--- a/lib/megaco/test/megaco_mess_SUITE.erl
+++ b/lib/megaco/test/megaco_mess_SUITE.erl
@@ -14158,51 +14158,8 @@ mtime() ->
try_tc(TCName, Pre, Case, Post) ->
try_tc(TCName, "TEST", ?TEST_VERBOSITY, Pre, Case, Post).
-try_tc(TCName, Name, Verbosity, Pre, Case, Post)
- when is_function(Pre, 0) andalso
- is_function(Case, 1) andalso
- is_function(Post, 1) ->
- put(verbosity, Verbosity),
- put(sname, Name),
- put(tc, TCName),
- i("try_tc -> starting: try pre"),
- try Pre() of
- State ->
- i("try_tc -> pre done: try case"),
- try Case(State) of
- Res ->
- i("try_tc -> case done: try post"),
- (catch Post(State)),
- i("try_tc -> done"),
- Res
- catch
- throw:{skip, _} = SKIP:_ ->
- i("try_tc -> case (throw) skip: try post"),
- (catch Post(State)),
- i("try_tc -> case (throw) skip: done"),
- SKIP;
- exit:{skip, _} = SKIP:_ ->
- i("try_tc -> case (exit) skip: try post"),
- (catch Post(State)),
- i("try_tc -> case (exit) skip: done"),
- SKIP;
- C:E:S ->
- i("try_tc -> case failed: try post"),
- (catch Post(State)),
- i("try_tc -> case failed: done"),
- {error, {case_catched, C, E, S}}
- end
- catch
- throw:{skip, _} = SKIP:_ ->
- i("try_tc -> pre (throw) skip"),
- SKIP;
- exit:{skip, _} = SKIP:_ ->
- i("try_tc -> pre (exit) skip"),
- SKIP;
- C:E:S ->
- i("try_tc -> pre failed: done"),
- {error, {pre_catched, C, E, S}}
- end.
+try_tc(TCName, Name, Verbosity, Pre, Case, Post) ->
+ ?TRY_TC(TCName, Name, Verbosity, Pre, Case, Post).
diff --git a/lib/megaco/test/megaco_test_lib.erl b/lib/megaco/test/megaco_test_lib.erl
index 60de4bd279..eede29a69e 100644
--- a/lib/megaco/test/megaco_test_lib.erl
+++ b/lib/megaco/test/megaco_test_lib.erl
@@ -46,6 +46,8 @@
display_alloc_info/0,
display_system_info/1, display_system_info/2, display_system_info/3,
+ try_tc/6,
+
prepare_test_case/5,
proxy_start/1, proxy_start/2,
@@ -581,6 +583,56 @@ reset_kill_timer(Config) ->
end.
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+try_tc(TCName, Name, Verbosity, Pre, Case, Post)
+ when is_function(Pre, 0) andalso
+ is_function(Case, 1) andalso
+ is_function(Post, 1) ->
+ put(verbosity, Verbosity),
+ put(sname, Name),
+ put(tc, TCName),
+ p("try_tc -> starting: try pre"),
+ try Pre() of
+ State ->
+ p("try_tc -> pre done: try case"),
+ try Case(State) of
+ Res ->
+ p("try_tc -> case done: try post"),
+ (catch Post(State)),
+ p("try_tc -> done"),
+ Res
+ catch
+ throw:{skip, _} = SKIP:_ ->
+ p("try_tc -> case (throw) skip: try post"),
+ (catch Post(State)),
+ p("try_tc -> case (throw) skip: done"),
+ SKIP;
+ exit:{skip, _} = SKIP:_ ->
+ p("try_tc -> case (exit) skip: try post"),
+ (catch Post(State)),
+ p("try_tc -> case (exit) skip: done"),
+ SKIP;
+ C:E:S ->
+ p("try_tc -> case failed: try post"),
+ (catch Post(State)),
+ p("try_tc -> case failed: done"),
+ {error, {case_catched, C, E, S}}
+ end
+ catch
+ throw:{skip, _} = SKIP:_ ->
+ p("try_tc -> pre (throw) skip"),
+ SKIP;
+ exit:{skip, _} = SKIP:_ ->
+ p("try_tc -> pre (exit) skip"),
+ SKIP;
+ C:E:S ->
+ p("try_tc -> pre failed: done"),
+ {error, {pre_catched, C, E, S}}
+ end.
+
+
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
prepare_test_case(Actions, N, Config, File, Line) ->
@@ -765,6 +817,9 @@ f(F, A) ->
e(F, A) ->
print("<ERROR> ", F, A).
+p(F) ->
+ p(F, []).
+
p(F, A) ->
print("<INFO> ", F, A).
diff --git a/lib/megaco/test/megaco_test_lib.hrl b/lib/megaco/test/megaco_test_lib.hrl
index 17eed0755f..2ff887178e 100644
--- a/lib/megaco/test/megaco_test_lib.hrl
+++ b/lib/megaco/test/megaco_test_lib.hrl
@@ -80,6 +80,9 @@
-define(MULTI_RECEIVE(Expected),
?VERIFY(lists:sort(Expected), lists:sort(?LIB:flush()))).
+-define(TRY_TC(TCN, N, V, PRE, CASE, POST),
+ ?LIB:try_tc(TCN, N, V, PRE, CASE, POST)).
+
-define(ACQUIRE_NODES(N, Config),
?LIB:prepare_test_case([init, {stop_app, megaco}],
N, Config, ?FILE, ?LINE)).