From 4c4466e455fd6940700125f8c21b326564915913 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 6 Oct 2023 09:46:04 +0000 Subject: finalize DragonFlyBSD support require_bsd and require_mods(':fcntl_lock') are now supported in TestCommon to make it easier to maintain than a big list of regexps. getsockopt for SO_ACCEPTFILTER seems to always succeed, even if the retrieved struct is all zeroes. --- lib/PublicInbox/TestCommon.pm | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'lib/PublicInbox/TestCommon.pm') diff --git a/lib/PublicInbox/TestCommon.pm b/lib/PublicInbox/TestCommon.pm index 32213fde..323152b4 100644 --- a/lib/PublicInbox/TestCommon.pm +++ b/lib/PublicInbox/TestCommon.pm @@ -23,7 +23,7 @@ BEGIN { @EXPORT = qw(tmpdir tcp_server tcp_connect require_git require_mods run_script start_script key2sub xsys xsys_e xqx eml_load tick have_xapian_compact json_utf8 setup_public_inboxes create_inbox - create_coderepo no_scm_rights + create_coderepo require_bsd quit_waiter_pipe wait_for_eof tcp_host_port test_lei lei lei_ok $lei_out $lei_err $lei_opt test_httpd xbail require_cmd is_xdeeply tail_f @@ -35,6 +35,15 @@ BEGIN { push @EXPORT, @methods; } +sub require_bsd (;$) { + state $ok = ($^O =~ m!\A(?:free|net|open)bsd\z! || + $^O eq 'dragonfly'); + return 1 if $ok; + return if defined(wantarray); + my $m = "$0 is BSD-only (\$^O=$^O)"; + @_ ? skip($m) : plan(skip_all => $m); +} + sub xbail (@) { BAIL_OUT join(' ', map { ref() ? (explain($_)) : ($_) } @_) } sub eml_load ($) { @@ -136,7 +145,8 @@ my %IPv6_VERSION = ( sub need_accept_filter ($) { my ($af) = @_; return if $^O eq 'netbsd'; # since NetBSD 5.0 - skip 'SO_ACCEPTFILTER is FreeBSD/NetBSD-only' if $^O ne 'freebsd'; + $^O =~ /\A(?:freebsd|dragonfly)\z/ or + skip 'SO_ACCEPTFILTER is FreeBSD/NetBSD/Dragonfly-only so far'; state $tried = {}; ($tried->{$af} //= system("kldstat -m $af >/dev/null")) and skip "$af not loaded: kldload $af"; @@ -175,6 +185,11 @@ sub require_mods { push @need, $msg; next; } + } elsif ($mod eq ':fcntl_lock') { + next if $^O eq 'linux' || require_bsd; + diag "untested platform: $^O, ". + "requiring File::FcntlLock..."; + push @mods, 'File::FcntlLock'; } elsif ($mod =~ /\A\+(accf_.*)\z/) { need_accept_filter($1); next -- cgit v1.2.3-24-ge0c7