[gcc r17-1915] libstdc++: Test fs::status and fs::symlink_status with dir symlink
Jonathan Wakely
redi@gcc.gnu.org
Fri Jun 26 11:40:11 GMT 2026
https://gcc.gnu.org/g:4c05f6e10358f379a6da28151b832509f0a3f485
commit r17-1915-g4c05f6e10358f379a6da28151b832509f0a3f485
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Fri Jun 26 12:30:57 2026 +0100
libstdc++: Test fs::status and fs::symlink_status with dir symlink
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.
Diff:
---
.../27_io/filesystem/operations/status.cc | 22 ++++++++++++++++++++++
.../27_io/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();
}
More information about the Libstdc++-cvs
mailing list