Skip to content
Snippets Groups Projects
Commit a8fb374b authored by Michael Gray's avatar Michael Gray
Browse files

t/lib/TestShared.pm: find e mpty ports dynamically.

Fixes RT 444665.
parent ab07db28
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,7 @@ our @EXPORT_OK = qw( do_subtests have_display init_zircon_conn mkwidg endpoint_p
use Test::More;
use Try::Tiny;
use Net::EmptyPort qw( check_port empty_port );
use ConnHandler;
......@@ -80,13 +81,24 @@ sub mkwidg {
return $M;
}
{
my $_port = 55667; # FIXME: dangerous to choose fixed ports
sub endpoint_pair {
my $base = 'tcp://127.0.0.1:';
return ( $base . $_port++, $base . $_port++ );
sub endpoint_pair {
my $p1 = empty_port();
unless ($p1) {
fail("Couldn't find empty first port");
return;
}
my $p2 = $p1;
while (++$p2) {
if ($p2 > 65000) {
fail("Couldn't find empty second port");
return;
}
last unless check_port($p2);
}
note("Ports: $p1, $p2");
my $base = 'tcp://127.0.0.1:';
return ( $base . $p1, $base . $p2 );
}
{
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment