]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libstdc++-v3/testsuite/27_io/filesystem/operations/symlink_status.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 27_io / filesystem / operations / symlink_status.cc
index 6f01419da3ea1f443617c4fae100f4ba85bfc9c8..5ec95ed9422dc7343539f73aa20ce022f9f5f064 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2017-2019 Free Software Foundation, Inc.
+// Copyright (C) 2017-2024 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
-// { dg-options "-std=gnu++17" }
 // { dg-do run { target c++17 } }
 // { dg-require-filesystem-ts "" }
-// { dg-xfail-if "symlinks not supported" { *-*-mingw* } }
 
 #include <filesystem>
 #include <testsuite_hooks.h>
@@ -40,6 +38,7 @@ test01()
   fs::file_status st2 = fs::symlink_status(dot);
   VERIFY( st2.type() == fs::file_type::directory );
 
+#ifndef NO_SYMLINKS
   fs::path link = __gnu_test::nonexistent_path();
   create_directory_symlink(dot, link);
   __gnu_test::scoped_file l(link, __gnu_test::scoped_file::adopt_file);
@@ -50,6 +49,7 @@ test01()
   st2 = fs::symlink_status(link, ec);
   VERIFY( !ec );
   VERIFY( st2.type() == fs::file_type::symlink );
+#endif
 }
 
 void
@@ -69,6 +69,10 @@ test02()
 void
 test03()
 {
+#ifndef NO_SYMLINKS
+  if (!__gnu_test::permissions_are_testable())
+    return;
+
   fs::path dir = __gnu_test::nonexistent_path();
   fs::create_directory(dir);
   __gnu_test::scoped_file d(dir, __gnu_test::scoped_file::adopt_file);
@@ -92,7 +96,7 @@ test03()
   std::error_code ec2;
   fs::path p, p2;
   try {
-    fs::symlink_status(f.path);
+    (void) fs::symlink_status(f.path);
   } catch (const fs::filesystem_error& e) {
     caught = true;
     p = e.path1();
@@ -109,6 +113,16 @@ test03()
   VERIFY( st2.type() == fs::file_type::symlink );
 
   fs::permissions(dir, fs::perms::owner_all, ec);
+#endif
+}
+
+void
+test04()
+{
+  // PR libstdc++/88881
+  fs::path p = "./";
+  auto st = symlink_status(p);
+  VERIFY( is_directory(st) );
 }
 
 int
@@ -117,4 +131,5 @@ main()
   test01();
   test02();
   test03();
+  test04();
 }