diff --git a/ylong_runtime/tests/async_pool.rs b/ylong_runtime/tests/async_pool.rs index 4742157a3bd7ffc41acbc19ce0a085dd780f46ab..f0e0df55ee3c2ea2476081537c78e66681189998 100644 --- a/ylong_runtime/tests/async_pool.rs +++ b/ylong_runtime/tests/async_pool.rs @@ -13,14 +13,13 @@ #![cfg(target_os = "linux")] #![cfg(not(feature = "ffrt"))] use libc::getpid; +use std::ffi::OsString; 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; // Simple asynchronous tasks async fn test_future(num: usize) -> usize { @@ -40,6 +39,18 @@ async fn test_nested_future(i: usize, j: usize) -> usize { test_multi_future(i, j).await } +// Gets the pid of all current threads (including the main thread) +unsafe fn dump_dir() -> Vec { + let current_pid = getpid(); + let dir = format!("/proc/{}/task", current_pid.to_string().as_str()); + let mut result = Vec::new(); + + for entry in fs::read_dir(dir.as_str()).expect("read failed") { + result.push(entry.unwrap().file_name()); + } + result +} + // Get the name of the thread based on the thread pid unsafe fn name_of_pid(pid: &str) -> Option { let current_pid = getpid(); diff --git a/ylong_runtime/tests/helpers/mod.rs b/ylong_runtime/tests/helpers/mod.rs index 64da3ba46e8998b18542ff5bd41b2c7e1e1c4e06..1d18b44f244a447f8c5713f1079800130b784c22 100644 --- a/ylong_runtime/tests/helpers/mod.rs +++ b/ylong_runtime/tests/helpers/mod.rs @@ -11,10 +11,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -use libc::getpid; -use std::ffi::OsString; -use std::fs; - pub async fn test_future(num: usize) -> usize { num } @@ -29,16 +25,3 @@ pub async fn test_multi_future_in_async(i: usize, j: usize) -> (usize, usize) { pub async fn test_async_in_async(i: usize, j: usize) -> (usize, usize) { test_multi_future_in_async(i, j).await } - -// Gets the pid of all current threads (including the main thread) -#[allow(dead_code)] -pub(crate) unsafe fn dump_dir() -> Vec { - let current_pid = getpid(); - let dir = format!("/proc/{}/task", current_pid.to_string().as_str()); - let mut result = Vec::new(); - - for entry in fs::read_dir(dir.as_str()).expect("read failed") { - result.push(entry.unwrap().file_name()); - } - result -}