Improve tests for error reporting in Filesystem TS
authorJonathan Wakely <jwakely@redhat.com>
Thu, 19 Oct 2017 13:57:10 +0000 (14:57 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Thu, 19 Oct 2017 13:57:10 +0000 (14:57 +0100)
* testsuite/experimental/filesystem/iterators/
recursive_directory_iterator.cc: Ensure that error_code arguments are
cleared when required.
* testsuite/experimental/filesystem/operations/create_directory.cc:
Remove redundant check.
* testsuite/experimental/filesystem/operations/temp_directory_path.cc:
Ensure that error_code argument is cleared when required.

From-SVN: r253897

libstdc++-v3/ChangeLog
libstdc++-v3/testsuite/experimental/filesystem/iterators/recursive_directory_iterator.cc
libstdc++-v3/testsuite/experimental/filesystem/operations/create_directory.cc
libstdc++-v3/testsuite/experimental/filesystem/operations/temp_directory_path.cc

index 76c87d65e74b8babbe81fe4835c130afed6ea268..ba43a4b37083cb98061b21e0cae56963188b0733 100644 (file)
@@ -1,5 +1,13 @@
 2017-10-19  Jonathan Wakely  <jwakely@redhat.com>
 
+       * testsuite/experimental/filesystem/iterators/
+       recursive_directory_iterator.cc: Ensure that error_code arguments are
+       cleared when required.
+       * testsuite/experimental/filesystem/operations/create_directory.cc:
+       Remove redundant check.
+       * testsuite/experimental/filesystem/operations/temp_directory_path.cc:
+       Ensure that error_code argument is cleared when required.
+
        * include/experimental/bits/fs_path.h (path::iterator++(int))
        (path::iterator--(int)): Fix for paths with only one component.
        * testsuite/experimental/filesystem/path/itr/traversal.cc: Test
index e7b5e53d43dc4aa8c8ae34a7d6b719167d1ccf65..50cc7d45de862dc0f9116e0979c738326d3267cc 100644 (file)
@@ -28,6 +28,7 @@ namespace fs = std::experimental::filesystem;
 void
 test01()
 {
+  const std::error_code bad_ec = make_error_code(std::errc::invalid_argument);
   std::error_code ec;
 
   // Test non-existent path.
@@ -37,15 +38,19 @@ test01()
   VERIFY( iter == end(iter) );
 
   // Test empty directory.
+  ec = bad_ec;
   create_directory(p, fs::current_path(), ec);
   VERIFY( !ec );
+  ec = bad_ec;
   iter = fs::recursive_directory_iterator(p, ec);
   VERIFY( !ec );
   VERIFY( iter == end(iter) );
 
   // Test non-empty directory.
-  create_directories(p / "d1/d2");
+  ec = bad_ec;
+  create_directories(p / "d1/d2", ec);
   VERIFY( !ec );
+  ec = bad_ec;
   iter = fs::recursive_directory_iterator(p, ec);
   VERIFY( !ec );
   VERIFY( iter != end(iter) );
@@ -56,6 +61,7 @@ test01()
   VERIFY( iter == end(iter) );
 
   // Test inaccessible directory.
+  ec = bad_ec;
   permissions(p, fs::perms::none, ec);
   VERIFY( !ec );
   iter = fs::recursive_directory_iterator(p, ec);
@@ -64,15 +70,19 @@ test01()
 
   // Test inaccessible directory, skipping permission denied.
   const auto opts = fs::directory_options::skip_permission_denied;
+  ec = bad_ec;
   iter = fs::recursive_directory_iterator(p, opts, ec);
   VERIFY( !ec );
   VERIFY( iter == end(iter) );
 
   // Test inaccessible sub-directory.
+  ec = bad_ec;
   permissions(p, fs::perms::owner_all, ec);
   VERIFY( !ec );
+  ec = bad_ec;
   permissions(p/"d1/d2", fs::perms::none, ec);
   VERIFY( !ec );
+  ec = bad_ec;
   iter = fs::recursive_directory_iterator(p, ec);
   VERIFY( !ec );
   VERIFY( iter != end(iter) );
@@ -84,12 +94,14 @@ test01()
   VERIFY( iter == end(iter) );
 
   // Test inaccessible sub-directory, skipping permission denied.
+  ec = bad_ec;
   iter = fs::recursive_directory_iterator(p, opts, ec);
   VERIFY( !ec );
   VERIFY( iter != end(iter) );
   VERIFY( iter->path() == p/"d1" );
   ++iter;              // should recurse into d1
   VERIFY( iter->path() == p/"d1/d2" );
+  ec = bad_ec;
   iter.increment(ec);  // should fail to recurse into p/d1/d2, so skip it
   VERIFY( !ec );
   VERIFY( iter == end(iter) );
@@ -101,12 +113,15 @@ test01()
 void
 test02()
 {
+  const std::error_code bad_ec = make_error_code(std::errc::invalid_argument);
   std::error_code ec;
   const auto p = __gnu_test::nonexistent_path();
+  ec = bad_ec;
   create_directories(p / "d1/d2", ec);
   VERIFY( !ec );
 
   // Test post-increment (libstdc++/71005)
+  ec = bad_ec;
   auto iter = fs::recursive_directory_iterator(p, ec);
   VERIFY( !ec );
   VERIFY( iter != end(iter) );
@@ -126,7 +141,7 @@ test02()
 void
 test03()
 {
-  std::error_code ec;
+  std::error_code ec = make_error_code(std::errc::invalid_argument);
   const auto p = __gnu_test::nonexistent_path();
   create_directories(p / "longer_than_small_string_buffer", ec);
   VERIFY( !ec );
index f1c50a6e8e3170427bbe5aa80b1bda29f99b6d10..85e8281a6e109a51a6f02d08d72bb192b48ffbfb 100644 (file)
@@ -50,7 +50,6 @@ test01()
   VERIFY( !ec );
   VERIFY( !b );
   b = create_directory(p);
-  VERIFY( !ec );
   VERIFY( !b );
 
   remove_all(p, ec);
index e8a6dd3cd85749f629f97841088c3d92ae3d0e39..1689a2a07757a9eb46d29c8d836f09b74d78f319 100644 (file)
@@ -43,7 +43,7 @@ test01()
   if (!fs::exists("/tmp"))
     return; // just give up
 
-  std::error_code ec;
+  std::error_code ec = make_error_code(std::errc::invalid_argument);
   fs::path p1 = fs::temp_directory_path(ec);
   VERIFY( !ec );
   VERIFY( exists(p1) );