* dfly wip
@ 2023-10-05 0:59 Eric Wong
0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2023-10-05 0:59 UTC (permalink / raw)
To: spew
diff --git a/ci/profiles.perl b/ci/profiles.perl
index 6f90a0e4..c815427d 100755
--- a/ci/profiles.perl
+++ b/ci/profiles.perl
@@ -7,7 +7,7 @@ if 0; # running under some shell
use v5.12;
BEGIN { require './install/os.perl' }
my $TASKS = do {
- if ($ID =~ /\A(?:free|net|open)bsd\z/) { <<EOM
+ if ($ID =~ /\A(?:free|net|open)bsd\z/ || $ID eq 'dragonfly') { <<EOM
all devtest Xapian-
all devtest IO::KQueue-
all devtest IO::KQueue
diff --git a/lib/PublicInbox/KQNotify.pm b/lib/PublicInbox/KQNotify.pm
index 2efa887d..1689f4cc 100644
--- a/lib/PublicInbox/KQNotify.pm
+++ b/lib/PublicInbox/KQNotify.pm
@@ -26,7 +26,7 @@ sub watch {
my $ident = fileno($w->[2]) // die "BUG: bad fileno $w->[2]: $!";
$self->{dskq}->{kq}->EV_SET($ident, # ident (fd)
EVFILT_VNODE, # filter
- EV_ADD | EV_CLEAR, # flags
+ EV_ADD, # flags
$mask, # fflags
0, $dir_delete); # data, udata
$self->{watch}->{$ident} = $w;
diff --git a/lib/PublicInbox/POP3D.pm b/lib/PublicInbox/POP3D.pm
index 2a9ccfdd..38e982ee 100644
--- a/lib/PublicInbox/POP3D.pm
+++ b/lib/PublicInbox/POP3D.pm
@@ -15,7 +15,7 @@ use File::Temp 0.19 (); # 0.19 for ->newdir
use Fcntl qw(F_SETLK F_UNLCK F_WRLCK SEEK_SET);
my ($FLOCK_TMPL, @FLOCK_ORDER);
# are all BSDs the same "struct flock"? tested Free+Net+Open...
-if ($^O eq 'linux' || $^O =~ /bsd/) {
+if ($^O =~ /\A(?:linux|dragonfly)\z/ || $^O =~ /bsd/) {
require Config;
my $off_t;
my $sz = $Config::Config{lseeksize};
@@ -28,7 +28,7 @@ if ($^O eq 'linux' || $^O =~ /bsd/) {
if ($^O eq 'linux') {
$FLOCK_TMPL = "ss\@8$off_t$off_t\@32";
@FLOCK_ORDER = qw(l_type l_whence l_start l_len);
- } elsif ($^O =~ /bsd/) { # @32 may be enough
+ } else { # *bsd including dragonfly
$FLOCK_TMPL = "${off_t}${off_t}lss\@256";
@FLOCK_ORDER = qw(l_start l_len l_pid l_type l_whence);
}
diff --git a/t/dir_idle.t b/t/dir_idle.t
index bb6f47eb..02759b54 100644
--- a/t/dir_idle.t
+++ b/t/dir_idle.t
@@ -1,7 +1,7 @@
#!perl -w
# Copyright (C) all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
-use v5.12; use strict; use PublicInbox::TestCommon;
+use v5.12; use PublicInbox::TestCommon;
use PublicInbox::DS qw(now);
use File::Path qw(make_path);
use_ok 'PublicInbox::DirIdle';
@@ -26,10 +26,12 @@ rmdir("$tmpdir/a") or xbail "rmdir $!";
@x = ();
$end = 3 + now;
PublicInbox::DS::event_loop();
-is(scalar(@x), 1, 'got an event') and
+if (is(scalar(@x), 1, 'got an event after rmdir')) {
is($x[0]->[0]->fullname, "$tmpdir/a", 'got expected fullname') and
ok($x[0]->[0]->IN_DELETE_SELF, 'IN_DELETE_SELF set');
-
+} else {
+ diag explain(\@x);
+}
rename("$tmpdir/c", "$tmpdir/j") or xbail "rmdir $!";
@x = ();
$end = 3 + now;
diff --git a/t/ds-kqxs.t b/t/ds-kqxs.t
index 57acb53f..87f7199d 100644
--- a/t/ds-kqxs.t
+++ b/t/ds-kqxs.t
@@ -6,8 +6,9 @@
use v5.12;
use Test::More;
unless (eval { require IO::KQueue }) {
- my $m = $^O !~ /bsd/ ? 'DSKQXS is only for *BSD systems'
- : "no IO::KQueue, skipping $0: $@";
+ my $m = ($^O =~ /bsd/ || $^O eq 'dragonfly') ?
+ "no IO::KQueue, skipping $0: $@" :
+ 'DSKQXS is only for *BSD systems';
plan skip_all => $m;
}
diff --git a/t/kqnotify.t b/t/kqnotify.t
index edecf2e1..94f76c84 100644
--- a/t/kqnotify.t
+++ b/t/kqnotify.t
@@ -7,7 +7,8 @@
use v5.12;
use PublicInbox::TestCommon;
use autodie;
-plan skip_all => 'KQNotify is only for *BSD systems' if $^O !~ /bsd/;
+($^O =~ /bsd/ || $^O eq 'dragonfly') or
+ plan skip_all => 'KQNotify is only for *BSD systems';
require_mods('IO::KQueue');
use_ok 'PublicInbox::KQNotify';
my ($tmpdir, $for_destroy) = tmpdir();
@@ -33,9 +34,35 @@ $hit = [ grep(m!/link$!, @read) ];
is_deeply($hit, ["$tmpdir/new/link"], 'link(2) detected (via NOTE_WRITE)')
or diag explain(\@read);
+{
+ my $d = "$tmpdir/new/ANOTHER";
+ mkdir $d;
+ $hit = [ map { $_->fullname } $kqn->read ];
+ is_xdeeply($hit, [ $d ], 'mkdir detected');
+ # no way to avoid detecting deletes if we're watching for dir ops
+ rmdir $d;
+ is_xdeeply($hit, [ $d ], 'rmdir detected');
+}
+
$w->cancel;
link("$tmpdir/new/tst", "$tmpdir/new/link2");
$hit = [ map { $_->fullname } $kqn->read ];
is_deeply($hit, [], 'link(2) not detected after cancel');
+# rearm:
+my $GONE = PublicInbox::KQNotify::NOTE_DELETE() |
+ PublicInbox::KQNotify::NOTE_REVOKE() |
+ PublicInbox::KQNotify::NOTE_ATTRIB() |
+ PublicInbox::KQNotify::NOTE_WRITE() |
+ PublicInbox::KQNotify::NOTE_RENAME();
+$w = $kqn->watch("$tmpdir/new", $mask|$GONE);
+my @unlink = sort glob("$tmpdir/new/*");
+unlink(@unlink);
+$hit = [ sort(map { $_->fullname } $kqn->read) ];
+is_xdeeply($hit, \@unlink, 'unlinked files match');
+
+rmdir "$tmpdir/new";
+$hit = [ sort(map { $_->fullname } $kqn->read) ];
+is(scalar(@$hit), 1, 'detected self removal');
+
done_testing;
diff --git a/t/pop3d-limit.t b/t/pop3d-limit.t
index 00da477d..1aa83119 100644
--- a/t/pop3d-limit.t
+++ b/t/pop3d-limit.t
@@ -4,7 +4,7 @@
use v5.12;
use PublicInbox::TestCommon;
require_mods(qw(DBD::SQLite Net::POP3));
-$^O =~ /\A(?:linux|(?:free|net|open)bsd)\z/ or
+($^O =~ /\A(?:linux|dragonfly)\z/ || $^O =~ /bsd/) or
require_mods(qw(File::FcntlLock));
use autodie;
my ($tmpdir, $for_destroy) = tmpdir();
diff --git a/t/pop3d.t b/t/pop3d.t
index fce4a788..e698b905 100644
--- a/t/pop3d.t
+++ b/t/pop3d.t
@@ -14,7 +14,7 @@ unless (-r $key && -r $cert) {
# Net::POP3 is part of the standard library, but distros may split it off...
require_mods(qw(DBD::SQLite Net::POP3 IO::Socket::SSL));
require_git('2.6'); # for v2
-$^O =~ /\A(?:linux|(?:free|net|open)bsd)\z/ or
+($^O =~ /\A(?:linux|dragonfly)\z/ || $^O =~ /bsd/) or
require_mods(qw(File::FcntlLock));
use_ok 'IO::Socket::SSL';
use_ok 'PublicInbox::TLS';
diff --git a/t/search.t b/t/search.t
index 636dc5cf..9ed3cd25 100644
--- a/t/search.t
+++ b/t/search.t
@@ -440,7 +440,7 @@ my $dir_mask = 02770;
# FreeBSD, OpenBSD and NetBSD do not allow non-root users to set S_ISGID,
# so git doesn't set it, either (see DIR_HAS_BSD_GROUP_SEMANTICS in git.git)
# Presumably all *BSDs behave the same way.
-if ($^O =~ /\A.+bsd\z/i) {
+if ($^O =~ /bsd/ || $^O eq 'dragonfly') {
$all_mask = 0777;
$dir_mask = 0770;
}
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2023-10-05 0:59 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-05 0:59 dfly wip Eric Wong
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).