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/io_async_read.rs:2 | #[test]
fn read_buf_error() {
struct Rd;
impl AsyncRead for Rd {
fn poll_read(
self: Pin<&mut Self>,
_cx: &mut Context<'_>,
_buf: &mut [u8],
) -> Poll<io::Result<usize>> {
let err = io::ErrorKind::Other.into();
Poll::Ready(Err(err))
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_read.rs | MIT | 966ccd5d5306adf6b6c39721331c2a3c32be6fa8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/966ccd5d5306adf6b6c39721331c2a3c32be6fa8/tokio/tests/io_async_read.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/io_async_read.rs:3 | task::spawn(Rd).enter(|cx, rd| {
let n = assert_ready_ok!(rd.poll_read_buf(cx, &mut buf));
assert_eq!(0, n);
});
}
#[test]
fn read_buf_no_uninitialized() {
struct Rd;
impl AsyncRead for Rd {
fn poll_read(
self: Pin<&mut Self>,
_cx: &mut Context<'_>,
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_read.rs | MIT | 966ccd5d5306adf6b6c39721331c2a3c32be6fa8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/966ccd5d5306adf6b6c39721331c2a3c32be6fa8/tokio/tests/io_async_read.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/io_async_read.rs:4 | }
fn poll_read(
self: Pin<&mut Self>,
_cx: &mut Context<'_>,
buf: &mut [u8],
) -> Poll<io::Result<usize>> {
assert_eq!(buf[0..11], b"hello world"[..]);
Poll::Ready(Ok(0))
}
}
// Can't create BytesMut w/ zero capacity, so fill ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_async_read.rs | MIT | 966ccd5d5306adf6b6c39721331c2a3c32be6fa8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/966ccd5d5306adf6b6c39721331c2a3c32be6fa8/tokio/tests/io_async_read.rs | 121 | 144 |
tokio-rs/tokio:tokio/tests/io_buf_reader.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
// https://github.com/rust-lang/futures-rs/blob/1803948ff091b4eabf7f3bf39e16bbbdefca5cc8/futures/tests/io_buf_reader.rs
use futures::task::{noop_waker_ref, Context, Poll};
use std::cmp;
use std::io::{self, Cursor};
use std::pin::Pin;
use tokio::io::{
AsyncBufRe... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_buf_reader.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_buf_reader.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_buf_reader.rs:2 | }
}
impl AsyncRead for MaybePending<'_> {
fn poll_read(
mut self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &mut ReadBuf<'_>,
) -> Poll<io::Result<()>> {
if self.ready_read {
self.ready_read = false;
Pin::new(&mut self.inner).poll_read(cx, buf)
}... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_buf_reader.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_buf_reader.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/io_buf_reader.rs:3 | #[tokio::test]
async fn test_buffered_reader() {
let inner: &[u8] = &[5, 6, 7, 0, 1, 2, 3, 4];
let mut reader = BufReader::with_capacity(2, inner);
let mut buf = [0, 0, 0];
let nread = reader.read(&mut buf).await.unwrap();
assert_eq!(nread, 3);
assert_eq!(buf, [5, 6, 7]);
assert_eq!(reader.... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_buf_reader.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_buf_reader.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/io_buf_reader.rs:4 | let mut reader = BufReader::with_capacity(2, Cursor::new(inner));
assert_eq!(reader.seek(SeekFrom::Start(3)).await.unwrap(), 3);
assert_eq!(run_fill_buf!(reader).unwrap(), &[0, 1][..]);
assert!(reader.seek(SeekFrom::Current(i64::MIN)).await.is_err());
assert_eq!(run_fill_buf!(reader).unwrap(), &[0, 1][... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_buf_reader.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_buf_reader.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/io_buf_reader.rs:5 | SeekFrom::Current(n) => {
self.pos = self.pos.wrapping_add(n as u64);
}
SeekFrom::End(n) => {
self.pos = u64::MAX.wrapping_add(n as u64);
}
}
Ok(())
}
fn poll_complete(self: Pin<&mut Self>, _:... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_buf_reader.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_buf_reader.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/io_buf_reader.rs:6 | _: &mut Context<'_>,
buf: &mut ReadBuf<'_>,
) -> Poll<io::Result<()>> {
if !self.lengths.is_empty() {
buf.advance(self.lengths.remove(0));
}
Poll::Ready(Ok(()))
}
}
let inner = ShortReader {
lengths: vec![0, 1, 2, 0, 1, 0],... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_buf_reader.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_buf_reader.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/io_buf_reader.rs:7 | let mut buf = [0];
let nread = reader.read(&mut buf).await.unwrap();
assert_eq!(nread, 1);
assert_eq!(buf, [2]);
assert_eq!(reader.buffer(), [3]);
let mut buf = [0, 0, 0];
let nread = reader.read(&mut buf).await.unwrap();
assert_eq!(nread, 1);
assert_eq!(buf, [3, 0, 0]);
assert_eq!(... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_buf_reader.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_buf_reader.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/io_buf_reader.rs:8 | #[tokio::test]
async fn maybe_pending_seek() {
struct MaybePendingSeek<'a> {
inner: Cursor<&'a [u8]>,
ready: bool,
seek_res: Option<io::Result<()>>,
}
impl<'a> MaybePendingSeek<'a> {
fn new(inner: &'a [u8]) -> Self {
Self {
inner: Cursor::new(inne... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_buf_reader.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_buf_reader.rs | 281 | 340 |
tokio-rs/tokio:tokio/tests/io_buf_reader.rs:9 | }
impl AsyncSeek for MaybePendingSeek<'_> {
fn start_seek(mut self: Pin<&mut Self>, pos: SeekFrom) -> io::Result<()> {
self.seek_res = Some(Pin::new(&mut self.inner).start_seek(pos));
Ok(())
}
fn poll_complete(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<i... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_buf_reader.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_buf_reader.rs | 321 | 379 |
tokio-rs/tokio:tokio/tests/io_buf_reader.rs:10 | assert_eq!(read.fill_buf().await.unwrap(), b"hello world");
read.consume(b"hello ".len());
assert_eq!(read.fill_buf().await.unwrap(), b"world");
assert_eq!(read.fill_buf().await.unwrap(), b"world");
read.consume(b"world".len());
let mut fill = spawn(read.fill_buf());
assert_pending!(fill.poll()... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_buf_reader.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_buf_reader.rs | 361 | 379 |
tokio-rs/tokio:tokio/tests/io_buf_reader.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
// https://github.com/rust-lang/futures-rs/blob/1803948ff091b4eabf7f3bf39e16bbbdefca5cc8/futures/tests/io_buf_reader.rs
use futures::task::{noop_waker_ref, Context, Poll};
use std::cmp;
use std::io::{self, Cursor};
use std::pin::Pin;
use tokio::io::{
AsyncBufRe... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_buf_reader.rs | MIT | f3ed064a269fd72711e40121dad1a9fd9f16bdc0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f3ed064a269fd72711e40121dad1a9fd9f16bdc0/tokio/tests/io_buf_reader.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_buf_reader.rs:2 | impl AsyncRead for MaybePending<'_> {
fn poll_read(
mut self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &mut ReadBuf<'_>,
) -> Poll<io::Result<()>> {
if self.ready_read {
self.ready_read = false;
Pin::new(&mut self.inner).poll_read(cx, buf)
} else... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_buf_reader.rs | MIT | f3ed064a269fd72711e40121dad1a9fd9f16bdc0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f3ed064a269fd72711e40121dad1a9fd9f16bdc0/tokio/tests/io_buf_reader.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/io_buf_reader.rs:3 | let inner: &[u8] = &[5, 6, 7, 0, 1, 2, 3, 4];
let mut reader = BufReader::with_capacity(2, inner);
let mut buf = [0, 0, 0];
let nread = reader.read(&mut buf).await.unwrap();
assert_eq!(nread, 3);
assert_eq!(buf, [5, 6, 7]);
assert_eq!(reader.buffer(), []);
let mut buf = [0, 0];
let nre... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_buf_reader.rs | MIT | f3ed064a269fd72711e40121dad1a9fd9f16bdc0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f3ed064a269fd72711e40121dad1a9fd9f16bdc0/tokio/tests/io_buf_reader.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/io_buf_reader.rs:4 | assert_eq!(reader.seek(SeekFrom::Start(3)).await.unwrap(), 3);
assert_eq!(run_fill_buf!(reader).unwrap(), &[0, 1][..]);
assert!(reader.seek(SeekFrom::Current(i64::MIN)).await.is_err());
assert_eq!(run_fill_buf!(reader).unwrap(), &[0, 1][..]);
assert_eq!(reader.seek(SeekFrom::Current(1)).await.unwrap(), ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_buf_reader.rs | MIT | f3ed064a269fd72711e40121dad1a9fd9f16bdc0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f3ed064a269fd72711e40121dad1a9fd9f16bdc0/tokio/tests/io_buf_reader.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/io_buf_reader.rs:5 | }
SeekFrom::End(n) => {
self.pos = u64::MAX.wrapping_add(n as u64);
}
}
Ok(())
}
fn poll_complete(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<io::Result<u64>> {
Poll::Ready(Ok(self.pos))
}
}
l... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_buf_reader.rs | MIT | f3ed064a269fd72711e40121dad1a9fd9f16bdc0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f3ed064a269fd72711e40121dad1a9fd9f16bdc0/tokio/tests/io_buf_reader.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/io_buf_reader.rs:6 | ) -> Poll<io::Result<()>> {
if !self.lengths.is_empty() {
buf.advance(self.lengths.remove(0));
}
Poll::Ready(Ok(()))
}
}
let inner = ShortReader {
lengths: vec![0, 1, 2, 0, 1, 0],
};
let mut reader = BufReader::new(inner);
let mut ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_buf_reader.rs | MIT | f3ed064a269fd72711e40121dad1a9fd9f16bdc0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f3ed064a269fd72711e40121dad1a9fd9f16bdc0/tokio/tests/io_buf_reader.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/io_buf_reader.rs:7 | let nread = reader.read(&mut buf).await.unwrap();
assert_eq!(nread, 1);
assert_eq!(buf, [2]);
assert_eq!(reader.buffer(), [3]);
let mut buf = [0, 0, 0];
let nread = reader.read(&mut buf).await.unwrap();
assert_eq!(nread, 1);
assert_eq!(buf, [3, 0, 0]);
assert_eq!(reader.buffer(), []);
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_buf_reader.rs | MIT | f3ed064a269fd72711e40121dad1a9fd9f16bdc0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f3ed064a269fd72711e40121dad1a9fd9f16bdc0/tokio/tests/io_buf_reader.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/io_buf_reader.rs:8 | struct MaybePendingSeek<'a> {
inner: Cursor<&'a [u8]>,
ready: bool,
seek_res: Option<io::Result<()>>,
}
impl<'a> MaybePendingSeek<'a> {
fn new(inner: &'a [u8]) -> Self {
Self {
inner: Cursor::new(inner),
ready: true,
se... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_buf_reader.rs | MIT | f3ed064a269fd72711e40121dad1a9fd9f16bdc0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f3ed064a269fd72711e40121dad1a9fd9f16bdc0/tokio/tests/io_buf_reader.rs | 281 | 340 |
tokio-rs/tokio:tokio/tests/io_buf_reader.rs:9 | impl AsyncSeek for MaybePendingSeek<'_> {
fn start_seek(mut self: Pin<&mut Self>, pos: SeekFrom) -> io::Result<()> {
self.seek_res = Some(Pin::new(&mut self.inner).start_seek(pos));
Ok(())
}
fn poll_complete(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Resu... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_buf_reader.rs | MIT | f3ed064a269fd72711e40121dad1a9fd9f16bdc0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f3ed064a269fd72711e40121dad1a9fd9f16bdc0/tokio/tests/io_buf_reader.rs | 321 | 350 |
tokio-rs/tokio:tokio/tests/io_buf_reader.rs:3 | let inner: &[u8] = &[5, 6, 7, 0, 1, 2, 3, 4];
let mut reader = BufReader::with_capacity(2, inner);
let mut buf = [0, 0, 0];
let nread = reader.read(&mut buf).await.unwrap();
assert_eq!(nread, 3);
assert_eq!(buf, [5, 6, 7]);
assert_eq!(reader.buffer(), []);
let mut buf = [0, 0];
let nre... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_buf_reader.rs | MIT | 8c395dfe61b7d5ad3535f8cb97c560c6017a15a9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8c395dfe61b7d5ad3535f8cb97c560c6017a15a9/tokio/tests/io_buf_reader.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/io_buf_reader.rs:4 | assert_eq!(reader.seek(SeekFrom::Start(3)).await.unwrap(), 3);
assert_eq!(run_fill_buf!(reader).unwrap(), &[0, 1][..]);
assert!(reader
.seek(SeekFrom::Current(i64::min_value()))
.await
.is_err());
assert_eq!(run_fill_buf!(reader).unwrap(), &[0, 1][..]);
assert_eq!(reader.seek(See... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_buf_reader.rs | MIT | 8c395dfe61b7d5ad3535f8cb97c560c6017a15a9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8c395dfe61b7d5ad3535f8cb97c560c6017a15a9/tokio/tests/io_buf_reader.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/io_buf_reader.rs:5 | }
SeekFrom::Current(n) => {
self.pos = self.pos.wrapping_add(n as u64);
}
SeekFrom::End(n) => {
self.pos = u64::max_value().wrapping_add(n as u64);
}
}
Ok(())
}
fn poll_complet... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_buf_reader.rs | MIT | 8c395dfe61b7d5ad3535f8cb97c560c6017a15a9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8c395dfe61b7d5ad3535f8cb97c560c6017a15a9/tokio/tests/io_buf_reader.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/io_buf_reader.rs:6 | struct ShortReader {
lengths: Vec<usize>,
}
impl AsyncRead for ShortReader {
fn poll_read(
mut self: Pin<&mut Self>,
_: &mut Context<'_>,
buf: &mut ReadBuf<'_>,
) -> Poll<io::Result<()>> {
if !self.lengths.is_empty() {
buf.... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_buf_reader.rs | MIT | 8c395dfe61b7d5ad3535f8cb97c560c6017a15a9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8c395dfe61b7d5ad3535f8cb97c560c6017a15a9/tokio/tests/io_buf_reader.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/io_buf_reader.rs:7 | assert_eq!(reader.buffer(), []);
let mut buf = [0, 0];
let nread = reader.read(&mut buf).await.unwrap();
assert_eq!(nread, 2);
assert_eq!(buf, [0, 1]);
assert_eq!(reader.buffer(), []);
let mut buf = [0];
let nread = reader.read(&mut buf).await.unwrap();
assert_eq!(nread, 1);
assert... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_buf_reader.rs | MIT | 8c395dfe61b7d5ad3535f8cb97c560c6017a15a9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8c395dfe61b7d5ad3535f8cb97c560c6017a15a9/tokio/tests/io_buf_reader.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/io_buf_reader.rs:8 | assert_eq!(v, [0]);
v.clear();
reader.read_until(9, &mut v).await.unwrap();
assert_eq!(v, []);
}
// https://github.com/rust-lang/futures-rs/pull/1573#discussion_r281162309
#[tokio::test]
async fn maybe_pending_seek() {
struct MaybePendingSeek<'a> {
inner: Cursor<&'a [u8]>,
ready: bool,
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_buf_reader.rs | MIT | 8c395dfe61b7d5ad3535f8cb97c560c6017a15a9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8c395dfe61b7d5ad3535f8cb97c560c6017a15a9/tokio/tests/io_buf_reader.rs | 281 | 340 |
tokio-rs/tokio:tokio/tests/io_buf_reader.rs:9 | let this: *mut Self = &mut *self as *mut _;
Pin::new(&mut unsafe { &mut *this }.inner).poll_fill_buf(cx)
}
fn consume(mut self: Pin<&mut Self>, amt: usize) {
Pin::new(&mut self.inner).consume(amt)
}
}
impl AsyncSeek for MaybePendingSeek<'_> {
fn start_se... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_buf_reader.rs | MIT | 8c395dfe61b7d5ad3535f8cb97c560c6017a15a9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8c395dfe61b7d5ad3535f8cb97c560c6017a15a9/tokio/tests/io_buf_reader.rs | 321 | 362 |
tokio-rs/tokio:tokio/tests/io_buf_writer.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
// https://github.com/rust-lang/futures-rs/blob/1803948ff091b4eabf7f3bf39e16bbbdefca5cc8/futures/tests/io_buf_writer.rs
use futures::task::{Context, Poll};
use std::io::{self, Cursor};
use std::pin::Pin;
use tokio::io::{AsyncSeek, AsyncSeekExt, AsyncWrite, AsyncWri... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_buf_writer.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_buf_writer.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_buf_writer.rs:2 | ) -> Poll<io::Result<usize>> {
if self.ready {
self.ready = false;
Pin::new(&mut self.inner).poll_write(cx, buf)
} else {
self.ready = true;
cx.waker().wake_by_ref();
Poll::Pending
}
}
fn poll_flush(mut self: Pin<&mut Self>, cx... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_buf_writer.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_buf_writer.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/io_buf_writer.rs:3 | assert_eq!(writer.write(&[3]).await.unwrap(), 1);
assert_eq!(writer.buffer(), [2, 3]);
assert_eq!(*writer.get_ref(), [0, 1]);
writer.flush().await.unwrap();
assert_eq!(writer.buffer(), []);
assert_eq!(*writer.get_ref(), [0, 1, 2, 3]);
assert_eq!(writer.write(&[4]).await.unwrap(), 1);
asser... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_buf_writer.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_buf_writer.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/io_buf_writer.rs:4 | #[tokio::test]
async fn buf_writer_seek() {
let mut w = BufWriter::with_capacity(3, Cursor::new(Vec::new()));
w.write_all(&[0, 1, 2, 3, 4, 5]).await.unwrap();
w.write_all(&[6, 7]).await.unwrap();
assert_eq!(w.seek(SeekFrom::Current(0)).await.unwrap(), 8);
assert_eq!(&w.get_ref().get_ref()[..], &[0, ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_buf_writer.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_buf_writer.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/io_buf_writer.rs:5 | assert_eq!(writer.get_ref().inner, &[0, 1, 2, 3, 4, 5]);
assert_eq!(writer.write(&[7, 8]).await.unwrap(), 2);
assert_eq!(writer.buffer(), []);
assert_eq!(writer.get_ref().inner, &[0, 1, 2, 3, 4, 5, 6, 7, 8]);
assert_eq!(writer.write(&[9, 10, 11]).await.unwrap(), 3);
assert_eq!(writer.buffer(), [])... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_buf_writer.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_buf_writer.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/io_buf_writer.rs:6 | impl MaybePendingSeek {
fn new(inner: Vec<u8>) -> Self {
Self {
inner: Cursor::new(inner),
ready_write: false,
ready_seek: false,
seek_res: None,
}
}
}
impl AsyncWrite for MaybePendingSeek {
fn poll_... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_buf_writer.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_buf_writer.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/io_buf_writer.rs:7 | }
fn poll_complete(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<u64>> {
if self.ready_seek {
self.ready_seek = false;
self.seek_res.take().unwrap_or(Ok(()))?;
Pin::new(&mut self.inner).poll_complete(cx)
} else {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_buf_writer.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_buf_writer.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/io_buf_writer.rs:8 | data: Vec::new(),
write_len,
vectored: false,
}
}
fn vectored(write_len: usize) -> Self {
MockWriter {
data: Vec::new(),
write_len,
vectored: true,
}
}
fn write_up_to(&mut self, buf: &[u8], limit: usize) -> usize {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_buf_writer.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_buf_writer.rs | 281 | 340 |
tokio-rs/tokio:tokio/tests/io_buf_writer.rs:9 | let n = this.write_up_to(buf, this.write_len - total_written);
total_written += n;
if total_written == this.write_len {
break;
}
}
Ok(total_written).into()
}
fn is_write_vectored(&self) -> bool {
self.vectored
}
fn poll_flush(... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_buf_writer.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_buf_writer.rs | 321 | 380 |
tokio-rs/tokio:tokio/tests/io_buf_writer.rs:10 | assert_eq!(n, 0);
let io_vec = [IoSlice::new(&[]); 3];
let n = assert_ok!(write_vectored(&mut w, &io_vec).await);
assert_eq!(n, 0);
assert_ok!(w.flush().await);
assert!(w.get_ref().data.is_empty());
}
#[tokio::test]
async fn write_vectored_basic_on_non_vectored() {
let msg = b"foo bar baz";
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_buf_writer.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_buf_writer.rs | 361 | 420 |
tokio-rs/tokio:tokio/tests/io_buf_writer.rs:11 | }
#[tokio::test]
async fn write_vectored_large_total_on_non_vectored() {
let msg = b"foo bar baz";
let mut bufs = [
IoSlice::new(&msg[0..4]),
IoSlice::new(&msg[4..8]),
IoSlice::new(&msg[8..]),
];
let io_vec = IoBufs::new(&mut bufs);
let mut w = BufWriter::with_capacity(8, Mo... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_buf_writer.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_buf_writer.rs | 401 | 460 |
tokio-rs/tokio:tokio/tests/io_buf_writer.rs:12 | }
struct VectoredWriteHarness {
writer: BufWriter<MockWriter>,
buf_capacity: usize,
}
impl VectoredWriteHarness {
fn new(buf_capacity: usize) -> Self {
VectoredWriteHarness {
writer: BufWriter::with_capacity(buf_capacity, MockWriter::new(4)),
buf_capacity,
}
}
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_buf_writer.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_buf_writer.rs | 441 | 500 |
tokio-rs/tokio:tokio/tests/io_buf_writer.rs:13 | #[tokio::test]
async fn write_vectored_odd_on_non_vectored() {
let msg = b"foo bar baz";
let mut bufs = [
IoSlice::new(&msg[0..4]),
IoSlice::new(&[]),
IoSlice::new(&msg[4..9]),
IoSlice::new(&msg[9..]),
];
let mut h = VectoredWriteHarness::new(8);
let bytes_written = h... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_buf_writer.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_buf_writer.rs | 481 | 537 |
tokio-rs/tokio:tokio/tests/io_buf_writer.rs:14 | assert_eq!(bytes_written, msg.len());
assert_eq!(h.flush().await, msg);
}
#[tokio::test]
async fn write_vectored_large_slice_on_vectored() {
let msg = b"foo bar baz";
let mut bufs = [
IoSlice::new(&[]),
IoSlice::new(&msg[..9]),
IoSlice::new(&msg[9..]),
];
let mut h = Vectore... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_buf_writer.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_buf_writer.rs | 521 | 537 |
tokio-rs/tokio:tokio/tests/io_buf_writer.rs:2 | ) -> Poll<io::Result<usize>> {
if self.ready {
self.ready = false;
Pin::new(&mut self.inner).poll_write(cx, buf)
} else {
self.ready = true;
cx.waker().wake_by_ref();
Poll::Pending
}
}
fn poll_flush(mut self: Pin<&mut Self>, cx... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_buf_writer.rs | MIT | 0531549b6ea66d22d301044910ddc6a77e8c7f1e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0531549b6ea66d22d301044910ddc6a77e8c7f1e/tokio/tests/io_buf_writer.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/io_buf_writer.rs:3 | writer.write(&[3]).await.unwrap();
assert_eq!(writer.buffer(), [2, 3]);
assert_eq!(*writer.get_ref(), [0, 1]);
writer.flush().await.unwrap();
assert_eq!(writer.buffer(), []);
assert_eq!(*writer.get_ref(), [0, 1, 2, 3]);
writer.write(&[4]).await.unwrap();
writer.write(&[5]).await.unwrap();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_buf_writer.rs | MIT | 0531549b6ea66d22d301044910ddc6a77e8c7f1e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0531549b6ea66d22d301044910ddc6a77e8c7f1e/tokio/tests/io_buf_writer.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/io_buf_writer.rs:4 | #[tokio::test]
async fn buf_writer_seek() {
let mut w = BufWriter::with_capacity(3, Cursor::new(Vec::new()));
w.write_all(&[0, 1, 2, 3, 4, 5]).await.unwrap();
w.write_all(&[6, 7]).await.unwrap();
assert_eq!(w.seek(SeekFrom::Current(0)).await.unwrap(), 8);
assert_eq!(&w.get_ref().get_ref()[..], &[0, ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_buf_writer.rs | MIT | 0531549b6ea66d22d301044910ddc6a77e8c7f1e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0531549b6ea66d22d301044910ddc6a77e8c7f1e/tokio/tests/io_buf_writer.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/io_buf_writer.rs:5 | assert_eq!(writer.get_ref().inner, &[0, 1, 2, 3, 4, 5]);
writer.write(&[7, 8]).await.unwrap();
assert_eq!(writer.buffer(), []);
assert_eq!(writer.get_ref().inner, &[0, 1, 2, 3, 4, 5, 6, 7, 8]);
writer.write(&[9, 10, 11]).await.unwrap();
assert_eq!(writer.buffer(), []);
assert_eq!(
writ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_buf_writer.rs | MIT | 0531549b6ea66d22d301044910ddc6a77e8c7f1e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0531549b6ea66d22d301044910ddc6a77e8c7f1e/tokio/tests/io_buf_writer.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/io_buf_writer.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
// https://github.com/rust-lang/futures-rs/blob/1803948ff091b4eabf7f3bf39e16bbbdefca5cc8/futures/tests/io_buf_writer.rs
use futures::task::{Context, Poll};
use std::io::{self, Cursor};
use std::pin::Pin;
use tokio::io::{AsyncSeek, AsyncSeekExt, AsyncWrite, AsyncWri... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_buf_writer.rs | MIT | 8c395dfe61b7d5ad3535f8cb97c560c6017a15a9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8c395dfe61b7d5ad3535f8cb97c560c6017a15a9/tokio/tests/io_buf_writer.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_buf_writer.rs:2 | fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
Pin::new(&mut self.inner).poll_flush(cx)
}
fn poll_shutdown(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
Pin::new(&mut self.inner).poll_shutdown(cx)
}
}
#[tokio::test]
async... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_buf_writer.rs | MIT | 8c395dfe61b7d5ad3535f8cb97c560c6017a15a9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8c395dfe61b7d5ad3535f8cb97c560c6017a15a9/tokio/tests/io_buf_writer.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/io_buf_writer.rs:3 | assert_eq!(*writer.get_ref(), [0, 1, 2, 3, 4, 5, 6, 7, 8]);
writer.write(&[9, 10, 11]).await.unwrap();
assert_eq!(writer.buffer(), []);
assert_eq!(*writer.get_ref(), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]);
writer.flush().await.unwrap();
assert_eq!(writer.buffer(), []);
assert_eq!(*writer.get_... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_buf_writer.rs | MIT | 8c395dfe61b7d5ad3535f8cb97c560c6017a15a9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8c395dfe61b7d5ad3535f8cb97c560c6017a15a9/tokio/tests/io_buf_writer.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/io_buf_writer.rs:4 | assert_eq!(&writer.get_ref().inner, &[0, 1]);
writer.write(&[2]).await.unwrap();
assert_eq!(writer.buffer(), [2]);
assert_eq!(&writer.get_ref().inner, &[0, 1]);
writer.write(&[3]).await.unwrap();
assert_eq!(writer.buffer(), [2, 3]);
assert_eq!(&writer.get_ref().inner, &[0, 1]);
writer.flu... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_buf_writer.rs | MIT | 8c395dfe61b7d5ad3535f8cb97c560c6017a15a9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8c395dfe61b7d5ad3535f8cb97c560c6017a15a9/tokio/tests/io_buf_writer.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/io_buf_writer.rs:5 | }
#[tokio::test]
async fn maybe_pending_buf_writer_inner_flushes() {
let mut w = BufWriter::with_capacity(3, MaybePending::new(Vec::new()));
w.write(&[0, 1]).await.unwrap();
assert_eq!(&w.get_ref().inner, &[]);
w.flush().await.unwrap();
let w = w.into_inner().inner;
assert_eq!(w, [0, 1]);
}
#[... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_buf_writer.rs | MIT | 8c395dfe61b7d5ad3535f8cb97c560c6017a15a9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8c395dfe61b7d5ad3535f8cb97c560c6017a15a9/tokio/tests/io_buf_writer.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/io_buf_writer.rs:6 | Pin::new(&mut self.inner).poll_write(cx, buf)
} else {
self.ready_write = true;
cx.waker().wake_by_ref();
Poll::Pending
}
}
fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
Pin::ne... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_buf_writer.rs | MIT | 8c395dfe61b7d5ad3535f8cb97c560c6017a15a9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8c395dfe61b7d5ad3535f8cb97c560c6017a15a9/tokio/tests/io_buf_writer.rs | 201 | 251 |
tokio-rs/tokio:tokio/tests/io_buf_writer.rs:7 | &w.get_ref().inner.get_ref()[..],
&[0, 1, 2, 3, 4, 5, 6, 7][..]
);
assert_eq!(w.seek(SeekFrom::Start(2)).await.unwrap(), 2);
w.write_all(&[8, 9]).await.unwrap();
w.flush().await.unwrap();
assert_eq!(
&w.into_inner().inner.into_inner()[..],
&[0, 1, 8, 9, 4, 5, 6, 7]
);
} | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_buf_writer.rs | MIT | 8c395dfe61b7d5ad3535f8cb97c560c6017a15a9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8c395dfe61b7d5ad3535f8cb97c560c6017a15a9/tokio/tests/io_buf_writer.rs | 241 | 251 |
tokio-rs/tokio:tokio/tests/io_chain.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::io::AsyncReadExt;
use tokio_test::assert_ok;
#[tokio::test]
async fn chain() {
let mut buf = Vec::new();
let rd1: &[u8] = b"hello ";
let rd2: &[u8] = b"world";
let mut rd = rd1.chain(rd2);
assert_ok!(rd.read_to_end(&mut buf).await);
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_chain.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_chain.rs | 1 | 16 |
tokio-rs/tokio:tokio/tests/io_copy.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use bytes::BytesMut;
use tokio::io::{self, AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt, ReadBuf};
use tokio_test::assert_ok;
use std::pin::Pin;
use std::task::{ready, Context, Poll};
#[tokio::test]
async fn copy() {
struct Rd(bool);
impl AsyncRead ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_copy.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_copy.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_copy.rs:2 | struct BufferedWd {
buf: BytesMut,
writer: io::DuplexStream,
}
impl AsyncWrite for BufferedWd {
fn poll_write(
self: Pin<&mut Self>,
_cx: &mut Context<'_>,
buf: &[u8],
) -> Poll<io::Result<usize>> {
self.get_mut().buf.extend_from_s... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_copy.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_copy.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/io_copy.rs:3 | assert_ok!(wd.flush().await);
let n = assert_ok!(io::copy(&mut rd, &mut wd).await);
assert_eq!(n, 1024);
}
#[tokio::test]
async fn copy_is_cooperative() {
tokio::select! {
biased;
_ = async {
loop {
let mut reader: &[u8] = b"hello";
let mut writ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_copy.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_copy.rs | 81 | 101 |
tokio-rs/tokio:tokio/tests/io_copy.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use bytes::BytesMut;
use futures::ready;
use tokio::io::{self, AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt, ReadBuf};
use tokio_test::assert_ok;
use std::pin::Pin;
use std::task::{Context, Poll};
#[tokio::test]
async fn copy() {
struct Rd(bool);
im... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_copy.rs | MIT | 3275cfb638fe6cac6b0bbb1f60ee59eb499f6c2a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3275cfb638fe6cac6b0bbb1f60ee59eb499f6c2a/tokio/tests/io_copy.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_copy.rs:2 | async fn proxy() {
struct BufferedWd {
buf: BytesMut,
writer: io::DuplexStream,
}
impl AsyncWrite for BufferedWd {
fn poll_write(
self: Pin<&mut Self>,
_cx: &mut Context<'_>,
buf: &[u8],
) -> Poll<io::Result<usize>> {
self.get_... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_copy.rs | MIT | 3275cfb638fe6cac6b0bbb1f60ee59eb499f6c2a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3275cfb638fe6cac6b0bbb1f60ee59eb499f6c2a/tokio/tests/io_copy.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/io_copy.rs:3 | assert_ok!(wd.write_all(&[0x42; 512]).await);
assert_ok!(wd.flush().await);
let n = assert_ok!(io::copy(&mut rd, &mut wd).await);
assert_eq!(n, 1024);
}
#[tokio::test]
async fn copy_is_cooperative() {
tokio::select! {
biased;
_ = async {
loop {
let mut read... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_copy.rs | MIT | 3275cfb638fe6cac6b0bbb1f60ee59eb499f6c2a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3275cfb638fe6cac6b0bbb1f60ee59eb499f6c2a/tokio/tests/io_copy.rs | 81 | 102 |
tokio-rs/tokio:tokio/tests/io_copy.rs:2 | async fn proxy() {
struct BufferedWd {
buf: BytesMut,
writer: io::DuplexStream,
}
impl AsyncWrite for BufferedWd {
fn poll_write(
self: Pin<&mut Self>,
_cx: &mut Context<'_>,
buf: &[u8],
) -> Poll<io::Result<usize>> {
self.get_... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_copy.rs | MIT | f51676891f79151f596c9f919e3c74c78cbc07ed | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f51676891f79151f596c9f919e3c74c78cbc07ed/tokio/tests/io_copy.rs | 41 | 87 |
tokio-rs/tokio:tokio/tests/io_copy.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::io::{self, AsyncRead, ReadBuf};
use tokio_test::assert_ok;
use std::pin::Pin;
use std::task::{Context, Poll};
#[tokio::test]
async fn copy() {
struct Rd(bool);
impl AsyncRead for Rd {
fn poll_read(
mut self: Pin<&mut Self>,
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_copy.rs | MIT | f8c91f2ead24ed6e268a820405c329032dd30da6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f8c91f2ead24ed6e268a820405c329032dd30da6/tokio/tests/io_copy.rs | 1 | 36 |
tokio-rs/tokio:tokio/tests/io_copy.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::io::{self, AsyncRead, ReadBuf};
use tokio_test::assert_ok;
use std::pin::Pin;
use std::task::{Context, Poll};
#[tokio::test]
async fn copy() {
struct Rd(bool);
impl AsyncRead for Rd {
fn poll_read(
mut self: Pin<&mut Self>,
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_copy.rs | MIT | c393236dfd12c13e82badd631d3a3a90481c6f95 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c393236dfd12c13e82badd631d3a3a90481c6f95/tokio/tests/io_copy.rs | 1 | 36 |
tokio-rs/tokio:tokio/tests/io_copy.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::io::{self, AsyncRead};
use tokio_test::assert_ok;
use std::pin::Pin;
use std::task::{Context, Poll};
#[tokio::test]
async fn copy() {
struct Rd(bool);
impl AsyncRead for Rd {
fn poll_read(
mut self: Pin<&mut Self>,
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_copy.rs | MIT | 3ecaa6d91cef271b4c079a2e28bc3270280bcee6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3ecaa6d91cef271b4c079a2e28bc3270280bcee6/tokio/tests/io_copy.rs | 1 | 36 |
tokio-rs/tokio:tokio/tests/io_copy.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::io::{AsyncRead, AsyncReadExt};
use tokio_test::assert_ok;
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
#[tokio::test]
async fn copy() {
struct Rd(bool);
impl AsyncRead for Rd {
fn poll_read(
mut self: Pin<... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_copy.rs | MIT | 7b4c999341809588a427a9a80d310ee4aa1c1a21 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7b4c999341809588a427a9a80d310ee4aa1c1a21/tokio/tests/io_copy.rs | 1 | 37 |
tokio-rs/tokio:tokio/tests/io_copy.rs:1 | #![deny(warnings, rust_2018_idioms)]
#![feature(async_await)]
use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite};
use tokio_test::assert_ok;
use bytes::BytesMut;
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
#[tokio::test]
async fn copy() {
struct Rd(bool);
impl AsyncRead for Rd {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_copy.rs | MIT | ed4d4a5353d07d2428072965ea23c9a6eba5d87d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ed4d4a5353d07d2428072965ea23c9a6eba5d87d/tokio/tests/io_copy.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_copy.rs:2 | self.0.extend(buf);
Ok(buf.len()).into()
}
fn poll_flush(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<io::Result<()>> {
Ok(()).into()
}
fn poll_shutdown(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<io::Result<()>> {
Ok(()).into()
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_copy.rs | MIT | ed4d4a5353d07d2428072965ea23c9a6eba5d87d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ed4d4a5353d07d2428072965ea23c9a6eba5d87d/tokio/tests/io_copy.rs | 41 | 61 |
tokio-rs/tokio:tokio/tests/io_copy.rs:1 | #![deny(warnings, rust_2018_idioms)]
#![feature(async_await)]
use tokio::io::{AsyncRead, AsyncWrite, AsyncReadExt};
use tokio_test::assert_ok;
use bytes::BytesMut;
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
#[tokio::test]
async fn copy() {
struct Rd(bool);
impl AsyncRead for Rd {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_copy.rs | MIT | 1f47ed3dcc4b582315cdbfb195495d7d4c76d3f3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1f47ed3dcc4b582315cdbfb195495d7d4c76d3f3/tokio/tests/io_copy.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_copy.rs:1 | #![deny(warnings, rust_2018_idioms)]
use tokio::io::{AsyncRead, AsyncWrite, AsyncReadExt};
use tokio_test::assert_ready_ok;
use tokio_test::task::MockTask;
use bytes::BytesMut;
use pin_utils::pin_mut;
use std::future::Future;
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
#[test]
fn copy() {
str... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_copy.rs | MIT | 11f6b2862fc458204aabbed9a6f919c65215aeb5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/11f6b2862fc458204aabbed9a6f919c65215aeb5/tokio/tests/io_copy.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_copy.rs:2 | buf: &[u8],
) -> Poll<io::Result<usize>> {
self.0.extend(buf);
Ok(buf.len()).into()
}
fn poll_flush(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<io::Result<()>> {
Ok(()).into()
}
fn poll_shutdown(self: Pin<&mut Self>, _cx: &mut Contex... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_copy.rs | MIT | 11f6b2862fc458204aabbed9a6f919c65215aeb5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/11f6b2862fc458204aabbed9a6f919c65215aeb5/tokio/tests/io_copy.rs | 41 | 71 |
tokio-rs/tokio:tokio/tests/io_copy_bidirectional.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support bind()
use std::time::Duration;
use tokio::io::{self, copy_bidirectional, AsyncReadExt, AsyncWriteExt};
use tokio::net::TcpStream;
use tokio::task::JoinHandle;
async fn make_socketpair() -> (TcpStream, TcpStrea... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_copy_bidirectional.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_copy_bidirectional.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_copy_bidirectional.rs:2 | Fut: std::future::Future<Output = ()>,
{
// We run the test twice, with streams passed to copy_bidirectional in
// different orders, in order to ensure that the two arguments are
// interchangeable.
let (a, mut a1) = make_socketpair().await;
let (b, mut b1) = make_socketpair().await;
let handl... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_copy_bidirectional.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_copy_bidirectional.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/io_copy_bidirectional.rs:3 | let mut tmp = [0; 4];
a.read_exact(&mut tmp).await.unwrap();
assert_eq!(&tmp[..], b"quux");
// Once both are closed, we should have our handle back
drop(b);
assert_eq!(handle.await.unwrap().unwrap(), (0, 4));
})
.await
}
#[tokio::test]
#[cfg_attr(miri, ignore)] // No `... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_copy_bidirectional.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_copy_bidirectional.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/io_copy_bidirectional.rs:4 | let mut a = tokio_test::io::Builder::new()
.read(payload)
.write_error(error())
.build();
let mut b = tokio_test::io::Builder::new()
.read(payload)
.write_error(error())
.build();
assert!(copy_bidirectional(&mut a, &mut b).await.is_err());
}
#[tokio::test]
asyn... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_copy_bidirectional.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_copy_bidirectional.rs | 121 | 168 |
tokio-rs/tokio:tokio/tests/io_copy_bidirectional.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi does not support bind()
use std::time::Duration;
use tokio::io::{self, copy_bidirectional, AsyncReadExt, AsyncWriteExt};
use tokio::net::TcpStream;
use tokio::task::JoinHandle;
async fn make_socketpair() -> (TcpStrea... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_copy_bidirectional.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/io_copy_bidirectional.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_copy_bidirectional.rs:2 | Fut: std::future::Future<Output = ()>,
{
// We run the test twice, with streams passed to copy_bidirectional in
// different orders, in order to ensure that the two arguments are
// interchangeable.
let (a, mut a1) = make_socketpair().await;
let (b, mut b1) = make_socketpair().await;
let handl... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_copy_bidirectional.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/io_copy_bidirectional.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/io_copy_bidirectional.rs:3 | assert_eq!(&tmp[..], b"quux");
// Once both are closed, we should have our handle back
drop(b);
assert_eq!(handle.await.unwrap().unwrap(), (0, 4));
})
.await
}
#[tokio::test]
async fn blocking_one_side_does_not_block_other() {
symmetric(|handle, mut a, mut b| async move {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_copy_bidirectional.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/io_copy_bidirectional.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/io_copy_bidirectional.rs:4 | .build();
let mut b = tokio_test::io::Builder::new()
.read(payload)
.write_error(error())
.build();
assert!(copy_bidirectional(&mut a, &mut b).await.is_err());
}
#[tokio::test]
async fn immediate_exit_on_read_error() {
let error = || io::Error::new(io::ErrorKind::Other, "got nothi... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_copy_bidirectional.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/io_copy_bidirectional.rs | 121 | 165 |
tokio-rs/tokio:tokio/tests/io_copy_bidirectional.rs:4 | .build();
let mut b = tokio_test::io::Builder::new()
.read(payload)
.write_error(error())
.build();
assert!(copy_bidirectional(&mut a, &mut b).await.is_err());
}
#[tokio::test]
async fn immediate_exit_on_read_error() {
let error = || io::Error::new(io::ErrorKind::Other, "got nothi... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_copy_bidirectional.rs | MIT | c445e467ce4363b3a9b6825268814a9bc27c0127 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/io_copy_bidirectional.rs | 121 | 140 |
tokio-rs/tokio:tokio/tests/io_copy_bidirectional.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi does not support bind()
use std::time::Duration;
use tokio::io::{self, copy_bidirectional, AsyncReadExt, AsyncWriteExt};
use tokio::net::TcpStream;
use tokio::task::JoinHandle;
async fn make_socketpair() -> (TcpStream, TcpStream) {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_copy_bidirectional.rs | MIT | 3966acf966ba6d3be06efb0a2a36f141bca0ae45 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3966acf966ba6d3be06efb0a2a36f141bca0ae45/tokio/tests/io_copy_bidirectional.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_copy_bidirectional.rs:3 | assert_eq!(&tmp[..], b"quux");
// Once both are closed, we should have our handle back
drop(b);
assert_eq!(handle.await.unwrap().unwrap(), (0, 4));
})
.await
}
#[tokio::test]
async fn blocking_one_side_does_not_block_other() {
symmetric(|handle, mut a, mut b| async move {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_copy_bidirectional.rs | MIT | b2ada60e701d5c9e6644cf8fc42a100774f8e23f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/tests/io_copy_bidirectional.rs | 81 | 128 |
tokio-rs/tokio:tokio/tests/io_copy_bidirectional.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use std::time::Duration;
use tokio::io::{self, copy_bidirectional, AsyncReadExt, AsyncWriteExt};
use tokio::net::TcpStream;
use tokio::task::JoinHandle;
async fn make_socketpair() -> (TcpStream, TcpStream) {
let listener = tokio::net::TcpListener::bind("127.0.0... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_copy_bidirectional.rs | MIT | 0d9430b99cc699824cc8545afbb01e0a7c520428 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0d9430b99cc699824cc8545afbb01e0a7c520428/tokio/tests/io_copy_bidirectional.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_copy_bidirectional.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use std::time::Duration;
use tokio::io::{self, copy_bidirectional, AsyncReadExt, AsyncWriteExt};
use tokio::net::TcpStream;
use tokio::task::JoinHandle;
async fn make_socketpair() -> (TcpStream, TcpStream) {
let listener = tokio::net::TcpListener::bind("127.0.0... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_copy_bidirectional.rs | MIT | 08ed41f339e345286f26bdbc6c67bf9f2975ed07 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/08ed41f339e345286f26bdbc6c67bf9f2975ed07/tokio/tests/io_copy_bidirectional.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_copy_bidirectional.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use std::time::Duration;
use tokio::io::{self, copy_bidirectional, AsyncReadExt, AsyncWriteExt};
use tokio::net::TcpStream;
use tokio::task::JoinHandle;
async fn make_socketpair() -> (TcpStream, TcpStream) {
let listener = tokio::net::TcpListener::bind("127.0.0... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_copy_bidirectional.rs | MIT | adad8fc3cdeffb6449edac55558510f4d12c95be | github | async-runtime | https://github.com/tokio-rs/tokio/blob/adad8fc3cdeffb6449edac55558510f4d12c95be/tokio/tests/io_copy_bidirectional.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_copy_bidirectional.rs:2 | Fut: std::future::Future<Output = ()>,
{
// We run the test twice, with streams passed to copy_bidirectional in
// different orders, in order to ensure that the two arguments are
// interchangable.
let (a, mut a1) = make_socketpair().await;
let (b, mut b1) = make_socketpair().await;
let handle... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_copy_bidirectional.rs | MIT | adad8fc3cdeffb6449edac55558510f4d12c95be | github | async-runtime | https://github.com/tokio-rs/tokio/blob/adad8fc3cdeffb6449edac55558510f4d12c95be/tokio/tests/io_copy_bidirectional.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/io_driver.rs:1 | #![warn(rust_2018_idioms)]
// Wasi does not support panic recovery or threading
#![cfg(all(feature = "full", not(target_os = "wasi")))]
use tokio::net::TcpListener;
use tokio::runtime;
use tokio_test::{assert_ok, assert_pending};
use futures::task::{waker_ref, ArcWake};
use std::future::Future;
use std::net::TcpStrea... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_driver.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_driver.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_driver.rs:2 | // Previously, there was a deadlock scenario where the reactor, while
// notifying, held a lock and the task being dropped attempted to acquire
// that same lock in order to clean up state.
//
// To simulate this case, we create a fake executor that does nothing when
// the task is notified. This si... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_driver.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_driver.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/io_driver.rs:3 | drop(task);
// Establish a connection to the acceptor
let _s = TcpStream::connect(addr).unwrap();
// Force the reactor to turn
rt.block_on(async {});
}
#[test]
#[should_panic(
expected = "A Tokio 1.x context was found, but IO is disabled. Call `enable_io` on the runtime builder to enable IO."
)]
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_driver.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_driver.rs | 81 | 105 |
tokio-rs/tokio:tokio/tests/io_driver.rs:2 | // Previously, there was a deadlock scenario where the reactor, while
// notifying, held a lock and the task being dropped attempted to acquire
// that same lock in order to clean up state.
//
// To simulate this case, we create a fake executor that does nothing when
// the task is notified. This si... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_driver.rs | MIT | 4047d7962a02722859b0f1c7bbcd85bc1bfc865d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4047d7962a02722859b0f1c7bbcd85bc1bfc865d/tokio/tests/io_driver.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/io_driver.rs:3 | drop(task);
// Establish a connection to the acceptor
let _s = TcpStream::connect(addr).unwrap();
// Force the reactor to turn
rt.block_on(async {});
}
#[test]
#[should_panic(
expected = "A Tokio 1.x context was found, but IO is disabled. Call `enable_io` on the runtime builder to enable IO."
)]
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_driver.rs | MIT | 4047d7962a02722859b0f1c7bbcd85bc1bfc865d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4047d7962a02722859b0f1c7bbcd85bc1bfc865d/tokio/tests/io_driver.rs | 81 | 102 |
tokio-rs/tokio:tokio/tests/io_driver.rs:1 | #![warn(rust_2018_idioms)]
// Wasi does not support panic recovery or threading
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))]
use tokio::net::TcpListener;
use tokio::runtime;
use tokio_test::{assert_ok, assert_pending};
use futures::task::{waker_ref, ArcWake};
use std::future::Future;
use std::ne... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_driver.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/io_driver.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_driver.rs:2 | // notifying, held a lock and the task being dropped attempted to acquire
// that same lock in order to clean up state.
//
// To simulate this case, we create a fake executor that does nothing when
// the task is notified. This simulates an executor in the process of
// shutting down. Then, when the... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_driver.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/io_driver.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/io_driver.rs:3 | // Establish a connection to the acceptor
let _s = TcpStream::connect(addr).unwrap();
// Force the reactor to turn
rt.block_on(async {});
}
#[test]
#[should_panic(
expected = "A Tokio 1.x context was found, but IO is disabled. Call `enable_io` on the runtime builder to enable IO."
)]
fn panics_when_io... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_driver.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/io_driver.rs | 81 | 100 |
tokio-rs/tokio:tokio/tests/io_driver.rs:1 | #![warn(rust_2018_idioms)]
// Wasi does not support panic recovery or threading
#![cfg(all(feature = "full", not(target_os = "wasi")))]
use tokio::net::TcpListener;
use tokio::runtime;
use tokio_test::{assert_ok, assert_pending};
use futures::task::{waker_ref, ArcWake};
use std::future::Future;
use std::net::TcpStrea... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_driver.rs | MIT | c445e467ce4363b3a9b6825268814a9bc27c0127 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/io_driver.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_driver.rs:1 | #![warn(rust_2018_idioms)]
// Wasi does not support panic recovery or threading
#![cfg(all(feature = "full", not(tokio_wasi)))]
use tokio::net::TcpListener;
use tokio::runtime;
use tokio_test::{assert_ok, assert_pending};
use futures::task::{waker_ref, ArcWake};
use std::future::Future;
use std::net::TcpStream;
use s... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_driver.rs | MIT | 22cff80048c62ed0fa20065888667d00d5aedd14 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/22cff80048c62ed0fa20065888667d00d5aedd14/tokio/tests/io_driver.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_driver.rs:2 | // notifying, held a lock and the task being dropped attempted to acquire
// that same lock in order to clean up state.
//
// To simulate this case, we create a fake executor that does nothing when
// the task is notified. This simulates an executor in the process of
// shutting down. Then, when the... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_driver.rs | MIT | b2ada60e701d5c9e6644cf8fc42a100774f8e23f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/tests/io_driver.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/io_driver.rs:3 | // Establish a connection to the acceptor
let _s = TcpStream::connect(&addr).unwrap();
// Force the reactor to turn
rt.block_on(async {});
}
#[test]
#[should_panic(
expected = "A Tokio 1.x context was found, but IO is disabled. Call `enable_io` on the runtime builder to enable IO."
)]
fn panics_when_i... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_driver.rs | MIT | b2ada60e701d5c9e6644cf8fc42a100774f8e23f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/tests/io_driver.rs | 81 | 100 |
tokio-rs/tokio:tokio/tests/io_driver.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::net::TcpListener;
use tokio::runtime;
use tokio_test::{assert_ok, assert_pending};
use futures::task::{waker_ref, ArcWake};
use std::future::Future;
use std::net::TcpStream;
use std::pin::Pin;
use std::sync::{mpsc, Arc, Mutex};
use std::task::Context;
s... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_driver.rs | MIT | fdde5583f853655fec57c44928b7d5f01621b754 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fdde5583f853655fec57c44928b7d5f01621b754/tokio/tests/io_driver.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_driver.rs:2 | // that same lock in order to clean up state.
//
// To simulate this case, we create a fake executor that does nothing when
// the task is notified. This simulates an executor in the process of
// shutting down. Then, when the task handle is dropped, the task itself is
// dropped.
let rt = runt... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_driver.rs | MIT | fdde5583f853655fec57c44928b7d5f01621b754 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fdde5583f853655fec57c44928b7d5f01621b754/tokio/tests/io_driver.rs | 41 | 99 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.