diff options
Diffstat (limited to 'vendor/rustix/tests/fs/flock.rs')
-rw-r--r-- | vendor/rustix/tests/fs/flock.rs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/vendor/rustix/tests/fs/flock.rs b/vendor/rustix/tests/fs/flock.rs new file mode 100644 index 000000000..1b7df6ffd --- /dev/null +++ b/vendor/rustix/tests/fs/flock.rs @@ -0,0 +1,34 @@ +#[cfg(not(target_os = "redox"))] +#[test] +fn test_flock() { + use rustix::fs::{cwd, flock, openat, FlockOperation, Mode, OFlags}; + + let f = openat(cwd(), "Cargo.toml", OFlags::RDONLY, Mode::empty()).unwrap(); + flock(&f, FlockOperation::LockExclusive).unwrap(); + flock(&f, FlockOperation::Unlock).unwrap(); + let g = openat(cwd(), "Cargo.toml", OFlags::RDONLY, Mode::empty()).unwrap(); + flock(&g, FlockOperation::LockExclusive).unwrap(); + flock(&g, FlockOperation::Unlock).unwrap(); + drop(f); + drop(g); + + let f = openat(cwd(), "Cargo.toml", OFlags::RDONLY, Mode::empty()).unwrap(); + flock(&f, FlockOperation::LockShared).unwrap(); + let g = openat(cwd(), "Cargo.toml", OFlags::RDONLY, Mode::empty()).unwrap(); + flock(&g, FlockOperation::LockShared).unwrap(); + flock(&f, FlockOperation::Unlock).unwrap(); + flock(&g, FlockOperation::Unlock).unwrap(); + drop(f); + drop(g); + + let f = openat(cwd(), "Cargo.toml", OFlags::RDONLY, Mode::empty()).unwrap(); + flock(&f, FlockOperation::LockShared).unwrap(); + flock(&f, FlockOperation::LockExclusive).unwrap(); + flock(&f, FlockOperation::Unlock).unwrap(); + let g = openat(cwd(), "Cargo.toml", OFlags::RDONLY, Mode::empty()).unwrap(); + flock(&g, FlockOperation::LockShared).unwrap(); + flock(&g, FlockOperation::LockExclusive).unwrap(); + flock(&g, FlockOperation::Unlock).unwrap(); + drop(f); + drop(g); +} |