mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
test/cp: fix test_copy_through_dangling_symlink_no_dereference_permissions (#3789)
* test/cp: -p changes ctime and added sleep for better timestamp testing * test/cp: add nanoseconds checking for copied timestamps * test/cp: made compilable on other OSes * test/cp: added error messages to assert_eq calls
This commit is contained in:
parent
175f8aa16f
commit
fee851dc1c
1 changed files with 17 additions and 8 deletions
|
@ -22,9 +22,7 @@ use filetime::FileTime;
|
|||
use rlimit::Resource;
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
use std::fs as std_fs;
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
use std::thread::sleep;
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
use std::time::Duration;
|
||||
use uucore::display::Quotable;
|
||||
|
||||
|
@ -1732,6 +1730,8 @@ fn test_copy_through_dangling_symlink_no_dereference_permissions() {
|
|||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
// target name link name
|
||||
at.symlink_file("no-such-file", "dangle");
|
||||
// to check if access time and modification time didn't change
|
||||
sleep(Duration::from_millis(5000));
|
||||
// don't dereference the link
|
||||
// | copy permissions, too
|
||||
// | | from the link
|
||||
|
@ -1742,18 +1742,27 @@ fn test_copy_through_dangling_symlink_no_dereference_permissions() {
|
|||
.succeeds()
|
||||
.no_stderr()
|
||||
.no_stdout();
|
||||
assert!(at.symlink_exists("d2"));
|
||||
assert!(at.symlink_exists("d2"), "symlink wasn't created");
|
||||
|
||||
// `-p` means `--preserve=mode,ownership,timestamps`
|
||||
#[cfg(unix)]
|
||||
{
|
||||
let metadata1 = at.symlink_metadata("dangle");
|
||||
let metadata2 = at.symlink_metadata("d2");
|
||||
assert_eq!(metadata1.mode(), metadata2.mode());
|
||||
assert_eq!(metadata1.uid(), metadata2.uid());
|
||||
assert_eq!(metadata1.atime(), metadata2.atime());
|
||||
assert_eq!(metadata1.mtime(), metadata2.mtime());
|
||||
assert_eq!(metadata1.ctime(), metadata2.ctime());
|
||||
assert_eq!(metadata1.mode(), metadata2.mode(), "mode is different");
|
||||
assert_eq!(metadata1.uid(), metadata2.uid(), "uid is different");
|
||||
assert_eq!(metadata1.atime(), metadata2.atime(), "atime is different");
|
||||
assert_eq!(
|
||||
metadata1.atime_nsec(),
|
||||
metadata2.atime_nsec(),
|
||||
"atime_nsec is different"
|
||||
);
|
||||
assert_eq!(metadata1.mtime(), metadata2.mtime(), "mtime is different");
|
||||
assert_eq!(
|
||||
metadata1.mtime_nsec(),
|
||||
metadata2.mtime_nsec(),
|
||||
"mtime_nsec is different"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue