about summary refs log tree commit homepage
path: root/xt
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-02-07 23:05:13 -1000
committerEric Wong <e@80x24.org>2021-02-08 22:07:43 +0000
commit860169adcd29341142b7c4a369c09b4ac492bd1e (patch)
treef08dcf8bd04efaeb0904a6cec40665c107482cac /xt
parentfb6aa4da304125a3fb7932e1335be85ff260e031 (diff)
downloadpublic-inbox-860169adcd29341142b7c4a369c09b4ac492bd1e.tar.gz
IPv4 gets plenty of real-world coverage, and apparently there's
Debian buildd hosts which lack IPv4(*).  So ensure everything
can work on IPv6 and not cause problems for odd setups.

(*) https://bugs.debian.org/979432
Diffstat (limited to 'xt')
-rw-r--r--xt/git-http-backend.t4
-rw-r--r--xt/httpd-async-stream.t2
-rw-r--r--xt/imapd-mbsync-oimap.t4
-rw-r--r--xt/imapd-validate.t4
-rw-r--r--xt/mem-imapd-tls.t2
-rw-r--r--xt/nntpd-validate.t3
-rw-r--r--xt/perf-nntpd.t16
-rw-r--r--xt/solver.t3
8 files changed, 16 insertions, 22 deletions
diff --git a/xt/git-http-backend.t b/xt/git-http-backend.t
index dcff72cc..adadebb0 100644
--- a/xt/git-http-backend.t
+++ b/xt/git-http-backend.t
@@ -19,8 +19,7 @@ my ($tmpdir, $for_destroy) = tmpdir();
 my $err = "$tmpdir/stderr.log";
 my $out = "$tmpdir/stdout.log";
 my $sock = tcp_server();
-my $host = $sock->sockhost;
-my $port = $sock->sockport;
+my ($host, $port) = tcp_host_port($sock);
 my $td;
 
 my $get_maxrss = sub {
@@ -37,7 +36,6 @@ my $get_maxrss = sub {
 };
 
 {
-        ok($sock, 'sock created');
         my $cmd = [ '-httpd', '-W0', "--stdout=$out", "--stderr=$err", $psgi ];
         $td = start_script($cmd, undef, { 3 => $sock });
 }
diff --git a/xt/httpd-async-stream.t b/xt/httpd-async-stream.t
index f6715c58..c7039f3e 100644
--- a/xt/httpd-async-stream.t
+++ b/xt/httpd-async-stream.t
@@ -41,7 +41,7 @@ address = test\@example.com
         # not using multiple workers, here, since we want to increase
         # the chance of tripping concurrency bugs within PublicInbox/HTTP*.pm
         my $cmd = [ '-httpd', "--stdout=$out", "--stderr=$err", '-W0' ];
-        my $host_port = $http->sockhost.':'.$http->sockport;
+        my $host_port = tcp_host_port($http);
         push @$cmd, "-lhttp://$host_port";
         my $url = "$host_port/test/$endpoint";
         print STDERR "# CMD ". join(' ', @$cmd). "\n";
diff --git a/xt/imapd-mbsync-oimap.t b/xt/imapd-mbsync-oimap.t
index 5f671fc8..6635e2b4 100644
--- a/xt/imapd-mbsync-oimap.t
+++ b/xt/imapd-mbsync-oimap.t
@@ -35,6 +35,8 @@ my $td = start_script($cmd, $env, { 3 => $sock }) or BAIL_OUT "-imapd: $?";
         my $c = tcp_connect($sock);
         like(readline($c), qr/CAPABILITY /, 'got greeting');
 }
+
+my $host_port = tcp_host_port($sock);
 my ($host, $port) = ($sock->sockhost, $sock->sockport);
 my %pids;
 
@@ -120,7 +122,7 @@ while (scalar keys %pids) {
 my $sec = $ENV{TEST_PERSIST} // 0;
 diag "TEST_PERSIST=$sec";
 if ($sec) {
-        diag "sleeping ${sec}s, imap://$host:$port/$mailbox available";
+        diag "sleeping ${sec}s, imap://$host_port/$mailbox available";
         diag "tmpdir=$tmpdir (Maildirs available)";
         diag "stdout=$out";
         diag "stderr=$err";
diff --git a/xt/imapd-validate.t b/xt/imapd-validate.t
index b6ac3e21..3a229883 100644
--- a/xt/imapd-validate.t
+++ b/xt/imapd-validate.t
@@ -152,11 +152,11 @@ $make_local_server = sub {
         # not using multiple workers, here, since we want to increase
         # the chance of tripping concurrency bugs within PublicInbox/IMAP*.pm
         my $cmd = [ '-imapd', "--stdout=$out", "--stderr=$err", '-W0' ];
-        push @$cmd, '-limap://'.$imap->sockhost.':'.$imap->sockport;
+        push @$cmd, '-limap://'.tcp_host_port($imap);
         if ($test_tls) {
                 my $imaps = tcp_server();
                 $rdr->{4} = $imaps;
-                push @$cmd, '-limaps://'.$imaps->sockhost.':'.$imaps->sockport;
+                push @$cmd, '-limaps://'.tcp_host_port($imaps);
                 push @$cmd, "--cert=$cert", "--key=$key";
                 my $tls_opt = [
                         SSL_hostname => 'server.local',
diff --git a/xt/mem-imapd-tls.t b/xt/mem-imapd-tls.t
index e4b3b8cd..99d8cb0d 100644
--- a/xt/mem-imapd-tls.t
+++ b/xt/mem-imapd-tls.t
@@ -45,7 +45,7 @@ my $imaps = tcp_server();
 EOF
         close $fh or die "close: $!\n";
 }
-my $imaps_addr = $imaps->sockhost . ':' . $imaps->sockport;
+my $imaps_addr = tcp_host_port($imaps);
 my $env = { PI_CONFIG => $pi_config };
 my $arg = $TEST_TLS ? [ "-limaps://$imaps_addr/?cert=$cert,key=$key" ] : [];
 my $cmd = [ '-imapd', '-W0', @$arg, "--stdout=$out", "--stderr=$err" ];
diff --git a/xt/nntpd-validate.t b/xt/nntpd-validate.t
index efe97c02..83f024f9 100644
--- a/xt/nntpd-validate.t
+++ b/xt/nntpd-validate.t
@@ -169,8 +169,7 @@ sub make_local_server {
                 open my $fh, '>', $_ or die "truncate: $!";
         }
         my $sock = tcp_server();
-        ok($sock, 'sock created');
-        $host_port = $sock->sockhost . ':' . $sock->sockport;
+        $host_port = tcp_host_port($sock);
 
         # not using multiple workers, here, since we want to increase
         # the chance of tripping concurrency bugs within PublicInbox/NNTP*.pm
diff --git a/xt/perf-nntpd.t b/xt/perf-nntpd.t
index cd0d4938..85db036c 100644
--- a/xt/perf-nntpd.t
+++ b/xt/perf-nntpd.t
@@ -8,12 +8,15 @@ use PublicInbox::Inbox;
 use Net::NNTP;
 my $inboxdir = $ENV{GIANT_INBOX_DIR} // $ENV{GIANT_PI_DIR};
 plan skip_all => "GIANT_INBOX_DIR not defined for $0" unless defined($inboxdir);
-my ($host_port, $group, %opts, $s, $td, $tmp_obj);
+my ($host_port, $group, $s, $td, $tmp_obj);
 use PublicInbox::TestCommon;
 
 if (($ENV{NNTP_TEST_URL} || '') =~ m!\Anntp://([^/]+)/([^/]+)\z!) {
         ($host_port, $group) = ($1, $2);
         $host_port .= ":119" unless index($host_port, ':') > 0;
+        my $six = substr($host_port, 0, 1) eq '[' ? '6' : '';
+        my $cls = "IO::Socket::INET$six";
+        $cls->new(Proto => 'tcp', Timeout => 1, PeerAddr => $host_port);
 } else {
         $group = 'inbox.test.perf.nntpd';
         my $ibx = { inboxdir => $inboxdir, newsgroup => $group };
@@ -34,18 +37,11 @@ if (($ENV{NNTP_TEST_URL} || '') =~ m!\Anntp://([^/]+)/([^/]+)\z!) {
         }
 
         my $sock = tcp_server();
-        ok($sock, 'sock created');
         my $cmd = [ '-nntpd', '-W0' ];
         $td = start_script($cmd, { PI_CONFIG => $pi_config }, { 3 => $sock });
-        $host_port = $sock->sockhost . ':' . $sock->sockport;
+        $host_port = tcp_host_port($sock);
+        $s = tcp_connect($sock);
 }
-%opts = (
-        PeerAddr => $host_port,
-        Proto => 'tcp',
-        Timeout => 1,
-);
-$s = IO::Socket::INET->new(%opts);
-$s->autoflush(1);
 my $buf = $s->getline;
 like($buf, qr/\A201 .* ready - post via email\r\n/s, 'got greeting');
 
diff --git a/xt/solver.t b/xt/solver.t
index 2f2fcc44..880458fb 100644
--- a/xt/solver.t
+++ b/xt/solver.t
@@ -67,8 +67,7 @@ SKIP: {
         my ($out, $err) = map { "$tmpdir/std$_.log" } qw(out err);
         my $cmd = [ qw(-httpd -W0), "--stdout=$out", "--stderr=$err" ];
         my $td = start_script($cmd, undef, { 3 => $sock });
-        my ($h, $p) = ($sock->sockhost, $sock->sockport);
-
+        my ($h, $p) = tcp_host_port($sock);
         local $ENV{PLACK_TEST_EXTERNALSERVER_URI} = "http://$h:$p";
         while (($ibx_name, $urls) = each %$todo) {
                 Plack::Test::ExternalServer::test_psgi(client => $client);