From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-2.9 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, T_RP_MATCHES_RCVD shortcircuit=no autolearn=unavailable version=3.3.2 X-Original-To: normalperson@yhbt.net Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 63821633819; Sat, 27 Dec 2014 23:55:09 +0000 (UTC) Date: Sat, 27 Dec 2014 23:55:09 +0000 From: Eric Wong To: sleepy.penguin@librelist.org Subject: [PATCH] test_inotify: add test for rm_watch Message-ID: <20141227235509.GA25523@dcvr.yhbt.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline List-Id: 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