mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
cp: rewrite test to remove procfs dependency
This commit is contained in:
parent
dfc2e249ef
commit
546e50846e
1 changed files with 9 additions and 10 deletions
|
@ -3,7 +3,7 @@
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
|
|
||||||
// spell-checker:ignore (flags) reflink (fs) tmpfs (linux) rlimit Rlim NOFILE clob btrfs neve ROOTDIR USERDIR procfs outfile uufs xattrs
|
// spell-checker:ignore (flags) reflink (fs) tmpfs (linux) rlimit Rlim NOFILE clob btrfs neve ROOTDIR USERDIR outfile uufs xattrs
|
||||||
// spell-checker:ignore bdfl hlsl IRWXO IRWXG nconfined matchpathcon libselinux-devel
|
// spell-checker:ignore bdfl hlsl IRWXO IRWXG nconfined matchpathcon libselinux-devel
|
||||||
use uucore::display::Quotable;
|
use uucore::display::Quotable;
|
||||||
use uutests::util::TestScenario;
|
use uutests::util::TestScenario;
|
||||||
|
@ -2556,22 +2556,21 @@ fn test_cp_reflink_insufficient_permission() {
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
#[test]
|
#[test]
|
||||||
fn test_closes_file_descriptors() {
|
fn test_closes_file_descriptors() {
|
||||||
use procfs::process::Process;
|
|
||||||
use rlimit::Resource;
|
use rlimit::Resource;
|
||||||
let me = Process::myself().unwrap();
|
|
||||||
|
let pid = std::process::id();
|
||||||
|
let fd_path = format!("/proc/{pid}/fd");
|
||||||
|
|
||||||
// The test suite runs in parallel, we have pipe, sockets
|
// The test suite runs in parallel, we have pipe, sockets
|
||||||
// opened by other tests.
|
// opened by other tests.
|
||||||
// So, we take in account the various fd to increase the limit
|
// So, we take in account the various fd to increase the limit
|
||||||
let number_file_already_opened: u64 = me.fd_count().unwrap().try_into().unwrap();
|
let number_file_already_opened: u64 = std::fs::read_dir(fd_path)
|
||||||
|
.unwrap()
|
||||||
|
.count()
|
||||||
|
.try_into()
|
||||||
|
.unwrap();
|
||||||
let limit_fd: u64 = number_file_already_opened + 9;
|
let limit_fd: u64 = number_file_already_opened + 9;
|
||||||
|
|
||||||
// For debugging purposes:
|
|
||||||
for f in me.fd().unwrap() {
|
|
||||||
let fd = f.unwrap();
|
|
||||||
println!("{fd:?} {:?}", fd.mode());
|
|
||||||
}
|
|
||||||
|
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.arg("-r")
|
.arg("-r")
|
||||||
.arg("--reflink=auto")
|
.arg("--reflink=auto")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue