about summary refs log tree commit diff
path: root/library/std/src/os/unix/fs/tests.rs
diff options
context:
space:
mode:
authorJiahao XU <Jiahao_XU@outlook.com>2025-04-07 00:04:57 +1000
committerJiahao XU <Jiahao_XU@outlook.com>2025-04-23 23:02:52 +1000
commit780f95dd182b1a432159430add57e9ab7cb45dd6 (patch)
tree134bdcc279d91cbb6b702cc66cf1975a457d73e5 /library/std/src/os/unix/fs/tests.rs
parent1bc56185ee257ed829a0aea7abdc3b03c5fed887 (diff)
downloadrust-780f95dd182b1a432159430add57e9ab7cb45dd6.tar.gz
rust-780f95dd182b1a432159430add57e9ab7cb45dd6.zip
Impl new API `std::os::unix::fs::mkfifo` under feature `unix_fifo`
Tracking issue #139324

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Diffstat (limited to 'library/std/src/os/unix/fs/tests.rs')
-rw-r--r--library/std/src/os/unix/fs/tests.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/library/std/src/os/unix/fs/tests.rs b/library/std/src/os/unix/fs/tests.rs
index db9621c8c20..1840bb38c17 100644
--- a/library/std/src/os/unix/fs/tests.rs
+++ b/library/std/src/os/unix/fs/tests.rs
@@ -55,3 +55,23 @@ fn write_vectored_at() {
     let content = fs::read(&filename).unwrap();
     assert_eq!(&content, expected);
 }
+
+#[test]
+fn test_mkfifo() {
+    let tmp_dir = crate::test_helpers::tmpdir();
+
+    let fifo = tmp_dir.path().join("fifo");
+
+    mkfifo(&fifo, Permissions::from_mode(0o774)).unwrap();
+
+    let mut wx = fs::File::options().read(true).write(true).open(&fifo).unwrap();
+    let mut rx = fs::File::open(fifo).unwrap();
+
+    wx.write_all(b"hello, world!").unwrap();
+    drop(wx);
+
+    let mut s = String::new();
+    rx.read_to_string(&mut s).unwrap();
+
+    assert_eq!(s, "hello, world!");
+}