Skip to content

Commit aecda39

Browse files
committed
Add a test for creating a hard link to a symlink.
1 parent 4395a30 commit aecda39

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tests/fs_additional.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,3 +402,18 @@ fn dir_searchable_unreadable() {
402402
.create_dir_with("dir/writeable_subdir", &options)
403403
.is_err());
404404
}
405+
406+
/// POSIX says that whether or not `link` follows symlinks in the `old`
407+
/// path is implementation-defined. We want `hard_link` to not follow
408+
/// symbolic links.
409+
#[test]
410+
fn symlink_hard_link() {
411+
let tmpdir = tmpdir();
412+
413+
check!(tmpdir.create("file"));
414+
check!(symlink_file("file", &tmpdir, "symlink"));
415+
check!(tmpdir.hard_link("symlink", &tmpdir, "hard_link"));
416+
let _ = check!(tmpdir.open("hard_link"));
417+
check!(tmpdir.rename("file", &tmpdir, "file.renamed"));
418+
assert!(tmpdir.open("hard_link").is_err());
419+
}

0 commit comments

Comments
 (0)