I realized that we didn't test that filesystem::status and
filesystem::symlink_status work correctly for directory symlinks.
For POSIX there's no reason it wouldn't Just Work, but for Windows
symlinks to directories and symlinks to regular files require different
handling. These tests will ensure that we get it right when Windows
symlinks are supported.
libstdc++-v3/ChangeLog:
* testsuite/27_io/filesystem/operations/status.cc: Check
handling of directory symlink.
* testsuite/27_io/filesystem/operations/symlink_status.cc:
Likewise.
---
Tested x86_64-linux. Pushed to trunk.
I've also tested this with my modified version of Adam Wood's patch for
Windows symlink support, and they PASS.
.../27_io/filesystem/operations/status.cc | 22 +++++++++++++++++++
.../filesystem/operations/symlink_status.cc | 22 +++++++++++++++++++
2 files changed, 44 insertions(+)
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/status.cc
b/libstdc++-v3/testsuite/27_io/filesystem/operations/status.cc
index f4321414e070..51737b19b2d4 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/status.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/status.cc
@@ -99,6 +99,27 @@ test04()
VERIFY( is_directory(st) );
}
+void
+test05()
+{
+#ifndef NO_SYMLINKS
+ struct scoped_dir
+ {
+ scoped_dir() { fs::create_directory(d); }
+ ~scoped_dir() { remove_all(d); }
+ fs::path d = __gnu_test::nonexistent_path();
+ fs::path operator/(const char* p) const { return d/p; }
+ };
+ const scoped_dir d;
+ fs::create_directory(d/"dir");
+ const fs::path link = d/"link";
+ fs::create_directory_symlink("dir", link);
+ auto st = fs::status(link);
+ VERIFY( is_directory(st) );
+ VERIFY( ! is_symlink(st) );
+#endif
+}
+
int
main()
{
@@ -106,4 +127,5 @@ main()
test02();
test03();
test04();
+ test05();
}
diff --git
a/libstdc++-v3/testsuite/27_io/filesystem/operations/symlink_status.cc
b/libstdc++-v3/testsuite/27_io/filesystem/operations/symlink_status.cc
index 06a5467d3e80..c542ac46cdc4 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/symlink_status.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/symlink_status.cc
@@ -125,6 +125,27 @@ test04()
VERIFY( is_directory(st) );
}
+void
+test05()
+{
+#ifndef NO_SYMLINKS
+ struct scoped_dir
+ {
+ scoped_dir() { fs::create_directory(d); }
+ ~scoped_dir() { remove_all(d); }
+ fs::path d = __gnu_test::nonexistent_path();
+ fs::path operator/(const char* p) const { return d/p; }
+ };
+ const scoped_dir d;
+ fs::create_directory(d/"dir");
+ const fs::path link = d/"link";
+ fs::create_directory_symlink("dir", link);
+ auto st = fs::symlink_status(link);
+ VERIFY( ! is_directory(st) );
+ VERIFY( is_symlink(st) );
+#endif
+}
+
int
main()
{
@@ -132,4 +153,5 @@ main()
test02();
test03();
test04();
+ test05();
}
--
2.54.0