X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Fcommon.perl;h=ccc7be46099aaa7708cb65126d3400b98102a87a;hb=dde1b083571ed893cbb1990f01f9e11ed804cba5;hp=e49a596524b17c5d559ed6f871bb80195e45fdef;hpb=b0e5062d43a96372801713ef78a78d6a1bc852bc;p=public-inbox.git
diff --git a/t/common.perl b/t/common.perl
index e49a5965..ccc7be46 100644
--- a/t/common.perl
+++ b/t/common.perl
@@ -1,8 +1,11 @@
-# Copyright (C) 2015-2018 all contributors
+# Copyright (C) 2015-2019 all contributors
# License: AGPL-3.0+
use Fcntl qw(FD_CLOEXEC F_SETFD F_GETFD);
use POSIX qw(dup2);
+use strict;
+use warnings;
+use IO::Socket::INET;
sub stream_to_string {
my ($res) = @_;
@@ -15,6 +18,39 @@ sub stream_to_string {
$str;
}
+sub tcp_server () {
+ IO::Socket::INET->new(
+ LocalAddr => '127.0.0.1',
+ ReuseAddr => 1,
+ Proto => 'tcp',
+ Type => Socket::SOCK_STREAM(),
+ Listen => 1024,
+ Blocking => 0,
+ )
+}
+
+sub unix_server ($) {
+ my $s = IO::Socket::UNIX->new(
+ Listen => 1024,
+ Type => Socket::SOCK_STREAM(),
+ Local => $_[0],
+ );
+ $s->blocking(0);
+ $s;
+}
+
+sub tcp_connect {
+ my ($dest, %opt) = @_;
+ my $s = IO::Socket::INET->new(
+ Proto => 'tcp',
+ Type => Socket::SOCK_STREAM(),
+ PeerAddr => $dest->sockhost . ':' . $dest->sockport,
+ %opt,
+ );
+ $s->autoflush(1);
+ $s;
+}
+
sub spawn_listener {
my ($env, $cmd, $socks) = @_;
my $pid = fork;
@@ -48,7 +84,7 @@ sub require_git ($;$) {
my $cur_int = ($cur_maj << 24) | ($cur_min << 16);
if ($cur_int < $req_int) {
return 0 if $maybe;
- plan skip_all => "git $req+ required, have $git_ver";
+ plan skip_all => "git $req+ required, have $cur_maj.$cur_min";
}
1;
}