summaryrefslogtreecommitdiffstats
path: root/tests/by-util
diff options
context:
space:
mode:
authorSylvestre Ledru <sylvestre@debian.org>2024-06-29 10:46:31 +0200
committerGitHub <noreply@github.com>2024-06-29 10:46:31 +0200
commite08c43ade27c2dcac0dfad43bd218319cd01fa13 (patch)
tree4c045f48c3842d2db3d337ed63f5debc0959b9ed /tests/by-util
parent2244adb0f2a6688946d6aa2fb0e66bde493b405c (diff)
parent2e223dfdfcbc1d896124cce0629a3d0ccbb6a97d (diff)
Merge pull request #6496 from djedi23/6267-cp-preserved-hardlinks-are-not-reported-in--verbose
cp: fix preserved hardlinks are not reported in --verbose
Diffstat (limited to 'tests/by-util')
-rw-r--r--tests/by-util/test_cp.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/by-util/test_cp.rs b/tests/by-util/test_cp.rs
index 3b4ec74f7..ca592f6fd 100644
--- a/tests/by-util/test_cp.rs
+++ b/tests/by-util/test_cp.rs
@@ -609,6 +609,36 @@ fn test_cp_arg_link_with_same_file() {
}
#[test]
+#[cfg(target_os = "linux")]
+fn test_cp_verbose_preserved_link_to_dir() {
+ use std::os::linux::fs::MetadataExt;
+
+ let (at, mut ucmd) = at_and_ucmd!();
+ let file = "file";
+ let hardlink = "hardlink";
+ let dir = "dir";
+ let dst_file = "dir/file";
+ let dst_hardlink = "dir/hardlink";
+
+ at.touch(file);
+ at.hard_link(file, hardlink);
+ at.mkdir(dir);
+
+ ucmd.args(&["-d", "--verbose", file, hardlink, dir])
+ .succeeds()
+ .stdout_is("'file' -> 'dir/file'\n'hardlink' -> 'dir/hardlink'\n");
+
+ assert!(at.file_exists(dst_file));
+ assert!(at.file_exists(dst_hardlink));
+ assert_eq!(at.metadata(dst_file).st_nlink(), 2);
+ assert_eq!(at.metadata(dst_hardlink).st_nlink(), 2);
+ assert_eq!(
+ at.metadata(dst_file).st_ino(),
+ at.metadata(dst_hardlink).st_ino()
+ );
+}
+
+#[test]
fn test_cp_arg_symlink() {
let (at, mut ucmd) = at_and_ucmd!();
ucmd.arg(TEST_HELLO_WORLD_SOURCE)