From ac4a8474f4e3b0961b48d27bbe5a020b7aa93442 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 27 Dec 2014 23:51:47 +0000 Subject: test_inotify: add test for rm_watch 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) -- cgit v1.2.3-24-ge0c7