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/fs_file_mocked.rs:17 | assert_eq!(1, pool::len());
pool::run_one();
assert!(t.is_woken());
assert_pending!(t.poll());
assert_eq!(1, pool::len());
pool::run_one();
assert!(t.is_woken());
assert_ready_ok!(t.poll());
}
#[test]
fn sync_data_err_ordered_after_write() {
let (mock, file) = sys::File::mock();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_file_mocked.rs | MIT | 987ba7373cf95c570bf23768c6021f7a7508286e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/987ba7373cf95c570bf23768c6021f7a7508286e/tokio/tests/fs_file_mocked.rs | 641 | 700 |
tokio-rs/tokio:tokio/tests/fs_file_mocked.rs:18 | fn open_set_len_ok() {
let (mock, file) = sys::File::mock();
mock.set_len(123);
let mut file = File::from_std(file);
let mut t = task::spawn(file.set_len(123));
assert_pending!(t.poll());
assert_eq!(1, mock.remaining());
pool::run_one();
assert_eq!(0, mock.remaining());
assert!(t... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_file_mocked.rs | MIT | 987ba7373cf95c570bf23768c6021f7a7508286e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/987ba7373cf95c570bf23768c6021f7a7508286e/tokio/tests/fs_file_mocked.rs | 681 | 740 |
tokio-rs/tokio:tokio/tests/fs_file_mocked.rs:19 | .set_len(123)
.read(FOO);
let mut buf = [0; 32];
let mut file = File::from_std(file);
{
let mut t = task::spawn(file.read(&mut buf));
assert_pending!(t.poll());
}
pool::run_one();
{
let mut t = task::spawn(file.set_len(123));
assert_pending!(t.poll())... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_file_mocked.rs | MIT | 987ba7373cf95c570bf23768c6021f7a7508286e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/987ba7373cf95c570bf23768c6021f7a7508286e/tokio/tests/fs_file_mocked.rs | 721 | 749 |
tokio-rs/tokio:tokio/tests/fs_link.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // WASI does not support all fs operations
use tokio::fs;
use std::io::Write;
use tempfile::tempdir;
#[tokio::test]
#[cfg_attr(miri, ignore)] // No `linkat` in miri.
async fn test_hard_link() {
let dir = tempdir().unwrap();
le... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_link.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/fs_link.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/fs_link.rs:2 | std::fs::File::create(&src)
.unwrap()
.write_all(b"hello")
.unwrap();
fs::symlink(&src, &dst).await.unwrap();
std::fs::File::create(&src)
.unwrap()
.write_all(b"new-data")
.unwrap();
let content = fs::read(&dst).await.unwrap();
assert_eq!(content, b"new... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_link.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/fs_link.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/fs_link.rs:3 | // Create source file
std::fs::write(&src, b"source content").unwrap();
// Create destination file
std::fs::write(&dst, b"destination content").unwrap();
// Attempt to create hard link when destination already exists
let err = fs::hard_link(&src, &dst).await.unwrap_err();
assert_eq!(err.kind()... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_link.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/fs_link.rs | 81 | 116 |
tokio-rs/tokio:tokio/tests/fs_link.rs:2 | std::fs::File::create(&src)
.unwrap()
.write_all(b"hello")
.unwrap();
fs::symlink(&src, &dst).await.unwrap();
std::fs::File::create(&src)
.unwrap()
.write_all(b"new-data")
.unwrap();
let content = fs::read(&dst).await.unwrap();
assert_eq!(content, b"new... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_link.rs | MIT | 4047d7962a02722859b0f1c7bbcd85bc1bfc865d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4047d7962a02722859b0f1c7bbcd85bc1bfc865d/tokio/tests/fs_link.rs | 41 | 62 |
tokio-rs/tokio:tokio/tests/fs_link.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // WASI does not support all fs operations
use tokio::fs;
use std::io::Write;
use tempfile::tempdir;
#[tokio::test]
#[cfg_attr(miri, ignore)]
async fn test_hard_link() {
let dir = tempdir().unwrap();
let src = dir.path().join(... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_link.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/fs_link.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/fs_link.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // WASI does not support all fs operations
use tokio::fs;
use std::io::Write;
use tempfile::tempdir;
#[tokio::test]
async fn test_hard_link() {
let dir = tempdir().unwrap();
let src = dir.path().join("src.txt");
let dst = ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_link.rs | MIT | c445e467ce4363b3a9b6825268814a9bc27c0127 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/fs_link.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/fs_link.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(tokio_wasi)))] // WASI does not support all fs operations
use tokio::fs;
use std::io::Write;
use tempfile::tempdir;
#[tokio::test]
async fn test_hard_link() {
let dir = tempdir().unwrap();
let src = dir.path().join("src.txt");
let dst = dir.path... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_link.rs | MIT | cadcd5da5ea4649b978c247ca11f270ddf54fa04 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cadcd5da5ea4649b978c247ca11f270ddf54fa04/tokio/tests/fs_link.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/fs_link.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi does not support file operations
use tokio::fs;
use std::io::prelude::*;
use std::io::BufReader;
use tempfile::tempdir;
#[tokio::test]
async fn test_hard_link() {
let dir = tempdir().unwrap();
let src = dir.path().join("src.tx... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_link.rs | MIT | b2ada60e701d5c9e6644cf8fc42a100774f8e23f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/tests/fs_link.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/fs_link.rs:2 | let dst = dir.path().join("dst.txt");
{
let mut file = std::fs::File::create(&src).unwrap();
file.write_all(b"hello").unwrap();
}
let src_2 = src.clone();
let dst_2 = dst.clone();
assert!(fs::symlink(src_2.clone(), dst_2.clone()).await.is_ok());
let mut content = String::new(... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_link.rs | MIT | b2ada60e701d5c9e6644cf8fc42a100774f8e23f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/tests/fs_link.rs | 41 | 68 |
tokio-rs/tokio:tokio/tests/fs_link.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support file operations
use tokio::fs;
use std::io::prelude::*;
use std::io::BufReader;
use tempfile::tempdir;
#[tokio::test]
async fn test_hard_link() {
let dir = tempdir().unwrap();
let src = dir.path().join... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_link.rs | MIT | 6d3f92dddc510e9276191cfab1b0432ce8248589 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6d3f92dddc510e9276191cfab1b0432ce8248589/tokio/tests/fs_link.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/fs_link.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::fs;
use std::io::prelude::*;
use std::io::BufReader;
use tempfile::tempdir;
#[tokio::test]
async fn test_hard_link() {
let dir = tempdir().unwrap();
let src = dir.path().join("src.txt");
let dst = dir.path().join("dst.txt");
{
l... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_link.rs | MIT | 3f29212cb7743462451293b65d4bb8b5b4973fc5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3f29212cb7743462451293b65d4bb8b5b4973fc5/tokio/tests/fs_link.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/fs_link.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::fs;
use std::io::prelude::*;
use std::io::BufReader;
use tempfile::tempdir;
#[tokio::test]
async fn test_hard_link() {
let dir = tempdir().unwrap();
let src = dir.path().join("src.txt");
let dst = dir.path().join("dst.txt");
{
l... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_link.rs | MIT | 7b4c999341809588a427a9a80d310ee4aa1c1a21 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7b4c999341809588a427a9a80d310ee4aa1c1a21/tokio/tests/fs_link.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/fs_link.rs:2 | let dst = dir.path().join("dst.txt");
{
let mut file = std::fs::File::create(&src).unwrap();
file.write_all(b"hello").unwrap();
}
let src_2 = src.clone();
let dst_2 = dst.clone();
assert!(fs::os::unix::symlink(src_2.clone(), dst_2.clone())
.await
.is_ok());
le... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_link.rs | MIT | 7b4c999341809588a427a9a80d310ee4aa1c1a21 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7b4c999341809588a427a9a80d310ee4aa1c1a21/tokio/tests/fs_link.rs | 41 | 70 |
tokio-rs/tokio:tokio/tests/fs_open_options.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // WASI does not support all fs operations
use std::io::Write;
use tempfile::NamedTempFile;
use tokio::fs::OpenOptions;
use tokio::io::AsyncReadExt;
const HELLO: &[u8] = b"hello world...";
#[tokio::test]
async fn open_with_open_option... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_open_options.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/fs_open_options.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/fs_open_options.rs:2 | }
#[tokio::test]
async fn open_options_create() {
// TESTING HACK: use Debug output to check the stored data
assert!(format!("{:?}", OpenOptions::new().create(true)).contains("create: true"));
}
#[tokio::test]
async fn open_options_create_new() {
// TESTING HACK: use Debug output to check the stored data
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_open_options.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/fs_open_options.rs | 41 | 84 |
tokio-rs/tokio:tokio/tests/fs_open_options.rs:2 | }
#[tokio::test]
async fn open_options_create() {
// TESTING HACK: use Debug output to check the stored data
assert!(format!("{:?}", OpenOptions::new().create(true)).contains("create: true"));
}
#[tokio::test]
async fn open_options_create_new() {
// TESTING HACK: use Debug output to check the stored data
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_open_options.rs | MIT | d4178cf34924d14fca4ecf551c97b8953376f25a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/fs_open_options.rs | 41 | 84 |
tokio-rs/tokio:tokio/tests/fs_open_options.rs:2 | }
#[tokio::test]
async fn open_options_create() {
// TESTING HACK: use Debug output to check the stored data
assert!(format!("{:?}", OpenOptions::new().create(true)).contains("create: true"));
}
#[tokio::test]
async fn open_options_create_new() {
// TESTING HACK: use Debug output to check the stored data
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_open_options.rs | MIT | 2a0df5fb05ae1a624fe2f6db756190f41812214b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2a0df5fb05ae1a624fe2f6db756190f41812214b/tokio/tests/fs_open_options.rs | 41 | 85 |
tokio-rs/tokio:tokio/tests/fs_open_options.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // WASI does not support all fs operations
use std::io::Write;
use tempfile::NamedTempFile;
use tokio::fs::OpenOptions;
use tokio::io::AsyncReadExt;
const HELLO: &[u8] = b"hello world...";
#[tokio::test]
async fn open_with_open_option... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_open_options.rs | MIT | c445e467ce4363b3a9b6825268814a9bc27c0127 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/fs_open_options.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/fs_open_options.rs:2 | }
#[tokio::test]
async fn open_options_create() {
// TESTING HACK: use Debug output to check the stored data
assert!(format!("{:?}", OpenOptions::new().create(true)).contains("create: true"));
}
#[tokio::test]
async fn open_options_create_new() {
// TESTING HACK: use Debug output to check the stored data
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_open_options.rs | MIT | c445e467ce4363b3a9b6825268814a9bc27c0127 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/fs_open_options.rs | 41 | 80 |
tokio-rs/tokio:tokio/tests/fs_open_options.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(tokio_wasi)))] // WASI does not support all fs operations
use std::io::Write;
use tempfile::NamedTempFile;
use tokio::fs::OpenOptions;
use tokio::io::AsyncReadExt;
const HELLO: &[u8] = b"hello world...";
#[tokio::test]
async fn open_with_open_options_and_re... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_open_options.rs | MIT | cadcd5da5ea4649b978c247ca11f270ddf54fa04 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cadcd5da5ea4649b978c247ca11f270ddf54fa04/tokio/tests/fs_open_options.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/fs_open_options_windows.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // WASI does not support all fs operations
#![cfg(windows)]
use tokio::fs::OpenOptions;
use windows_sys::Win32::Storage::FileSystem;
#[tokio::test]
#[cfg(windows)]
async fn open_options_windows_access_mode() {
// TESTING HACK: use ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_open_options_windows.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/fs_open_options_windows.rs | 1 | 51 |
tokio-rs/tokio:tokio/tests/fs_open_options_windows.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(tokio_wasi)))] // WASI does not support all fs operations
#![cfg(windows)]
use tokio::fs::OpenOptions;
use windows_sys::Win32::Storage::FileSystem;
#[tokio::test]
#[cfg(windows)]
async fn open_options_windows_access_mode() {
// TESTING HACK: use Debug ou... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_open_options_windows.rs | MIT | cadcd5da5ea4649b978c247ca11f270ddf54fa04 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cadcd5da5ea4649b978c247ca11f270ddf54fa04/tokio/tests/fs_open_options_windows.rs | 1 | 51 |
tokio-rs/tokio:tokio/tests/fs_remove_dir_all.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // WASI does not support all fs operations
use tempfile::tempdir;
use tokio::fs;
#[tokio::test]
async fn remove_dir_all() {
let temp_dir = tempdir().unwrap();
let test_dir = temp_dir.path().join("test");
fs::create_dir(&te... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_remove_dir_all.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/fs_remove_dir_all.rs | 1 | 31 |
tokio-rs/tokio:tokio/tests/fs_remove_dir_all.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(tokio_wasi)))] // WASI does not support all fs operations
use tempfile::tempdir;
use tokio::fs;
#[tokio::test]
async fn remove_dir_all() {
let temp_dir = tempdir().unwrap();
let test_dir = temp_dir.path().join("test");
fs::create_dir(&test_dir).... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_remove_dir_all.rs | MIT | cadcd5da5ea4649b978c247ca11f270ddf54fa04 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cadcd5da5ea4649b978c247ca11f270ddf54fa04/tokio/tests/fs_remove_dir_all.rs | 1 | 31 |
tokio-rs/tokio:tokio/tests/fs_remove_file.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // WASI does not support all fs operations
use tempfile::tempdir;
use tokio::fs;
#[tokio::test]
async fn remove_file() {
let temp_dir = tempdir().unwrap();
let file_path = temp_dir.path().join("a.txt");
fs::write(&file_pa... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_remove_file.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/fs_remove_file.rs | 1 | 24 |
tokio-rs/tokio:tokio/tests/fs_remove_file.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(tokio_wasi)))] // WASI does not support all fs operations
use tempfile::tempdir;
use tokio::fs;
#[tokio::test]
async fn remove_file() {
let temp_dir = tempdir().unwrap();
let file_path = temp_dir.path().join("a.txt");
fs::write(&file_path, b"He... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_remove_file.rs | MIT | cadcd5da5ea4649b978c247ca11f270ddf54fa04 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cadcd5da5ea4649b978c247ca11f270ddf54fa04/tokio/tests/fs_remove_file.rs | 1 | 24 |
tokio-rs/tokio:tokio/tests/fs_rename.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // WASI does not support all fs operations
use tempfile::tempdir;
use tokio::fs;
#[tokio::test]
async fn rename_file() {
let temp_dir = tempdir().unwrap();
let file_path = temp_dir.path().join("a.txt");
fs::write(&file_pa... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_rename.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/fs_rename.rs | 1 | 28 |
tokio-rs/tokio:tokio/tests/fs_rename.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(tokio_wasi)))] // WASI does not support all fs operations
use tempfile::tempdir;
use tokio::fs;
#[tokio::test]
async fn rename_file() {
let temp_dir = tempdir().unwrap();
let file_path = temp_dir.path().join("a.txt");
fs::write(&file_path, b"He... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_rename.rs | MIT | cadcd5da5ea4649b978c247ca11f270ddf54fa04 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cadcd5da5ea4649b978c247ca11f270ddf54fa04/tokio/tests/fs_rename.rs | 1 | 28 |
tokio-rs/tokio:tokio/tests/fs_symlink_dir_windows.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // WASI does not support all fs operations
#![cfg(windows)]
use tempfile::tempdir;
use tokio::fs;
#[tokio::test]
async fn symlink_dir_windows() {
const FILE_NAME: &str = "abc.txt";
let temp_dir = tempdir().unwrap();
let d... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_symlink_dir_windows.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/fs_symlink_dir_windows.rs | 1 | 31 |
tokio-rs/tokio:tokio/tests/fs_symlink_dir_windows.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // WASI does not support all fs operations
#![cfg(windows)]
use tempfile::tempdir;
use tokio::fs;
#[tokio::test]
async fn symlink_file_windows() {
const FILE_NAME: &str = "abc.txt";
let temp_dir = tempdir().unwrap();
let ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_symlink_dir_windows.rs | MIT | c445e467ce4363b3a9b6825268814a9bc27c0127 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/fs_symlink_dir_windows.rs | 1 | 31 |
tokio-rs/tokio:tokio/tests/fs_symlink_dir_windows.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(tokio_wasi)))] // WASI does not support all fs operations
#![cfg(windows)]
use tempfile::tempdir;
use tokio::fs;
#[tokio::test]
async fn symlink_file_windows() {
const FILE_NAME: &str = "abc.txt";
let temp_dir = tempdir().unwrap();
let dir1 = t... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_symlink_dir_windows.rs | MIT | cadcd5da5ea4649b978c247ca11f270ddf54fa04 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cadcd5da5ea4649b978c247ca11f270ddf54fa04/tokio/tests/fs_symlink_dir_windows.rs | 1 | 31 |
tokio-rs/tokio:tokio/tests/fs_symlink_file_windows.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // WASI does not support all fs operations
#![cfg(windows)]
use tempfile::tempdir;
use tokio::fs;
#[tokio::test]
async fn symlink_file_windows() {
let dir = tempdir().unwrap();
let source_path = dir.path().join("foo.txt");
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_symlink_file_windows.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/fs_symlink_file_windows.rs | 1 | 24 |
tokio-rs/tokio:tokio/tests/fs_symlink_file_windows.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(tokio_wasi)))] // WASI does not support all fs operations
#![cfg(windows)]
use tempfile::tempdir;
use tokio::fs;
#[tokio::test]
async fn symlink_file_windows() {
let dir = tempdir().unwrap();
let source_path = dir.path().join("foo.txt");
let des... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_symlink_file_windows.rs | MIT | cadcd5da5ea4649b978c247ca11f270ddf54fa04 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cadcd5da5ea4649b978c247ca11f270ddf54fa04/tokio/tests/fs_symlink_file_windows.rs | 1 | 24 |
tokio-rs/tokio:tokio/tests/fs_try_exists.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // WASI does not support all fs operations
use tempfile::tempdir;
use tokio::fs;
#[tokio::test]
#[cfg_attr(miri, ignore)] // No `chmod` in miri.
async fn try_exists() {
let dir = tempdir().unwrap();
let existing_path = dir.pat... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_try_exists.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/fs_try_exists.rs | 1 | 48 |
tokio-rs/tokio:tokio/tests/fs_try_exists.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // WASI does not support all fs operations
use tempfile::tempdir;
use tokio::fs;
#[tokio::test]
#[cfg_attr(miri, ignore)] // No `chmod` in miri.
async fn try_exists() {
let dir = tempdir().unwrap();
let existing_path = dir.pat... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_try_exists.rs | MIT | 01ea8f22eaf670ad0cfa5a1facd554ab364bfdcd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/01ea8f22eaf670ad0cfa5a1facd554ab364bfdcd/tokio/tests/fs_try_exists.rs | 1 | 45 |
tokio-rs/tokio:tokio/tests/fs_try_exists.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // WASI does not support all fs operations
use tempfile::tempdir;
use tokio::fs;
#[tokio::test]
#[cfg_attr(miri, ignore)] // No `chmod` in miri.
async fn try_exists() {
let dir = tempdir().unwrap();
let existing_path = dir.pat... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_try_exists.rs | MIT | 4047d7962a02722859b0f1c7bbcd85bc1bfc865d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4047d7962a02722859b0f1c7bbcd85bc1bfc865d/tokio/tests/fs_try_exists.rs | 1 | 45 |
tokio-rs/tokio:tokio/tests/fs_try_exists.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // WASI does not support all fs operations
use tempfile::tempdir;
use tokio::fs;
#[tokio::test]
#[cfg_attr(miri, ignore)]
async fn try_exists() {
let dir = tempdir().unwrap();
let existing_path = dir.path().join("foo.txt");
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_try_exists.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/fs_try_exists.rs | 1 | 45 |
tokio-rs/tokio:tokio/tests/fs_try_exists.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // WASI does not support all fs operations
use tempfile::tempdir;
use tokio::fs;
#[tokio::test]
async fn try_exists() {
let dir = tempdir().unwrap();
let existing_path = dir.path().join("foo.txt");
fs::write(&existing_path... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_try_exists.rs | MIT | c445e467ce4363b3a9b6825268814a9bc27c0127 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/fs_try_exists.rs | 1 | 44 |
tokio-rs/tokio:tokio/tests/fs_try_exists.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(tokio_wasi)))] // WASI does not support all fs operations
use tempfile::tempdir;
use tokio::fs;
#[tokio::test]
async fn try_exists() {
let dir = tempdir().unwrap();
let existing_path = dir.path().join("foo.txt");
fs::write(&existing_path, b"Hell... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_try_exists.rs | MIT | cadcd5da5ea4649b978c247ca11f270ddf54fa04 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cadcd5da5ea4649b978c247ca11f270ddf54fa04/tokio/tests/fs_try_exists.rs | 1 | 44 |
tokio-rs/tokio:tokio/tests/fs_try_exists.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi does not support file operations
use tempfile::tempdir;
use tokio::fs;
#[tokio::test]
async fn try_exists() {
let dir = tempdir().unwrap();
let existing_path = dir.path().join("foo.txt");
fs::write(&existing_path, b"Hello ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_try_exists.rs | MIT | 12f81ffa61aa2e18e2aa717a1bafd16dccf128bf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12f81ffa61aa2e18e2aa717a1bafd16dccf128bf/tokio/tests/fs_try_exists.rs | 1 | 44 |
tokio-rs/tokio:tokio/tests/fs_uring.rs:1 | //! Uring file operations tests.
#![cfg(all(
tokio_unstable,
feature = "io-uring",
feature = "rt",
feature = "fs",
target_os = "linux"
))]
use futures::future::FutureExt;
use std::sync::mpsc;
use std::task::Poll;
use std::time::Duration;
use std::{future::poll_fn, path::PathBuf};
use tempfile::Nam... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_uring.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/fs_uring.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/fs_uring.rs:2 | multi_rt(2),
multi_rt(8),
multi_rt(64),
multi_rt(256),
]
}
#[test]
fn shutdown_runtime_while_performing_io_uring_ops() {
fn run(rt: Runtime) {
let (tx, rx) = mpsc::channel();
let (done_tx, done_rx) = mpsc::channel();
let (_tmp, path) = create_tmp_files(1);
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_uring.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/fs_uring.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/fs_uring.rs:3 | for rt in rt_combinations() {
run(rt());
}
}
#[test]
fn open_many_files() {
fn run(rt: Runtime) {
const NUM_FILES: usize = 512;
let (_tmp_files, paths): (Vec<NamedTempFile>, Vec<PathBuf>) = create_tmp_files(NUM_FILES);
rt.block_on(async move {
let tracker = TaskTra... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_uring.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/fs_uring.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/fs_uring.rs:4 | let mut opt = tokio::fs::OpenOptions::new();
opt.read(true);
opt
};
let fut = opt.open(&path[0]);
// If io_uring is enabled (and not falling back to the thread pool),
// the first poll should return Pending.
let _pending = Box... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_uring.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/fs_uring.rs | 121 | 157 |
tokio-rs/tokio:tokio/tests/fs_uring.rs:1 | //! Uring file operations tests.
#![cfg(all(tokio_uring, feature = "rt", feature = "fs", target_os = "linux"))]
use futures::future::FutureExt;
use std::sync::mpsc;
use std::task::Poll;
use std::time::Duration;
use std::{future::poll_fn, path::PathBuf};
use tempfile::NamedTempFile;
use tokio::{
fs::OpenOptions,
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_uring.rs | MIT | 3e84a198e4d6283f015965cd627ee5aaff69e022 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3e84a198e4d6283f015965cd627ee5aaff69e022/tokio/tests/fs_uring.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/fs_uring.rs:2 | #[test]
fn shutdown_runtime_while_performing_io_uring_ops() {
fn run(rt: Runtime) {
let (tx, rx) = mpsc::channel();
let (done_tx, done_rx) = mpsc::channel();
let (_tmp, path) = create_tmp_files(1);
rt.spawn(async move {
let path = path[0].clone();
// spawnin... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_uring.rs | MIT | 3e84a198e4d6283f015965cd627ee5aaff69e022 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3e84a198e4d6283f015965cd627ee5aaff69e022/tokio/tests/fs_uring.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/fs_uring.rs:3 | #[test]
fn open_many_files() {
fn run(rt: Runtime) {
const NUM_FILES: usize = 512;
let (_tmp_files, paths): (Vec<NamedTempFile>, Vec<PathBuf>) = create_tmp_files(NUM_FILES);
rt.block_on(async move {
let tracker = TaskTracker::new();
for i in 0..10_000 {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_uring.rs | MIT | 3e84a198e4d6283f015965cd627ee5aaff69e022 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3e84a198e4d6283f015965cd627ee5aaff69e022/tokio/tests/fs_uring.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/fs_uring.rs:4 | // If io_uring is enabled (and not falling back to the thread pool),
// the first poll should return Pending.
let _pending = Box::pin(fut).poll_unpin(cx);
tx.send(()).unwrap();
Poll::<()>::Pending
})
.await;
});
// Wait for the first poll
rx... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_uring.rs | MIT | 3e84a198e4d6283f015965cd627ee5aaff69e022 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3e84a198e4d6283f015965cd627ee5aaff69e022/tokio/tests/fs_uring.rs | 121 | 151 |
tokio-rs/tokio:tokio/tests/fs_uring_cancel_open.rs:1 | //! Uring file operations tests.
#![cfg(all(
tokio_unstable,
feature = "io-uring",
feature = "rt",
feature = "fs",
target_os = "linux"
))]
use futures::future::FutureExt;
use std::fs;
use std::future::poll_fn;
use std::task::Poll;
use tempfile::NamedTempFile;
use tokio_test::assert_pending;
use c... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_uring_cancel_open.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/fs_uring_cancel_open.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/fs_uring_cancel_open.rs:2 | poll_fn(|cx| {
let opt = {
let mut opt = tokio::fs::OpenOptions::new();
opt.read(true);
opt
};
let fut = opt.open(&path);
// If io_uring is enabled (and not falling back to the thread pool),
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_uring_cancel_open.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/fs_uring_cancel_open.rs | 41 | 80 |
tokio-rs/tokio:tokio/tests/fs_uring_cancel_open.rs:1 | //! Uring file operations tests.
#![cfg(all(
tokio_unstable,
feature = "io-uring",
feature = "rt",
feature = "fs",
target_os = "linux"
))]
use futures::future::FutureExt;
use std::fs;
use std::future::poll_fn;
use std::task::Poll;
use tempfile::NamedTempFile;
// see: https://github.com/tokio-rs/t... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_uring_cancel_open.rs | MIT | c79121391db8f8d36d4213feeb25381caee110c7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c79121391db8f8d36d4213feeb25381caee110c7/tokio/tests/fs_uring_cancel_open.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/fs_uring_cancel_open.rs:2 | // is actually pending because we run some checks on old kernel that
// do not support uring.
let _pending = Box::pin(fut).poll_unpin(cx);
tx.send(()).unwrap();
Poll::<()>::Pending
})
.await;
});
// Wait for the f... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_uring_cancel_open.rs | MIT | c79121391db8f8d36d4213feeb25381caee110c7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c79121391db8f8d36d4213feeb25381caee110c7/tokio/tests/fs_uring_cancel_open.rs | 41 | 71 |
tokio-rs/tokio:tokio/tests/fs_uring_completed_then_dropped_before_repoll.rs:1 | #![cfg(all(
tokio_unstable,
feature = "io-uring",
feature = "rt",
feature = "fs",
target_os = "linux"
))]
mod support {
pub(crate) mod io_uring;
}
use std::fmt::Debug;
use std::fs;
use std::future::Future;
use std::path::PathBuf;
use std::pin::Pin;
use std::task::{Context, Poll};
use std::time... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_uring_completed_then_dropped_before_repoll.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/fs_uring_completed_then_dropped_before_repoll.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/fs_uring_completed_then_dropped_before_repoll.rs:2 | /// - **intentionally does not poll the inner open future again**,
/// - stays pending forever so the task can be aborted.
///
/// Aborting the task here drops the inner `open()` future while Tokio still has
/// a completed CQE sitting in the slab.
struct PollOpenOnceThenNeverRepoll<F> {
inner: Pin<Box<F>>,
fir... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_uring_completed_then_dropped_before_repoll.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/fs_uring_completed_then_dropped_before_repoll.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/fs_uring_completed_then_dropped_before_repoll.rs:3 | let (first_tx, mut first_rx) = unbounded_channel();
let (second_tx, mut second_rx) = unbounded_channel();
let handle = tokio::spawn(async move {
let mut opt = tokio::fs::OpenOptions::new();
opt.read(true);
PollOpenOnceThenNeverRepoll {
inner: Box::pin(opt.open(&path)),
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_uring_completed_then_dropped_before_repoll.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/fs_uring_completed_then_dropped_before_repoll.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/fs_uring_completed_then_dropped_before_repoll.rs:4 | rt.block_on(async {
let before = fd_count();
let tmp = NamedTempFile::new().unwrap();
let path = tmp.path().to_path_buf();
for _ in 0..128 {
completed_then_dropped_before_repoll(path.clone()).await;
}
// Give completions a moment to settle before counting fd... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_uring_completed_then_dropped_before_repoll.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/fs_uring_completed_then_dropped_before_repoll.rs | 121 | 145 |
tokio-rs/tokio:tokio/tests/fs_uring_completed_then_dropped_before_repoll.rs:1 | #![cfg(all(
tokio_unstable,
feature = "io-uring",
feature = "rt",
feature = "fs",
target_os = "linux"
))]
use std::fs;
use std::future::Future;
use std::path::PathBuf;
use std::pin::Pin;
use std::task::{Context, Poll};
use std::time::Duration;
use tempfile::NamedTempFile;
use tokio::sync::mpsc::{u... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_uring_completed_then_dropped_before_repoll.rs | MIT | c79121391db8f8d36d4213feeb25381caee110c7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c79121391db8f8d36d4213feeb25381caee110c7/tokio/tests/fs_uring_completed_then_dropped_before_repoll.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/fs_uring_completed_then_dropped_before_repoll.rs:2 | second_poll_tx: Option<UnboundedSender<()>>,
polled_once: bool,
}
impl<F: Future> Future for PollOpenOnceThenNeverRepoll<F> {
type Output = ();
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
if !self.polled_once {
// We don't check if the result is actu... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_uring_completed_then_dropped_before_repoll.rs | MIT | c79121391db8f8d36d4213feeb25381caee110c7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c79121391db8f8d36d4213feeb25381caee110c7/tokio/tests/fs_uring_completed_then_dropped_before_repoll.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/fs_uring_completed_then_dropped_before_repoll.rs:3 | polled_once: false,
}
.await;
});
// Wait until the inner open has been polled once and registered with io_uring.
first_rx.recv().await.unwrap();
// Wait until Tokio wakes the task because the open completed. At this point
// the CQE should already be stored as `Lifecycle::Complete... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_uring_completed_then_dropped_before_repoll.rs | MIT | c79121391db8f8d36d4213feeb25381caee110c7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c79121391db8f8d36d4213feeb25381caee110c7/tokio/tests/fs_uring_completed_then_dropped_before_repoll.rs | 81 | 130 |
tokio-rs/tokio:tokio/tests/fs_uring_completed_then_dropped_before_repoll.rs:4 | // Since we are opening 128 files, we expect that the related fds
// related to this operation will be closed. Since some other fds
// can be opened in the meantime, we expect this number to be higher
// than the counter before opening the files. This number could be
// lower, but to avo... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_uring_completed_then_dropped_before_repoll.rs | MIT | c79121391db8f8d36d4213feeb25381caee110c7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c79121391db8f8d36d4213feeb25381caee110c7/tokio/tests/fs_uring_completed_then_dropped_before_repoll.rs | 121 | 130 |
tokio-rs/tokio:tokio/tests/fs_uring_file_read.rs:1 | //! Tests for AsyncRead on tokio::fs::File via io-uring.
#![cfg(all(
tokio_unstable,
feature = "io-uring",
feature = "rt",
feature = "fs",
target_os = "linux"
))]
use std::io::Write;
use std::path::PathBuf;
use std::sync::mpsc;
use std::time::Duration;
use tempfile::NamedTempFile;
use tokio::fs::F... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_uring_file_read.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/fs_uring_file_read.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/fs_uring_file_read.rs:2 | tmp.write_all(data).unwrap();
tmp.flush().unwrap();
let path = tmp.path().to_path_buf();
(tmp, path)
}
#[tokio::test]
async fn test_file_read() {
let data = b"hello io-uring";
let (_tmp, path) = create_temp_file(data);
let mut file = File::open(&path).await.unwrap();
let mut buf = vec![0u8... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_uring_file_read.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/fs_uring_file_read.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/fs_uring_file_read.rs:3 | // Small file
{
let data: Vec<u8> = (0..100u8).collect();
let (_tmp, path) = create_temp_file(&data);
let mut file = File::open(&path).await.unwrap();
let mut buf = Vec::new();
file.read_to_end(&mut buf).await.unwrap();
assert_eq!(buf, data);
}
// File larger... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_uring_file_read.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/fs_uring_file_read.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/fs_uring_file_read.rs:4 | assert_eq!(n, 0);
}
#[tokio::test]
async fn test_file_read_large() {
let data: Vec<u8> = (0..3_000_000u32).map(|i| (i % 256) as u8).collect();
let (_tmp, path) = create_temp_file(&data);
let mut file = File::open(&path).await.unwrap();
let mut buf = Vec::new();
file.read_to_end(&mut buf).await.unw... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_uring_file_read.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/fs_uring_file_read.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/fs_uring_file_read.rs:5 | let mut rest = Vec::new();
file.read_to_end(&mut rest).await.unwrap();
assert_eq!(rest, data[5..]);
}
#[tokio::test]
async fn test_file_read_seek() {
let data = b"hello world";
let (_tmp, path) = create_temp_file(data);
let mut file = File::open(&path).await.unwrap();
file.seek(std::io::SeekFr... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_uring_file_read.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/fs_uring_file_read.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/fs_uring_file_read.rs:6 | async fn test_file_read_after_write() {
let tmp = NamedTempFile::new().unwrap();
let path = tmp.path().to_path_buf();
let mut file = tokio::fs::OpenOptions::new()
.read(true)
.write(true)
.open(&path)
.await
.unwrap();
file.write_all(b"hello uring").await.unwrap... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_uring_file_read.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/fs_uring_file_read.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/fs_uring_file_read.rs:7 | file.read_to_end(&mut buf).await.unwrap();
assert_eq!(buf, data);
}
#[tokio::test]
async fn test_file_read_concurrent() {
const NUM_FILES: usize = 100;
let files: Vec<_> = (0..NUM_FILES)
.map(|i| {
let data: Vec<u8> = (0..1024).map(|j| ((i as u16 + j) % 256) as u8).collect();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_uring_file_read.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/fs_uring_file_read.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/fs_uring_file_read.rs:8 | let mut file = File::open(&path).await.unwrap();
let mut buf = Vec::new();
file.read_to_end(&mut buf).await.unwrap();
buf
});
assert_eq!(result, data);
}
}
#[test]
fn shutdown_runtime_with_pending_reads() {
for rt_factory in rt_combinations() {
let r... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_uring_file_read.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/fs_uring_file_read.rs | 281 | 340 |
tokio-rs/tokio:tokio/tests/fs_uring_file_read.rs:9 | let data = b"hello from_std io-uring";
tmp.write_all(data).unwrap();
tmp.flush().unwrap();
let path = tmp.path().to_owned();
let rt = Builder::new_multi_thread()
.worker_threads(2)
.enable_all()
.build()
.unwrap();
rt.block_on(async {
let std_file = std::fs:... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_uring_file_read.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/fs_uring_file_read.rs | 321 | 380 |
tokio-rs/tokio:tokio/tests/fs_uring_file_read.rs:10 | assert!(n > 0);
assert_eq!(&buf[..n], &data[4..4 + n]);
// Read the rest
let mut rest = Vec::new();
file.read_to_end(&mut rest).await.unwrap();
let total = 4 + n + rest.len();
assert_eq!(total, data.len());
}
#[tokio::test]
async fn test_file_read_with_bigger_buf() {
let data = b"hello io-... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_uring_file_read.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/fs_uring_file_read.rs | 361 | 420 |
tokio-rs/tokio:tokio/tests/fs_uring_file_read.rs:11 | let mut buf = Vec::new();
file.read_to_end(&mut buf).await.unwrap();
assert_eq!(buf.len(), data.len());
assert_eq!(buf, data);
}
/// Read some bytes from a file, then write, verifying the implicit seek-back
/// works correctly.
#[tokio::test]
async fn test_file_read_then_write() {
let original = b"hell... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_uring_file_read.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/fs_uring_file_read.rs | 401 | 460 |
tokio-rs/tokio:tokio/tests/fs_uring_file_read.rs:12 | let data = b"abcdefghijklmnopqrstuvwxyz";
let (_tmp, path) = create_temp_file(data);
let mut file = tokio::fs::OpenOptions::new()
.read(true)
.write(true)
.open(&path)
.await
.unwrap();
// First read fills internal buffer.
let mut buf = vec![0u8; 10];
file.r... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_uring_file_read.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/fs_uring_file_read.rs | 441 | 471 |
tokio-rs/tokio:tokio/tests/fs_uring_read.rs:1 | //! Uring file operations tests.
#![cfg(all(
tokio_unstable,
feature = "io-uring",
feature = "rt",
feature = "fs",
target_os = "linux"
))]
use futures::future::Future;
use std::future::poll_fn;
use std::io::Write;
use std::path::PathBuf;
use std::sync::mpsc;
use std::task::{Context, Poll, Waker};
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_uring_read.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/fs_uring_read.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/fs_uring_read.rs:2 | multi_rt(1),
multi_rt(2),
multi_rt(8),
multi_rt(64),
multi_rt(256),
]
}
#[test]
fn shutdown_runtime_while_performing_io_uring_ops() {
fn run(rt: Runtime) {
let (done_tx, done_rx) = mpsc::channel();
let (_tmp, path) = create_tmp_files(1);
// keep 100 permi... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_uring_read.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/fs_uring_read.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/fs_uring_read.rs:3 | done_tx.send(()).unwrap();
});
done_rx.recv().unwrap();
}
for rt in rt_combinations() {
run(rt());
}
}
#[test]
fn read_many_files() {
fn run(rt: Runtime) {
const NUM_FILES: usize = 512;
let (_tmp_files, paths): (Vec<NamedTempFile>, Vec<PathBuf>) = create_tmp_f... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_uring_read.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/fs_uring_read.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/fs_uring_read.rs:4 | let (_tmp, path) = create_large_temp_file();
let bytes = read(path).await.unwrap();
assert_eq!(bytes, create_buf(5000));
let (_tmp, path) = create_small_temp_file();
let bytes = read(path).await.unwrap();
assert_eq!(bytes, create_buf(20));
}
#[tokio::test]
async fn cancel_op_future() {
let... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_uring_read.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/fs_uring_read.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/fs_uring_read.rs:5 | handle.abort();
let res = handle.await.unwrap_err();
assert!(res.is_cancelled());
}
fn create_tmp_files(num_files: usize) -> (Vec<NamedTempFile>, Vec<PathBuf>) {
let mut files = Vec::with_capacity(num_files);
for _ in 0..num_files {
let mut tmp = NamedTempFile::new().unwrap();
let buf ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_uring_read.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/fs_uring_read.rs | 161 | 202 |
tokio-rs/tokio:tokio/tests/fs_uring_runtime_shutdown.rs:1 | //! Uring file operations tests.
#![cfg(all(
tokio_unstable,
feature = "io-uring",
feature = "rt",
feature = "fs",
target_os = "linux"
))]
use futures::FutureExt;
use std::fs;
use std::future::poll_fn;
use std::task::Poll;
use tempfile::NamedTempFile;
use tokio::runtime::Builder;
use tokio_test::a... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_uring_runtime_shutdown.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/fs_uring_runtime_shutdown.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/fs_uring_runtime_shutdown.rs:2 | let (tx, mut rx) = tokio::sync::mpsc::unbounded_channel();
let path = path.clone();
let handle = tokio::spawn(async move {
poll_fn(|cx| {
let opt = {
let mut opt = tokio::fs::OpenOptions::new();
opt.read(true);
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_uring_runtime_shutdown.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/fs_uring_runtime_shutdown.rs | 41 | 87 |
tokio-rs/tokio:tokio/tests/fs_uring_runtime_shutdown.rs:1 | //! Uring file operations tests.
#![cfg(all(
tokio_unstable,
feature = "io-uring",
feature = "rt",
feature = "fs",
target_os = "linux"
))]
use futures::FutureExt;
use std::fs;
use std::future::poll_fn;
use std::task::Poll;
use tempfile::NamedTempFile;
use tokio::runtime::Builder;
// see: https://... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_uring_runtime_shutdown.rs | MIT | c79121391db8f8d36d4213feeb25381caee110c7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c79121391db8f8d36d4213feeb25381caee110c7/tokio/tests/fs_uring_runtime_shutdown.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/fs_uring_runtime_shutdown.rs:2 | let fut = opt.open(&path);
// If io_uring is enabled (and not falling back to the thread pool),
// the first poll should return Pending. We don't check if the result
// is actually a pending because we run some CI checks based on old
// ke... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_uring_runtime_shutdown.rs | MIT | c79121391db8f8d36d4213feeb25381caee110c7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c79121391db8f8d36d4213feeb25381caee110c7/tokio/tests/fs_uring_runtime_shutdown.rs | 41 | 78 |
tokio-rs/tokio:tokio/tests/fs_write.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // WASI does not support all fs operations
use tempfile::tempdir;
use tokio::fs;
#[tokio::test]
async fn write() {
let dir = tempdir().unwrap();
let path = dir.path().join("test.txt");
fs::write(&path, "Hello, World!").awa... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/fs_write.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/fs_write.rs | 1 | 16 |
tokio-rs/tokio:tokio/tests/global.rs:1 | #![cfg(feature = "broken")]
#![deny(warnings, rust_2018_idioms)]
use env_logger;
use futures::prelude::*;
use std::sync::atomic::AtomicUsize;
use std::sync::atomic::Ordering::Relaxed;
use std::sync::Arc;
use std::{io, thread};
use tokio;
use tokio::net::{TcpListener, TcpStream};
use tokio::runtime::Runtime;
use tokio_... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/global.rs | MIT | 29e417c257c62ae95cfa73f6b56825b3f833dde8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/29e417c257c62ae95cfa73f6b56825b3f833dde8/tokio/tests/global.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/global.rs:2 | assert_eq!(t!(mine.local_addr()), t!(theirs.peer_addr()));
assert_eq!(t!(theirs.local_addr()), t!(mine.peer_addr()));
})
})
.collect::<Vec<_>>();
for thread in threads {
thread.join().unwrap();
}
}
struct Rd(Arc<TcpStream>);
struct Wr(Arc<TcpStream>);
impl i... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/global.rs | MIT | 29e417c257c62ae95cfa73f6b56825b3f833dde8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/29e417c257c62ae95cfa73f6b56825b3f833dde8/tokio/tests/global.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/global.rs:3 | const N: usize = 100;
const ITER: usize = 10;
let _ = env_logger::try_init();
for _ in 0..ITER {
let srv = t!(TcpListener::bind(&"127.0.0.1:0".parse().unwrap()));
let addr = t!(srv.local_addr());
let cnt = Arc::new(AtomicUsize::new(0));
let rt = Runtime::new().unwrap();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/global.rs | MIT | 29e417c257c62ae95cfa73f6b56825b3f833dde8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/29e417c257c62ae95cfa73f6b56825b3f833dde8/tokio/tests/global.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/global.rs:4 | .map_err(|e| panic!("accept error = {:?}", e))
.take(N as u64)
.for_each(move |socket| {
split(socket, cnt.clone());
Ok(())
})
});
for _ in 0..N {
rt.spawn({
let cnt = cnt.clone();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/global.rs | MIT | 29e417c257c62ae95cfa73f6b56825b3f833dde8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/29e417c257c62ae95cfa73f6b56825b3f833dde8/tokio/tests/global.rs | 121 | 141 |
tokio-rs/tokio:tokio/tests/global.rs:1 | #![deny(warnings, rust_2018_idioms)]
use env_logger;
use futures::prelude::*;
use std::sync::atomic::AtomicUsize;
use std::sync::atomic::Ordering::Relaxed;
use std::sync::Arc;
use std::{io, thread};
use tokio;
use tokio::net::{TcpListener, TcpStream};
use tokio::runtime::Runtime;
use tokio_io;
macro_rules! t {
($... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/global.rs | MIT | 4f6395b31c2e5e550188c8ae01de2c4eaee2937b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4f6395b31c2e5e550188c8ae01de2c4eaee2937b/tokio/tests/global.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/global.rs:2 | assert_eq!(t!(theirs.local_addr()), t!(mine.peer_addr()));
})
})
.collect::<Vec<_>>();
for thread in threads {
thread.join().unwrap();
}
}
struct Rd(Arc<TcpStream>);
struct Wr(Arc<TcpStream>);
impl io::Read for Rd {
fn read(&mut self, dst: &mut [u8]) -> io::Result<usize... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/global.rs | MIT | 4f6395b31c2e5e550188c8ae01de2c4eaee2937b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4f6395b31c2e5e550188c8ae01de2c4eaee2937b/tokio/tests/global.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/global.rs:3 | const N: usize = 100;
const ITER: usize = 10;
let _ = env_logger::try_init();
for _ in 0..ITER {
let srv = t!(TcpListener::bind(&"127.0.0.1:0".parse().unwrap()));
let addr = t!(srv.local_addr());
let cnt = Arc::new(AtomicUsize::new(0));
let rt = Runtime::new().unwrap();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/global.rs | MIT | 4f6395b31c2e5e550188c8ae01de2c4eaee2937b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4f6395b31c2e5e550188c8ae01de2c4eaee2937b/tokio/tests/global.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/global.rs:4 | .take(N as u64)
.for_each(move |socket| {
split(socket, cnt.clone());
Ok(())
})
});
for _ in 0..N {
rt.spawn({
let cnt = cnt.clone();
TcpStream::connect(&addr)
.map_er... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/global.rs | MIT | 4f6395b31c2e5e550188c8ae01de2c4eaee2937b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4f6395b31c2e5e550188c8ae01de2c4eaee2937b/tokio/tests/global.rs | 121 | 140 |
tokio-rs/tokio:tokio/tests/global.rs:2 | assert_eq!(t!(theirs.local_addr()), t!(mine.peer_addr()));
})
})
.collect::<Vec<_>>();
for thread in threads {
thread.join().unwrap();
}
}
struct Rd(Arc<TcpStream>);
struct Wr(Arc<TcpStream>);
impl io::Read for Rd {
fn read(&mut self, dst: &mut [u8]) -> io::Result<usize... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/global.rs | MIT | cb4aea394e6851ae8cc45a68beeaf2c93cc9a0c0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cb4aea394e6851ae8cc45a68beeaf2c93cc9a0c0/tokio/tests/global.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/global.rs:3 | const N: usize = 100;
const ITER: usize = 10;
let _ = env_logger::try_init();
for _ in 0..ITER {
let srv = t!(TcpListener::bind(&"127.0.0.1:0".parse().unwrap()));
let addr = t!(srv.local_addr());
let cnt = Arc::new(AtomicUsize::new(0));
let mut rt = Runtime::new().unwrap(... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/global.rs | MIT | cb4aea394e6851ae8cc45a68beeaf2c93cc9a0c0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cb4aea394e6851ae8cc45a68beeaf2c93cc9a0c0/tokio/tests/global.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/io.rs:1 | use bytes::BytesMut;
use pin_utils::pin_mut;
use std::future::Future;
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
use tokio::io::{AsyncRead, AsyncWrite};
use tokio_test::assert_ready_ok;
use tokio_test::task::MockTask; | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io.rs | MIT | 11f6b2862fc458204aabbed9a6f919c65215aeb5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/11f6b2862fc458204aabbed9a6f919c65215aeb5/tokio/tests/io.rs | 1 | 9 |
tokio-rs/tokio:tokio/tests/io.rs:1 | use bytes::BytesMut;
use pin_utils::pin_mut;
use std::future::Future;
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
use tokio::io::{AsyncRead, AsyncWrite};
use tokio_test::assert_ready_ok;
use tokio_test::task::MockTask;
#[test]
fn write() {
struct Wr(BytesMut);
impl AsyncWrite for Wr {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io.rs | MIT | 0784dc27679beecdb06f273ea8c8af0168212c12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0784dc27679beecdb06f273ea8c8af0168212c12/tokio/tests/io.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io.rs:2 | let n = assert_ready_ok!(write.poll(cx));
assert_eq!(n, 11);
});
}
#[test]
fn read() {
struct Rd;
impl AsyncRead for Rd {
fn poll_read(
self: Pin<&mut Self>,
_cx: &mut Context<'_>,
buf: &mut [u8],
) -> Poll<io::Result<usize>> {
buf[0.... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io.rs | MIT | 0784dc27679beecdb06f273ea8c8af0168212c12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0784dc27679beecdb06f273ea8c8af0168212c12/tokio/tests/io.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/io.rs:3 | impl AsyncRead for Rd {
fn poll_read(
mut self: Pin<&mut Self>,
_cx: &mut Context<'_>,
buf: &mut [u8],
) -> Poll<io::Result<usize>> {
if self.0 {
buf[0..11].copy_from_slice(b"hello world");
self.0 = false;
Po... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io.rs | MIT | 0784dc27679beecdb06f273ea8c8af0168212c12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0784dc27679beecdb06f273ea8c8af0168212c12/tokio/tests/io.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/io.rs:4 | task.enter(|cx| {
let mut rd = Rd(true);
let mut wr = Wr(buf);
let copy = tokio::io::copy(&mut rd, &mut wr);
pin_mut!(copy);
let n = assert_ready_ok!(copy.poll(cx));
assert_eq!(n, 11);
assert_eq!(wr.0[..], b"hello world"[..]);
});
}
#[test]
fn read_exact()... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io.rs | MIT | 0784dc27679beecdb06f273ea8c8af0168212c12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0784dc27679beecdb06f273ea8c8af0168212c12/tokio/tests/io.rs | 121 | 169 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.