diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2019-02-16 00:05:47 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2019-02-16 11:49:25 +0300 |
commit | cc8c13b8435f34ef8901bb968c6998587ba9a19b (patch) | |
tree | cbb080a33af32aecfa753c7ad92dc738dff2daef /tests/link | |
parent | 39ce51acd1a187891d9951e8ae5460f9b6f4603c (diff) |
Fix non-detecting dangling junctions if built with mingw gcc
Diffstat (limited to 'tests/link')
-rw-r--r-- | tests/link/driver.cxx | 48 |
1 files changed, 48 insertions, 0 deletions
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<bool, entry_stat> pe (path_entry (ld / "f")); assert (pe.first && pe.second.type == entry_type::regular); } { + pair<bool, entry_stat> pe (path_entry (lld / "f")); + assert (pe.first && pe.second.type == entry_type::regular); + } + + { pair<bool, entry_stat> 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<bool, entry_stat> pe (path_entry (lld)); + assert (pe.first && pe.second.type == entry_type::symlink); + } + + { + pair<bool, entry_stat> 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<bool, entry_stat> pe (path_entry (ld)); + assert (pe.first && pe.second.type == entry_type::symlink); + } +#endif + + { + pair<bool, entry_stat> 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); |