summaryrefslogtreecommitdiffstats
path: root/vendor/rustix/tests/fs/file.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /vendor/rustix/tests/fs/file.rs
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
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);
+}