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/tracing_task.rs:3
.named("runtime.spawn") .with_target("tokio::task") .with_fields(expect::field("loc.file").with_value(&file!())); let (subscriber, handle) = subscriber::mock().new_span(task_span).run_with_handle(); { let _guard = tracing::subscriber::set_default(subscriber); task::Builder::ne...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tracing_task.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/tracing_task.rs
81
140
tokio-rs/tokio:tokio/tests/tracing_task.rs:4
.expect("failed to await join handle"); } handle.assert_finished(); } #[tokio::test] async fn task_big_spawn_sizes_recorded() { let future = { async fn big<const N: usize>() { let mut a = [0_u8; N]; for (idx, item) in a.iter_mut().enumerate() { *item = (idx ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tracing_task.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/tracing_task.rs
121
180
tokio-rs/tokio:tokio/tests/tracing_task.rs:5
{ let _guard = tracing::subscriber::set_default(subscriber); task::Builder::new() .spawn(future) .unwrap() .await .expect("failed to await join handle"); } handle.assert_finished(); } /// Expect a task with name /// /// This is a convenience fun...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tracing_task.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/tracing_task.rs
161
186
tokio-rs/tokio:tokio/tests/tracing_task.rs:5
{ let _guard = tracing::subscriber::set_default(subscriber); task::Builder::new() .spawn(future) .unwrap() .await .expect("failed to await join handle"); } handle.assert_finished(); } /// Expect a task with name /// /// This is a convenience fun...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tracing_task.rs
MIT
7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7f09959b0a13cbea2b0e5c20ec1b7ac3f208dbad/tokio/tests/tracing_task.rs
161
186
tokio-rs/tokio:tokio/tests/tracing_time.rs:1
//! Tests for time resource instrumentation. //! //! These tests ensure that the instrumentation for tokio //! synchronization primitives is correct. #![warn(rust_2018_idioms)] #![cfg(all(tokio_unstable, feature = "tracing", target_has_atomic = "64"))] use std::time::Duration; use tracing_mock::{expect, subscriber}; ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tracing_time.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/tracing_time.rs
1
60
tokio-rs/tokio:tokio/tests/tracing_time.rs:2
let (subscriber, handle) = subscriber::mock() .new_span(sleep_span.clone().with_ancestry(expect::is_explicit_root())) .enter(sleep_span.clone()) .event(state_update) .new_span( async_op_span .clone() .with_ancestry(expect::has_contextual_parent...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/tracing_time.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/tracing_time.rs
41
71
tokio-rs/tokio:tokio/tests/udp.rs:1
#![warn(rust_2018_idioms)] // WASIp1 doesn't support bind // No `socket` on miri. #![cfg(all( feature = "net", feature = "macros", feature = "rt", feature = "io-util", not(all(target_os = "wasi", target_env = "p1")), not(miri) ))] use std::future::poll_fn; use std::io; use std::sync::Arc; use s...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/udp.rs
1
60
tokio-rs/tokio:tokio/tests/udp.rs:2
async fn send_recv_poll() -> std::io::Result<()> { let sender = UdpSocket::bind("127.0.0.1:0").await?; let receiver = UdpSocket::bind("127.0.0.1:0").await?; sender.connect(receiver.local_addr()?).await?; receiver.connect(sender.local_addr()?).await?; poll_fn(|cx| sender.poll_send(cx, MSG)).await?;...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/udp.rs
41
100
tokio-rs/tokio:tokio/tests/udp.rs:3
matches!( errno, io::ErrorKind::ConnectionRefused | io::ErrorKind::ConnectionReset ) ); Ok(()) } #[tokio::test] #[cfg_attr( target_os = "wasi", ignore = "temporarily disabled for WASI pending https://github.com/WebAssembly/wasi-libc/pull/734" )] async fn send_to_recv_fro...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/udp.rs
81
140
tokio-rs/tokio:tokio/tests/udp.rs:4
let mut recv_buf = [0u8; 32]; let mut read = ReadBuf::new(&mut recv_buf); let addr = poll_fn(|cx| receiver.poll_recv_from(cx, &mut read)).await?; assert_eq!(read.filled(), MSG); assert_eq!(addr, sender.local_addr()?); Ok(()) } #[cfg_attr(target_os = "wasi", ignore = "WASI does not yet support peek...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/udp.rs
121
180
tokio-rs/tokio:tokio/tests/udp.rs:5
async fn send_to_try_peek_from() -> std::io::Result<()> { let sender = UdpSocket::bind("127.0.0.1:0").await?; let receiver = UdpSocket::bind("127.0.0.1:0").await?; let receiver_addr = receiver.local_addr()?; poll_fn(|cx| sender.poll_send_to(cx, MSG, receiver_addr)).await?; // peek let mut recv...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/udp.rs
161
220
tokio-rs/tokio:tokio/tests/udp.rs:6
async fn send_to_peek_from_poll() -> std::io::Result<()> { let sender = UdpSocket::bind("127.0.0.1:0").await?; let receiver = UdpSocket::bind("127.0.0.1:0").await?; let receiver_addr = receiver.local_addr()?; poll_fn(|cx| sender.poll_send_to(cx, MSG, receiver_addr)).await?; let mut recv_buf = [0u8...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/udp.rs
201
260
tokio-rs/tokio:tokio/tests/udp.rs:7
assert_eq!(peeked_sender, sender_addr); // Assert that `peek_sender()` returns the right sender but // doesn't remove from the receive queue. let mut recv_buf = [0u8; 32]; let (read, received_sender) = receiver.recv_from(&mut recv_buf).await?; assert_eq!(&recv_buf[..read], msg); assert_eq!(rec...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/udp.rs
241
300
tokio-rs/tokio:tokio/tests/udp.rs:8
#[cfg_attr(target_os = "wasi", ignore = "WASI does not yet support peeking")] #[tokio::test] async fn try_peek_sender() -> std::io::Result<()> { let sender = UdpSocket::bind("127.0.0.1:0").await?; let receiver = UdpSocket::bind("127.0.0.1:0").await?; let sender_addr = sender.local_addr()?; let receiver...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/udp.rs
281
340
tokio-rs/tokio:tokio/tests/udp.rs:9
let r = s.clone(); let addr = s.local_addr()?; tokio::spawn(async move { s.send_to(MSG, &addr).await.unwrap(); }); let mut recv_buf = [0u8; 32]; let (len, _) = r.recv_from(&mut recv_buf[..]).await?; assert_eq!(&recv_buf[..len], MSG); Ok(()) } #[tokio::test] async fn split_chan() ->...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/udp.rs
321
380
tokio-rs/tokio:tokio/tests/udp.rs:10
assert_eq!(&recv_buf[..len], MSG); Ok(()) } #[tokio::test] async fn split_chan_poll() -> std::io::Result<()> { // setup UdpSocket that will echo all sent items let socket = UdpSocket::bind("127.0.0.1:0").await?; let addr = socket.local_addr().unwrap(); let s = Arc::new(socket); let r = s.clone(...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/udp.rs
361
420
tokio-rs/tokio:tokio/tests/udp.rs:11
// # Note // // This test is purposely written such that each time `sender` sends data on // the socket, `receiver` awaits the data. On Unix, it would be okay waiting // until the end of the test to receive all the data. On Windows, this would // **not** be okay because it's resources are completion based (via IOCP). /...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/udp.rs
401
460
tokio-rs/tokio:tokio/tests/udp.rs:12
assert_eq!(sent, &MSG2_LEN); received += receiver.recv(&mut buf[..]).await.unwrap(); std::thread::spawn(move || { let sent = &sender.try_send(MSG).unwrap(); assert_eq!(sent, &MSG_LEN); }) .join() .unwrap(); received += receiver.recv(&mut buf[..]).await.unwrap(); assert_eq!(...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/udp.rs
441
500
tokio-rs/tokio:tokio/tests/udp.rs:13
loop { server.readable().await.unwrap(); let mut buf = [0; 512]; match server.try_recv(&mut buf) { Ok(n) => { assert_eq!(n, 11); assert_eq!(&buf[0..11], &b"hello world"[..]); break; } ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/udp.rs
481
540
tokio-rs/tokio:tokio/tests/udp.rs:14
} Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => continue, Err(e) => panic!("{e:?}"), } } loop { server.readable().await.unwrap(); let mut buf = [0; 512]; match server.try_recv_from(&mut buf) { Ok(...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/udp.rs
521
580
tokio-rs/tokio:tokio/tests/udp.rs:15
match client.try_send(b"hello world") { Ok(n) => { assert_eq!(n, 11); break; } Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => continue, Err(e) => panic!("{e:?}"), } } loop { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/udp.rs
561
620
tokio-rs/tokio:tokio/tests/udp.rs:16
assert_eq!(len, MSG_LEN); assert_eq!(&recv_buf[..len], MSG); Ok(()) } #[tokio::test] #[cfg_attr( target_os = "wasi", ignore = "temporarily disabled for WASI pending https://github.com/WebAssembly/wasi-libc/pull/734" )] async fn try_recv_buf_from() { // Create listener let server = UdpSocket::bi...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/udp.rs
601
660
tokio-rs/tokio:tokio/tests/udp.rs:17
Ok((n, addr)) => { assert_eq!(n, 11); assert_eq!(addr, caddr); assert_eq!(&buf[0..11], &b"hello world"[..]); break; } Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => continue, Err(e) =>...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/udp.rs
641
700
tokio-rs/tokio:tokio/tests/udp.rs:18
// Create listener let server = UdpSocket::bind("127.0.0.1:0").await.unwrap(); let saddr = server.local_addr().unwrap(); // Create socket pair let client = UdpSocket::bind("127.0.0.1:0").await.unwrap(); let caddr = client.local_addr().unwrap(); for _ in 0..5 { loop { assert...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/udp.rs
681
740
tokio-rs/tokio:tokio/tests/udp.rs:19
/// Macro to create a simple test to set and get a socket option. macro_rules! test { // Test using the `arg`ument as expected return value. ($( #[ $attr: meta ] )* $get_fn: ident, $set_fn: ident ( $arg: expr ) ) => { test!($( #[$attr] )* $get_fn, $set_fn($arg), $arg); }; ($( #[ $attr: meta ] )*...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/udp.rs
721
780
tokio-rs/tokio:tokio/tests/udp.rs:20
let got = socket.$get_fn().expect("failed to get value"); let expected = $expected; assert_eq!(got, expected, "set and get values differ"); }; } #[cfg(not(target_os = "wasi"))] // WASI does not yet support broadcast test!(broadcast, set_broadcast(true)); #[cfg(not(target_os = "wasi"))] // WASI doe...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/udp.rs
761
802
tokio-rs/tokio:tokio/tests/udp.rs:1
#![warn(rust_2018_idioms)] // WASIp1 doesn't support bind // No `socket` on miri. #![cfg(all( feature = "net", feature = "macros", feature = "rt", feature = "io-util", not(all(target_os = "wasi", target_env = "p1")), not(miri) ))] use std::future::poll_fn; use std::io; use std::sync::Arc; use t...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
43134f1e5784993eb4fb3863933d74ac9e28f598
github
async-runtime
https://github.com/tokio-rs/tokio/blob/43134f1e5784993eb4fb3863933d74ac9e28f598/tokio/tests/udp.rs
1
60
tokio-rs/tokio:tokio/tests/udp.rs:2
let sender = UdpSocket::bind("127.0.0.1:0").await?; let receiver = UdpSocket::bind("127.0.0.1:0").await?; sender.connect(receiver.local_addr()?).await?; receiver.connect(sender.local_addr()?).await?; poll_fn(|cx| sender.poll_send(cx, MSG)).await?; let mut recv_buf = [0u8; 32]; let mut read = ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
43134f1e5784993eb4fb3863933d74ac9e28f598
github
async-runtime
https://github.com/tokio-rs/tokio/blob/43134f1e5784993eb4fb3863933d74ac9e28f598/tokio/tests/udp.rs
41
100
tokio-rs/tokio:tokio/tests/udp.rs:3
)] async fn send_to_recv_from_poll() -> std::io::Result<()> { let sender = UdpSocket::bind("127.0.0.1:0").await?; let receiver = UdpSocket::bind("127.0.0.1:0").await?; let receiver_addr = receiver.local_addr()?; poll_fn(|cx| sender.poll_send_to(cx, MSG, receiver_addr)).await?; let mut recv_buf = [...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
43134f1e5784993eb4fb3863933d74ac9e28f598
github
async-runtime
https://github.com/tokio-rs/tokio/blob/43134f1e5784993eb4fb3863933d74ac9e28f598/tokio/tests/udp.rs
81
140
tokio-rs/tokio:tokio/tests/udp.rs:4
assert_eq!(&recv_buf[..n], MSG); assert_eq!(addr, sender.local_addr()?); Ok(()) } #[cfg_attr(target_os = "wasi", ignore = "WASI does not yet support peeking")] #[tokio::test] async fn send_to_try_peek_from() -> std::io::Result<()> { let sender = UdpSocket::bind("127.0.0.1:0").await?; let receiver = Ud...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
43134f1e5784993eb4fb3863933d74ac9e28f598
github
async-runtime
https://github.com/tokio-rs/tokio/blob/43134f1e5784993eb4fb3863933d74ac9e28f598/tokio/tests/udp.rs
121
180
tokio-rs/tokio:tokio/tests/udp.rs:5
assert_eq!(&recv_buf[..n], MSG); assert_eq!(addr, sender.local_addr()?); Ok(()) } #[cfg_attr(target_os = "wasi", ignore = "WASI does not yet support peeking")] #[tokio::test] async fn send_to_peek_from_poll() -> std::io::Result<()> { let sender = UdpSocket::bind("127.0.0.1:0").await?; let receiver = U...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
43134f1e5784993eb4fb3863933d74ac9e28f598
github
async-runtime
https://github.com/tokio-rs/tokio/blob/43134f1e5784993eb4fb3863933d74ac9e28f598/tokio/tests/udp.rs
161
220
tokio-rs/tokio:tokio/tests/udp.rs:6
let sender_addr = sender.local_addr()?; let receiver_addr = receiver.local_addr()?; let msg = b"Hello, world!"; sender.send_to(msg, receiver_addr).await?; let peeked_sender = receiver.peek_sender().await?; assert_eq!(peeked_sender, sender_addr); // Assert that `peek_sender()` returns the righ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
43134f1e5784993eb4fb3863933d74ac9e28f598
github
async-runtime
https://github.com/tokio-rs/tokio/blob/43134f1e5784993eb4fb3863933d74ac9e28f598/tokio/tests/udp.rs
201
260
tokio-rs/tokio:tokio/tests/udp.rs:7
let received_sender = poll_fn(|cx| receiver.poll_recv_from(cx, &mut read)).await?; assert_eq!(read.filled(), msg); assert_eq!(received_sender, peeked_sender); Ok(()) } #[cfg_attr(target_os = "wasi", ignore = "WASI does not yet support peeking")] #[tokio::test] async fn try_peek_sender() -> std::io::Resul...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
43134f1e5784993eb4fb3863933d74ac9e28f598
github
async-runtime
https://github.com/tokio-rs/tokio/blob/43134f1e5784993eb4fb3863933d74ac9e28f598/tokio/tests/udp.rs
241
300
tokio-rs/tokio:tokio/tests/udp.rs:8
Ok(()) } #[tokio::test] async fn split() -> std::io::Result<()> { let socket = UdpSocket::bind("127.0.0.1:0").await?; let s = Arc::new(socket); let r = s.clone(); let addr = s.local_addr()?; tokio::spawn(async move { s.send_to(MSG, &addr).await.unwrap(); }); let mut recv_buf = [0u8...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
43134f1e5784993eb4fb3863933d74ac9e28f598
github
async-runtime
https://github.com/tokio-rs/tokio/blob/43134f1e5784993eb4fb3863933d74ac9e28f598/tokio/tests/udp.rs
281
340
tokio-rs/tokio:tokio/tests/udp.rs:9
} }); // test that we can send a value and get back some response let sender = UdpSocket::bind("127.0.0.1:0").await?; sender.send_to(MSG, addr).await?; let mut recv_buf = [0u8; 32]; let (len, _) = sender.recv_from(&mut recv_buf).await?; assert_eq!(&recv_buf[..len], MSG); Ok(()) } #[tok...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
43134f1e5784993eb4fb3863933d74ac9e28f598
github
async-runtime
https://github.com/tokio-rs/tokio/blob/43134f1e5784993eb4fb3863933d74ac9e28f598/tokio/tests/udp.rs
321
380
tokio-rs/tokio:tokio/tests/udp.rs:10
poll_fn(|cx| sender.poll_send_to(cx, MSG, addr)).await?; let mut recv_buf = [0u8; 32]; let mut read = ReadBuf::new(&mut recv_buf); let _ = poll_fn(|cx| sender.poll_recv_from(cx, &mut read)).await?; assert_eq!(read.filled(), MSG); Ok(()) } // # Note // // This test is purposely written such that ea...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
43134f1e5784993eb4fb3863933d74ac9e28f598
github
async-runtime
https://github.com/tokio-rs/tokio/blob/43134f1e5784993eb4fb3863933d74ac9e28f598/tokio/tests/udp.rs
361
420
tokio-rs/tokio:tokio/tests/udp.rs:11
let mut buf = [0u8; 32]; let mut received = receiver.recv(&mut buf[..]).await.unwrap(); sender .connect(receiver.local_addr().unwrap()) .await .unwrap(); let sent = &sender.try_send(MSG2).unwrap(); assert_eq!(sent, &MSG2_LEN); received += receiver.recv(&mut buf[..]).await.un...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
43134f1e5784993eb4fb3863933d74ac9e28f598
github
async-runtime
https://github.com/tokio-rs/tokio/blob/43134f1e5784993eb4fb3863933d74ac9e28f598/tokio/tests/udp.rs
401
460
tokio-rs/tokio:tokio/tests/udp.rs:12
assert_eq!(n, 11); break; } Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => continue, Err(e) => panic!("{e:?}"), } } loop { server.readable().await.unwrap(); let mut buf = [0; 512]; ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
43134f1e5784993eb4fb3863933d74ac9e28f598
github
async-runtime
https://github.com/tokio-rs/tokio/blob/43134f1e5784993eb4fb3863933d74ac9e28f598/tokio/tests/udp.rs
441
500
tokio-rs/tokio:tokio/tests/udp.rs:13
for _ in 0..5 { loop { client.writable().await.unwrap(); match client.try_send_to(b"hello world", saddr) { Ok(n) => { assert_eq!(n, 11); break; } Err(ref e) if e.kind() == io::ErrorKind::WouldBlock =...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
43134f1e5784993eb4fb3863933d74ac9e28f598
github
async-runtime
https://github.com/tokio-rs/tokio/blob/43134f1e5784993eb4fb3863933d74ac9e28f598/tokio/tests/udp.rs
481
540
tokio-rs/tokio:tokio/tests/udp.rs:14
// Connect the two client.connect(server.local_addr().unwrap()).await.unwrap(); server.connect(client.local_addr().unwrap()).await.unwrap(); for _ in 0..5 { loop { client.writable().await.unwrap(); match client.try_send(b"hello world") { Ok(n) => { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
43134f1e5784993eb4fb3863933d74ac9e28f598
github
async-runtime
https://github.com/tokio-rs/tokio/blob/43134f1e5784993eb4fb3863933d74ac9e28f598/tokio/tests/udp.rs
521
580
tokio-rs/tokio:tokio/tests/udp.rs:15
let receiver = UdpSocket::bind("127.0.0.1:0").await?; sender.connect(receiver.local_addr()?).await?; receiver.connect(sender.local_addr()?).await?; sender.send(MSG).await?; let mut recv_buf = Vec::with_capacity(32); let len = receiver.recv_buf(&mut recv_buf).await?; assert_eq!(len, MSG_LEN); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
43134f1e5784993eb4fb3863933d74ac9e28f598
github
async-runtime
https://github.com/tokio-rs/tokio/blob/43134f1e5784993eb4fb3863933d74ac9e28f598/tokio/tests/udp.rs
561
620
tokio-rs/tokio:tokio/tests/udp.rs:16
} loop { server.readable().await.unwrap(); let mut buf = Vec::with_capacity(512); match server.try_recv_buf_from(&mut buf) { Ok((n, addr)) => { assert_eq!(n, 11); assert_eq!(addr, caddr); assert_eq...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
43134f1e5784993eb4fb3863933d74ac9e28f598
github
async-runtime
https://github.com/tokio-rs/tokio/blob/43134f1e5784993eb4fb3863933d74ac9e28f598/tokio/tests/udp.rs
601
660
tokio-rs/tokio:tokio/tests/udp.rs:17
} #[tokio::test] #[cfg_attr( target_os = "wasi", ignore = "temporarily disabled for WASI pending https://github.com/WebAssembly/wasi-libc/pull/734" )] async fn poll_ready() { // Create listener let server = UdpSocket::bind("127.0.0.1:0").await.unwrap(); let saddr = server.local_addr().unwrap(); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
43134f1e5784993eb4fb3863933d74ac9e28f598
github
async-runtime
https://github.com/tokio-rs/tokio/blob/43134f1e5784993eb4fb3863933d74ac9e28f598/tokio/tests/udp.rs
641
700
tokio-rs/tokio:tokio/tests/udp.rs:18
break; } Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => continue, Err(e) => panic!("{e:?}"), } } } } /// Macro to create a simple test to set and get a socket option. macro_rules! test { // Test using the `arg`ument as expected return ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
43134f1e5784993eb4fb3863933d74ac9e28f598
github
async-runtime
https://github.com/tokio-rs/tokio/blob/43134f1e5784993eb4fb3863933d74ac9e28f598/tokio/tests/udp.rs
681
740
tokio-rs/tokio:tokio/tests/udp.rs:19
(__ $addr: literal, $get_fn: ident, $set_fn: ident ( $arg: expr ), $expected: expr ) => { let socket = UdpSocket::bind($addr).await.expect("failed to create `UdpSocket`"); let initial = socket.$get_fn().expect("failed to get initial value"); let arg = $arg; assert_ne!(initial, arg, "ini...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
43134f1e5784993eb4fb3863933d74ac9e28f598
github
async-runtime
https://github.com/tokio-rs/tokio/blob/43134f1e5784993eb4fb3863933d74ac9e28f598/tokio/tests/udp.rs
721
770
tokio-rs/tokio:tokio/tests/udp.rs:20
#[cfg(not(any( target_os = "fuchsia", target_os = "redox", target_os = "solaris", target_os = "illumos", target_os = "haiku", target_os = "wasi" )))] test!(IPv4 tos_v4, set_tos_v4(96));
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
43134f1e5784993eb4fb3863933d74ac9e28f598
github
async-runtime
https://github.com/tokio-rs/tokio/blob/43134f1e5784993eb4fb3863933d74ac9e28f598/tokio/tests/udp.rs
761
770
tokio-rs/tokio:tokio/tests/udp.rs:1
#![warn(rust_2018_idioms)] #![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi does not support bind or UDP // No `socket` on miri. use std::future::poll_fn; use std::io; use std::sync::Arc; use tokio::{io::ReadBuf, net::UdpSocke...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
7388f2d2ea5311af4b2fa0e088d890facfbf4054
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7388f2d2ea5311af4b2fa0e088d890facfbf4054/tokio/tests/udp.rs
1
60
tokio-rs/tokio:tokio/tests/udp.rs:2
let mut recv_buf = [0u8; 32]; let mut read = ReadBuf::new(&mut recv_buf); poll_fn(|cx| receiver.poll_recv(cx, &mut read)).await?; assert_eq!(read.filled(), MSG); Ok(()) } #[tokio::test] async fn send_to_recv_from() -> std::io::Result<()> { let sender = UdpSocket::bind("127.0.0.1:0").await?; le...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
7388f2d2ea5311af4b2fa0e088d890facfbf4054
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7388f2d2ea5311af4b2fa0e088d890facfbf4054/tokio/tests/udp.rs
41
100
tokio-rs/tokio:tokio/tests/udp.rs:3
#[tokio::test] async fn send_to_peek_from() -> std::io::Result<()> { let sender = UdpSocket::bind("127.0.0.1:0").await?; let receiver = UdpSocket::bind("127.0.0.1:0").await?; let receiver_addr = receiver.local_addr()?; poll_fn(|cx| sender.poll_send_to(cx, MSG, receiver_addr)).await?; // peek l...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
7388f2d2ea5311af4b2fa0e088d890facfbf4054
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7388f2d2ea5311af4b2fa0e088d890facfbf4054/tokio/tests/udp.rs
81
140
tokio-rs/tokio:tokio/tests/udp.rs:4
loop { match receiver.try_peek_from(&mut recv_buf) { Ok((n, addr)) => { assert_eq!(&recv_buf[..n], MSG); assert_eq!(addr, sender.local_addr()?); break; } Err(e) if e.kind() == io::ErrorKind::WouldBlock => { recei...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
7388f2d2ea5311af4b2fa0e088d890facfbf4054
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7388f2d2ea5311af4b2fa0e088d890facfbf4054/tokio/tests/udp.rs
121
180
tokio-rs/tokio:tokio/tests/udp.rs:5
assert_eq!(read.filled(), MSG); assert_eq!(addr, sender.local_addr()?); let mut recv_buf = [0u8; 32]; let mut read = ReadBuf::new(&mut recv_buf); poll_fn(|cx| receiver.poll_peek_from(cx, &mut read)).await?; assert_eq!(read.filled(), MSG); let mut recv_buf = [0u8; 32]; let mut read = ReadBu...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
7388f2d2ea5311af4b2fa0e088d890facfbf4054
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7388f2d2ea5311af4b2fa0e088d890facfbf4054/tokio/tests/udp.rs
161
220
tokio-rs/tokio:tokio/tests/udp.rs:6
#[tokio::test] async fn poll_peek_sender() -> std::io::Result<()> { let sender = UdpSocket::bind("127.0.0.1:0").await?; let receiver = UdpSocket::bind("127.0.0.1:0").await?; let sender_addr = sender.local_addr()?; let receiver_addr = receiver.local_addr()?; let msg = b"Hello, world!"; poll_fn(...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
7388f2d2ea5311af4b2fa0e088d890facfbf4054
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7388f2d2ea5311af4b2fa0e088d890facfbf4054/tokio/tests/udp.rs
201
260
tokio-rs/tokio:tokio/tests/udp.rs:7
Ok(peeked_sender) => break peeked_sender, Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => { receiver.readable().await?; } Err(e) => return Err(e), } }; assert_eq!(peeked_sender, sender_addr); // Assert that `try_peek_sender()` returns the ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
7388f2d2ea5311af4b2fa0e088d890facfbf4054
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7388f2d2ea5311af4b2fa0e088d890facfbf4054/tokio/tests/udp.rs
241
300
tokio-rs/tokio:tokio/tests/udp.rs:8
// setup UdpSocket that will echo all sent items let socket = UdpSocket::bind("127.0.0.1:0").await?; let addr = socket.local_addr().unwrap(); let s = Arc::new(socket); let r = s.clone(); let (tx, mut rx) = tokio::sync::mpsc::channel::<(Vec<u8>, std::net::SocketAddr)>(1_000); tokio::spawn(async ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
7388f2d2ea5311af4b2fa0e088d890facfbf4054
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7388f2d2ea5311af4b2fa0e088d890facfbf4054/tokio/tests/udp.rs
281
340
tokio-rs/tokio:tokio/tests/udp.rs:9
while let Some((bytes, addr)) = rx.recv().await { poll_fn(|cx| s.poll_send_to(cx, &bytes, addr)) .await .unwrap(); } }); tokio::spawn(async move { let mut recv_buf = [0u8; 32]; let mut read = ReadBuf::new(&mut recv_buf); loop { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
7388f2d2ea5311af4b2fa0e088d890facfbf4054
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7388f2d2ea5311af4b2fa0e088d890facfbf4054/tokio/tests/udp.rs
321
380
tokio-rs/tokio:tokio/tests/udp.rs:10
let sender = UdpSocket::bind("127.0.0.1:0").await.unwrap(); let receiver = UdpSocket::bind("127.0.0.1:0").await.unwrap(); receiver .connect(sender.local_addr().unwrap()) .await .unwrap(); sender.writable().await.unwrap(); let sent = &sender .try_send_to(MSG, receiver.l...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
7388f2d2ea5311af4b2fa0e088d890facfbf4054
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7388f2d2ea5311af4b2fa0e088d890facfbf4054/tokio/tests/udp.rs
361
420
tokio-rs/tokio:tokio/tests/udp.rs:11
// Create socket pair let client = UdpSocket::bind("127.0.0.1:0").await.unwrap(); // Connect the two client.connect(server.local_addr().unwrap()).await.unwrap(); server.connect(client.local_addr().unwrap()).await.unwrap(); for _ in 0..5 { loop { client.writable().await.unwrap()...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
7388f2d2ea5311af4b2fa0e088d890facfbf4054
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7388f2d2ea5311af4b2fa0e088d890facfbf4054/tokio/tests/udp.rs
401
460
tokio-rs/tokio:tokio/tests/udp.rs:12
#[tokio::test] async fn try_send_to_recv_from() { // Create listener let server = UdpSocket::bind("127.0.0.1:0").await.unwrap(); let saddr = server.local_addr().unwrap(); // Create socket pair let client = UdpSocket::bind("127.0.0.1:0").await.unwrap(); let caddr = client.local_addr().unwrap(); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
7388f2d2ea5311af4b2fa0e088d890facfbf4054
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7388f2d2ea5311af4b2fa0e088d890facfbf4054/tokio/tests/udp.rs
441
500
tokio-rs/tokio:tokio/tests/udp.rs:13
} } #[tokio::test] async fn try_recv_buf() { // Create listener let server = UdpSocket::bind("127.0.0.1:0").await.unwrap(); // Create socket pair let client = UdpSocket::bind("127.0.0.1:0").await.unwrap(); // Connect the two client.connect(server.local_addr().unwrap()).await.unwrap(); ser...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
7388f2d2ea5311af4b2fa0e088d890facfbf4054
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7388f2d2ea5311af4b2fa0e088d890facfbf4054/tokio/tests/udp.rs
481
540
tokio-rs/tokio:tokio/tests/udp.rs:14
Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => continue, Err(e) => panic!("{e:?}"), } } } } #[tokio::test] async fn recv_buf() -> std::io::Result<()> { let sender = UdpSocket::bind("127.0.0.1:0").await?; let receiver = UdpSocket::bind("127.0.0.1:0").await?; ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
7388f2d2ea5311af4b2fa0e088d890facfbf4054
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7388f2d2ea5311af4b2fa0e088d890facfbf4054/tokio/tests/udp.rs
521
580
tokio-rs/tokio:tokio/tests/udp.rs:15
assert_eq!(n, 11); break; } Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => continue, Err(e) => panic!("{e:?}"), } } loop { server.readable().await.unwrap(); let mut buf = Vec::with_capacity(...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
7388f2d2ea5311af4b2fa0e088d890facfbf4054
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7388f2d2ea5311af4b2fa0e088d890facfbf4054/tokio/tests/udp.rs
561
620
tokio-rs/tokio:tokio/tests/udp.rs:16
assert_eq!(caddr, sender.local_addr()?); Ok(()) } #[tokio::test] async fn poll_ready() { // Create listener let server = UdpSocket::bind("127.0.0.1:0").await.unwrap(); let saddr = server.local_addr().unwrap(); // Create socket pair let client = UdpSocket::bind("127.0.0.1:0").await.unwrap(); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
7388f2d2ea5311af4b2fa0e088d890facfbf4054
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7388f2d2ea5311af4b2fa0e088d890facfbf4054/tokio/tests/udp.rs
601
660
tokio-rs/tokio:tokio/tests/udp.rs:17
Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => continue, Err(e) => panic!("{e:?}"), } } } } /// Macro to create a simple test to set and get a socket option. macro_rules! test { // Test using the `arg`ument as expected return value. ($( #[ $attr: meta ] )* $get_f...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
7388f2d2ea5311af4b2fa0e088d890facfbf4054
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7388f2d2ea5311af4b2fa0e088d890facfbf4054/tokio/tests/udp.rs
641
700
tokio-rs/tokio:tokio/tests/udp.rs:18
let initial = socket.$get_fn().expect("failed to get initial value"); let arg = $arg; assert_ne!(initial, arg, "initial value and argument are the same"); socket.$set_fn(arg).expect("failed to set option"); let got = socket.$get_fn().expect("failed to get value"); let expected =...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
7388f2d2ea5311af4b2fa0e088d890facfbf4054
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7388f2d2ea5311af4b2fa0e088d890facfbf4054/tokio/tests/udp.rs
681
724
tokio-rs/tokio:tokio/tests/udp.rs:16
assert_eq!(caddr, sender.local_addr()?); Ok(()) } #[tokio::test] async fn poll_ready() { // Create listener let server = UdpSocket::bind("127.0.0.1:0").await.unwrap(); let saddr = server.local_addr().unwrap(); // Create socket pair let client = UdpSocket::bind("127.0.0.1:0").await.unwrap(); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
4047d7962a02722859b0f1c7bbcd85bc1bfc865d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4047d7962a02722859b0f1c7bbcd85bc1bfc865d/tokio/tests/udp.rs
601
646
tokio-rs/tokio:tokio/tests/udp.rs:1
#![warn(rust_2018_idioms)] #![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi does not support bind or UDP use std::future::poll_fn; use std::io; use std::sync::Arc; use tokio::{io::ReadBuf, net::UdpSocket}; use tokio_test::assert_ok; const MSG: &[u8] = b"hello"; const MSG_LEN: usize = MSG.len...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
d4178cf34924d14fca4ecf551c97b8953376f25a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/udp.rs
1
60
tokio-rs/tokio:tokio/tests/udp.rs:2
let mut read = ReadBuf::new(&mut recv_buf); poll_fn(|cx| receiver.poll_recv(cx, &mut read)).await?; assert_eq!(read.filled(), MSG); Ok(()) } #[tokio::test] async fn send_to_recv_from() -> std::io::Result<()> { let sender = UdpSocket::bind("127.0.0.1:0").await?; let receiver = UdpSocket::bind("127....
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
d4178cf34924d14fca4ecf551c97b8953376f25a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/udp.rs
41
100
tokio-rs/tokio:tokio/tests/udp.rs:3
#[tokio::test] async fn send_to_peek_from() -> std::io::Result<()> { let sender = UdpSocket::bind("127.0.0.1:0").await?; let receiver = UdpSocket::bind("127.0.0.1:0").await?; let receiver_addr = receiver.local_addr()?; poll_fn(|cx| sender.poll_send_to(cx, MSG, receiver_addr)).await?; // peek l...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
d4178cf34924d14fca4ecf551c97b8953376f25a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/udp.rs
81
140
tokio-rs/tokio:tokio/tests/udp.rs:4
match receiver.try_peek_from(&mut recv_buf) { Ok((n, addr)) => { assert_eq!(&recv_buf[..n], MSG); assert_eq!(addr, sender.local_addr()?); break; } Err(e) if e.kind() == io::ErrorKind::WouldBlock => { receiver.readable()....
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
d4178cf34924d14fca4ecf551c97b8953376f25a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/udp.rs
121
180
tokio-rs/tokio:tokio/tests/udp.rs:5
assert_eq!(addr, sender.local_addr()?); let mut recv_buf = [0u8; 32]; let mut read = ReadBuf::new(&mut recv_buf); poll_fn(|cx| receiver.poll_peek_from(cx, &mut read)).await?; assert_eq!(read.filled(), MSG); let mut recv_buf = [0u8; 32]; let mut read = ReadBuf::new(&mut recv_buf); poll_fn(...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
d4178cf34924d14fca4ecf551c97b8953376f25a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/udp.rs
161
220
tokio-rs/tokio:tokio/tests/udp.rs:6
#[tokio::test] async fn poll_peek_sender() -> std::io::Result<()> { let sender = UdpSocket::bind("127.0.0.1:0").await?; let receiver = UdpSocket::bind("127.0.0.1:0").await?; let sender_addr = sender.local_addr()?; let receiver_addr = receiver.local_addr()?; let msg = b"Hello, world!"; poll_fn(...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
d4178cf34924d14fca4ecf551c97b8953376f25a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/udp.rs
201
260
tokio-rs/tokio:tokio/tests/udp.rs:7
Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => { receiver.readable().await?; } Err(e) => return Err(e), } }; assert_eq!(peeked_sender, sender_addr); // Assert that `try_peek_sender()` returns the right sender but // didn't remove from the receive...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
d4178cf34924d14fca4ecf551c97b8953376f25a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/udp.rs
241
300
tokio-rs/tokio:tokio/tests/udp.rs:8
let socket = UdpSocket::bind("127.0.0.1:0").await?; let addr = socket.local_addr().unwrap(); let s = Arc::new(socket); let r = s.clone(); let (tx, mut rx) = tokio::sync::mpsc::channel::<(Vec<u8>, std::net::SocketAddr)>(1_000); tokio::spawn(async move { while let Some((bytes, addr)) = rx.rec...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
d4178cf34924d14fca4ecf551c97b8953376f25a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/udp.rs
281
340
tokio-rs/tokio:tokio/tests/udp.rs:9
poll_fn(|cx| s.poll_send_to(cx, &bytes, addr)) .await .unwrap(); } }); tokio::spawn(async move { let mut recv_buf = [0u8; 32]; let mut read = ReadBuf::new(&mut recv_buf); loop { let addr = poll_fn(|cx| r.poll_recv_from(cx, &mut read))....
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
d4178cf34924d14fca4ecf551c97b8953376f25a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/udp.rs
321
380
tokio-rs/tokio:tokio/tests/udp.rs:10
let receiver = UdpSocket::bind("127.0.0.1:0").await.unwrap(); receiver .connect(sender.local_addr().unwrap()) .await .unwrap(); sender.writable().await.unwrap(); let sent = &sender .try_send_to(MSG, receiver.local_addr().unwrap()) .unwrap(); assert_eq!(sent, &M...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
d4178cf34924d14fca4ecf551c97b8953376f25a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/udp.rs
361
420
tokio-rs/tokio:tokio/tests/udp.rs:11
// Create socket pair let client = UdpSocket::bind("127.0.0.1:0").await.unwrap(); // Connect the two client.connect(server.local_addr().unwrap()).await.unwrap(); server.connect(client.local_addr().unwrap()).await.unwrap(); for _ in 0..5 { loop { client.writable().await.unwrap()...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
d4178cf34924d14fca4ecf551c97b8953376f25a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/udp.rs
401
460
tokio-rs/tokio:tokio/tests/udp.rs:12
async fn try_send_to_recv_from() { // Create listener let server = UdpSocket::bind("127.0.0.1:0").await.unwrap(); let saddr = server.local_addr().unwrap(); // Create socket pair let client = UdpSocket::bind("127.0.0.1:0").await.unwrap(); let caddr = client.local_addr().unwrap(); for _ in 0...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
d4178cf34924d14fca4ecf551c97b8953376f25a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/udp.rs
441
500
tokio-rs/tokio:tokio/tests/udp.rs:13
} #[tokio::test] async fn try_recv_buf() { // Create listener let server = UdpSocket::bind("127.0.0.1:0").await.unwrap(); // Create socket pair let client = UdpSocket::bind("127.0.0.1:0").await.unwrap(); // Connect the two client.connect(server.local_addr().unwrap()).await.unwrap(); serve...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
d4178cf34924d14fca4ecf551c97b8953376f25a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/udp.rs
481
540
tokio-rs/tokio:tokio/tests/udp.rs:14
Err(e) => panic!("{e:?}"), } } } } #[tokio::test] async fn recv_buf() -> std::io::Result<()> { let sender = UdpSocket::bind("127.0.0.1:0").await?; let receiver = UdpSocket::bind("127.0.0.1:0").await?; sender.connect(receiver.local_addr()?).await?; receiver.connect(sender.local_...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
d4178cf34924d14fca4ecf551c97b8953376f25a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/udp.rs
521
580
tokio-rs/tokio:tokio/tests/udp.rs:15
break; } Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => continue, Err(e) => panic!("{e:?}"), } } loop { server.readable().await.unwrap(); let mut buf = Vec::with_capacity(512); match server.try_rec...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
d4178cf34924d14fca4ecf551c97b8953376f25a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/udp.rs
561
620
tokio-rs/tokio:tokio/tests/udp.rs:16
Ok(()) } #[tokio::test] async fn poll_ready() { // Create listener let server = UdpSocket::bind("127.0.0.1:0").await.unwrap(); let saddr = server.local_addr().unwrap(); // Create socket pair let client = UdpSocket::bind("127.0.0.1:0").await.unwrap(); let caddr = client.local_addr().unwrap(); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
d4178cf34924d14fca4ecf551c97b8953376f25a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/udp.rs
601
645
tokio-rs/tokio:tokio/tests/udp.rs:10
let receiver = UdpSocket::bind("127.0.0.1:0").await.unwrap(); receiver .connect(sender.local_addr().unwrap()) .await .unwrap(); sender.writable().await.unwrap(); let sent = &sender .try_send_to(MSG, receiver.local_addr().unwrap()) .unwrap(); assert_eq!(sent, &M...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
161b8c80d58a4a070c7f41db18d43ea258737db7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/udp.rs
361
420
tokio-rs/tokio:tokio/tests/udp.rs:11
// Create socket pair let client = UdpSocket::bind("127.0.0.1:0").await.unwrap(); // Connect the two client.connect(server.local_addr().unwrap()).await.unwrap(); server.connect(client.local_addr().unwrap()).await.unwrap(); for _ in 0..5 { loop { client.writable().await.unwrap()...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
161b8c80d58a4a070c7f41db18d43ea258737db7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/udp.rs
401
460
tokio-rs/tokio:tokio/tests/udp.rs:12
async fn try_send_to_recv_from() { // Create listener let server = UdpSocket::bind("127.0.0.1:0").await.unwrap(); let saddr = server.local_addr().unwrap(); // Create socket pair let client = UdpSocket::bind("127.0.0.1:0").await.unwrap(); let caddr = client.local_addr().unwrap(); for _ in 0...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
161b8c80d58a4a070c7f41db18d43ea258737db7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/udp.rs
441
500
tokio-rs/tokio:tokio/tests/udp.rs:13
} #[tokio::test] async fn try_recv_buf() { // Create listener let server = UdpSocket::bind("127.0.0.1:0").await.unwrap(); // Create socket pair let client = UdpSocket::bind("127.0.0.1:0").await.unwrap(); // Connect the two client.connect(server.local_addr().unwrap()).await.unwrap(); serve...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
161b8c80d58a4a070c7f41db18d43ea258737db7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/udp.rs
481
540
tokio-rs/tokio:tokio/tests/udp.rs:14
Err(e) => panic!("{:?}", e), } } } } #[tokio::test] async fn recv_buf() -> std::io::Result<()> { let sender = UdpSocket::bind("127.0.0.1:0").await?; let receiver = UdpSocket::bind("127.0.0.1:0").await?; sender.connect(receiver.local_addr()?).await?; receiver.connect(sender.loca...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
161b8c80d58a4a070c7f41db18d43ea258737db7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/udp.rs
521
580
tokio-rs/tokio:tokio/tests/udp.rs:15
break; } Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => continue, Err(e) => panic!("{:?}", e), } } loop { server.readable().await.unwrap(); let mut buf = Vec::with_capacity(512); match server.try_r...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
161b8c80d58a4a070c7f41db18d43ea258737db7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/udp.rs
561
620
tokio-rs/tokio:tokio/tests/udp.rs:16
Ok(()) } #[tokio::test] async fn poll_ready() { // Create listener let server = UdpSocket::bind("127.0.0.1:0").await.unwrap(); let saddr = server.local_addr().unwrap(); // Create socket pair let client = UdpSocket::bind("127.0.0.1:0").await.unwrap(); let caddr = client.local_addr().unwrap(); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
161b8c80d58a4a070c7f41db18d43ea258737db7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/udp.rs
601
645
tokio-rs/tokio:tokio/tests/udp.rs:1
#![warn(rust_2018_idioms)] #![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support bind or UDP use std::future::poll_fn; use std::io; use std::sync::Arc; use tokio::{io::ReadBuf, net::UdpSocket}; use tokio_test::assert_ok; const MSG: &[u8] = b"hello"; const MSG_LEN: usize = MSG.len(); #[toki...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
12b2567b959ec754e6f58fb76b88a1a38f805771
github
async-runtime
https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/udp.rs
1
60
tokio-rs/tokio:tokio/tests/udp.rs:1
#![warn(rust_2018_idioms)] #![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support bind or UDP use futures::future::poll_fn; use std::io; use std::sync::Arc; use tokio::{io::ReadBuf, net::UdpSocket}; use tokio_test::assert_ok; const MSG: &[u8] = b"hello"; const MSG_LEN: usize = MSG.len(); #[...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
c445e467ce4363b3a9b6825268814a9bc27c0127
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/udp.rs
1
60
tokio-rs/tokio:tokio/tests/udp.rs:1
#![warn(rust_2018_idioms)] #![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi does not support bind or UDP use futures::future::poll_fn; use std::io; use std::sync::Arc; use tokio::{io::ReadBuf, net::UdpSocket}; use tokio_test::assert_ok; const MSG: &[u8] = b"hello"; const MSG_LEN: usize = MSG.len(); #[tokio::t...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
b31f1a4662e708596fe9cd89853a153b62ec056b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b31f1a4662e708596fe9cd89853a153b62ec056b/tokio/tests/udp.rs
1
60
tokio-rs/tokio:tokio/tests/udp.rs:13
} #[tokio::test] async fn try_recv_buf() { // Create listener let server = UdpSocket::bind("127.0.0.1:0").await.unwrap(); // Create socket pair let client = UdpSocket::bind("127.0.0.1:0").await.unwrap(); // Connect the two client.connect(server.local_addr().unwrap()).await.unwrap(); serve...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
d459a9345334911be4af1bba58b6c796d92fde66
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d459a9345334911be4af1bba58b6c796d92fde66/tokio/tests/udp.rs
481
540
tokio-rs/tokio:tokio/tests/udp.rs:14
Err(e) => panic!("{:?}", e), } } } } #[tokio::test] async fn try_recv_buf_from() { // Create listener let server = UdpSocket::bind("127.0.0.1:0").await.unwrap(); let saddr = server.local_addr().unwrap(); // Create socket pair let client = UdpSocket::bind("127.0.0.1:0").awai...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
d459a9345334911be4af1bba58b6c796d92fde66
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d459a9345334911be4af1bba58b6c796d92fde66/tokio/tests/udp.rs
521
580
tokio-rs/tokio:tokio/tests/udp.rs:15
break; } Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => continue, Err(e) => panic!("{:?}", e), } } } } #[tokio::test] async fn poll_ready() { // Create listener let server = UdpSocket::bind("127.0.0.1:0").await.unwrap(); let sa...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
d459a9345334911be4af1bba58b6c796d92fde66
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d459a9345334911be4af1bba58b6c796d92fde66/tokio/tests/udp.rs
561
611
tokio-rs/tokio:tokio/tests/udp.rs:16
assert_eq!(n, 11); assert_eq!(addr, caddr); assert_eq!(&buf[0..11], &b"hello world"[..]); break; } Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => continue, Err(e) => panic!("{:?}", e), } ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
d459a9345334911be4af1bba58b6c796d92fde66
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d459a9345334911be4af1bba58b6c796d92fde66/tokio/tests/udp.rs
601
611
tokio-rs/tokio:tokio/tests/udp.rs:3
#[tokio::test] async fn send_to_peek_from() -> std::io::Result<()> { let sender = UdpSocket::bind("127.0.0.1:0").await?; let receiver = UdpSocket::bind("127.0.0.1:0").await?; let receiver_addr = receiver.local_addr()?; poll_fn(|cx| sender.poll_send_to(cx, MSG, receiver_addr)).await?; // peek l...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
fc9518b62714daac9a38b46c698b94ac5d5b1ca2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fc9518b62714daac9a38b46c698b94ac5d5b1ca2/tokio/tests/udp.rs
81
140
tokio-rs/tokio:tokio/tests/udp.rs:4
assert_eq!(read.filled(), MSG); assert_eq!(addr, sender.local_addr()?); let mut recv_buf = [0u8; 32]; let mut read = ReadBuf::new(&mut recv_buf); poll_fn(|cx| receiver.poll_peek_from(cx, &mut read)).await?; assert_eq!(read.filled(), MSG); let mut recv_buf = [0u8; 32]; let mut read = ReadBu...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
fc9518b62714daac9a38b46c698b94ac5d5b1ca2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fc9518b62714daac9a38b46c698b94ac5d5b1ca2/tokio/tests/udp.rs
121
180
tokio-rs/tokio:tokio/tests/udp.rs:5
let (tx, mut rx) = tokio::sync::mpsc::channel::<(Vec<u8>, std::net::SocketAddr)>(1_000); tokio::spawn(async move { while let Some((bytes, addr)) = rx.recv().await { s.send_to(&bytes, &addr).await.unwrap(); } }); tokio::spawn(async move { let mut buf = [0u8; 32]; ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
fc9518b62714daac9a38b46c698b94ac5d5b1ca2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fc9518b62714daac9a38b46c698b94ac5d5b1ca2/tokio/tests/udp.rs
161
220
tokio-rs/tokio:tokio/tests/udp.rs:6
tokio::spawn(async move { let mut recv_buf = [0u8; 32]; let mut read = ReadBuf::new(&mut recv_buf); loop { let addr = poll_fn(|cx| r.poll_recv_from(cx, &mut read)).await.unwrap(); tx.send((read.filled().to_vec(), addr)).await.unwrap(); } }); // test that ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
fc9518b62714daac9a38b46c698b94ac5d5b1ca2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fc9518b62714daac9a38b46c698b94ac5d5b1ca2/tokio/tests/udp.rs
201
260
tokio-rs/tokio:tokio/tests/udp.rs:7
.unwrap(); sender.writable().await.unwrap(); let sent = &sender .try_send_to(MSG, receiver.local_addr().unwrap()) .unwrap(); assert_eq!(sent, &MSG_LEN); let mut buf = [0u8; 32]; let mut received = receiver.recv(&mut buf[..]).await.unwrap(); sender .connect(receiver.loc...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/udp.rs
MIT
fc9518b62714daac9a38b46c698b94ac5d5b1ca2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fc9518b62714daac9a38b46c698b94ac5d5b1ca2/tokio/tests/udp.rs
241
300