id stringlengths 22 133 | text stringlengths 40 40.2k | arch stringclasses 1
value | syntax stringclasses 1
value | kind stringclasses 4
values | repo stringclasses 27
values | path stringlengths 5 116 | license stringclasses 6
values | commit stringlengths 40 40 | source_host stringclasses 1
value | category stringclasses 16
values | source_url stringlengths 85 196 | line_start int64 1 4.28k | line_end int64 4 4.31k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
tokio-rs/tokio:tokio/tests/net_panic.rs:3 | let panic_location_file = test_panic(|| {
let rt = runtime_without_io();
rt.block_on(async {
let _ = UnixListener::bind(&sock_path);
});
});
// The panic location should be in this file
assert_eq!(&panic_location_file.unwrap(), file!());
Ok(())
}
#[test]
#[cfg(unix... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_panic.rs | MIT | c445e467ce4363b3a9b6825268814a9bc27c0127 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/net_panic.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/net_panic.rs:4 | let dir = tempfile::tempdir().unwrap();
let sock_path = dir.path().join("socket");
let _std_listener = std::os::unix::net::UnixListener::bind(&sock_path).unwrap();
let std_stream = std::os::unix::net::UnixStream::connect(&sock_path).unwrap();
let panic_location_file = test_panic(|| {
let rt = r... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_panic.rs | MIT | c445e467ce4363b3a9b6825268814a9bc27c0127 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/net_panic.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/net_panic.rs:5 | assert_eq!(&panic_location_file.unwrap(), file!());
Ok(())
}
#[test]
#[cfg(windows)]
fn server_options_max_instances_panic_caller() -> Result<(), Box<dyn Error>> {
use tokio::net::windows::named_pipe::ServerOptions;
let panic_location_file = test_panic(move || {
let rt = runtime_without_io();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_panic.rs | MIT | c445e467ce4363b3a9b6825268814a9bc27c0127 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/net_panic.rs | 161 | 188 |
tokio-rs/tokio:tokio/tests/net_panic.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(tokio_wasi)))]
use std::error::Error;
use tokio::net::{TcpListener, TcpStream};
use tokio::runtime::{Builder, Runtime};
mod support {
pub mod panic;
}
use support::panic::test_panic;
#[test]
fn udp_socket_from_std_panic_caller() -> Result<(), Box<dyn Er... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_panic.rs | MIT | 9b87daad7e79904ef451b98211133b1142bedc29 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9b87daad7e79904ef451b98211133b1142bedc29/tokio/tests/net_panic.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/net_panic.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(tokio_wasi)))]
use std::error::Error;
use tokio::net::{TcpListener, TcpStream};
use tokio::runtime::{Builder, Runtime};
mod support {
pub mod panic;
}
use support::panic::test_panic;
#[test]
fn udp_socket_from_std_panic_caller() -> Result<(), Box<dyn Er... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_panic.rs | MIT | b2ada60e701d5c9e6644cf8fc42a100774f8e23f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/tests/net_panic.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/net_panic.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))]
use std::error::Error;
use tokio::net::{TcpListener, TcpStream};
use tokio::runtime::{Builder, Runtime};
mod support {
pub mod panic;
}
use support::panic::test_panic;
#[test]
fn udp_socket_from_std_panic_caller() -> Result<(), Bo... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_panic.rs | MIT | cbdba8bd32a7a6afd63d43afd5ab978b91745814 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cbdba8bd32a7a6afd63d43afd5ab978b91745814/tokio/tests/net_panic.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/net_quickack.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(
feature = "net",
any(
target_os = "linux",
target_os = "android",
target_os = "fuchsia",
target_os = "cygwin",
)
))]
#![cfg(not(miri))] // No `socket` in miri.
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::net::TcpListener;
u... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_quickack.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/net_quickack.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/net_quickack.rs:2 | // at this point, we just want to test the `false` case.
stream.set_quickack(false).unwrap();
assert!(!stream.quickack().unwrap());
stream.shutdown().await.unwrap();
});
let port = rx_port.await.unwrap();
let client = tokio::spawn(async move {
let mut stream = TcpStream::co... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_quickack.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/net_quickack.rs | 41 | 71 |
tokio-rs/tokio:tokio/tests/net_types_unwind.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use std::panic::{RefUnwindSafe, UnwindSafe};
#[test]
fn net_types_are_unwind_safe() {
is_unwind_safe::<tokio::net::TcpListener>();
is_unwind_safe::<tokio::net::TcpSocket>();
is_unwind_safe::<tokio::net::TcpStream>();
is_unwind_safe::<tokio::net::Udp... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_types_unwind.rs | MIT | ac2343d9842e1a12ec986a95a73148544ee91a1a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ac2343d9842e1a12ec986a95a73148544ee91a1a/tokio/tests/net_types_unwind.rs | 1 | 32 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:1 | #![cfg(feature = "full")]
#![cfg(unix)]
use tokio::io::{AsyncReadExt, AsyncWriteExt, Interest};
use tokio::net::unix::pipe;
use tokio_test::task;
use tokio_test::{assert_err, assert_ok, assert_pending, assert_ready_ok};
use std::fs::File;
use std::io;
use std::os::fd::AsFd;
use std::os::unix::fs::OpenOptionsExt;
use ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/net_unix_pipe.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:2 | async fn fifo_simple_send() -> io::Result<()> {
const DATA: &[u8] = b"this is some data to write to the fifo";
let fifo = TempFifo::new("simple_send")?;
// Create a reading task which should wait for data from the pipe.
let mut reader = pipe::OpenOptions::new().open_receiver(&fifo)?;
let mut read_... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/net_unix_pipe.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:3 | assert_eq!(err.raw_os_error(), Some(libc::ENXIO));
// `open_sender` in read-write mode should succeed and the pipe should be ready to write.
let mut writer = pipe::OpenOptions::new()
.read_write(true)
.open_sender(&fifo)?;
writer.write_all(DATA).await?;
// Read the written data and val... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/net_unix_pipe.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:4 | assert_ok!(reader.read_exact(&mut read_data).await);
// Check that reader hits EOF.
let err = assert_err!(reader.read_exact(&mut read_data).await);
assert_eq!(err.kind(), io::ErrorKind::UnexpectedEof);
// Write more data and read again.
write_and_close(&fifo, DATA).await?;
assert_ok!(reader.re... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/net_unix_pipe.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:5 | // Write more data and read again.
write_and_close(&fifo, DATA).await?;
assert_ok!(second_read_fut.await);
Ok(())
}
#[tokio::test]
#[cfg_attr(miri, ignore)] // No `O_NONBLOCK` for open64 in miri.
async fn open_detects_not_a_fifo() -> io::Result<()> {
let dir = tempfile::Builder::new()
.prefix(... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/net_unix_pipe.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:6 | .custom_flags(libc::O_NONBLOCK)
.open(&fifo)?;
let mut reader = pipe::Receiver::from_file(file)?;
// Construct a Sender from a File.
let file = std::fs::OpenOptions::new()
.write(true)
.custom_flags(libc::O_NONBLOCK)
.open(&fifo)?;
let mut writer = pipe::Sender::from_fil... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/net_unix_pipe.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:7 | let err = assert_err!(pipe::Sender::from_file(file));
assert_eq!(err.kind(), io::ErrorKind::InvalidInput);
// Check if Receiver detects invalid file type.
let file = std::fs::OpenOptions::new().read(true).open(&path)?;
let err = assert_err!(pipe::Receiver::from_file(file));
assert_eq!(err.kind(), i... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/net_unix_pipe.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:8 | Ok((flags & libc::O_NONBLOCK) != 0)
}
#[tokio::test]
#[cfg_attr(miri, ignore)] // No `mkfifo` in miri.
async fn from_file_sets_nonblock() -> io::Result<()> {
let fifo = TempFifo::new("sets_nonblock")?;
// Open read and write ends to let blocking files open.
let _reader = pipe::OpenOptions::new().open_rece... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/net_unix_pipe.rs | 281 | 340 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:9 | // Fill the pipe buffer with `try_write`.
let mut write_data = Vec::new();
while writable_by_poll(&writer) {
match writer.try_write(DATA) {
Ok(n) => write_data.extend(&DATA[..n]),
Err(e) => {
assert_eq!(e.kind(), io::ErrorKind::WouldBlock);
break;
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/net_unix_pipe.rs | 321 | 380 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:10 | let writer = pipe::OpenOptions::new().open_sender(&fifo)?;
let write_bufs: Vec<_> = DATA.chunks(3).map(io::IoSlice::new).collect();
// Fill the pipe buffer with `try_write_vectored`.
let mut write_data = Vec::new();
while writable_by_poll(&writer) {
match writer.try_write_vectored(&write_bufs)... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/net_unix_pipe.rs | 361 | 420 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:11 | #[tokio::test]
#[cfg_attr(miri, ignore)] // No `mkfifo` in miri.
async fn try_read_buf() -> std::io::Result<()> {
const DATA: &[u8] = b"this is some data to write to the fifo";
// Create a pipe pair over a fifo file.
let fifo = TempFifo::new("try_read_write_vectored")?;
let reader = pipe::OpenOptions::... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/net_unix_pipe.rs | 401 | 460 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:12 | #[tokio::test]
async fn anon_pipe_simple_send() -> io::Result<()> {
const DATA: &[u8] = b"this is some data to write to the pipe";
let (mut writer, mut reader) = pipe::pipe()?;
// Create a reading task which should wait for data from the pipe.
let mut read_fut = task::spawn(async move {
let mu... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/net_unix_pipe.rs | 441 | 500 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:13 | .arg(DATA)
.stdout(tx.into_blocking_fd()?)
.status();
let mut buf = vec![0; DATA.len()];
rx.read_exact(&mut buf).await?;
assert_eq!(String::from_utf8(buf).unwrap(), DATA);
let exit_code = status.await?;
assert!(exit_code.success());
// Check if the pipe is closed.
buf = Ve... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/net_unix_pipe.rs | 481 | 540 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:14 | async fn anon_pipe_into_nonblocking_fd() -> std::io::Result<()> {
let (tx, rx) = pipe::pipe()?;
let tx_fd = tx.into_nonblocking_fd()?;
let rx_fd = rx.into_nonblocking_fd()?;
assert!(is_nonblocking(&tx_fd)?);
assert!(is_nonblocking(&rx_fd)?);
Ok(())
}
#[tokio::test]
async fn anon_pipe_into_bl... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/net_unix_pipe.rs | 521 | 580 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:15 | "closure should have been called, since socket should still be marked as writable"
);
}
{
let mut called = false;
let _ = tx.try_io(|| {
called = true;
io::Result::<()>::Err(io::ErrorKind::WouldBlock.into())
});
assert!(
called,
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/net_unix_pipe.rs | 561 | 620 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:16 | assert!(
!called,
"closure should not have been called, since socket should not be readable"
);
}
// Make `a` readable by writing to `b`.
// Give the runtime some time to update bookkeeping.
tx.write_all(&[0]).await?;
tokio::task::yield_now().await;
{
le... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/net_unix_pipe.rs | 601 | 646 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:6 | .custom_flags(libc::O_NONBLOCK)
.open(&fifo)?;
let mut reader = pipe::Receiver::from_file(file)?;
// Construct a Sender from a File.
let file = std::fs::OpenOptions::new()
.write(true)
.custom_flags(libc::O_NONBLOCK)
.open(&fifo)?;
let mut writer = pipe::Sender::from_fil... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | 5db10f538b683fe88d699dfd11be31d193db011c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5db10f538b683fe88d699dfd11be31d193db011c/tokio/tests/net_unix_pipe.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:7 | let file = std::fs::OpenOptions::new().write(true).open(&path)?;
let err = assert_err!(pipe::Sender::from_file(file));
assert_eq!(err.kind(), io::ErrorKind::InvalidInput);
// Check if Receiver detects invalid file type.
let file = std::fs::OpenOptions::new().read(true).open(&path)?;
let err = asser... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | 5db10f538b683fe88d699dfd11be31d193db011c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5db10f538b683fe88d699dfd11be31d193db011c/tokio/tests/net_unix_pipe.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:8 | let flags = nix::fcntl::fcntl(fd.as_fd(), nix::fcntl::F_GETFL)?;
Ok((flags & libc::O_NONBLOCK) != 0)
}
#[tokio::test]
#[cfg_attr(miri, ignore)] // No `mkfifo` in miri.
async fn from_file_sets_nonblock() -> io::Result<()> {
let fifo = TempFifo::new("sets_nonblock")?;
// Open read and write ends to let bloc... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | 5db10f538b683fe88d699dfd11be31d193db011c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5db10f538b683fe88d699dfd11be31d193db011c/tokio/tests/net_unix_pipe.rs | 281 | 340 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:9 | let writer = pipe::OpenOptions::new().open_sender(&fifo)?;
// Fill the pipe buffer with `try_write`.
let mut write_data = Vec::new();
while writable_by_poll(&writer) {
match writer.try_write(DATA) {
Ok(n) => write_data.extend(&DATA[..n]),
Err(e) => {
assert_e... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | 5db10f538b683fe88d699dfd11be31d193db011c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5db10f538b683fe88d699dfd11be31d193db011c/tokio/tests/net_unix_pipe.rs | 321 | 380 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:10 | let reader = pipe::OpenOptions::new().open_receiver(&fifo)?;
let writer = pipe::OpenOptions::new().open_sender(&fifo)?;
let write_bufs: Vec<_> = DATA.chunks(3).map(io::IoSlice::new).collect();
// Fill the pipe buffer with `try_write_vectored`.
let mut write_data = Vec::new();
while writable_by_pol... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | 5db10f538b683fe88d699dfd11be31d193db011c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5db10f538b683fe88d699dfd11be31d193db011c/tokio/tests/net_unix_pipe.rs | 361 | 420 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:11 | #[tokio::test]
#[cfg_attr(miri, ignore)] // No `mkfifo` in miri.
async fn try_read_buf() -> std::io::Result<()> {
const DATA: &[u8] = b"this is some data to write to the fifo";
// Create a pipe pair over a fifo file.
let fifo = TempFifo::new("try_read_write_vectored")?;
let reader = pipe::OpenOptions::... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | 5db10f538b683fe88d699dfd11be31d193db011c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5db10f538b683fe88d699dfd11be31d193db011c/tokio/tests/net_unix_pipe.rs | 401 | 460 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:12 | }
#[tokio::test]
async fn anon_pipe_simple_send() -> io::Result<()> {
const DATA: &[u8] = b"this is some data to write to the pipe";
let (mut writer, mut reader) = pipe::pipe()?;
// Create a reading task which should wait for data from the pipe.
let mut read_fut = task::spawn(async move {
let... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | 5db10f538b683fe88d699dfd11be31d193db011c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5db10f538b683fe88d699dfd11be31d193db011c/tokio/tests/net_unix_pipe.rs | 441 | 500 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:13 | .arg("-n")
.arg(DATA)
.stdout(tx.into_blocking_fd()?)
.status();
let mut buf = vec![0; DATA.len()];
rx.read_exact(&mut buf).await?;
assert_eq!(String::from_utf8(buf).unwrap(), DATA);
let exit_code = status.await?;
assert!(exit_code.success());
// Check if the pipe is c... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | 5db10f538b683fe88d699dfd11be31d193db011c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5db10f538b683fe88d699dfd11be31d193db011c/tokio/tests/net_unix_pipe.rs | 481 | 540 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:14 | #[tokio::test]
async fn anon_pipe_into_nonblocking_fd() -> std::io::Result<()> {
let (tx, rx) = pipe::pipe()?;
let tx_fd = tx.into_nonblocking_fd()?;
let rx_fd = rx.into_nonblocking_fd()?;
assert!(is_nonblocking(&tx_fd)?);
assert!(is_nonblocking(&rx_fd)?);
Ok(())
}
#[tokio::test]
async fn an... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | 5db10f538b683fe88d699dfd11be31d193db011c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5db10f538b683fe88d699dfd11be31d193db011c/tokio/tests/net_unix_pipe.rs | 521 | 580 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:15 | assert!(
called,
"closure should have been called, since socket should still be marked as writable"
);
}
{
let mut called = false;
let _ = tx.try_io(|| {
called = true;
io::Result::<()>::Err(io::ErrorKind::WouldBlock.into())
});
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | 5db10f538b683fe88d699dfd11be31d193db011c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5db10f538b683fe88d699dfd11be31d193db011c/tokio/tests/net_unix_pipe.rs | 561 | 620 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:16 | Ok(())
});
assert!(
!called,
"closure should not have been called, since socket should not be readable"
);
}
// Make `a` readable by writing to `b`.
// Give the runtime some time to update bookkeeping.
tx.write_all(&[0]).await?;
tokio::task::yield_now... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | 5db10f538b683fe88d699dfd11be31d193db011c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5db10f538b683fe88d699dfd11be31d193db011c/tokio/tests/net_unix_pipe.rs | 601 | 648 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:14 | #[tokio::test]
async fn anon_pipe_into_nonblocking_fd() -> std::io::Result<()> {
let (tx, rx) = pipe::pipe()?;
let tx_fd = tx.into_nonblocking_fd()?;
let rx_fd = rx.into_nonblocking_fd()?;
assert!(is_nonblocking(&tx_fd)?);
assert!(is_nonblocking(&rx_fd)?);
Ok(())
}
#[tokio::test]
async fn an... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | d7db722bb47d29b81c9b98992813115dfaed491d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d7db722bb47d29b81c9b98992813115dfaed491d/tokio/tests/net_unix_pipe.rs | 521 | 546 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:1 | #![cfg(feature = "full")]
#![cfg(unix)]
use tokio::io::{AsyncReadExt, AsyncWriteExt, Interest};
use tokio::net::unix::pipe;
use tokio_test::task;
use tokio_test::{assert_err, assert_ok, assert_pending, assert_ready_ok};
use std::fs::File;
use std::io;
use std::os::unix::fs::OpenOptionsExt;
use std::os::unix::io::AsRa... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | a708ad19cb9ae652d8a813554e68cb1d86593eb9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a708ad19cb9ae652d8a813554e68cb1d86593eb9/tokio/tests/net_unix_pipe.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:7 | let file = std::fs::OpenOptions::new().write(true).open(&path)?;
let err = assert_err!(pipe::Sender::from_file(file));
assert_eq!(err.kind(), io::ErrorKind::InvalidInput);
// Check if Receiver detects invalid file type.
let file = std::fs::OpenOptions::new().read(true).open(&path)?;
let err = asser... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | a708ad19cb9ae652d8a813554e68cb1d86593eb9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a708ad19cb9ae652d8a813554e68cb1d86593eb9/tokio/tests/net_unix_pipe.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:8 | let flags = nix::fcntl::fcntl(fd.as_raw_fd(), nix::fcntl::F_GETFL)?;
Ok((flags & libc::O_NONBLOCK) != 0)
}
#[tokio::test]
#[cfg_attr(miri, ignore)] // No `mkfifo` in miri.
async fn from_file_sets_nonblock() -> io::Result<()> {
let fifo = TempFifo::new("sets_nonblock")?;
// Open read and write ends to let ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | a708ad19cb9ae652d8a813554e68cb1d86593eb9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a708ad19cb9ae652d8a813554e68cb1d86593eb9/tokio/tests/net_unix_pipe.rs | 281 | 340 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:7 | let file = std::fs::OpenOptions::new().write(true).open(&path)?;
let err = assert_err!(pipe::Sender::from_file(file));
assert_eq!(err.kind(), io::ErrorKind::InvalidInput);
// Check if Receiver detects invalid file type.
let file = std::fs::OpenOptions::new().read(true).open(&path)?;
let err = asser... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | 6b705b3053d2c777e05cb60c758202ff9d4b2e7d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6b705b3053d2c777e05cb60c758202ff9d4b2e7d/tokio/tests/net_unix_pipe.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:8 | let flags = nix::fcntl::fcntl(fd.as_raw_fd(), nix::fcntl::F_GETFL)?;
Ok((flags & libc::O_NONBLOCK) != 0)
}
#[tokio::test]
#[cfg_attr(miri, ignore)] // No `mkfifo` in miri.
async fn from_file_sets_nonblock() -> io::Result<()> {
let fifo = TempFifo::new("sets_nonblock")?;
// Open read and write ends to let ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | 6b705b3053d2c777e05cb60c758202ff9d4b2e7d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6b705b3053d2c777e05cb60c758202ff9d4b2e7d/tokio/tests/net_unix_pipe.rs | 281 | 340 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:2 | async fn fifo_simple_send() -> io::Result<()> {
const DATA: &[u8] = b"this is some data to write to the fifo";
let fifo = TempFifo::new("simple_send")?;
// Create a reading task which should wait for data from the pipe.
let mut reader = pipe::OpenOptions::new().open_receiver(&fifo)?;
let mut read_... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | 2440d113ff9841060b1876628c1153f0bcf2945c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2440d113ff9841060b1876628c1153f0bcf2945c/tokio/tests/net_unix_pipe.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:3 | assert_eq!(err.raw_os_error(), Some(libc::ENXIO));
// `open_sender` in read-write mode should succeed and the pipe should be ready to write.
let mut writer = pipe::OpenOptions::new()
.read_write(true)
.open_sender(&fifo)?;
writer.write_all(DATA).await?;
// Read the written data and val... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | 2440d113ff9841060b1876628c1153f0bcf2945c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2440d113ff9841060b1876628c1153f0bcf2945c/tokio/tests/net_unix_pipe.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:4 | assert_ok!(reader.read_exact(&mut read_data).await);
// Check that reader hits EOF.
let err = assert_err!(reader.read_exact(&mut read_data).await);
assert_eq!(err.kind(), io::ErrorKind::UnexpectedEof);
// Write more data and read again.
write_and_close(&fifo, DATA).await?;
assert_ok!(reader.re... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | 2440d113ff9841060b1876628c1153f0bcf2945c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2440d113ff9841060b1876628c1153f0bcf2945c/tokio/tests/net_unix_pipe.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:12 | }
#[tokio::test]
async fn anon_pipe_simple_send() -> io::Result<()> {
const DATA: &[u8] = b"this is some data to write to the pipe";
let (mut writer, mut reader) = pipe::pipe()?;
// Create a reading task which should wait for data from the pipe.
let mut read_fut = task::spawn(async move {
let... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | 4047d7962a02722859b0f1c7bbcd85bc1bfc865d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4047d7962a02722859b0f1c7bbcd85bc1bfc865d/tokio/tests/net_unix_pipe.rs | 441 | 500 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:13 | .arg("-n")
.arg(DATA)
.stdout(tx.into_blocking_fd()?)
.status();
let mut buf = vec![0; DATA.len()];
rx.read_exact(&mut buf).await?;
assert_eq!(String::from_utf8(buf).unwrap(), DATA);
let exit_code = status.await?;
assert!(exit_code.success());
// Check if the pipe is c... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | 4047d7962a02722859b0f1c7bbcd85bc1bfc865d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4047d7962a02722859b0f1c7bbcd85bc1bfc865d/tokio/tests/net_unix_pipe.rs | 481 | 540 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:14 | #[tokio::test]
#[cfg_attr(miri, ignore)] // No F_GETFL for fcntl in miri.
async fn anon_pipe_into_nonblocking_fd() -> std::io::Result<()> {
let (tx, rx) = pipe::pipe()?;
let tx_fd = tx.into_nonblocking_fd()?;
let rx_fd = rx.into_nonblocking_fd()?;
assert!(is_nonblocking(&tx_fd)?);
assert!(is_nonbl... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | 4047d7962a02722859b0f1c7bbcd85bc1bfc865d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4047d7962a02722859b0f1c7bbcd85bc1bfc865d/tokio/tests/net_unix_pipe.rs | 521 | 548 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:1 | #![cfg(feature = "full")]
#![cfg(unix)]
#![cfg(not(miri))]
use tokio::io::{AsyncReadExt, AsyncWriteExt, Interest};
use tokio::net::unix::pipe;
use tokio_test::task;
use tokio_test::{assert_err, assert_ok, assert_pending, assert_ready_ok};
use std::fs::File;
use std::io;
use std::os::unix::fs::OpenOptionsExt;
use std:... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/net_unix_pipe.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:2 | async fn fifo_simple_send() -> io::Result<()> {
const DATA: &[u8] = b"this is some data to write to the fifo";
let fifo = TempFifo::new("simple_send")?;
// Create a reading task which should wait for data from the pipe.
let mut reader = pipe::OpenOptions::new().open_receiver(&fifo)?;
let mut read_... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/net_unix_pipe.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:3 | // `open_sender` in read-write mode should succeed and the pipe should be ready to write.
let mut writer = pipe::OpenOptions::new()
.read_write(true)
.open_sender(&fifo)?;
writer.write_all(DATA).await?;
// Read the written data and validate.
let mut reader = pipe::OpenOptions::new().ope... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/net_unix_pipe.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:4 | // Check that reader hits EOF.
let err = assert_err!(reader.read_exact(&mut read_data).await);
assert_eq!(err.kind(), io::ErrorKind::UnexpectedEof);
// Write more data and read again.
write_and_close(&fifo, DATA).await?;
assert_ok!(reader.read_exact(&mut read_data).await);
Ok(())
}
/// Checks... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/net_unix_pipe.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:5 | Ok(())
}
#[tokio::test]
async fn open_detects_not_a_fifo() -> io::Result<()> {
let dir = tempfile::Builder::new()
.prefix("tokio-fifo-tests")
.tempdir()
.unwrap();
let path = dir.path().join("not_a_fifo");
// Create an ordinary file.
File::create(&path)?;
// Check if Sende... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/net_unix_pipe.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:6 | let file = std::fs::OpenOptions::new()
.write(true)
.custom_flags(libc::O_NONBLOCK)
.open(&fifo)?;
let mut writer = pipe::Sender::from_file(file)?;
// Write and read some data to test async.
let mut read_fut = task::spawn(async move {
let mut buf = vec![0; DATA.len()];
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/net_unix_pipe.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:7 | let err = assert_err!(pipe::Receiver::from_file(file));
assert_eq!(err.kind(), io::ErrorKind::InvalidInput);
Ok(())
}
#[tokio::test]
async fn from_file_detects_wrong_access_mode() -> io::Result<()> {
let fifo = TempFifo::new("wrong_access_mode")?;
// Open a read end to open the fifo for writing.
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/net_unix_pipe.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:8 | // Open read and write ends to let blocking files open.
let _reader = pipe::OpenOptions::new().open_receiver(&fifo)?;
let _writer = pipe::OpenOptions::new().open_sender(&fifo)?;
// Check if Receiver sets the pipe in non-blocking mode.
let rdonly = std::fs::OpenOptions::new().read(true).open(&fifo)?;
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/net_unix_pipe.rs | 281 | 340 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:9 | break;
}
}
}
// Drain the pipe buffer with `try_read`.
let mut read_data = vec![0; write_data.len()];
let mut i = 0;
while i < write_data.len() {
reader.readable().await?;
match reader.try_read(&mut read_data[i..]) {
Ok(n) => i += n,
Err(e... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/net_unix_pipe.rs | 321 | 380 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:10 | Err(e) => {
assert_eq!(e.kind(), io::ErrorKind::WouldBlock);
break;
}
}
}
// Drain the pipe buffer with `try_read_vectored`.
let mut read_data = vec![0; write_data.len()];
let mut i = 0;
while i < write_data.len() {
reader.readable().await... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/net_unix_pipe.rs | 361 | 420 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:11 | // Fill the pipe buffer with `try_write`.
let mut write_data = Vec::new();
while writable_by_poll(&writer) {
match writer.try_write(DATA) {
Ok(n) => write_data.extend(&DATA[..n]),
Err(e) => {
assert_eq!(e.kind(), io::ErrorKind::WouldBlock);
break;
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/net_unix_pipe.rs | 401 | 460 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:12 | reader.read_exact(&mut buf).await?;
Ok::<_, io::Error>(buf)
});
assert_pending!(read_fut.poll());
writer.write_all(DATA).await?;
// Let the IO driver poll events for the reader.
while !read_fut.is_woken() {
tokio::task::yield_now().await;
}
// Reading task should be ready ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/net_unix_pipe.rs | 441 | 500 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:13 | // Check if the pipe is closed.
buf = Vec::new();
let total = assert_ok!(rx.try_read(&mut buf));
assert_eq!(total, 0);
Ok(())
}
#[tokio::test]
#[cfg(target_os = "linux")]
async fn anon_pipe_from_owned_fd() -> std::io::Result<()> {
use nix::fcntl::OFlag;
const DATA: &[u8] = b"this is some data... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/net_unix_pipe.rs | 481 | 533 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:14 | #[tokio::test]
async fn anon_pipe_into_blocking_fd() -> std::io::Result<()> {
let (tx, rx) = pipe::pipe()?;
let tx_fd = tx.into_blocking_fd()?;
let rx_fd = rx.into_blocking_fd()?;
assert!(!is_nonblocking(&tx_fd)?);
assert!(!is_nonblocking(&rx_fd)?);
Ok(())
} | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/net_unix_pipe.rs | 521 | 533 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:1 | #![cfg(feature = "full")]
#![cfg(unix)]
use tokio::io::{AsyncReadExt, AsyncWriteExt, Interest};
use tokio::net::unix::pipe;
use tokio_test::task;
use tokio_test::{assert_err, assert_ok, assert_pending, assert_ready_ok};
use std::fs::File;
use std::io;
use std::os::unix::fs::OpenOptionsExt;
use std::os::unix::io::AsRa... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | 12920cea45e81bf831eb7174a3337b6d06b0b27d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12920cea45e81bf831eb7174a3337b6d06b0b27d/tokio/tests/net_unix_pipe.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:2 | const DATA: &[u8] = b"this is some data to write to the fifo";
let fifo = TempFifo::new("simple_send")?;
// Create a reading task which should wait for data from the pipe.
let mut reader = pipe::OpenOptions::new().open_receiver(&fifo)?;
let mut read_fut = task::spawn(async move {
let mut buf =... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | 12920cea45e81bf831eb7174a3337b6d06b0b27d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12920cea45e81bf831eb7174a3337b6d06b0b27d/tokio/tests/net_unix_pipe.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:3 | // `open_sender` in read-write mode should succeed and the pipe should be ready to write.
let mut writer = pipe::OpenOptions::new()
.read_write(true)
.open_sender(&fifo)?;
writer.write_all(DATA).await?;
// Read the written data and validate.
let mut reader = pipe::OpenOptions::new().ope... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | 12920cea45e81bf831eb7174a3337b6d06b0b27d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12920cea45e81bf831eb7174a3337b6d06b0b27d/tokio/tests/net_unix_pipe.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:4 | let err = assert_err!(reader.read_exact(&mut read_data).await);
assert_eq!(err.kind(), io::ErrorKind::UnexpectedEof);
// Write more data and read again.
write_and_close(&fifo, DATA).await?;
assert_ok!(reader.read_exact(&mut read_data).await);
Ok(())
}
/// Checks behavior of a resilient reader (Re... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | 12920cea45e81bf831eb7174a3337b6d06b0b27d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12920cea45e81bf831eb7174a3337b6d06b0b27d/tokio/tests/net_unix_pipe.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:5 | Ok(())
}
#[tokio::test]
async fn open_detects_not_a_fifo() -> io::Result<()> {
let dir = tempfile::Builder::new()
.prefix("tokio-fifo-tests")
.tempdir()
.unwrap();
let path = dir.path().join("not_a_fifo");
// Create an ordinary file.
File::create(&path)?;
// Check if Sende... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | 12920cea45e81bf831eb7174a3337b6d06b0b27d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12920cea45e81bf831eb7174a3337b6d06b0b27d/tokio/tests/net_unix_pipe.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:6 | .write(true)
.custom_flags(libc::O_NONBLOCK)
.open(&fifo)?;
let mut writer = pipe::Sender::from_file(file)?;
// Write and read some data to test async.
let mut read_fut = task::spawn(async move {
let mut buf = vec![0; DATA.len()];
reader.read_exact(&mut buf).await?;
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | 12920cea45e81bf831eb7174a3337b6d06b0b27d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12920cea45e81bf831eb7174a3337b6d06b0b27d/tokio/tests/net_unix_pipe.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:7 | assert_eq!(err.kind(), io::ErrorKind::InvalidInput);
Ok(())
}
#[tokio::test]
async fn from_file_detects_wrong_access_mode() -> io::Result<()> {
let fifo = TempFifo::new("wrong_access_mode")?;
// Open a read end to open the fifo for writing.
let _reader = pipe::OpenOptions::new().open_receiver(&fifo)?... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | 12920cea45e81bf831eb7174a3337b6d06b0b27d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12920cea45e81bf831eb7174a3337b6d06b0b27d/tokio/tests/net_unix_pipe.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:9 | }
}
}
// Drain the pipe buffer with `try_read`.
let mut read_data = vec![0; write_data.len()];
let mut i = 0;
while i < write_data.len() {
reader.readable().await?;
match reader.try_read(&mut read_data[i..]) {
Ok(n) => i += n,
Err(e) => {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | 12920cea45e81bf831eb7174a3337b6d06b0b27d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12920cea45e81bf831eb7174a3337b6d06b0b27d/tokio/tests/net_unix_pipe.rs | 321 | 380 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:10 | assert_eq!(e.kind(), io::ErrorKind::WouldBlock);
break;
}
}
}
// Drain the pipe buffer with `try_read_vectored`.
let mut read_data = vec![0; write_data.len()];
let mut i = 0;
while i < write_data.len() {
reader.readable().await?;
let mut read_buf... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | 12920cea45e81bf831eb7174a3337b6d06b0b27d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12920cea45e81bf831eb7174a3337b6d06b0b27d/tokio/tests/net_unix_pipe.rs | 361 | 420 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:11 | let mut write_data = Vec::new();
while writable_by_poll(&writer) {
match writer.try_write(DATA) {
Ok(n) => write_data.extend(&DATA[..n]),
Err(e) => {
assert_eq!(e.kind(), io::ErrorKind::WouldBlock);
break;
}
}
}
// Drain th... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | 12920cea45e81bf831eb7174a3337b6d06b0b27d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12920cea45e81bf831eb7174a3337b6d06b0b27d/tokio/tests/net_unix_pipe.rs | 401 | 460 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:12 | Ok::<_, io::Error>(buf)
});
assert_pending!(read_fut.poll());
writer.write_all(DATA).await?;
// Let the IO driver poll events for the reader.
while !read_fut.is_woken() {
tokio::task::yield_now().await;
}
// Reading task should be ready now.
let read_data = assert_ready_ok!(re... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | 12920cea45e81bf831eb7174a3337b6d06b0b27d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12920cea45e81bf831eb7174a3337b6d06b0b27d/tokio/tests/net_unix_pipe.rs | 441 | 500 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:13 | buf = Vec::new();
let total = assert_ok!(rx.try_read(&mut buf));
assert_eq!(total, 0);
Ok(())
}
#[tokio::test]
#[cfg(target_os = "linux")]
async fn anon_pipe_from_owned_fd() -> std::io::Result<()> {
use nix::fcntl::OFlag;
const DATA: &[u8] = b"this is some data to write to the pipe";
let (rx... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | 12920cea45e81bf831eb7174a3337b6d06b0b27d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12920cea45e81bf831eb7174a3337b6d06b0b27d/tokio/tests/net_unix_pipe.rs | 481 | 532 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:12 | Ok::<_, io::Error>(buf)
});
assert_pending!(read_fut.poll());
writer.write_all(DATA).await?;
// Let the IO driver poll events for the reader.
while !read_fut.is_woken() {
tokio::task::yield_now().await;
}
// Reading task should be ready now.
let read_data = assert_ready_ok!(re... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | 48345d6e4822b4c0ea00d5c1c075a6b5ac663acf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/48345d6e4822b4c0ea00d5c1c075a6b5ac663acf/tokio/tests/net_unix_pipe.rs | 441 | 500 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:13 | buf = Vec::new();
let total = assert_ok!(rx.try_read(&mut buf));
assert_eq!(total, 0);
Ok(())
}
#[tokio::test]
#[cfg(target_os = "linux")]
async fn anon_pipe_from_owned_fd() -> std::io::Result<()> {
use nix::fcntl::OFlag;
use std::os::unix::io::{FromRawFd, OwnedFd};
const DATA: &[u8] = b"this... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | 48345d6e4822b4c0ea00d5c1c075a6b5ac663acf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/48345d6e4822b4c0ea00d5c1c075a6b5ac663acf/tokio/tests/net_unix_pipe.rs | 481 | 534 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:14 | }
#[tokio::test]
async fn anon_pipe_into_blocking_fd() -> std::io::Result<()> {
let (tx, rx) = pipe::pipe()?;
let tx_fd = tx.into_blocking_fd()?;
let rx_fd = rx.into_blocking_fd()?;
assert!(!is_nonblocking(&tx_fd)?);
assert!(!is_nonblocking(&rx_fd)?);
Ok(())
} | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | 48345d6e4822b4c0ea00d5c1c075a6b5ac663acf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/48345d6e4822b4c0ea00d5c1c075a6b5ac663acf/tokio/tests/net_unix_pipe.rs | 521 | 534 |
tokio-rs/tokio:tokio/tests/net_unix_pipe.rs:11 | let mut write_data = Vec::new();
while writable_by_poll(&writer) {
match writer.try_write(DATA) {
Ok(n) => write_data.extend(&DATA[..n]),
Err(e) => {
assert_eq!(e.kind(), io::ErrorKind::WouldBlock);
break;
}
}
}
// Drain th... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/net_unix_pipe.rs | MIT | 5a3abe56eeb03b383a994375026b370161a05946 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5a3abe56eeb03b383a994375026b370161a05946/tokio/tests/net_unix_pipe.rs | 401 | 429 |
tokio-rs/tokio:tokio/tests/no_rt.rs:1 | #![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support panic recovery
use tokio::net::TcpStream;
use tokio::sync::oneshot;
use tokio::time::{timeout, Duration};
use futures::executor::block_on;
use std::net::TcpListener;
#[test]
#[should_panic(
expected = "there is no reactor running, ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/no_rt.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/no_rt.rs | 1 | 47 |
tokio-rs/tokio:tokio/tests/no_rt.rs:1 | #![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support panic recovery
use tokio::net::TcpStream;
use tokio::sync::oneshot;
use tokio::time::{timeout, Duration};
use futures::executor::block_on;
use std::net::TcpListener;
#[test]
#[should_panic(
expected = "there is no reactor running, ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/no_rt.rs | MIT | 4047d7962a02722859b0f1c7bbcd85bc1bfc865d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4047d7962a02722859b0f1c7bbcd85bc1bfc865d/tokio/tests/no_rt.rs | 1 | 43 |
tokio-rs/tokio:tokio/tests/no_rt.rs:1 | #![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi does not support panic recovery
use tokio::net::TcpStream;
use tokio::sync::oneshot;
use tokio::time::{timeout, Duration};
use futures::executor::block_on;
use std::net::TcpListener;
#[test]
#[should_panic(
expected = "there is no reacto... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/no_rt.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/no_rt.rs | 1 | 41 |
tokio-rs/tokio:tokio/tests/no_rt.rs:1 | #![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support panic recovery
use tokio::net::TcpStream;
use tokio::sync::oneshot;
use tokio::time::{timeout, Duration};
use futures::executor::block_on;
use std::net::TcpListener;
#[test]
#[should_panic(
expected = "there is no reactor running, ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/no_rt.rs | MIT | c445e467ce4363b3a9b6825268814a9bc27c0127 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/no_rt.rs | 1 | 41 |
tokio-rs/tokio:tokio/tests/no_rt.rs:1 | #![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi does not support panic recovery
use tokio::net::TcpStream;
use tokio::sync::oneshot;
use tokio::time::{timeout, Duration};
use futures::executor::block_on;
use std::net::TcpListener;
#[test]
#[should_panic(
expected = "there is no reactor running, must be ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/no_rt.rs | MIT | b2ada60e701d5c9e6644cf8fc42a100774f8e23f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/tests/no_rt.rs | 1 | 41 |
tokio-rs/tokio:tokio/tests/no_rt.rs:1 | #![cfg(feature = "full")]
use tokio::net::TcpStream;
use tokio::sync::oneshot;
use tokio::time::{timeout, Duration};
use futures::executor::block_on;
use std::net::TcpListener;
#[test]
#[should_panic(
expected = "there is no reactor running, must be called from the context of a Tokio 1.x runtime"
)]
fn timeout_... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/no_rt.rs | MIT | 2747043f6f7e0870cc5aa72c146dfae9543c5ba8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2747043f6f7e0870cc5aa72c146dfae9543c5ba8/tokio/tests/no_rt.rs | 1 | 41 |
tokio-rs/tokio:tokio/tests/no_rt.rs:1 | use tokio::net::TcpStream;
use tokio::sync::oneshot;
use tokio::time::{timeout, Duration};
use futures::executor::block_on;
use std::net::TcpListener;
#[test]
#[should_panic(
expected = "there is no reactor running, must be called from the context of a Tokio 1.x runtime"
)]
fn timeout_panics_when_no_tokio_contex... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/no_rt.rs | MIT | 0d9430b99cc699824cc8545afbb01e0a7c520428 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0d9430b99cc699824cc8545afbb01e0a7c520428/tokio/tests/no_rt.rs | 1 | 39 |
tokio-rs/tokio:tokio/tests/no_rt.rs:1 | use tokio::net::TcpStream;
use tokio::sync::oneshot;
use tokio::time::{timeout, Duration};
use futures::executor::block_on;
use std::net::TcpListener;
#[test]
#[should_panic(
expected = "there is no reactor running, must be called from the context of a Tokio 1.x runtime"
)]
fn timeout_panics_when_no_tokio_contex... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/no_rt.rs | MIT | fdde5583f853655fec57c44928b7d5f01621b754 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fdde5583f853655fec57c44928b7d5f01621b754/tokio/tests/no_rt.rs | 1 | 39 |
tokio-rs/tokio:tokio/tests/no_rt.rs:1 | use tokio::net::TcpStream;
use tokio::sync::oneshot;
use tokio::time::{timeout, Duration};
use futures::executor::block_on;
use std::net::TcpListener;
#[test]
#[should_panic(expected = "no timer running")]
fn panics_when_no_timer() {
block_on(timeout_value());
}
#[test]
#[should_panic(expected = "no reactor run... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/no_rt.rs | MIT | 9eca96aa214cb8e2fd695cbed179f93826b3ef46 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9eca96aa214cb8e2fd695cbed179f93826b3ef46/tokio/tests/no_rt.rs | 1 | 27 |
tokio-rs/tokio:tokio/tests/pipe-hup.rs:1 | #![cfg(feature = "broken")]
#![cfg(unix)]
#![deny(warnings, rust_2018_idioms)]
use env_logger;
use futures::Future;
use libc;
use mio;
use mio::event::Evented;
use mio::unix::{EventedFd, UnixReady};
use mio::{PollOpt, Ready, Token};
use std::fs::File;
use std::io::{self, Write};
use std::os::unix::io::{AsRawFd, FromRa... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/pipe-hup.rs | MIT | 29e417c257c62ae95cfa73f6b56825b3f833dde8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/29e417c257c62ae95cfa73f6b56825b3f833dde8/tokio/tests/pipe-hup.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/pipe-hup.rs:2 | impl io::Read for MyFile {
fn read(&mut self, bytes: &mut [u8]) -> io::Result<usize> {
self.0.read(bytes)
}
}
impl Evented for MyFile {
fn register(
&self,
poll: &mio::Poll,
token: Token,
interest: Ready,
opts: PollOpt,
) -> io::Result<()> {
let h... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/pipe-hup.rs | MIT | 29e417c257c62ae95cfa73f6b56825b3f833dde8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/29e417c257c62ae95cfa73f6b56825b3f833dde8/tokio/tests/pipe-hup.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/pipe-hup.rs:3 | libc::pipe(pipes.as_mut_ptr()) != -1,
"pipe error: {}",
io::Error::last_os_error()
);
let read = File::from_raw_fd(pipes[0]);
let mut write = File::from_raw_fd(pipes[1]);
let t = thread::spawn(move || {
write.write_all(b"Hello!\n").unwrap();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/pipe-hup.rs | MIT | 29e417c257c62ae95cfa73f6b56825b3f833dde8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/29e417c257c62ae95cfa73f6b56825b3f833dde8/tokio/tests/pipe-hup.rs | 81 | 100 |
tokio-rs/tokio:tokio/tests/pipe-hup.rs:1 | #![cfg(unix)]
#![deny(warnings, rust_2018_idioms)]
use env_logger;
use futures::Future;
use libc;
use mio;
use mio::event::Evented;
use mio::unix::{EventedFd, UnixReady};
use mio::{PollOpt, Ready, Token};
use std::fs::File;
use std::io::{self, Write};
use std::os::unix::io::{AsRawFd, FromRawFd};
use std::thread;
use s... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/pipe-hup.rs | MIT | cb4aea394e6851ae8cc45a68beeaf2c93cc9a0c0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cb4aea394e6851ae8cc45a68beeaf2c93cc9a0c0/tokio/tests/pipe-hup.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/pipe-hup.rs:2 | fn read(&mut self, bytes: &mut [u8]) -> io::Result<usize> {
self.0.read(bytes)
}
}
impl Evented for MyFile {
fn register(
&self,
poll: &mio::Poll,
token: Token,
interest: Ready,
opts: PollOpt,
) -> io::Result<()> {
let hup: Ready = UnixReady::hup().in... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/pipe-hup.rs | MIT | cb4aea394e6851ae8cc45a68beeaf2c93cc9a0c0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cb4aea394e6851ae8cc45a68beeaf2c93cc9a0c0/tokio/tests/pipe-hup.rs | 41 | 99 |
tokio-rs/tokio:tokio/tests/pipe-hup.rs:3 | "pipe error: {}",
io::Error::last_os_error()
);
let read = File::from_raw_fd(pipes[0]);
let mut write = File::from_raw_fd(pipes[1]);
let t = thread::spawn(move || {
write.write_all(b"Hello!\n").unwrap();
write.write_all(b"Good bye!\n").unwrap();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/pipe-hup.rs | MIT | cb4aea394e6851ae8cc45a68beeaf2c93cc9a0c0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cb4aea394e6851ae8cc45a68beeaf2c93cc9a0c0/tokio/tests/pipe-hup.rs | 81 | 99 |
tokio-rs/tokio:tokio/tests/process_arg0.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", unix, not(miri)))]
use tokio::process::Command;
#[tokio::test]
async fn arg0() {
let mut cmd = Command::new("sh");
cmd.arg0("test_string").arg("-c").arg("echo $0");
let output = cmd.output().await.unwrap();
assert_eq!(output.stdout, b"test_strin... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/process_arg0.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/process_arg0.rs | 1 | 13 |
tokio-rs/tokio:tokio/tests/process_arg0.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", unix))]
use tokio::process::Command;
#[tokio::test]
async fn arg0() {
let mut cmd = Command::new("sh");
cmd.arg0("test_string").arg("-c").arg("echo $0");
let output = cmd.output().await.unwrap();
assert_eq!(output.stdout, b"test_string\n");
} | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/process_arg0.rs | MIT | c85a0e524e171531770cdb04521a61033747b3c3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c85a0e524e171531770cdb04521a61033747b3c3/tokio/tests/process_arg0.rs | 1 | 13 |
tokio-rs/tokio:tokio/tests/process_change_of_runtime.rs:1 | #![cfg(feature = "process")]
#![warn(rust_2018_idioms)]
// This tests test the behavior of `process::Command::spawn` when it is used
// outside runtime, and when `process::Child::wait ` is used in a different
// runtime from which `process::Command::spawn` is used.
#![cfg(all(unix, not(target_os = "freebsd"), not(miri)... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/process_change_of_runtime.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/process_change_of_runtime.rs | 1 | 34 |
tokio-rs/tokio:tokio/tests/process_change_of_runtime.rs:1 | #![cfg(feature = "process")]
#![warn(rust_2018_idioms)]
// This tests test the behavior of `process::Command::spawn` when it is used
// outside runtime, and when `process::Child::wait ` is used in a different
// runtime from which `process::Command::spawn` is used.
#![cfg(all(unix, not(target_os = "freebsd"), not(miri)... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/process_change_of_runtime.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/process_change_of_runtime.rs | 1 | 34 |
tokio-rs/tokio:tokio/tests/process_change_of_runtime.rs:1 | #![cfg(feature = "process")]
#![warn(rust_2018_idioms)]
// This tests test the behavior of `process::Command::spawn` when it is used
// outside runtime, and when `process::Child::wait ` is used in a different
// runtime from which `process::Command::spawn` is used.
#![cfg(all(unix, not(target_os = "freebsd")))]
use st... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/process_change_of_runtime.rs | MIT | e4f9bcb5775a8cbbc848aedea3ad49aa60dd1dae | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e4f9bcb5775a8cbbc848aedea3ad49aa60dd1dae/tokio/tests/process_change_of_runtime.rs | 1 | 34 |
tokio-rs/tokio:tokio/tests/process_issue_2174.rs:1 | #![cfg(feature = "process")]
#![warn(rust_2018_idioms)]
// This test reveals a difference in behavior of kqueue on FreeBSD. When the
// reader disconnects, there does not seem to be an `EVFILT_WRITE` filter that
// is returned.
//
// It is expected that `EVFILT_WRITE` would be returned with either the
// `EV_EOF` or `E... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/process_issue_2174.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/process_issue_2174.rs | 1 | 46 |
tokio-rs/tokio:tokio/tests/process_issue_2174.rs:1 | #![cfg(feature = "process")]
#![warn(rust_2018_idioms)]
// This test reveals a difference in behavior of kqueue on FreeBSD. When the
// reader disconnects, there does not seem to be an `EVFILT_WRITE` filter that
// is returned.
//
// It is expected that `EVFILT_WRITE` would be returned with either the
// `EV_EOF` or `E... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/process_issue_2174.rs | MIT | 58edfc61abe4acdc2dda485c1d66715790b9315c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/58edfc61abe4acdc2dda485c1d66715790b9315c/tokio/tests/process_issue_2174.rs | 1 | 46 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.