summaryrefslogtreecommitdiffstats
path: root/tests/by-util
diff options
context:
space:
mode:
authorMoïse Valvassori <moise.valvassori@gmail.com>2024-06-26 06:44:55 +0200
committerMoïse Valvassori <moise.valvassori@gmail.com>2024-06-26 06:44:55 +0200
commit2e223dfdfcbc1d896124cce0629a3d0ccbb6a97d (patch)
tree9af57fd329e4f98ae7141934d1dd3817f255521c /tests/by-util
parent92665144c9ddf100d5044dc0c52af122a94587d0 (diff)
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)