qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Ilya Leoshkevich <iii@linux.ibm.com>
To: "Paolo Bonzini" <pbonzini@redhat.com>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Ed Maste" <emaste@freebsd.org>, "Li-Wen Hsu" <lwhsu@freebsd.org>,
	"Warner Losh" <imp@bsdimp.com>
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"Thomas Huth" <thuth@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Wainer dos Santos Moschetta" <wainersm@redhat.com>,
	"Beraldo Leal" <bleal@redhat.com>,
	"Kyle Evans" <kevans@freebsd.org>,
	qemu-devel@nongnu.org, "Ilya Leoshkevich" <iii@linux.ibm.com>
Subject: [PATCH v2 3/4] tests/test-util-filemonitor: Adapt to FreeBSD inotify rename semantics
Date: Mon,  5 Feb 2024 19:11:34 +0100	[thread overview]
Message-ID: <20240205181352.1567-4-iii@linux.ibm.com> (raw)
In-Reply-To: <20240205181352.1567-1-iii@linux.ibm.com>

Unlike on Linux, on FreeBSD renaming a file when the destination
already exists results in IN_DELETE event for that existing file:

    $ FILEMONITOR_DEBUG=1 build/tests/unit/test-util-filemonitor
    Rename /tmp/test-util-filemonitor-K13LI2/fish/one.txt -> /tmp/test-util-filemonitor-K13LI2/two.txt
    Event id=200000000 event=2 file=one.txt
    Queue event id 200000000 event 2 file one.txt
    Queue event id 100000000 event 2 file two.txt
    Queue event id 100000002 event 2 file two.txt
    Queue event id 100000000 event 0 file two.txt
    Queue event id 100000002 event 0 file two.txt
    Event id=100000000 event=0 file=two.txt
    Expected event 0 but got 2

This difference in behavior is not expected to break the real users, so
teach the test to accept it.

Suggested-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
 tests/unit/test-util-filemonitor.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/tests/unit/test-util-filemonitor.c b/tests/unit/test-util-filemonitor.c
index a22de275955..02e67fc96ac 100644
--- a/tests/unit/test-util-filemonitor.c
+++ b/tests/unit/test-util-filemonitor.c
@@ -333,60 +333,68 @@ test_file_monitor_events(void)
 
 
         { .type = QFILE_MONITOR_TEST_OP_MKDIR,
           .filesrc = "fish", },
         { .type = QFILE_MONITOR_TEST_OP_EVENT,
           .filesrc = "fish", .watchid = &watch0,
           .eventid = QFILE_MONITOR_EVENT_CREATED },
 
 
         { .type = QFILE_MONITOR_TEST_OP_ADD_WATCH,
           .filesrc = "fish/", .watchid = &watch4 },
         { .type = QFILE_MONITOR_TEST_OP_ADD_WATCH,
           .filesrc = "fish/one.txt", .watchid = &watch5 },
         { .type = QFILE_MONITOR_TEST_OP_CREATE,
           .filesrc = "fish/one.txt", },
         { .type = QFILE_MONITOR_TEST_OP_EVENT,
           .filesrc = "one.txt", .watchid = &watch4,
           .eventid = QFILE_MONITOR_EVENT_CREATED },
         { .type = QFILE_MONITOR_TEST_OP_EVENT,
           .filesrc = "one.txt", .watchid = &watch5,
           .eventid = QFILE_MONITOR_EVENT_CREATED },
 
 
         { .type = QFILE_MONITOR_TEST_OP_DEL_WATCH,
           .filesrc = "fish/one.txt", .watchid = &watch5 },
         { .type = QFILE_MONITOR_TEST_OP_RENAME,
           .filesrc = "fish/one.txt", .filedst = "two.txt", },
         { .type = QFILE_MONITOR_TEST_OP_EVENT,
           .filesrc = "one.txt", .watchid = &watch4,
           .eventid = QFILE_MONITOR_EVENT_DELETED },
+#ifdef __FreeBSD__
+        { .type = QFILE_MONITOR_TEST_OP_EVENT,
+          .filesrc = "two.txt", .watchid = &watch0,
+          .eventid = QFILE_MONITOR_EVENT_DELETED },
+        { .type = QFILE_MONITOR_TEST_OP_EVENT,
+          .filesrc = "two.txt", .watchid = &watch2,
+          .eventid = QFILE_MONITOR_EVENT_DELETED },
+#endif
         { .type = QFILE_MONITOR_TEST_OP_EVENT,
           .filesrc = "two.txt", .watchid = &watch0,
           .eventid = QFILE_MONITOR_EVENT_CREATED },
         { .type = QFILE_MONITOR_TEST_OP_EVENT,
           .filesrc = "two.txt", .watchid = &watch2,
           .eventid = QFILE_MONITOR_EVENT_CREATED },
 
 
         { .type = QFILE_MONITOR_TEST_OP_RMDIR,
           .filesrc = "fish", },
         { .type = QFILE_MONITOR_TEST_OP_EVENT,
           .filesrc = "", .watchid = &watch4,
           .eventid = QFILE_MONITOR_EVENT_IGNORED,
           .swapnext = true },
         { .type = QFILE_MONITOR_TEST_OP_EVENT,
           .filesrc = "fish", .watchid = &watch0,
           .eventid = QFILE_MONITOR_EVENT_DELETED },
         { .type = QFILE_MONITOR_TEST_OP_DEL_WATCH,
           .filesrc = "fish", .watchid = &watch4 },
 
 
         { .type = QFILE_MONITOR_TEST_OP_UNLINK,
           .filesrc = "two.txt", },
         { .type = QFILE_MONITOR_TEST_OP_EVENT,
           .filesrc = "two.txt", .watchid = &watch0,
           .eventid = QFILE_MONITOR_EVENT_DELETED },
         { .type = QFILE_MONITOR_TEST_OP_EVENT,
           .filesrc = "two.txt", .watchid = &watch2,
           .eventid = QFILE_MONITOR_EVENT_DELETED },
 
-- 
2.43.0



  parent reply	other threads:[~2024-02-05 18:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-05 18:11 [PATCH v2 0/4] make vm-build-freebsd fixes Ilya Leoshkevich
2024-02-05 18:11 ` [PATCH v2 1/4] tests/vm: Set UseDNS=no in the sshd configuration Ilya Leoshkevich
2024-02-05 18:11 ` [PATCH v2 2/4] tests/vm/freebsd: Reload " Ilya Leoshkevich
2024-02-05 18:54   ` Thomas Huth
2024-02-05 18:11 ` Ilya Leoshkevich [this message]
2024-02-05 18:11 ` [PATCH v2 4/4] meson: Link with libinotify on FreeBSD Ilya Leoshkevich
2024-02-05 18:36   ` Philippe Mathieu-Daudé
2024-02-05 18:55     ` Ilya Leoshkevich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240205181352.1567-4-iii@linux.ibm.com \
    --to=iii@linux.ibm.com \
    --cc=alex.bennee@linaro.org \
    --cc=berrange@redhat.com \
    --cc=bleal@redhat.com \
    --cc=emaste@freebsd.org \
    --cc=imp@bsdimp.com \
    --cc=kevans@freebsd.org \
    --cc=lwhsu@freebsd.org \
    --cc=marcandre.lureau@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@redhat.com \
    --cc=wainersm@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 NNTP newsgroup(s).