Browse Source

MT#61368 tests: add new_call_nc()

New helper function to create a new call without closing previously
opened ports.

Also make it possible to override the automatically inserted call ID in
methods.

Change-Id: Ie9133f78bc7bd5ff4e191966ef26187da02e40ff
pull/1897/head
Richard Fuchs 1 year ago
parent
commit
c4ce936487
1 changed files with 14 additions and 9 deletions
  1. +14
    -9
      perl/NGCP/Rtpengine/AutoTest.pm

+ 14
- 9
perl/NGCP/Rtpengine/AutoTest.pm View File

@ -20,7 +20,7 @@ our $launch_cb;
BEGIN { BEGIN {
require Exporter; require Exporter;
@ISA = qw(Exporter); @ISA = qw(Exporter);
our @EXPORT = qw(autotest_start new_call offer answer ft tt cid snd srtp_snd rtp rcv srtp_rcv rcv_no
our @EXPORT = qw(autotest_start new_call new_call_nc offer answer ft tt cid snd srtp_snd rtp rcv srtp_rcv rcv_no
srtp_dec escape rtpm rtpmre reverse_tags new_ft new_tt crlf sdp_split rtpe_req offer_answer srtp_dec escape rtpm rtpmre reverse_tags new_ft new_tt crlf sdp_split rtpe_req offer_answer
autotest_init subscribe_request subscribe_answer publish use_json); autotest_init subscribe_request subscribe_answer publish use_json);
}; };
@ -86,12 +86,9 @@ sub autotest_init {
return 1; return 1;
} }
sub new_call {
sub new_call_nc {
my @ports = @_; my @ports = @_;
for my $s (@sockets) {
$s->close();
}
@sockets = ();
my @ret;
$cid = $tag_iter++ . "-test-callID" . $tag_suffix; $cid = $tag_iter++ . "-test-callID" . $tag_suffix;
$ft = $tag_iter++ . "-test-fromtag" . $tag_suffix; $ft = $tag_iter++ . "-test-fromtag" . $tag_suffix;
$tt = $tag_iter++ . "-test-totag" . $tag_suffix; $tt = $tag_iter++ . "-test-totag" . $tag_suffix;
@ -101,9 +98,17 @@ sub new_call {
my $s = IO::Socket::IP->new(Type => &SOCK_DGRAM, Proto => 'udp', my $s = IO::Socket::IP->new(Type => &SOCK_DGRAM, Proto => 'udp',
LocalHost => $addr, LocalPort => $port) LocalHost => $addr, LocalPort => $port)
or die; or die;
push(@sockets, $s);
push(@ret, $s);
} }
return @sockets;
push(@sockets, @ret);
return @ret;
}
sub new_call {
for my $s (@sockets) {
$s->close();
}
@sockets = ();
new_call_nc(@_);
} }
sub crlf { sub crlf {
my ($s) = @_; my ($s) = @_;
@ -117,7 +122,7 @@ sub sdp_split {
sub rtpe_req { sub rtpe_req {
my ($cmd, $name, $req) = @_; my ($cmd, $name, $req) = @_;
$req->{command} = $cmd; $req->{command} = $cmd;
$req->{'call-id'} = $cid;
$req->{'call-id'} //= $cid;
my $resp; my $resp;
eval { eval {
alarm(3); alarm(3);


Loading…
Cancel
Save