diff --git a/base/src/sys/unix/descriptor.rs b/base/src/sys/unix/descriptor.rs index 7ae2e1428a..7320d626ba 100644 --- a/base/src/sys/unix/descriptor.rs +++ b/base/src/sys/unix/descriptor.rs @@ -214,28 +214,3 @@ IntoRawDescriptor!(UnixDatagram); AsRawDescriptor!(Stdin); AsRawDescriptor!(Stdout); AsRawDescriptor!(Stderr); - -#[test] -#[allow(clippy::eq_op)] -fn clone_equality() { - let ret = unsafe { libc::eventfd(0, 0) }; - if ret < 0 { - panic!("failed to create eventfd"); - } - let descriptor = unsafe { SafeDescriptor::from_raw_descriptor(ret) }; - - assert_eq!(descriptor, descriptor); - - assert_eq!( - descriptor, - descriptor.try_clone().expect("failed to clone eventfd") - ); - - let ret = unsafe { libc::eventfd(0, 0) }; - if ret < 0 { - panic!("failed to create eventfd"); - } - let another = unsafe { SafeDescriptor::from_raw_descriptor(ret) }; - - assert_ne!(descriptor, another); -} diff --git a/base/tests/unix/main.rs b/base/tests/unix/main.rs index d3299cc88a..745347e23f 100644 --- a/base/tests/unix/main.rs +++ b/base/tests/unix/main.rs @@ -8,6 +8,8 @@ use std::path::Path; use base::safe_descriptor_from_path; use base::Error; +use base::FromRawDescriptor; +use base::SafeDescriptor; use libc::EBADF; use libc::EINVAL; @@ -47,3 +49,28 @@ fn safe_descriptor_from_path_none() { None ); } + +#[test] +#[allow(clippy::eq_op)] +fn clone_equality() { + let ret = unsafe { libc::eventfd(0, 0) }; + if ret < 0 { + panic!("failed to create eventfd"); + } + let descriptor = unsafe { SafeDescriptor::from_raw_descriptor(ret) }; + + assert_eq!(descriptor, descriptor); + + assert_eq!( + descriptor, + descriptor.try_clone().expect("failed to clone eventfd") + ); + + let ret = unsafe { libc::eventfd(0, 0) }; + if ret < 0 { + panic!("failed to create eventfd"); + } + let another = unsafe { SafeDescriptor::from_raw_descriptor(ret) }; + + assert_ne!(descriptor, another); +}