summaryrefslogtreecommitdiffstats
path: root/vendor/rustix/tests/fs/file.rs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/rustix/tests/fs/file.rs')
-rw-r--r--vendor/rustix/tests/fs/file.rs83
1 files changed, 83 insertions, 0 deletions
diff --git a/vendor/rustix/tests/fs/file.rs b/vendor/rustix/tests/fs/file.rs
new file mode 100644
index 000000000..5c09f640d
--- /dev/null
+++ b/vendor/rustix/tests/fs/file.rs
@@ -0,0 +1,83 @@
+#[cfg(not(target_os = "redox"))]
+#[test]
+fn test_file() {
+ #[cfg(not(target_os = "illumos"))]
+ rustix::fs::accessat(
+ rustix::fs::cwd(),
+ "Cargo.toml",
+ rustix::fs::Access::READ_OK,
+ rustix::fs::AtFlags::empty(),
+ )
+ .unwrap();
+
+ assert_eq!(
+ rustix::fs::openat(
+ rustix::fs::cwd(),
+ "Cagro.motl",
+ rustix::fs::OFlags::RDONLY,
+ rustix::fs::Mode::empty(),
+ )
+ .unwrap_err(),
+ rustix::io::Errno::NOENT
+ );
+
+ let file = rustix::fs::openat(
+ rustix::fs::cwd(),
+ "Cargo.toml",
+ rustix::fs::OFlags::RDONLY,
+ rustix::fs::Mode::empty(),
+ )
+ .unwrap();
+
+ assert_eq!(
+ rustix::fs::openat(
+ &file,
+ "Cargo.toml",
+ rustix::fs::OFlags::RDONLY,
+ rustix::fs::Mode::empty(),
+ )
+ .unwrap_err(),
+ rustix::io::Errno::NOTDIR
+ );
+
+ #[cfg(not(any(
+ target_os = "dragonfly",
+ target_os = "illumos",
+ target_os = "ios",
+ target_os = "macos",
+ target_os = "netbsd",
+ target_os = "openbsd",
+ target_os = "redox",
+ )))]
+ rustix::fs::fadvise(&file, 0, 10, rustix::fs::Advice::Normal).unwrap();
+
+ assert_eq!(
+ rustix::fs::fcntl_getfd(&file).unwrap(),
+ rustix::fs::FdFlags::empty()
+ );
+ assert_eq!(
+ rustix::fs::fcntl_getfl(&file).unwrap(),
+ rustix::fs::OFlags::empty()
+ );
+
+ let stat = rustix::fs::fstat(&file).unwrap();
+ assert!(stat.st_size > 0);
+ assert!(stat.st_blocks > 0);
+
+ #[cfg(not(any(
+ target_os = "illumos",
+ target_os = "netbsd",
+ target_os = "redox",
+ target_os = "wasi",
+ )))]
+ // not implemented in libc for netbsd yet
+ {
+ let statfs = rustix::fs::fstatfs(&file).unwrap();
+ assert!(statfs.f_blocks > 0);
+ }
+
+ #[cfg(feature = "net")]
+ assert_eq!(rustix::io::is_read_write(&file).unwrap(), (true, false));
+
+ assert_ne!(rustix::io::ioctl_fionread(&file).unwrap(), 0);
+}