aboutsummaryrefslogtreecommitdiffstats
path: root/lib/diameter/test/diameter_util.erl
diff options
context:
space:
mode:
authorAnders Svensson <[email protected]>2011-10-09 20:36:31 +0200
committerAnders Svensson <[email protected]>2011-10-10 11:27:07 +0200
commit52f3b4e508cf1f43c88bd20b0e1e6cc75ec4f020 (patch)
tree57b1353d4f2c531b4ba6cb59029f378eab3acf1f /lib/diameter/test/diameter_util.erl
parent698360f3a8c7bb8298d70ccc054cd2124a11f10e (diff)
downloadotp-52f3b4e508cf1f43c88bd20b0e1e6cc75ec4f020.tar.gz
otp-52f3b4e508cf1f43c88bd20b0e1e6cc75ec4f020.tar.bz2
otp-52f3b4e508cf1f43c88bd20b0e1e6cc75ec4f020.zip
Use tcp/sctp port resolution from testsuites
Diffstat (limited to 'lib/diameter/test/diameter_util.erl')
-rw-r--r--lib/diameter/test/diameter_util.erl31
1 files changed, 29 insertions, 2 deletions
diff --git a/lib/diameter/test/diameter_util.erl b/lib/diameter/test/diameter_util.erl
index f9942c3408..3313e6ab75 100644
--- a/lib/diameter/test/diameter_util.erl
+++ b/lib/diameter/test/diameter_util.erl
@@ -23,12 +23,19 @@
%% Utility functions.
%%
+%% generic
-export([consult/2,
run/1,
fold/3,
foldl/3,
- scramble/1,
- write_priv/3,
+ scramble/1]).
+
+%% diameter-specific
+-export([lport/2,
+ lport/3]).
+
+%% common_test-specific
+-export([write_priv/3,
read_priv/2]).
-define(L, atom_to_list).
@@ -172,6 +179,26 @@ eval(F)
when is_function(F,0) ->
F().
+%% lport/2-3
+
+lport(M, Ref) ->
+ lport(M, Ref, 1).
+
+lport(M, Ref, Tries) ->
+ lp(tmod(M), Ref, Tries).
+
+tmod(sctp) -> diameter_sctp;
+tmod(tcp) -> diameter_tcp.
+
+lp(M, Ref, T) ->
+ L = [N || {listen, N, _} <- M:ports(Ref)],
+ if [] /= L orelse T =< 1 ->
+ L;
+ true ->
+ receive after 50 -> ok end,
+ lp(M, Ref, T-1)
+ end.
+
%% write_priv/3
write_priv(Config, Name, Term) ->