test-util-filemonitor: Adapt to FreeBSD 15's native inotify semantics
PATCH 1/1 test-util-filemonitor: Adapt to FreeBSD 15's native inotify semantics
FreeBSD 15 introduces a native inotify implementation rather than requiring use of the kqueue-based libinotify package. This native implementation does not generate the extra deleted events, so don't expect them. However, the original implementation did have a bug that caused IN_IGNORED to never be generated if you did not also watch for IN_DELETE_SELF, which affects 15.0 and 15.1, but has been fixed and will no longer apply in 15.2 / 16.0.
Note that the deleted event check is for the userspace version, since that governs whether libinotify is being used or not, whereas the ignored event check is both for the userspace version (to check if we're using the native syscall) and the kernel version (to check if the kernel has the bug or not).
All __FreeBSD_version values used here correspond to the value in-tree at the time of the relevant commits. Since neither commit bumped the value there will be a window of development snapshots between each commit and the previous bump that will be incorrectly identified here, but this is the best we can do, and something users of snapshots should be prepared to deal with.
--- tests/unit/test-util-filemonitor.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-)
tests/unit/test-util-filemonitor.c +28 -1
@@ -27,6 +27,10 @@#include <utime.h> +#ifdef __FreeBSD__ +#include <osreldate.h> +#endif +enum {QFILE_MONITOR_TEST_OP_ADD_WATCH ,QFILE_MONITOR_TEST_OP_DEL_WATCH ,
@@ -221,6 +225,24 @@ qemu_file_monitor_test_expect(QFileMonitorTestData *data, } +static bool +expect_broken_ignored (void ) +{ +#if defined(__FreeBSD__) && __FreeBSD_version >=1500051 +int osreldate; + + osreldate =getosreldate (); +if (osreldate ==-1 ) { +g_printerr ("Unable to call getosreldate: %s\n" ,strerror (errno)); +abort (); + } +return osreldate <1501501 || (osreldate >=1600000 && osreldate <1600019 ); +#else +return false; +#endif +} + +static void test_file_monitor_events (void ) {
@@ -360,7 +382,7 @@ test_file_monitor_events(void) { .type = QFILE_MONITOR_TEST_OP_EVENT, .filesrc = "one.txt", .watchid = &watch4, .eventid = QFILE_MONITOR_EVENT_DELETED }, -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) && __FreeBSD_version < 1500051 { .type = QFILE_MONITOR_TEST_OP_EVENT, .filesrc = "two.txt", .watchid = &watch0, .eventid = QFILE_MONITOR_EVENT_DELETED },
@@ -539,6 +561,11 @@ test_file_monitor_events(void)g_printerr ("Event id=%" PRIx64" event=%d file=%s\n" , *op->watchid, op->eventid, op->filesrc); } +if (op->eventid ==QFILE_MONITOR_EVENT_IGNORED && +expect_broken_ignored ()) { +g_printerr ("Expect ignored event to be broken, skipping\n" ); +break ; + }if (!qemu_file_monitor_test_expect (&data, *op->watchid, op->eventid, op->filesrc, op->swapnext))
Signature · 1 line
2.53.0
Quoted 21 lines · Jessica Clarke
FreeBSD 15 introduces a native inotify implementation rather than requiring use of the kqueue-based libinotify package. This native implementation does not generate the extra deleted events, so don't expect them. However, the original implementation did have a bug that caused
IN_IGNOREDto never be generated if you did not also watch forIN_DELETE_SELF, which affects 15.0 and 15.1, but has been fixed and will no longer apply in 15.2 / 16.0.Note that the deleted event check is for the userspace version, since that governs whether libinotify is being used or not, whereas the ignored event check is both for the userspace version (to check if we're using the native syscall) and the kernel version (to check if the kernel has the bug or not).
All
__FreeBSD_versionvalues used here correspond to the value in-tree at the time of the relevant commits. Since neither commit bumped the value there will be a window of development snapshots between each commit and the previous bump that will be incorrectly identified here, but this is the best we can do, and something users of snapshots should be prepared to deal with.
Quoted 4 lines
Signed-off-by Jessica Clarke <[email protected]>--- tests/unit/test-util-filemonitor.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-)
and queued.
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com ~~ https://hachyderm.io/@berrange :| |: https://libvirt.org ~~ https://entangle-photo.org :| |: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|