From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-2.9 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00 shortcircuit=no autolearn=unavailable version=3.3.2 X-Original-To: meta@public-inbox.org Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id AE8B720103 for ; Mon, 21 Sep 2015 11:11:15 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 4/6] t/nntpd.t: improve test runnability Date: Mon, 21 Sep 2015 11:11:10 +0000 Message-Id: <20150921111112.18873-5-e@80x24.org> In-Reply-To: <20150921111112.18873-1-e@80x24.org> References: <20150921111112.18873-1-e@80x24.org> List-Id: 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