From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 4/6] t/nntpd.t: improve test runnability
Date: Mon, 21 Sep 2015 11:11:10 +0000 [thread overview]
Message-ID: <20150921111112.18873-5-e@80x24.org> (raw)
In-Reply-To: <20150921111112.18873-1-e@80x24.org>
The created socket FD number may not be 3 in the test,
force it to be so inside the child process.
---
t/nntpd.t | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/t/nntpd.t b/t/nntpd.t
index 527cfc2..d30ed63 100644
--- a/t/nntpd.t
+++ b/t/nntpd.t
@@ -44,7 +44,6 @@ my %opts = (
Listen => 1024,
);
my $sock = IO::Socket::INET->new(%opts);
-plan skip_all => 'sock fd!=3, cannot test nntpd integration' if fileno($sock) != 3;
my $pid;
END { kill 'TERM', $pid if defined $pid };
{
@@ -78,8 +77,10 @@ EOF
is($fl, FD_CLOEXEC, 'cloexec set by default (Perl behavior)');
$pid = fork;
if ($pid == 0) {
+ use POSIX qw(dup2);
# pretend to be systemd
fcntl($sock, F_SETFD, $fl &= ~FD_CLOEXEC);
+ dup2(fileno($sock), 3) or die "dup2 failed: $!\n";
$ENV{LISTEN_PID} = $$;
$ENV{LISTEN_FDS} = 1;
exec $nntpd, "--stdout=$out", "--stderr=$err";
--
EW
next prev parent reply other threads:[~2015-09-21 11:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-21 11:11 [PATCH 0/6] more NNTP server updates Eric Wong
2015-09-21 11:11 ` [PATCH 1/6] msgmap: minor cleanup to move constant declaration Eric Wong
2015-09-21 11:11 ` [PATCH 2/6] nntp: speed up XHDR Xref for rtin Eric Wong
2015-09-21 11:11 ` [PATCH 3/6] nntp: speed up xover slightly Eric Wong
2015-09-21 11:11 ` Eric Wong [this message]
2015-09-21 11:11 ` [PATCH 5/6] remove bytes:: for length checks Eric Wong
2015-09-21 11:11 ` [PATCH 6/6] nntp: proper UTF-8 support (hopefully?) Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150921111112.18873-5-e@80x24.org \
--to=e@80x24.org \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).