aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/test_server/src/test_server.erl20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/test_server/src/test_server.erl b/lib/test_server/src/test_server.erl
index 337bc1d6d7..039ea720a8 100644
--- a/lib/test_server/src/test_server.erl
+++ b/lib/test_server/src/test_server.erl
@@ -1905,8 +1905,28 @@ time_ms({Other,_N}) ->
exit({invalid_time_spec,Other});
time_ms(Ms) when is_integer(Ms) -> Ms;
time_ms(infinity) -> infinity;
+time_ms(Fun) when is_function(Fun) ->
+ try Fun() of
+ Val -> time_ms1(Val)
+ catch
+ _:Error ->
+ exit({timetrap_error,Error})
+ end;
+time_ms({M,F,A}) when is_atom(M), is_atom(F), is_list(A) ->
+ try apply(M, F, A) of
+ Val -> time_ms1(Val)
+ catch
+ _:Error ->
+ exit({timetrap_error,Error})
+ end;
time_ms(Other) -> exit({invalid_time_spec,Other}).
+time_ms1(MFA = {M,F,A}) when is_atom(M), is_atom(F), is_list(A) ->
+ exit({invalid_time_spec,MFA});
+time_ms1(Fun) when is_function(Fun) ->
+ exit({invalid_time_spec,Fun});
+time_ms1(Other) ->
+ time_ms(Other).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% timetrap_cancel(Handle) -> ok