sleepy_penguin RubyGem user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
From: Eric Wong <normalperson@yhbt.net>
To: sleepy.penguin@librelist.org
Subject: [PATCH] test_inotify: add test for rm_watch
Date: Sat, 27 Dec 2014 23:55:09 +0000	[thread overview]
Message-ID: <20141227235509.GA25523@dcvr.yhbt.net> (raw)

Ugh, unfortunately this seems buggy in some cases, but we
need to ensure the regular case works.

ref: https://lkml.org/lkml/2007/7/9/3
Subject: inotify_rm_watch() EINVAL race condition for deleted files
---
 test/test_inotify.rb | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/test/test_inotify.rb b/test/test_inotify.rb
index 5cf5839..895e13b 100644
--- a/test/test_inotify.rb
+++ b/test/test_inotify.rb
@@ -103,4 +103,17 @@ class TestInotify < Testcase
     end
     assert_equal 0, nr
   end
+
+  def test_rm_watch
+    ino = Inotify.new Inotify::CLOEXEC
+    tmp = Tempfile.new 'a'
+    wd = ino.add_watch tmp.path, Inotify::ALL_EVENTS
+    assert_kind_of Integer, wd
+    tmp.syswrite '.'
+    event = ino.take
+    assert_equal wd, event.wd
+    assert_kind_of Inotify::Event, event
+    assert_equal [:MODIFY], event.events
+    assert_equal 0, ino.rm_watch(wd)
+  end
 end if defined?(SleepyPenguin::Inotify)
-- 
EW



                 reply	other threads:[~2014-12-27 23:55 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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

  List information: https://yhbt.net/sleepy_penguin/

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

  git send-email \
    --in-reply-to=20141227235509.GA25523@dcvr.yhbt.net \
    --to=normalperson@yhbt.net \
    --cc=sleepy.penguin@librelist.org \
    /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.
Code repositories for project(s) associated with this public inbox

	https://yhbt.net/sleepy_penguin.git/

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).