Server IP : 127.0.0.2 / Your IP : 18.189.43.15 Web Server : Apache/2.4.18 (Ubuntu) System : User : www-data ( ) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : disk_free_space,disk_total_space,diskfreespace,dl,exec,fpaththru,getmyuid,getmypid,highlight_file,ignore_user_abord,leak,listen,link,opcache_get_configuration,opcache_get_status,passthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,php_uname,phpinfo,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,pclose,popen,proc_open,proc_close,proc_get_status,proc_nice,proc_terminate,shell_exec,source,show_source,system,virtual MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/share/postgresql-common/t/ |
Upload File : |
# Check PgCommon's next_free_port() use strict; use lib '.'; use PgCommon; use lib 't'; use TestLib; use Test::More tests => $PgCommon::rpm ? 1 : 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'); exit if ($PgCommon::rpm); # RedHat doesn't provide nc, stop here # open a localhost ipv4 socket push @pids, open2(\*CHLD_OUT, \*CHLD_IN, qw(nc -4 -q0 -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 -q0 -l 5433)); usleep $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); # open a localhost ipv6 socket push @pids, open2(\*CHLD_OUT, \*CHLD_IN, qw(nc -6 -q0 -l ::1 5434)); usleep $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 -q0 -l 5435)); usleep $delay; is (next_free_port, 5436, 'next_free_port detects wildcard ipv6 socket'); } # clean up kill 15, @pids; # vim: filetype=perl