repo
stringclasses
7 values
lang
stringclasses
2 values
aspect
stringclasses
7 values
file
stringlengths
5
48
content
stringlengths
283
144k
tokio
rust
async_runtime
tracing_task.rs
#![warn(rust_2018_idioms)] #![cfg(all(tokio_unstable, feature = "tracing", target_has_atomic = "64"))] use std::{mem, time::Duration}; use tokio::task; use tracing_mock::{expect, span::NewSpan, subscriber}; static TEST_MUTEX: std::sync::Mutex<()> = std::sync::Mutex::new(()); fn run_test<F: std::future::Future>(f: i...
tokio
rust
async_runtime
rt_panic.rs
#![warn(rust_2018_idioms)] #![cfg(any( feature = "full", all(target_os = "emscripten", feature = "rt", feature = "macros") ))] #![cfg(not(target_os = "wasi"))] // Wasi doesn't support panic recovery #![cfg(panic = "unwind")] use futures::future; use std::error::Error; #[cfg(feature = "rt-multi-thread")] use to...
tokio
rust
async_runtime
net_quickack.rs
#![warn(rust_2018_idioms)] #![cfg(all( feature = "net", any( target_os = "linux", target_os = "android", target_os = "fuchsia", target_os = "cygwin", ) ))] #![cfg(not(miri))] // Miri doesn't support TCP quickack socket option. use tokio::io::{AsyncReadExt, AsyncWriteExt}; us...
tokio
rust
async_runtime
fs_uring_runtime_shutdown.rs
#![cfg(all( tokio_unstable, feature = "io-uring", feature = "rt", feature = "fs", target_os = "linux" ))] use futures::FutureExt; use std::fs; use std::future::poll_fn; use std::task::Poll; use std::time::{Duration, Instant}; use tempfile::NamedTempFile; use tokio::runtime::Builder; use tokio_test:...
tokio
rust
async_runtime
time_pause.rs
#![warn(rust_2018_idioms)] #![cfg(any( feature = "full", all( target_os = "emscripten", feature = "rt", feature = "macros", feature = "test-util" ) ))] #![cfg(not(miri))] // Too slow on miri. use rand::SeedableRng; use rand::{rngs::StdRng, Rng}; use tokio::time::{self, Durat...
tokio
rust
async_runtime
sync_errors.rs
#![warn(rust_2018_idioms)] #![cfg(feature = "sync")] #[cfg(all(target_family = "wasm", target_os = "unknown"))] use wasm_bindgen_test::wasm_bindgen_test as test; fn is_error<T: std::error::Error + Send + Sync>() {} #[test] fn mpsc_error_bound() { use tokio::sync::mpsc::error; is_error::<error::SendError<()>...
tokio
rust
async_runtime
fs_remove_file.rs
#![warn(rust_2018_idioms)] #![cfg(all( any( feature = "full", all( target_os = "emscripten", feature = "fs", feature = "macros", feature = "rt", feature = "io-util" ) ), not(target_os = "wasi") ))] // WASI does not support a...
tokio
rust
async_runtime
unix_shutdown.rs
#![warn(rust_2018_idioms)] #![cfg(all(feature = "full", unix))] // Unix domain sockets are only available on Unix #![cfg(not(miri))] // No Unix domain sockets on miri. use tokio::io::{AsyncReadExt, AsyncWriteExt}; use tokio::net::UnixStream; use tokio_test::assert_ok; #[tokio::test] async fn shutdown() { let (mut...
tokio
rust
async_runtime
rt_poll_callbacks.rs
#![allow(unknown_lints, unexpected_cfgs)] #![cfg(tokio_unstable)] use std::sync::{atomic::AtomicUsize, Arc, Mutex}; use tokio::task::yield_now; #[cfg(not(target_os = "wasi"))] #[test] fn callbacks_fire_multi_thread() { let poll_start_counter = Arc::new(AtomicUsize::new(0)); let poll_stop_counter = Arc::new(A...
tokio
rust
async_runtime
tcp_accept.rs
#![warn(rust_2018_idioms)] // WASIp1 doesn't support bind #![cfg(all( feature = "net", feature = "macros", feature = "rt", feature = "io-util", not(all(target_os = "wasi", target_env = "p1")), ))] use tokio::net::{TcpListener, TcpStream}; use tokio::sync::{mpsc, oneshot}; use tokio_test::assert_ok;...
tokio
rust
async_runtime
fs_uring_rename.rs
#![cfg(all( tokio_unstable, feature = "io-uring", feature = "rt", feature = "fs", target_os = "linux" ))] use futures::future::FutureExt; use libc::PATH_MAX; use std::future::{pending, poll_fn}; use std::io::Write; use std::path::PathBuf; use std::sync::mpsc; use std::task::Poll; use std::time::Dur...
tokio
rust
async_runtime
uds_split.rs
#![warn(rust_2018_idioms)] #![cfg(feature = "full")] #![cfg(unix)] #![cfg(not(miri))] // No Unix domain sockets in miri. use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt}; use tokio::net::UnixStream; /// Checks that `UnixStream` can be split into a read half and a write half using /// `UnixStream::s...
tokio
rust
async_runtime
signal_info.rs
#![warn(rust_2018_idioms)] #![cfg(feature = "full")] #![cfg(any( target_os = "dragonfly", target_os = "freebsd", target_os = "macos", target_os = "netbsd", target_os = "openbsd", target_os = "illumos" ))] #![cfg(not(miri))] // No `sigaction` on Miri mod support { pub mod signal; } use suppo...
tokio
rust
async_runtime
rt_common_before_park.rs
#![warn(rust_2018_idioms)] #![cfg(feature = "full")] #![cfg(not(target_os = "wasi"))] // Wasi doesn't support threads use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; use std::time::Duration; use tokio::runtime::Builder; use tokio::sync::Notify; #[test] fn before_park_wakes_block_on_task() { let...
tokio
rust
async_runtime
process_issue_7144.rs
#![cfg(feature = "process")] #![warn(rust_2018_idioms)] #![cfg(target_os = "linux")] #![cfg(not(miri))] use tokio::process::Command; use tokio::time::{sleep, Duration}; #[tokio::test] async fn issue_7144() { let mut threads = vec![]; for _ in 0..20 { threads.push(tokio::spawn(test_one())); } f...
tokio
rust
async_runtime
io_read_to_end.rs
#![warn(rust_2018_idioms)] #![cfg(any( feature = "full", all( target_os = "emscripten", feature = "rt", feature = "macros", feature = "io-util" ) ))] use std::io; use std::pin::Pin; use std::task::{Context, Poll}; use tokio::io::{AsyncRead, AsyncReadExt, ReadBuf}; use tokio_...
tokio
rust
async_runtime
signal_panic.rs
#![warn(rust_2018_idioms)] #![cfg(feature = "full")] #![cfg(unix)] #![cfg(panic = "unwind")] #![cfg(not(miri))] // No `sigaction` on Miri. use std::error::Error; use tokio::runtime::Builder; use tokio::signal::unix::{signal, SignalKind}; mod support { pub mod panic; } use support::panic::test_panic; #[test] fn s...
tokio
rust
async_runtime
task_local_set.rs
#![warn(rust_2018_idioms)] #![cfg(feature = "full")] use futures::{ future::{pending, ready}, FutureExt, }; use tokio::runtime; use tokio::sync::{mpsc, oneshot}; use tokio::task::{self, LocalSet}; use tokio::time; #[cfg(not(target_os = "wasi"))] use std::cell::Cell; use std::sync::atomic::AtomicBool; #[cfg(n...
tokio
rust
async_runtime
task_hooks.rs
#![warn(rust_2018_idioms)] #![cfg(all(feature = "full", tokio_unstable, target_has_atomic = "64"))] use std::collections::HashSet; use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::{Arc, Mutex}; #[cfg(feature = "schedule-latency")] use std::time::{Duration, Instant}; use tokio::runtime::Builder; const T...
tokio
rust
async_runtime
sync_semaphore_owned.rs
#![cfg(feature = "sync")] #[cfg(all(target_family = "wasm", target_os = "unknown"))] use wasm_bindgen_test::wasm_bindgen_test as test; use std::sync::Arc; use tokio::sync::Semaphore; #[test] fn try_acquire() { let sem = Arc::new(Semaphore::new(1)); { let p1 = sem.clone().try_acquire_owned(); ...
tokio
rust
async_runtime
sync_broadcast_weak.rs
#![allow(clippy::redundant_clone)] #![warn(rust_2018_idioms)] #![cfg(feature = "sync")] #[cfg(all(target_family = "wasm", target_os = "unknown"))] use wasm_bindgen_test::wasm_bindgen_test as test; use tokio::sync::broadcast::{self, channel}; #[tokio::test] async fn weak_sender() { let (tx, mut rx) = channel(11);...
tokio
rust
async_runtime
rt_handle.rs
#![warn(rust_2018_idioms)] #![cfg(any( feature = "full", all(target_os = "emscripten", feature = "rt", feature = "macros") ))] use std::sync::Arc; use tokio::runtime::Runtime; use tokio::sync::{mpsc, Barrier}; #[test] #[cfg_attr(panic = "abort", ignore)] fn basic_enter() { let rt1 = rt(); let rt2 = rt...
tokio
rust
async_runtime
rt_time_start_paused.rs
#![cfg(any( feature = "full", all( target_os = "emscripten", feature = "rt", feature = "macros", feature = "test-util" ) ))] use tokio::time::{Duration, Instant}; #[tokio::test(start_paused = true)] async fn test_start_paused() { let now = Instant::now(); // Pause ...
tokio
rust
async_runtime
signal_notify_both.rs
#![warn(rust_2018_idioms)] #![cfg(feature = "full")] #![cfg(unix)] #![cfg(not(miri))] // No `sigaction` on Miri. mod support { pub mod signal; } use support::signal::send_signal; use tokio::signal::unix::{signal, SignalKind}; #[tokio::test] async fn notify_both() { let kind = SignalKind::user_defined2(); ...
tokio
rust
async_runtime
io_driver_drop.rs
#![warn(rust_2018_idioms)] #![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support bind use tokio::net::TcpListener; use tokio::runtime; use tokio_test::{assert_err, assert_pending, assert_ready, task}; use futures::task::{waker_ref, ArcWake}; use std::sync::atomic::{AtomicBool, Ordering}; us...
tokio
rust
async_runtime
process_issue_7051.rs
#![cfg(feature = "process")] #![warn(rust_2018_idioms)] #![cfg(target_os = "linux")] #![cfg(not(miri))] use std::process::Stdio; use tokio::io::AsyncReadExt; use tokio::process::Command; use tokio::time::{timeout, Duration}; // A read on a packet mode pipe returns a single packet, so a read that is shorter than the b...
tokio
rust
async_runtime
signal_ctrl_c.rs
#![warn(rust_2018_idioms)] #![cfg(feature = "full")] #![cfg(unix)] #![cfg(not(miri))] // No `sigaction` on Miri mod support { pub mod signal; } use support::signal::send_signal; use tokio::signal; use tokio_test::assert_ok; #[tokio::test] async fn ctrl_c() { let ctrl_c = signal::ctrl_c(); tokio::spawn(a...
tokio
rust
async_runtime
fs_uring_statx.rs
#![cfg(all( tokio_unstable, feature = "io-uring", feature = "rt", feature = "fs", target_os = "linux" ))] use futures::future::FutureExt; use libc::PATH_MAX; use std::future::{pending, poll_fn}; use std::io::Write; use std::os::unix::fs::PermissionsExt; use std::path::PathBuf; use std::sync::mpsc; ...
tokio
rust
async_runtime
rt_unstable_metrics.rs
#![warn(rust_2018_idioms)] #![cfg(all( feature = "full", tokio_unstable, not(target_os = "wasi"), target_has_atomic = "64" ))] use std::future::Future; use std::sync::{mpsc, Arc, Mutex}; use std::task::Poll; use std::thread; use tokio::macros::support::poll_fn; use tokio::runtime::{HistogramConfigurat...
tokio
rust
async_runtime
sync_once_cell.rs
#![warn(rust_2018_idioms)] #![cfg(any( feature = "full", all( target_os = "emscripten", feature = "rt", feature = "macros", feature = "test-util" ) ))] use std::mem; use std::sync::atomic::{AtomicU32, Ordering}; use std::sync::Arc; use std::time::Duration; use tokio::runtime...
tokio
rust
async_runtime
process_issue_42.rs
#![warn(rust_2018_idioms)] #![cfg(feature = "full")] #![cfg(unix)] #![cfg(not(miri))] use futures::future::join_all; use std::process::Stdio; use tokio::process::Command; use tokio::task; #[tokio::test] async fn issue_42() { // We spawn a many batches of processes which should exit at roughly the // same time...
tokio
rust
async_runtime
fs_write.rs
#![warn(rust_2018_idioms)] #![cfg(all( any( feature = "full", all( target_os = "emscripten", feature = "fs", feature = "macros", feature = "rt", feature = "io-util" ) ), not(target_os = "wasi") ))] // WASI does not support a...
tokio
rust
async_runtime
time_wasm.rs
#![warn(rust_2018_idioms)] #![cfg(all( target_arch = "wasm32", not(target_os = "wasi"), not(target_os = "emscripten") ))] use wasm_bindgen_test::wasm_bindgen_test; #[wasm_bindgen_test] #[should_panic] fn instant_now_panics() { let _ = tokio::time::Instant::now(); } #[cfg(all(feature = "rt", not(featu...
tokio
rust
async_runtime
io_write_int.rs
#![warn(rust_2018_idioms)] #![cfg(any( feature = "full", all( target_os = "emscripten", feature = "rt", feature = "macros", feature = "io-util" ) ))] use tokio::io::{AsyncWrite, AsyncWriteExt}; use std::io::{self, ErrorKind}; use std::pin::Pin; use std::task::{Context, Poll...
tokio
rust
async_runtime
signal_drop_rt.rs
#![warn(rust_2018_idioms)] #![cfg(feature = "full")] #![cfg(unix)] #![cfg(not(miri))] // No `sigaction` in miri. mod support { pub mod signal; } use support::signal::send_signal; use tokio::runtime::Runtime; use tokio::signal::unix::{signal, SignalKind}; #[test] fn dropping_loops_does_not_cause_starvation() { ...
tokio
rust
async_runtime
time_rt.rs
#![warn(rust_2018_idioms)] #![cfg(feature = "full")] use tokio::runtime::Runtime; use tokio::time::*; use std::sync::mpsc; fn rt_combinations() -> Vec<Runtime> { let mut rts = vec![]; let rt = tokio::runtime::Builder::new_current_thread() .enable_all() .build() .unwrap(); rts.pus...
tokio
rust
async_runtime
time_interval.rs
#![warn(rust_2018_idioms)] #![cfg(any( feature = "full", all( target_os = "emscripten", feature = "rt", feature = "macros", feature = "test-util" ) ))] use std::pin::Pin; use std::task::{Context, Poll}; use futures::{Stream, StreamExt}; use tokio::time::{self, Duration, Ins...
tokio
rust
async_runtime
io_take.rs
#![warn(rust_2018_idioms)] #![cfg(any( all(feature = "full", not(target_os = "wasi")), // Wasi does not support panic recovery all( target_os = "emscripten", feature = "rt", feature = "macros", feature = "io-util" ) ))] use std::pin::Pin; use std::task::{Context, Poll}; use ...
tokio
rust
async_runtime
fs_remove_dir_all.rs
#![warn(rust_2018_idioms)] #![cfg(all( any( feature = "full", all( target_os = "emscripten", feature = "fs", feature = "macros", feature = "rt", feature = "io-util" ) ), not(target_os = "wasi") ))] // WASI does not support a...
tokio
rust
async_runtime
tcp_connect.rs
#![warn(rust_2018_idioms)] // WASIp1 doesn't support bind #![cfg(all( feature = "net", feature = "macros", feature = "rt", feature = "io-util", not(all(target_os = "wasi", target_env = "p1")), ))] use tokio::net::{TcpListener, TcpStream}; use tokio::sync::oneshot; use tokio_test::assert_ok; use fu...
tokio
rust
async_runtime
fs_dir.rs
#![warn(rust_2018_idioms)] #![cfg(all( any( feature = "full", all( target_os = "emscripten", feature = "fs", feature = "macros", feature = "rt", feature = "io-util" ) ), not(target_os = "wasi") ))] // WASI does not support a...
tokio
rust
async_runtime
io_repeat.rs
#![warn(rust_2018_idioms)] #![cfg(any( all(feature = "full", not(miri)), all( target_os = "emscripten", feature = "rt", feature = "macros", feature = "io-util" ) ))] use tokio::io::AsyncReadExt; #[tokio::test] async fn repeat_poll_read_is_cooperative() { tokio::select! ...
tokio
rust
async_runtime
fs_symlink_file_windows.rs
#![warn(rust_2018_idioms)] #![cfg(all(feature = "full", not(target_os = "wasi")))] // WASI does not support all fs operations #![cfg(windows)] use tempfile::tempdir; use tokio::fs; #[tokio::test] async fn symlink_file_windows() { let dir = tempdir().unwrap(); let source_path = dir.path().join("foo.txt"); ...
tokio
rust
async_runtime
tcp_into_std.rs
#![warn(rust_2018_idioms)] // WASIp1 doesn't support bind #![cfg(all( feature = "net", feature = "macros", feature = "rt", feature = "io-util", not(all(target_os = "wasi", target_env = "p1")), ))] use std::io::Read; use std::io::Result; use tokio::io::{AsyncReadExt, AsyncWriteExt}; use tokio::net::...
tokio
rust
async_runtime
sync_semaphore.rs
#![cfg(feature = "sync")] #[cfg(all(target_family = "wasm", target_os = "unknown"))] use wasm_bindgen_test::wasm_bindgen_test as test; use std::sync::Arc; use tokio::sync::Semaphore; #[test] fn no_permits() { // this should not panic Semaphore::new(0); } #[test] fn try_acquire() { let sem = Semaphore::n...
tokio
rust
async_runtime
macros_select.rs
#![cfg(feature = "macros")] #![allow(clippy::disallowed_names)] #[cfg(all(target_family = "wasm", target_os = "unknown"))] use wasm_bindgen_test::wasm_bindgen_test as maybe_tokio_test; #[cfg(not(all(target_family = "wasm", target_os = "unknown")))] use tokio::test as maybe_tokio_test; use tokio::sync::oneshot; use t...
tokio
rust
async_runtime
fs_copy.rs
#![warn(rust_2018_idioms)] #![cfg(all( any( feature = "full", all( target_os = "emscripten", feature = "fs", feature = "macros", feature = "rt", feature = "io-util" ) ), not(target_os = "wasi") ))] // WASI does not support a...
tokio
rust
async_runtime
io_write.rs
#![warn(rust_2018_idioms)] #![cfg(any( feature = "full", all( target_os = "emscripten", feature = "rt", feature = "macros", feature = "io-util" ) ))] use tokio::io::{AsyncWrite, AsyncWriteExt}; use tokio_test::assert_ok; use bytes::BytesMut; use std::io; use std::pin::Pin; ...
tokio
rust
async_runtime
buffered.rs
#![warn(rust_2018_idioms)] #![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support bind() use tokio::net::TcpListener; use tokio_test::assert_ok; use std::io::prelude::*; use std::net::TcpStream; use std::thread; #[tokio::test] #[cfg_attr(miri, ignore)] // No `socket` on miri. async fn echo_...
tokio
rust
async_runtime
fs_try_exists.rs
#![warn(rust_2018_idioms)] #![cfg(all( any( feature = "full", all( target_os = "emscripten", feature = "fs", feature = "macros", feature = "rt", feature = "io-util" ) ), not(target_os = "wasi") ))] // WASI does not support a...
tokio
rust
async_runtime
no_rt.rs
#![cfg(feature = "rt")] #[test] #[cfg(all(feature = "sync", feature = "time"))] #[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_context() { use futures::executor::block_on; use tokio::sync::oneshot; use ...
tokio
rust
async_runtime
sync_mutex_owned.rs
#![warn(rust_2018_idioms)] #![cfg(feature = "sync")] #[cfg(all(target_family = "wasm", target_os = "unknown"))] use wasm_bindgen_test::wasm_bindgen_test as test; #[cfg(all(target_family = "wasm", target_os = "unknown"))] use wasm_bindgen_test::wasm_bindgen_test as maybe_tokio_test; #[cfg(not(all(target_family = "wasm...
tokio
rust
async_runtime
rt_emscripten_block_on.rs
#![cfg(all( target_os = "emscripten", not(target_feature = "atomics"), feature = "rt", feature = "time", feature = "sync", feature = "macros" ))] use std::panic::{catch_unwind, AssertUnwindSafe}; use std::time::Duration; use tokio::runtime::Builder; extern "C" { /// Emscripten's `ASYNCIFY...
tokio
rust
async_runtime
sync_mpsc.rs
#![allow(clippy::redundant_clone)] #![warn(rust_2018_idioms)] #![cfg(feature = "sync")] #[cfg(all(target_family = "wasm", target_os = "unknown"))] use wasm_bindgen_test::wasm_bindgen_test as test; #[cfg(all(target_family = "wasm", target_os = "unknown"))] use wasm_bindgen_test::wasm_bindgen_test as maybe_tokio_test; ...
tokio
rust
async_runtime
fs_uring.rs
#![cfg(all( tokio_unstable, feature = "io-uring", feature = "rt", feature = "fs", target_os = "linux" ))] use futures::future::FutureExt; use std::sync::mpsc; use std::task::Poll; use std::time::Duration; use std::{future::poll_fn, path::PathBuf}; use tempfile::NamedTempFile; use tokio::task::JoinS...
tokio
rust
async_runtime
sync_panic.rs
#![warn(rust_2018_idioms)] #![cfg(any( all(feature = "full", not(target_os = "wasi")), all(target_os = "emscripten", feature = "rt", feature = "sync") ))] #![cfg(panic = "unwind")] use std::{error::Error, sync::Arc}; use tokio::{ runtime::{Builder, Runtime}, sync::{broadcast, mpsc, oneshot, Mutex, RwLo...
tokio
rust
async_runtime
sync_set_once.rs
#![warn(rust_2018_idioms)] #![cfg(any( feature = "full", all( target_os = "emscripten", feature = "rt", feature = "sync", feature = "macros" ) ))] use std::sync::{ atomic::{AtomicU32, Ordering}, Arc, }; use tokio::sync::SetOnce; #[derive(Clone)] struct DropCounter {...
tokio
rust
async_runtime
net_bind_resource.rs
#![warn(rust_2018_idioms)] // WASIp1 doesn't support bind #![cfg(all( feature = "net", feature = "macros", feature = "rt", feature = "io-util", not(all(target_os = "wasi", target_env = "p1")), ))] use tokio::net::TcpListener; use std::net; #[test] #[should_panic] fn no_runtime_panics_binding_net_...
tokio
rust
async_runtime
io_util_empty.rs
#![cfg(any( feature = "full", all( target_os = "emscripten", feature = "rt", feature = "macros", feature = "io-util" ) ))] use tokio::io::{AsyncBufReadExt, AsyncReadExt, AsyncSeekExt}; #[tokio::test] async fn empty_read_is_cooperative() { tokio::select! { biased;...
tokio
rust
async_runtime
net_panic.rs
#![warn(rust_2018_idioms)] #![cfg(all(feature = "full", not(target_os = "wasi")))] #![cfg(panic = "unwind")] 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] #[cfg_attr(miri, ignore)] //...
tokio
rust
async_runtime
fs_uring_no_io.rs
#![cfg(all( tokio_unstable, feature = "io-uring", feature = "rt", feature = "fs", target_os = "linux" ))] use std::future::poll_fn; use std::io::Write; use std::pin::Pin; use tempfile::{tempdir, NamedTempFile}; use tokio::io::{AsyncRead, ReadBuf}; use tokio::runtime::{Builder, Runtime}; fn runtim...
tokio
rust
async_runtime
rt_common.rs
#![allow(clippy::needless_range_loop)] #![warn(rust_2018_idioms)] #![cfg(feature = "full")] // Tests to run on both current-thread & multi-thread runtime variants. macro_rules! rt_test { ($($t:tt)*) => { mod current_thread_scheduler { $($t)* #[cfg(not(target_os="wasi"))] ...
tokio
rust
async_runtime
task_blocking.rs
#![warn(rust_2018_idioms)] #![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi doesn't support threads use tokio::{runtime, task, time}; use tokio_test::assert_ok; use std::thread; use std::time::Duration; mod support { pub(crate) mod mpsc_stream; } #[tokio::test] async fn basic_blocking(...
tokio
rust
async_runtime
tcp_echo.rs
#![warn(rust_2018_idioms)] // WASIp1 doesn't support bind #![cfg(all( feature = "net", feature = "macros", feature = "rt", feature = "io-util", not(all(target_os = "wasi", target_env = "p1")), ))] use tokio::io::{self, AsyncReadExt, AsyncWriteExt}; use tokio::net::{TcpListener, TcpStream}; use toki...
tokio
rust
async_runtime
rt_handle_block_on.rs
#![warn(rust_2018_idioms)] #![cfg(feature = "full")] use std::time::Duration; use tokio::runtime::{Handle, Runtime}; use tokio::sync::mpsc; #[cfg(not(target_os = "wasi"))] use tokio::{net, time}; #[cfg(not(target_os = "wasi"))] // Wasi doesn't support threads macro_rules! multi_threaded_rt_test { ($($t:tt)*) => {...
tokio
rust
async_runtime
fs_file.rs
#![warn(rust_2018_idioms)] #![cfg(all( any( feature = "full", all( target_os = "emscripten", feature = "fs", feature = "macros", feature = "rt", feature = "io-util" ) ), not(target_os = "wasi") ))] // WASI does not support a...
tokio
rust
async_runtime
io_poll_aio.rs
#![warn(rust_2018_idioms)] #![cfg(all(target_os = "freebsd", feature = "net"))] use mio_aio::{AioFsyncMode, SourceApi}; use std::{ future::Future, io, mem, os::fd::{AsFd, BorrowedFd}, os::unix::io::AsRawFd, pin::{pin, Pin}, task::{Context, Poll}, }; use tempfile::tempfile; use tokio::io::bsd::{...
tokio
rust
async_runtime
fs_open_options_windows.rs
#![warn(rust_2018_idioms)] #![cfg(all(feature = "full", not(target_os = "wasi")))] // WASI does not support all fs operations #![cfg(windows)] use tokio::fs::OpenOptions; use windows_sys::Win32::Storage::FileSystem; #[tokio::test] #[cfg(windows)] async fn open_options_windows_access_mode() { // TESTING HACK: use ...
tokio
rust
async_runtime
sync_notify.rs
#![warn(rust_2018_idioms)] #![cfg(feature = "sync")] #[cfg(all(target_family = "wasm", target_os = "unknown"))] use wasm_bindgen_test::wasm_bindgen_test as test; use tokio::sync::Notify; use tokio_test::task::spawn; use tokio_test::*; #[allow(unused)] trait AssertSend: Send + Sync {} impl AssertSend for Notify {} #...
tokio
rust
async_runtime
process_stdin_shutdown.rs
#![warn(rust_2018_idioms)] #![cfg(all( feature = "full", any(unix, windows), not(target_os = "wasi"), not(miri) ))] use std::io::IoSlice; #[cfg(unix)] use std::os::fd::AsFd; #[cfg(windows)] use std::os::windows::io::AsHandle; use std::process::Stdio; use tokio::io::AsyncWriteExt; use tokio::process::{C...
tokio
rust
async_runtime
io_buf_writer.rs
#![warn(rust_2018_idioms)] #![cfg(any( feature = "full", all( target_os = "emscripten", feature = "rt", feature = "macros", feature = "io-util" ) ))] // https://github.com/rust-lang/futures-rs/blob/1803948ff091b4eabf7f3bf39e16bbbdefca5cc8/futures/tests/io_buf_writer.rs use ...
tokio
rust
async_runtime
rt_multi_thread_emscripten.rs
#![warn(rust_2018_idioms)] #![cfg(all( target_os = "emscripten", feature = "rt-multi-thread", feature = "macros" ))] use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::{Arc, Barrier}; use std::time::Duration; #[test] fn block_on_multi_thread() { let rt = tokio::runtime::Builder::new_multi...
tokio
rust
async_runtime
time_timeout.rs
#![warn(rust_2018_idioms)] #![cfg(any( feature = "full", all( target_os = "emscripten", feature = "rt", feature = "macros", feature = "test-util", feature = "io-util" ) ))] use tokio::sync::oneshot; use tokio::time::{self, timeout, timeout_at, Instant}; use tokio_tes...
tokio
rust
async_runtime
rt_busy_tick.rs
#![warn(rust_2018_idioms)] #![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] use std::time::Duration; use tokio::io::{AsyncReadExt, AsyncWriteExt}; use tokio::net::{TcpListener, TcpStream}; #[test] #[should_panic(expected = "max_io_events_per_busy_tick must be non-zero")] fn zero_busy_tick_panics() {...
tokio
rust
async_runtime
unwindsafe.rs
#![warn(rust_2018_idioms)] #![cfg(any( all(feature = "full", not(target_os = "wasi")), // Wasi does not support panic recovery all(target_os = "emscripten", feature = "rt", feature = "sync") ))] use std::panic::{RefUnwindSafe, UnwindSafe}; #[test] fn notify_is_unwind_safe() { is_unwind_safe::<tokio::sync:...
tokio
rust
async_runtime
task_trace_self.rs
#![allow(unknown_lints, unexpected_cfgs)] #![cfg(all( tokio_unstable, feature = "taskdump", target_os = "linux", any( target_arch = "aarch64", target_arch = "x86", target_arch = "x86_64", target_arch = "s390x" ) ))] use std::future::Future; use std::pin::Pin; use std...
tokio
rust
async_runtime
fs_canonicalize_dir.rs
#![warn(rust_2018_idioms)] #![cfg(all( any( feature = "full", all( target_os = "emscripten", feature = "fs", feature = "macros", feature = "rt", feature = "io-util" ) ), not(target_os = "wasi") ))] // WASI does not support a...
tokio
rust
async_runtime
task_id.rs
#![warn(rust_2018_idioms)] #![cfg(any( feature = "full", all( target_os = "emscripten", feature = "rt", feature = "sync", feature = "macros" ) ))] use std::error::Error; use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}; #[cfg(not(target_family = "wa...
tokio
rust
async_runtime
process_change_of_runtime.rs
#![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)...
tokio
rust
async_runtime
io_fill_buf.rs
#![warn(rust_2018_idioms)] #![cfg(any( all(feature = "full", not(target_os = "wasi")), all( target_os = "emscripten", feature = "rt", feature = "macros", feature = "io-util", feature = "fs" ) ))] use tempfile::NamedTempFile; use tokio::fs::File; use tokio::io::{Async...
tokio
rust
async_runtime
io_write_buf.rs
#![warn(rust_2018_idioms)] #![cfg(any( feature = "full", all( target_os = "emscripten", feature = "rt", feature = "macros", feature = "io-util" ) ))] use tokio::io::{AsyncWrite, AsyncWriteExt}; use tokio_test::assert_ok; use bytes::BytesMut; use std::cmp; use std::io::{self...
tokio
rust
async_runtime
fs_symlink_dir_windows.rs
#![warn(rust_2018_idioms)] #![cfg(all(feature = "full", not(target_os = "wasi")))] // WASI does not support all fs operations #![cfg(windows)] use tempfile::tempdir; use tokio::fs; #[tokio::test] async fn symlink_dir_windows() { const FILE_NAME: &str = "abc.txt"; let temp_dir = tempdir().unwrap(); let d...
tokio
rust
async_runtime
io_buf_reader.rs
#![warn(rust_2018_idioms)] #![cfg(any( feature = "full", all( target_os = "emscripten", feature = "rt", feature = "macros", feature = "io-util" ) ))] // https://github.com/rust-lang/futures-rs/blob/1803948ff091b4eabf7f3bf39e16bbbdefca5cc8/futures/tests/io_buf_reader.rs use ...
tokio
rust
async_runtime
io_copy_buf.rs
#![warn(rust_2018_idioms)] #![cfg(feature = "full")] use std::io::ErrorKind; #[tokio::test] async fn retry_on_io_interrupted() { let mut reader = tokio_test::io::Builder::new() .read_error(ErrorKind::Interrupted.into()) .read(b"ab") .read_error(ErrorKind::Interrupted.into()) .read(...
tokio
rust
async_runtime
process_raw_handle.rs
#![warn(rust_2018_idioms)] #![cfg(feature = "full")] #![cfg(windows)] #![cfg(not(miri))] use std::future::Future; use std::os::windows::io::RawHandle; use std::pin::pin; use std::process::Stdio; use std::sync::atomic::{AtomicU32, Ordering}; use std::sync::Arc; use std::task::{Context, Wake, Waker}; use tokio::io::Asyn...
tokio
rust
async_runtime
io_copy.rs
#![warn(rust_2018_idioms)] #![cfg(any( feature = "full", all( target_os = "emscripten", feature = "rt", feature = "macros", feature = "io-util" ) ))] use bytes::BytesMut; use tokio::io::{self, AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt, ReadBuf}; use tokio_test::asse...
tokio
rust
async_runtime
duplex_stream.rs
#![warn(rust_2018_idioms)] #![cfg(feature = "full")] use std::io::IoSlice; use tokio::io::{AsyncReadExt, AsyncWriteExt}; const HELLO: &[u8] = b"hello world..."; #[tokio::test] async fn write_vectored() { let (mut client, mut server) = tokio::io::duplex(64); let ret = client .write_vectored(&[IoSlice...
tokio
rust
async_runtime
coop_budget.rs
#![warn(rust_2018_idioms)] #![cfg(all(feature = "full", target_os = "linux"))] use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::Arc; use tokio::net::UdpSocket; use tokio::task::coop::{consume_budget, has_budget_remaining}; const BUDGET: usize = 128; /// Ensure that UDP sockets have functional budgeting...
tokio
rust
async_runtime
sync_oneshot.rs
#![warn(rust_2018_idioms)] #![cfg(feature = "sync")] #[cfg(all(target_family = "wasm", target_os = "unknown"))] use wasm_bindgen_test::wasm_bindgen_test as test; #[cfg(all(target_family = "wasm", target_os = "unknown"))] use wasm_bindgen_test::wasm_bindgen_test as maybe_tokio_test; #[cfg(not(all(target_family = "wasm...
tokio
rust
async_runtime
io_read_until.rs
#![warn(rust_2018_idioms)] #![cfg(any( feature = "full", all( target_os = "emscripten", feature = "rt", feature = "macros", feature = "io-util" ) ))] use std::io::ErrorKind; use tokio::io::{AsyncBufReadExt, BufReader, Error}; use tokio_test::{assert_ok, io::Builder}; #[toki...
tokio
rust
async_runtime
process_kill_on_drop.rs
#![cfg(all(unix, feature = "process", not(miri)))] #![warn(rust_2018_idioms)] use std::io::ErrorKind; use std::process::Stdio; use std::time::Duration; use tokio::io::AsyncReadExt; use tokio::process::Command; use tokio::time::sleep; use tokio_test::assert_ok; #[tokio::test] async fn kill_on_drop() { let mut cmd ...
tokio
rust
async_runtime
task_builder.rs
#![cfg(all(tokio_unstable, feature = "tracing"))] use std::rc::Rc; use tokio::task::{Builder, LocalSet}; #[tokio::test] async fn spawn_with_name() { let result = Builder::new() .name("name") .spawn(async { "task executed" }) .unwrap() .await; assert_eq!(result.unwrap(), "task ...
tokio
rust
async_runtime
rt_metrics.rs
#![warn(rust_2018_idioms)] #![cfg(all(feature = "full", not(target_os = "wasi"), target_has_atomic = "64"))] use std::sync::mpsc; use std::time::Duration; use tokio::runtime::Runtime; use tokio::time; #[test] fn num_workers() { let rt = current_thread(); assert_eq!(1, rt.metrics().num_workers()); let rt ...
tokio
rust
async_runtime
time_alt.rs
#![warn(rust_2018_idioms)] #![cfg(all(tokio_unstable, feature = "time", feature = "rt-multi-thread"))] use tokio::runtime::Runtime; use tokio::time::*; use std::future::Future; use futures::FutureExt; use futures_test::task::noop_context; use tokio_test::assert_pending; fn rt_combinations() -> Vec<Runtime> { le...
tokio
rust
async_runtime
uds_stream.rs
#![cfg(feature = "full")] #![warn(rust_2018_idioms)] #![cfg(unix)] #![cfg(not(miri))] // No Unix domain sockets on miri. use std::io; #[cfg(target_os = "android")] use std::os::android::net::SocketAddrExt; #[cfg(target_os = "linux")] use std::os::linux::net::SocketAddrExt; use std::os::unix::net::SocketAddr; use std::...
tokio
rust
async_runtime
rt_emscripten_jspi.rs
#![cfg(all( target_os = "emscripten", not(target_feature = "atomics"), feature = "rt", feature = "time", feature = "sync", feature = "macros" ))] use std::sync::Arc; use std::time::Duration; use tokio::runtime::Builder; use tokio::sync::Notify; use tokio::time::{sleep, Instant}; fn rt() -> to...
tokio
rust
async_runtime
io_join.rs
#![warn(rust_2018_idioms)] #![cfg(any( feature = "full", all( target_os = "emscripten", feature = "rt", feature = "macros", feature = "io-util" ) ))] use tokio::io::{join, AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt, Join, ReadBuf}; use std::io; use std::pin::Pin; us...
tokio
rust
async_runtime
io_write_all_buf.rs
#![warn(rust_2018_idioms)] #![cfg(any( feature = "full", all( target_os = "emscripten", feature = "rt", feature = "macros", feature = "io-util" ) ))] use tokio::io::{AsyncWrite, AsyncWriteExt}; use tokio_test::io::Builder; use tokio_test::{assert_err, assert_ok}; use bytes:...
tokio
rust
async_runtime
async_send_sync.rs
#![warn(rust_2018_idioms)] #![cfg(feature = "full")] #![allow(clippy::type_complexity, clippy::diverging_sub_expression)] use std::cell::Cell; use std::future::Future; use std::io::SeekFrom; use std::net::SocketAddr; use std::pin::Pin; use std::rc::Rc; use tokio::net::TcpStream; use tokio::time::{Duration, Instant}; ...
tokio
rust
async_runtime
rt_spawn_blocking.rs
#![warn(rust_2018_idioms)] #![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] use std::time::Duration; use tokio::runtime::Builder; use tokio::sync::mpsc; use tokio::task::JoinSet; #[test] fn issue_8056_regression_test() { type Senders = Vec<mpsc::Sender<()>>; type Handles = JoinSet<()>; ...