X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Fnntpd-tls.t;h=a0522e1f64d9da0ef916d90d899d3b50a177c1cf;hb=0f6b0cac5bf10d036a84dbab732e8991edf56c34;hp=25b7bd1c0913d7bf91a6b41167ca862b9041a6b2;hpb=3c313f9034aac96182e2efdc2f92c40803626f32;p=public-inbox.git diff --git a/t/nntpd-tls.t b/t/nntpd-tls.t index 25b7bd1c..a0522e1f 100644 --- a/t/nntpd-tls.t +++ b/t/nntpd-tls.t @@ -1,15 +1,13 @@ -# Copyright (C) 2019 all contributors +# Copyright (C) 2019-2020 all contributors # License: AGPL-3.0+ use strict; use warnings; use Test::More; use Socket qw(SOCK_STREAM IPPROTO_TCP SOL_SOCKET); +use PublicInbox::TestCommon; # IO::Poll and Net::NNTP are part of the standard library, but # distros may split them off... -foreach my $mod (qw(DBD::SQLite IO::Socket::SSL Net::NNTP IO::Poll)) { - eval "require $mod"; - plan skip_all => "$mod missing for $0" if $@; -} +require_mods(qw(DBD::SQLite IO::Socket::SSL Net::NNTP IO::Poll)); Net::NNTP->can('starttls') or plan skip_all => 'Net::NNTP does not support TLS'; IO::Socket::SSL->VERSION(2.007) or @@ -24,7 +22,6 @@ unless (-r $key && -r $cert) { use_ok 'PublicInbox::TLS'; use_ok 'IO::Socket::SSL'; -use PublicInbox::TestCommon; require PublicInbox::InboxWritable; require PublicInbox::MIME; require PublicInbox::SearchIdx; @@ -66,11 +63,9 @@ EOF { my $im = $ibx->importer(0); - my $mime = PublicInbox::MIME->new(do { - open my $fh, '<', 't/data/0001.patch' or die; - local $/; - <$fh> - }); + my $eml = 't/data/0001.patch'; + my $mime = PublicInbox::InboxWritable::mime_from_path($eml) or + die "open $eml: $!"; ok($im->add($mime), 'message added'); $im->done; if ($version == 1) { @@ -177,7 +172,7 @@ for my $args ( SKIP: { skip 'TCP_DEFER_ACCEPT is Linux-only', 2 if $^O ne 'linux'; - my $var = Socket::TCP_DEFER_ACCEPT(); + my $var = eval { Socket::TCP_DEFER_ACCEPT() } // 9; defined(my $x = getsockopt($nntps, IPPROTO_TCP, $var)) or die; ok(unpack('i', $x) > 0, 'TCP_DEFER_ACCEPT set on NNTPS'); defined($x = getsockopt($starttls, IPPROTO_TCP, $var)) or die;