summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/27_io/filesystem/iterators/97731.cc
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2022-02-01 14:02:56 +0000
committerJonathan Wakely <jwakely@redhat.com>2022-02-01 21:56:35 +0000
commit2dc2f417288d4f0839b4bc01388e676ee343f941 (patch)
tree6e7d9054b3461d8960f8b40102175a03158db5bf /libstdc++-v3/testsuite/27_io/filesystem/iterators/97731.cc
parentec09a5335f0ade7071f6157dfd97dbb3de3e4f97 (diff)
libstdc++: Add more tests for filesystem directory iterators
The PR 97731 test was added to verify a fix to the Filesystem TS code, but we should also have the same test to avoid similar regressions in the C++17 std::filesystem code. Also add tests for directory_options::follow_directory_symlink libstdc++-v3/ChangeLog: * testsuite/27_io/filesystem/iterators/97731.cc: New test. * testsuite/27_io/filesystem/iterators/recursive_directory_iterator.cc: Check follow_directory_symlink option. * testsuite/experimental/filesystem/iterators/recursive_directory_iterator.cc: Likewise.
Diffstat (limited to 'libstdc++-v3/testsuite/27_io/filesystem/iterators/97731.cc')
-rw-r--r--libstdc++-v3/testsuite/27_io/filesystem/iterators/97731.cc48
1 files changed, 48 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/iterators/97731.cc b/libstdc++-v3/testsuite/27_io/filesystem/iterators/97731.cc
new file mode 100644
index 00000000000..9021e6edf41
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/filesystem/iterators/97731.cc
@@ -0,0 +1,48 @@
+// Copyright (C) 2020-2022 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-do run { target c++17 } }
+// { dg-require-filesystem-ts "" }
+
+#include <filesystem>
+#include <cerrno>
+#include <testsuite_hooks.h>
+
+bool used_custom_readdir = false;
+
+extern "C" void* readdir(void*)
+{
+ used_custom_readdir = true;
+ errno = EIO;
+ return nullptr;
+}
+
+void
+test01()
+{
+ using std::filesystem::recursive_directory_iterator;
+ std::error_code ec;
+ recursive_directory_iterator it(".", ec);
+ if (used_custom_readdir)
+ VERIFY( ec.value() == EIO );
+}
+
+int
+main()
+{
+ test01();
+}