From 3cd7bbfd62619a23751ed9c2ce937b7b315cb3df Mon Sep 17 00:00:00 2001 From: fqwert Date: Mon, 26 Jun 2023 15:05:04 +0800 Subject: [PATCH] move the requird-features to its test file Signed-off-by: fqwert --- ylong_runtime/Cargo.toml | 75 -------------------------- ylong_runtime/tests/async_buf_read.rs | 2 + ylong_runtime/tests/async_buf_write.rs | 2 + ylong_runtime/tests/async_dir.rs | 2 + ylong_runtime/tests/async_fs.rs | 2 + ylong_runtime/tests/async_pool.rs | 6 +-- ylong_runtime/tests/async_read.rs | 2 + ylong_runtime/tests/block_on.rs | 2 + ylong_runtime/tests/builder.rs | 2 + ylong_runtime/tests/join_set.rs | 9 +--- ylong_runtime/tests/mpsc_test.rs | 2 + ylong_runtime/tests/spawn.rs | 2 + ylong_runtime/tests/spawn_blocking.rs | 2 + ylong_runtime/tests/sync.rs | 2 + ylong_runtime/tests/tcp_test.rs | 2 + ylong_runtime/tests/timer_test.rs | 2 + ylong_runtime/tests/udp_test.rs | 2 + 17 files changed, 33 insertions(+), 85 deletions(-) diff --git a/ylong_runtime/Cargo.toml b/ylong_runtime/Cargo.toml index d6b9e5e..8b7477d 100644 --- a/ylong_runtime/Cargo.toml +++ b/ylong_runtime/Cargo.toml @@ -142,78 +142,3 @@ required-features = ["multi_instance_runtime"] name = "ylong_runtime_timer_sleep" path = "examples/ylong_runtime_timer_sleep.rs" required-features = ["time", "multi_instance_runtime"] - -[[test]] -name = "tcp_test" -path = "tests/tcp_test.rs" -required-features = ["net"] - -[[test]] -name = "udp_test" -path = "tests/udp_test.rs" -required-features = ["net"] - -[[test]] -name = "async_dir" -path = "tests/async_dir.rs" -required-features = ["fs"] - -[[test]] -name = "async_fs" -path = "tests/async_fs.rs" -required-features = ["fs", "multi_instance_runtime"] - -[[test]] -name = "async_read" -path = "tests/async_read.rs" -required-features = ["net"] - -[[test]] -name = "spawn_blocking" -path = "tests/spawn_blocking.rs" -required-features = ["multi_instance_runtime"] - -[[test]] -name = "async_pool" -path = "tests/async_pool.rs" -required-features = ["multi_instance_runtime"] - -[[test]] -name = "builder" -path = "tests/builder.rs" -required-features = ["multi_instance_runtime"] - -[[test]] -name = "sync" -path = "tests/sync.rs" -required-features = ["sync", "multi_instance_runtime"] - -[[test]] -name = "block_on" -path = "tests/block_on.rs" -required-features = ["multi_instance_runtime"] - -[[test]] -name = "spawn" -path = "tests/spawn.rs" -required-features = ["multi_instance_runtime"] - -[[test]] -name = "timer_test" -path = "tests/timer_test.rs" -required-features = ["time", "sync"] - -[[test]] -name = "mpsc_test" -path = "tests/mpsc_test.rs" -required-features = ["sync", "time"] - -[[test]] -name = "async_buf_read" -path = "tests/async_buf_read.rs" -required-features = ["fs", "net"] - -[[test]] -name = "async_buf_write" -path = "tests/async_buf_write.rs" -required-features = ["fs", "net"] diff --git a/ylong_runtime/tests/async_buf_read.rs b/ylong_runtime/tests/async_buf_read.rs index f683f38..13b6ee9 100644 --- a/ylong_runtime/tests/async_buf_read.rs +++ b/ylong_runtime/tests/async_buf_read.rs @@ -13,6 +13,8 @@ * limitations under the License. */ +#![cfg(all(feature = "fs", feature = "net"))] + use std::io::SeekFrom; use ylong_runtime::fs::File; use ylong_runtime::io::{ diff --git a/ylong_runtime/tests/async_buf_write.rs b/ylong_runtime/tests/async_buf_write.rs index c3d3430..70fe52e 100644 --- a/ylong_runtime/tests/async_buf_write.rs +++ b/ylong_runtime/tests/async_buf_write.rs @@ -13,6 +13,8 @@ * limitations under the License. */ +#![cfg(all(feature = "fs", feature = "net"))] + use std::io::{IoSlice, SeekFrom}; use ylong_runtime::fs::File; use ylong_runtime::io::{AsyncBufWriter, AsyncReadExt, AsyncSeekExt, AsyncWriteExt}; diff --git a/ylong_runtime/tests/async_dir.rs b/ylong_runtime/tests/async_dir.rs index 066d750..77ec573 100644 --- a/ylong_runtime/tests/async_dir.rs +++ b/ylong_runtime/tests/async_dir.rs @@ -13,6 +13,8 @@ * limitations under the License. */ +#![cfg(feature = "fs")] + use ylong_runtime::fs::{create_dir, create_dir_all, read_dir, remove_dir, remove_dir_all, File}; /// SDV test for directory operations. diff --git a/ylong_runtime/tests/async_fs.rs b/ylong_runtime/tests/async_fs.rs index fa5c755..fe28d67 100644 --- a/ylong_runtime/tests/async_fs.rs +++ b/ylong_runtime/tests/async_fs.rs @@ -13,6 +13,8 @@ * limitations under the License. */ +#![cfg(all(feature = "fs", feature = "multi_instance_runtime"))] + use std::fs; use std::io::SeekFrom; use ylong_runtime::builder::RuntimeBuilder; diff --git a/ylong_runtime/tests/async_pool.rs b/ylong_runtime/tests/async_pool.rs index 0aa1a3f..5a4888e 100644 --- a/ylong_runtime/tests/async_pool.rs +++ b/ylong_runtime/tests/async_pool.rs @@ -12,14 +12,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + #![cfg(target_os = "linux")] -#![cfg(not(feature = "ffrt"))] +#![cfg(all(feature = "multi_instance_runtime", not(feature = "ffrt")))] + use libc::getpid; use std::fs; use ylong_runtime::builder::RuntimeBuilder; -#[cfg(target_os = "linux")] use ylong_runtime::util::core_affinity::linux::get_other_thread_affinity; -#[cfg(target_os = "linux")] use ylong_runtime::util::num_cpus::get_cpu_num; pub mod helpers; use helpers::dump_dir; diff --git a/ylong_runtime/tests/async_read.rs b/ylong_runtime/tests/async_read.rs index 31a0d9e..4c098d3 100644 --- a/ylong_runtime/tests/async_read.rs +++ b/ylong_runtime/tests/async_read.rs @@ -13,6 +13,8 @@ * limitations under the License. */ +#![cfg(feature = "net")] + extern crate core; use ylong_runtime::io::{AsyncBufReader, AsyncReadExt, AsyncWriteExt}; diff --git a/ylong_runtime/tests/block_on.rs b/ylong_runtime/tests/block_on.rs index 6040e85..61d57c4 100644 --- a/ylong_runtime/tests/block_on.rs +++ b/ylong_runtime/tests/block_on.rs @@ -13,6 +13,8 @@ * limitations under the License. */ +#![cfg(feature = "multi_instance_runtime")] + use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}; diff --git a/ylong_runtime/tests/builder.rs b/ylong_runtime/tests/builder.rs index f65fcca..fd95b86 100644 --- a/ylong_runtime/tests/builder.rs +++ b/ylong_runtime/tests/builder.rs @@ -13,6 +13,8 @@ * limitations under the License. */ +#![cfg(feature = "multi_instance_runtime")] + use std::sync::{Arc, Mutex}; use ylong_runtime::builder::RuntimeBuilder; diff --git a/ylong_runtime/tests/join_set.rs b/ylong_runtime/tests/join_set.rs index fd4b54b..7014aed 100644 --- a/ylong_runtime/tests/join_set.rs +++ b/ylong_runtime/tests/join_set.rs @@ -13,6 +13,8 @@ * limitations under the License. */ +#![cfg(feature = "time")] + use std::future::Future; use std::pin::Pin; use std::sync::atomic::AtomicUsize; @@ -21,13 +23,6 @@ use std::sync::Arc; use std::task::{Context, Poll}; use ylong_runtime::task::{JoinSet, PriorityLevel}; -#[cfg(feature = "time")] -use std::time::Duration; -#[cfg(feature = "time")] -use ylong_runtime::error::ErrorKind; -#[cfg(feature = "time")] -use ylong_runtime::time::sleep; - /// SDV test for spawning and waiting for a simple future. /// /// # Title diff --git a/ylong_runtime/tests/mpsc_test.rs b/ylong_runtime/tests/mpsc_test.rs index af47061..6dc4181 100644 --- a/ylong_runtime/tests/mpsc_test.rs +++ b/ylong_runtime/tests/mpsc_test.rs @@ -13,6 +13,8 @@ * limitations under the License. */ +#![cfg(all(feature = "time", feature = "sync"))] + use std::time::Duration; use ylong_runtime::sync::mpsc::bounded_channel; use ylong_runtime::sync::mpsc::unbounded_channel; diff --git a/ylong_runtime/tests/spawn.rs b/ylong_runtime/tests/spawn.rs index 1f31354..444a892 100644 --- a/ylong_runtime/tests/spawn.rs +++ b/ylong_runtime/tests/spawn.rs @@ -13,6 +13,8 @@ * limitations under the License. */ +#![cfg(feature = "multi_instance_runtime")] + use ylong_runtime::builder::RuntimeBuilder; mod helpers; diff --git a/ylong_runtime/tests/spawn_blocking.rs b/ylong_runtime/tests/spawn_blocking.rs index 6eebc74..6b7f0eb 100644 --- a/ylong_runtime/tests/spawn_blocking.rs +++ b/ylong_runtime/tests/spawn_blocking.rs @@ -13,6 +13,8 @@ * limitations under the License. */ +#![cfg(feature = "multi_instance_runtime")] + use std::thread::sleep; use std::time; use ylong_runtime::builder::RuntimeBuilder; diff --git a/ylong_runtime/tests/sync.rs b/ylong_runtime/tests/sync.rs index 860e39c..7cfd179 100644 --- a/ylong_runtime/tests/sync.rs +++ b/ylong_runtime/tests/sync.rs @@ -13,6 +13,8 @@ * limitations under the License. */ +#![cfg(all(feature = "sync", feature = "multi_instance_runtime"))] + use std::sync::{Arc, Mutex}; use ylong_runtime::sync::Mutex as YlongMutex; diff --git a/ylong_runtime/tests/tcp_test.rs b/ylong_runtime/tests/tcp_test.rs index 0eaa82d..40123b8 100644 --- a/ylong_runtime/tests/tcp_test.rs +++ b/ylong_runtime/tests/tcp_test.rs @@ -13,6 +13,8 @@ * limitations under the License. */ +#![cfg(feature = "net")] + use std::thread; use ylong_runtime::io::{AsyncReadExt, AsyncWriteExt}; use ylong_runtime::net::{TcpListener, TcpStream}; diff --git a/ylong_runtime/tests/timer_test.rs b/ylong_runtime/tests/timer_test.rs index c0eca9f..4c5d3d2 100644 --- a/ylong_runtime/tests/timer_test.rs +++ b/ylong_runtime/tests/timer_test.rs @@ -13,6 +13,8 @@ * limitations under the License. */ +#![cfg(all(feature = "time", feature = "sync"))] + use std::collections::HashMap; use std::sync::Arc; use std::time::Duration; diff --git a/ylong_runtime/tests/udp_test.rs b/ylong_runtime/tests/udp_test.rs index e7ff2d3..efdd71a 100644 --- a/ylong_runtime/tests/udp_test.rs +++ b/ylong_runtime/tests/udp_test.rs @@ -13,6 +13,8 @@ * limitations under the License. */ +#![cfg(feature = "net")] + use std::{io, thread}; use ylong_runtime::net::UdpSocket; -- Gitee