cp: test that file descriptors are closed

This commit is contained in:
Michael Debertol 2021-06-02 18:08:09 +02:00
parent e5c4681e04
commit 7ffc7d073c
11 changed files with 15 additions and 1 deletions

View file

@ -1,4 +1,4 @@
// spell-checker:ignore (flags) reflink (fs) tmpfs
// spell-checker:ignore (flags) reflink (fs) tmpfs (linux) rlimit Rlim NOFILE
use crate::common::util::*;
#[cfg(not(windows))]
@ -14,6 +14,8 @@ use std::os::windows::fs::symlink_file;
#[cfg(target_os = "linux")]
use filetime::FileTime;
#[cfg(target_os = "linux")]
use rlimit::Resource;
#[cfg(not(windows))]
use std::env;
#[cfg(target_os = "linux")]
@ -1276,3 +1278,15 @@ fn test_cp_reflink_insufficient_permission() {
.fails()
.stderr_only("cp: 'unreadable' -> 'existing_file.txt': Permission denied (os error 13)");
}
#[cfg(target_os = "linux")]
#[test]
fn test_closes_file_descriptors() {
new_ucmd!()
.arg("-r")
.arg("--reflink=auto")
.arg("dir_with_10_files/")
.arg("dir_with_10_files_new/")
.with_limit(Resource::NOFILE, 9, 9)
.succeeds();
}

0
tests/fixtures/cp/dir_with_10_files/0 vendored Normal file
View file

0
tests/fixtures/cp/dir_with_10_files/1 vendored Normal file
View file

0
tests/fixtures/cp/dir_with_10_files/2 vendored Normal file
View file

0
tests/fixtures/cp/dir_with_10_files/3 vendored Normal file
View file

0
tests/fixtures/cp/dir_with_10_files/4 vendored Normal file
View file

0
tests/fixtures/cp/dir_with_10_files/5 vendored Normal file
View file

0
tests/fixtures/cp/dir_with_10_files/6 vendored Normal file
View file

0
tests/fixtures/cp/dir_with_10_files/7 vendored Normal file
View file

0
tests/fixtures/cp/dir_with_10_files/8 vendored Normal file
View file

0
tests/fixtures/cp/dir_with_10_files/9 vendored Normal file
View file