From cc8c13b8435f34ef8901bb968c6998587ba9a19b Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Sat, 16 Feb 2019 00:05:47 +0300 Subject: Fix non-detecting dangling junctions if built with mingw gcc --- tests/dir-iterator/testscript | 13 +++++++++--- tests/link/driver.cxx | 48 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/dir-iterator/testscript b/tests/dir-iterator/testscript index 956eacb..370fd2f 100644 --- a/tests/dir-iterator/testscript +++ b/tests/dir-iterator/testscript @@ -36,14 +36,21 @@ else { +mkdir a +mkdir --no-cleanup a/b - +ln -s a/b a/l + +ln -s a/b a/bl +rmdir a/b +touch a/c + +mkdir a/d + +ln -s a/d a/dl + # On Wine dangling symlinks are not visible (see mksymlink() for details). # - #$* ../a >! 2>! != 0 : keep + #$* ../a >! 2>! != 0 : keep - $* -i ../a >'reg c' : skip + : skip + : + $* -i ../a >>~%EOO% + %(reg c|dir d|sym dir dl)%{3} + EOO } diff --git a/tests/link/driver.cxx b/tests/link/driver.cxx index 76cdbfc..6489d8d 100644 --- a/tests/link/driver.cxx +++ b/tests/link/driver.cxx @@ -179,12 +179,22 @@ main () dir_path ld (td / dir_path ("dslink")); assert (link_dir (dp, ld, false /* hard */, true /* check_content */)); + // Create the symlink to a directory symlink using an absolute path. + // + dir_path lld (td / dir_path ("dslinkslink")); + assert (link_dir (ld, lld, false /* hard */, true /* check_content */)); + { pair pe (path_entry (ld / "f")); assert (pe.first && pe.second.type == entry_type::regular); } { + pair pe (path_entry (lld / "f")); + assert (pe.first && pe.second.type == entry_type::regular); + } + + { pair pe (path_entry (ld)); assert (pe.first && pe.second.type == entry_type::symlink); } @@ -194,16 +204,31 @@ main () assert (pe.first && pe.second.type == entry_type::directory); } + { + pair pe (path_entry (lld)); + assert (pe.first && pe.second.type == entry_type::symlink); + } + + { + pair pe (path_entry (lld, true /* follow_symlinks */)); + assert (pe.first && pe.second.type == entry_type::directory); + } + for (const dir_entry& de: dir_iterator (td, false /* ignore_dangling */)) { assert (de.path () != path ("dslink") || (de.type () == entry_type::directory && de.ltype () == entry_type::symlink)); + + assert (de.path () != path ("dslinkslink") || + (de.type () == entry_type::directory && + de.ltype () == entry_type::symlink)); } // Remove the directory symlink and make sure the target's content still // exists. // + assert (try_rmsymlink (lld) == rmfile_status::success); assert (try_rmsymlink (ld) == rmfile_status::success); { @@ -221,6 +246,29 @@ main () assert (link_dir (dn, td / dir_path ("rdslink"), false, true)); #endif + // Delete the junction target and verify the junction entry status. + // + assert (link_dir (dp, ld, false /* hard */, true /* check_content */)); + rmdir_r (dp); + + // On Wine dangling junctions are not visible. That's why we also re-create + // the target before the junction removal. + // +#if 0 + { + pair pe (path_entry (ld)); + assert (pe.first && pe.second.type == entry_type::symlink); + } +#endif + + { + pair pe (path_entry (ld, true /* follow_symlinks */)); + assert (!pe.first); + } + + assert (try_mkdir (dp) == mkdir_status::success); + assert (try_rmsymlink (ld) == rmfile_status::success); + try { rmdir_r (td); -- cgit v1.1