diff options
Diffstat (limited to 't/lib/MemcachedTest.pm')
-rw-r--r-- | t/lib/MemcachedTest.pm | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/t/lib/MemcachedTest.pm b/t/lib/MemcachedTest.pm index 88f37a2..d78ad42 100644 --- a/t/lib/MemcachedTest.pm +++ b/t/lib/MemcachedTest.pm @@ -11,6 +11,7 @@ use vars qw(@EXPORT); use Cwd; my $builddir = getcwd; +my @unixsockets = (); @EXPORT = qw(new_memcached sleep mem_get_is mem_gets mem_gets_is mem_stats supports_sasl free_port); @@ -150,7 +151,7 @@ sub supports_sasl { sub new_memcached { my ($args, $passed_port) = @_; - my $port = $passed_port || free_port(); + my $port = $passed_port; my $host = '127.0.0.1'; if ($ENV{T_MEMD_USE_DAEMON}) { @@ -164,13 +165,22 @@ sub new_memcached { croak("Failed to connect to specified memcached server.") unless $conn; } - my $udpport = free_port("udp"); - $args .= " -p $port"; - if (supports_udp()) { - $args .= " -U $udpport"; - } - if ($< == 0) { - $args .= " -u root"; + my $udpport; + if ($args =~ /-l (\S+)/) { + $port = free_port(); + $udpport = free_port("udp"); + $args .= " -p $port"; + if (supports_udp()) { + $args .= " -U $udpport"; + } + if ($< == 0) { + $args .= " -u root"; + } + } elsif ($args !~ /-s (\S+)/) { + my $num = @unixsockets; + my $file = "/tmp/memcachetest.$$.$num"; + $args .= " -s $file"; + push(@unixsockets, $file); } my $childpid = fork(); @@ -215,6 +225,12 @@ sub new_memcached { croak("Failed to startup/connect to memcached server."); } +END { + for (@unixsockets) { + unlink $_; + } +} + ############################################################################ package Memcached::Handle; sub new { |