summaryrefslogtreecommitdiffstats
path: root/vendor/rustix/tests/fs/mknodat.rs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/rustix/tests/fs/mknodat.rs')
-rw-r--r--vendor/rustix/tests/fs/mknodat.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/vendor/rustix/tests/fs/mknodat.rs b/vendor/rustix/tests/fs/mknodat.rs
new file mode 100644
index 000000000..fa1c84f69
--- /dev/null
+++ b/vendor/rustix/tests/fs/mknodat.rs
@@ -0,0 +1,27 @@
+#[cfg(not(any(
+ target_os = "ios",
+ target_os = "macos",
+ target_os = "redox",
+ target_os = "wasi",
+)))]
+#[test]
+fn test_mknodat() {
+ use rustix::fs::{cwd, mknodat, openat, statat, unlinkat, AtFlags, FileType, Mode, OFlags};
+
+ let tmp = tempfile::tempdir().unwrap();
+ let dir = openat(cwd(), tmp.path(), OFlags::RDONLY, Mode::empty()).unwrap();
+
+ // Create a regular file. Not supported on FreeBSD or OpenBSD.
+ #[cfg(not(any(target_os = "freebsd", target_os = "openbsd")))]
+ {
+ mknodat(&dir, "foo", FileType::RegularFile, Mode::empty(), 0).unwrap();
+ let stat = statat(&dir, "foo", AtFlags::empty()).unwrap();
+ assert_eq!(FileType::from_raw_mode(stat.st_mode), FileType::RegularFile);
+ unlinkat(&dir, "foo", AtFlags::empty()).unwrap();
+ }
+
+ mknodat(&dir, "foo", FileType::Fifo, Mode::empty(), 0).unwrap();
+ let stat = statat(&dir, "foo", AtFlags::empty()).unwrap();
+ assert_eq!(FileType::from_raw_mode(stat.st_mode), FileType::Fifo);
+ unlinkat(&dir, "foo", AtFlags::empty()).unwrap();
+}