mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2024-11-24 20:48:55 +00:00
base: Move clone_equality test to integration test
In non-privileged containers, comparing a file descriptor may not work. So the test will not work in every runtime environment. BUG=b:244623061 TEST=dev_container --podman --unprivileged tools/run_tests base:base Change-Id: Ifa67e11db9694c36b47cd5ae88de9247284e1cdf Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3999711 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Dennis Kempin <denniskempin@google.com>
This commit is contained in:
parent
11322f007d
commit
86034fd5fb
2 changed files with 27 additions and 25 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue