From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.1 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 124CC1F61A; Sat, 10 Dec 2022 20:44:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1670705087; bh=EE/upuROOogYk1F20QFaKV+apXrNgjVPWFaRlwBKP+Y=; h=Date:From:To:Subject:References:In-Reply-To:From; b=GYfxey3AHYBmlN5BL0Qs8MA9YTZPG2G0AIaHZXgLpGJrQ3mFkHPfxv/RKeTRwltqP 1zh3ASL8QSF8vcUNbGDaqpYk5rjL8YitViyIUk9NMtw1L371qYRONsVXUorPFNW9uy GyzowQzVRRJ3ZHbFOq47502jqiQPcHVlzXaw8n0s= Date: Sat, 10 Dec 2022 20:45:26 +0000 From: Eric Wong To: mwrap-perl@80x24.org Subject: Re: [PATCH 1/4] t/httpd-unit: extra test for fencepost errors Message-ID: <20221210204526.M184262@dcvr> References: <20221210100144.19796-1-e@80x24.org> <20221210100144.19796-2-e@80x24.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20221210100144.19796-2-e@80x24.org> List-Id: Eric Wong wrote: > +# check for fencepost errors > +my $len = 108 - length("$tmp"); FreeBSD only uses sun_path[104] whereas Linux uses 108 diff --git a/t/httpd-unit.t b/t/httpd-unit.t index 30d1717..768b2db 100644 --- a/t/httpd-unit.t +++ b/t/httpd-unit.t @@ -96,10 +96,16 @@ isnt(system(@vg, $exe, "socket_dir:$s"), 0, "listen dir on socket fails"); like($end_err->(), qr/stat.*directory/, 'stat failure shown'); # check for fencepost errors -my $len = 108 - length("$tmp"); -$len -= length("\0//$TEST_PID.sock"); -my $max = "$tmp/".('x'x$len); -is(system(@vg, $exe, "socket_dir:$max"), 0, "listen dir on max"); -isnt(system(@vg, $exe, "socket_dir:$max+"), 0, "listen dir too long"); +my $len; +if ($^O eq 'linux') { $len = 108 } +elsif ($^O eq 'freebsd') { $len = 104 } +SKIP: { + skip "length unknown on $^O OS", 2 if !defined($len); + $len -= length("$tmp"); + $len -= length("\0//$TEST_PID.sock"); + my $max = "$tmp/".('x'x$len); + is(system(@vg, $exe, "socket_dir:$max"), 0, "listen dir on max"); + isnt(system(@vg, $exe, "socket_dir:$max+"), 0, "listen dir too long"); +} done_testing;