From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 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.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id CC4021F4C4 for ; Mon, 11 Nov 2024 21:56:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1731362216; bh=hbEzR4vpY9fP3Ky6/J7sCiCQyPmjuDpO3cTPcYm06cc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Krd1TR63tT8P4UC5j3tEukcNWlvGNwZY6SCtywm7ReVrKQoJDmz9oBbZ6EteEn17e hpMe7KpGNNPnRbjXQhivPfmqs31d8KRL2U8T2DzX0wEHaimrOY0m2FHj2V3zZAMRnc bVpXMj77ic/3CUrF1PD4DxzwWUK4J2ntVg0MsUuw= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 1/4] t/inbox_idle: delay for low-res FS w/o inotify||kqueue Date: Mon, 11 Nov 2024 21:56:53 +0000 Message-ID: <20241111215656.2411957-2-e@80x24.org> In-Reply-To: <20241111215656.2411957-1-e@80x24.org> References: <20241111215656.2411957-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: On systems without inotify||kqueue, changes are unreliably detected on filesystems with low-resolution timestamps. The FakeInotify emulation can't detect changes properly in all cases. While this remains a problem for real-world use cases, systems w/o inotify or IO::KQueue are probably rare, so we'll just change this test case to accomodate old FSes which lack high resolution timestamps. Keep in mind that mounting an old FS on a modern kernel doesn't automatically give it high-resolution timestamps. I discovered this problem because I still use an ancient ext3 FS created decades ago on a modern kernel :x --- t/inbox_idle.t | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/t/inbox_idle.t b/t/inbox_idle.t index 0ccffab7..94f3845c 100644 --- a/t/inbox_idle.t +++ b/t/inbox_idle.t @@ -9,6 +9,11 @@ require PublicInbox::SearchIdx; use_ok 'PublicInbox::InboxIdle'; my ($tmpdir, $for_destroy) = tmpdir(); +# for non-inotify|kqueue systems w/ low-res FS timestamps +# This only makes the test work, but either high-res FS timestamps +# or inotify or kqueue support needs to be added to your system. +my $poll_delay = 1; + for my $V (1, 2) { my $inboxdir = "$tmpdir/$V"; my $ibx = create_inbox "idle$V", tmpdir => $inboxdir, version => $V, @@ -35,16 +40,21 @@ EOF my $ii = PublicInbox::InboxIdle->new($pi_cfg); ok($ii, 'InboxIdle created'); SKIP: { - skip('inotify or kqueue missing', 1) unless $ii->{sock}; + $ii->{sock} or skip +'inotify or kqueue missing, expect real-world breakage on low-res FSes', 1; ok(fileno($ii->{sock}) >= 0, 'fileno() gave valid FD'); + $poll_delay = 0; } my $im = $ibx->importer(0); ok($im->add(eml_load('t/utf8.eml')), "$V added"); + tick $poll_delay if $poll_delay; $im->done; $ii->event_step; - is(scalar @{$obj->{called}}, 1, 'called on unlock'); + is(scalar @{$obj->{called}}, 1, 'called on unlock') or + diag explain($obj); $pi_cfg->each_inbox(sub { shift->unsubscribe_unlock($ident) }); ok($im->add(eml_load('t/data/0001.patch')), "$V added #2"); + tick $poll_delay if $poll_delay; $im->done; $ii->event_step; is(scalar @{$obj->{called}}, 1, 'not called when unsubbed');