diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-18 02:49:50 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-18 02:49:50 +0000 |
commit | 9835e2ae736235810b4ea1c162ca5e65c547e770 (patch) | |
tree | 3fcebf40ed70e581d776a8a4c65923e8ec20e026 /vendor/nix/test/sys/test_inotify.rs | |
parent | Releasing progress-linux version 1.70.0+dfsg2-1~progress7.99u1. (diff) | |
download | rustc-9835e2ae736235810b4ea1c162ca5e65c547e770.tar.xz rustc-9835e2ae736235810b4ea1c162ca5e65c547e770.zip |
Merging upstream version 1.71.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/nix/test/sys/test_inotify.rs')
-rw-r--r-- | vendor/nix/test/sys/test_inotify.rs | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/vendor/nix/test/sys/test_inotify.rs b/vendor/nix/test/sys/test_inotify.rs deleted file mode 100644 index bb5851a90..000000000 --- a/vendor/nix/test/sys/test_inotify.rs +++ /dev/null @@ -1,65 +0,0 @@ -use nix::errno::Errno; -use nix::sys::inotify::{AddWatchFlags, InitFlags, Inotify}; -use std::ffi::OsString; -use std::fs::{rename, File}; - -#[test] -pub fn test_inotify() { - let instance = Inotify::init(InitFlags::IN_NONBLOCK).unwrap(); - let tempdir = tempfile::tempdir().unwrap(); - - instance - .add_watch(tempdir.path(), AddWatchFlags::IN_ALL_EVENTS) - .unwrap(); - - let events = instance.read_events(); - assert_eq!(events.unwrap_err(), Errno::EAGAIN); - - File::create(tempdir.path().join("test")).unwrap(); - - let events = instance.read_events().unwrap(); - assert_eq!(events[0].name, Some(OsString::from("test"))); -} - -#[test] -pub fn test_inotify_multi_events() { - let instance = Inotify::init(InitFlags::IN_NONBLOCK).unwrap(); - let tempdir = tempfile::tempdir().unwrap(); - - instance - .add_watch(tempdir.path(), AddWatchFlags::IN_ALL_EVENTS) - .unwrap(); - - let events = instance.read_events(); - assert_eq!(events.unwrap_err(), Errno::EAGAIN); - - File::create(tempdir.path().join("test")).unwrap(); - rename(tempdir.path().join("test"), tempdir.path().join("test2")).unwrap(); - - // Now there should be 5 events in queue: - // - IN_CREATE on test - // - IN_OPEN on test - // - IN_CLOSE_WRITE on test - // - IN_MOVED_FROM on test with a cookie - // - IN_MOVED_TO on test2 with the same cookie - - let events = instance.read_events().unwrap(); - assert_eq!(events.len(), 5); - - assert_eq!(events[0].mask, AddWatchFlags::IN_CREATE); - assert_eq!(events[0].name, Some(OsString::from("test"))); - - assert_eq!(events[1].mask, AddWatchFlags::IN_OPEN); - assert_eq!(events[1].name, Some(OsString::from("test"))); - - assert_eq!(events[2].mask, AddWatchFlags::IN_CLOSE_WRITE); - assert_eq!(events[2].name, Some(OsString::from("test"))); - - assert_eq!(events[3].mask, AddWatchFlags::IN_MOVED_FROM); - assert_eq!(events[3].name, Some(OsString::from("test"))); - - assert_eq!(events[4].mask, AddWatchFlags::IN_MOVED_TO); - assert_eq!(events[4].name, Some(OsString::from("test2"))); - - assert_eq!(events[3].cookie, events[4].cookie); -} |