mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
test_cp: verify metadata for preserve no args case
This commit is contained in:
parent
8591d99c1b
commit
a6c48b084c
1 changed files with 21 additions and 3 deletions
|
@ -881,11 +881,29 @@ fn test_cp_issue_1665() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_cp_preserve_no_args() {
|
fn test_cp_preserve_no_args() {
|
||||||
new_ucmd!()
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
.arg(TEST_COPY_FROM_FOLDER_FILE)
|
let src_file = "a";
|
||||||
.arg(TEST_HELLO_WORLD_DEST)
|
let dst_file = "b";
|
||||||
|
|
||||||
|
// Prepare the source file
|
||||||
|
at.touch(src_file);
|
||||||
|
#[cfg(unix)]
|
||||||
|
at.set_mode(src_file, 0o0500);
|
||||||
|
|
||||||
|
// Copy
|
||||||
|
ucmd.arg(src_file)
|
||||||
|
.arg(dst_file)
|
||||||
.arg("--preserve")
|
.arg("--preserve")
|
||||||
.succeeds();
|
.succeeds();
|
||||||
|
|
||||||
|
#[cfg(unix)]
|
||||||
|
{
|
||||||
|
// Assert that the mode, ownership, and timestamps are preserved
|
||||||
|
// NOTICE: the ownership is not modified on the src file, because that requires root permissions
|
||||||
|
let metadata_src = at.metadata(src_file);
|
||||||
|
let metadata_dst = at.metadata(dst_file);
|
||||||
|
assert_metadata_eq!(metadata_src, metadata_dst);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue