fs::path foo = dir/"foo", bar = dir/"bar";
fs::create_directory(foo);
fs::create_directory(bar);
+#ifdef NO_SYMLINKS
#if defined(__MINGW32__) || defined(__MINGW64__)
- // No symlink support
const fs::path baz = dir/"foo\\\\..\\bar///";
+#else
+ const fs::path baz = dir/"foo//../bar///";
+#endif
#else
fs::create_symlink("../bar", foo/"baz");
const fs::path baz = dir/"foo//./baz///";
void
test02()
{
-#if defined(__MINGW32__) || defined(__MINGW64__)
- // No symlink support
- return;
-#endif
-
+#ifndef NO_SYMLINKS
const std::error_code bad_ec = make_error_code(std::errc::invalid_argument);
auto from = __gnu_test::nonexistent_path();
std::error_code ec;
remove(from, ec);
remove(to, ec);
+#endif
}
// Test is_regular_file(f) case.
void
test04()
{
-#if defined(__MINGW32__) || defined(__MINGW64__)
- // no symlinks
-#else
+#ifndef NO_SYMLINKS
// PR libstdc++/101510
// create_directories reports an error if the path is a symlink to a dir
std::error_code ec = make_error_code(std::errc::invalid_argument);
VERIFY( e.path1() == f );
}
-#if defined(__MINGW32__) || defined(__MINGW64__)
- // no symlinks
-#else
+#ifndef NO_SYMLINKS
// PR libstdc++/101510 create_directory on an existing symlink to a directory
fs::create_directory(p/"dir");
auto link = p/"link";
void
test03()
{
+#ifndef NO_SYMLINKS
using std::filesystem::perms;
using std::filesystem::perm_options;
VERIFY( !caught );
remove(p);
+#endif
}
void
test04()
{
+#ifndef NO_SYMLINKS
using perms = std::filesystem::perms;
auto p = __gnu_test::nonexistent_path();
VERIFY( ec == ec2 );
remove(p);
+#endif
}
void
// { dg-do run { target c++17 } }
// { dg-require-filesystem-ts "" }
-// { dg-xfail-if "symlinks not supported" { *-*-mingw* } }
+// { dg-require-target-fs-symlinks "" }
#include <filesystem>
#include <testsuite_hooks.h>
VERIFY( !ec );
VERIFY( !n );
-#if defined(__MINGW32__) || defined(__MINGW64__)
- // No symlink support
-#else
+#ifndef NO_SYMLINKS
auto link = __gnu_test::nonexistent_path();
create_symlink(p, link); // dangling symlink
ec = bad_ec;
VERIFY( !ec );
VERIFY( n == 0 );
-#if defined(__MINGW32__) || defined(__MINGW64__)
- // No symlink support
-#else
+#ifndef NO_SYMLINKS
auto link = __gnu_test::nonexistent_path();
create_symlink(p, link); // dangling symlink
ec = bad_ec;
void
test_symlinks()
{
-#if defined(__MINGW32__) || defined(__MINGW64__)
- // No symlink support
-#else
+#ifndef NO_SYMLINKS
std::error_code ec;
const std::error_code bad_ec = make_error_code(std::errc::invalid_argument);
// { dg-do run { target c++17 } }
// { dg-require-filesystem-ts "" }
-// { dg-xfail-if "symlinks not supported" { *-*-mingw* } }
#include <filesystem>
#include <testsuite_hooks.h>
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);
st2 = fs::symlink_status(link, ec);
VERIFY( !ec );
VERIFY( st2.type() == fs::file_type::symlink );
+#endif
}
void
void
test03()
{
+#ifndef NO_SYMLINKS
if (!__gnu_test::permissions_are_testable())
return;
VERIFY( st2.type() == fs::file_type::symlink );
fs::permissions(dir, fs::perms::owner_all, ec);
+#endif
}
void
fs::create_directory(bar/"baz");
fs::path p;
-#if defined(__MINGW32__) || defined(__MINGW64__)
- // No symlink support
-#else
+#ifndef NO_SYMLINKS
fs::create_symlink("../bar", foo/"bar");
p = fs::weakly_canonical(dir/"foo//./bar///../biz/.");
void
test06()
{
-#if !(defined __MINGW32__ || defined __MINGW64__)
+#ifndef NO_SYMLINKS
auto p = __gnu_test::nonexistent_path();
create_directories(p/"d1/d2");
create_directory_symlink("d1", p/"link");
void
test02()
{
-#if defined(__MINGW32__) || defined(__MINGW64__)
- // No symlink support
- return;
-#endif
-
+#ifndef NO_SYMLINKS
auto from = __gnu_test::nonexistent_path();
std::error_code ec, bad = std::make_error_code(std::errc::invalid_argument);
remove(from, ec);
remove(to, ec);
+#endif
}
// Test is_regular_file(f) case.
void
test04()
{
-#if defined(__MINGW32__) || defined(__MINGW64__)
- // no symlinks
-#else
+#ifndef NO_SYMLINKS
// PR libstdc++/101510
// create_directories reports an error if the path is a symlink to a dir
std::error_code ec = make_error_code(std::errc::invalid_argument);
VERIFY( e.path1() == f );
}
-#if defined(__MINGW32__) || defined(__MINGW64__)
- // no symlinks
-#else
+#ifndef NO_SYMLINKS
// PR libstdc++/101510 create_directory on an existing symlink to a directory
fs::create_directory(p/"dir");
auto link = p/"link";
void
test03()
{
+#ifndef NO_SYMLINKS
using perms = std::experimental::filesystem::perms;
__gnu_test::scoped_file f;
VERIFY( ec == ec2 );
remove(p);
+#endif
}
void
test04()
{
+#ifndef NO_SYMLINKS
using perms = std::experimental::filesystem::perms;
auto p = __gnu_test::nonexistent_path();
VERIFY( ec == ec2 );
remove(p);
+#endif
}
void
// { dg-options "-DUSE_FILESYSTEM_TS -lstdc++fs" }
// { dg-do run { target c++11 } }
// { dg-require-filesystem-ts "" }
-// { dg-xfail-if "symlinks not supported" { *-*-mingw* } }
+// { dg-require-target-fs-symlinks "" }
#include <experimental/filesystem>
#include <testsuite_hooks.h>
VERIFY( !ec );
VERIFY( !n );
-#if defined(__MINGW32__) || defined(__MINGW64__)
- // No symlink support
- return;
-#else
+#ifndef NO_SYMLINKS
auto link = __gnu_test::nonexistent_path();
create_symlink(p, link); // dangling symlink
ec = bad_ec;
VERIFY( !ec );
VERIFY( n == 0 );
-#if defined(__MINGW32__) || defined(__MINGW64__)
- // No symlink support
-#else
+#ifndef NO_SYMLINKS
auto link = __gnu_test::nonexistent_path();
create_symlink(p, link); // dangling symlink
ec = bad_ec;
void
test_symlinks()
{
-#if defined(__MINGW32__) || defined(__MINGW64__)
- // No symlink support
-#else
+#ifndef NO_SYMLINKS
std::error_code ec;
const std::error_code bad_ec = make_error_code(std::errc::invalid_argument);
return
}
+proc dg-require-target-fs-symlinks { args } {
+ if { ![ check_v3_target_fs_symlinks ] } {
+ upvar dg-do-what dg-do-what
+ set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
+ return
+ }
+ return
+}
+
proc add_options_for_no_pch { flags } {
# This forces any generated and possibly included PCH to be invalid.
return "-D__GLIBCXX__=99999999"
}
# Return 1 if COND evaluates to true in the preprocessor, 0 otherwise.
-# The <bits/c++config.h> config header is included.
-proc v3_check_preprocessor_condition { name cond } {
+# The <bits/c++config.h> config header is included, and INC, if given,
+# is pasted between it and the condition evaluation, so it can be used
+# for additional #include's.
+proc v3_check_preprocessor_condition { name cond { inc "" } } {
global cxxflags
global DEFAULT_CXXFLAGS
set code "
#include <bits/c++config.h>
+ $inc
#if ! ($cond)
#error '$cond' is false
#endif
}]
}
+# Return 1 if the libstdc++ filesystem create_symlinks implementation
+# is not an always-failing dummy.
+proc check_v3_target_fs_symlinks { } {
+ set inc "#include <testsuite_fs.h>"
+ set cond "!defined NO_SYMLINKS"
+ return [v3_check_preprocessor_condition fs_symlinks $cond $inc]
+}
+
# Return 1 if the "cxx11" ABI is in use using the current flags, 0 otherwise.
# Any flags provided by RUNTESTFLAGS or a target board will be used here.
# Flags added in the test by dg-options or dg-add-options will not be used.
#include <random> // std::random_device
#endif
+#ifndef _GLIBCXX_HAVE_SYMLINK
+#define NO_SYMLINKS
+#endif
+
namespace __gnu_test
{
#define PATH_CHK(p1, p2, fn) \