From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2140) id 5478538418BE; Tue, 21 Jun 2022 00:16:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5478538418BE Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Alexandre Oliva To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc(refs/users/aoliva/heads/testme)] libstdc++: testsuite: fs rename to self may fail X-Act-Checkin: gcc X-Git-Author: Alexandre Oliva X-Git-Refname: refs/users/aoliva/heads/testme X-Git-Oldrev: 75ca2e120aa78abf67b51c47db48ac3dc626a136 X-Git-Newrev: 8412b8a269f159eb502e66e4ef99f17717d0cbce Message-Id: <20220621001654.5478538418BE@sourceware.org> Date: Tue, 21 Jun 2022 00:16:54 +0000 (GMT) X-BeenThere: libstdc++-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Jun 2022 00:16:54 -0000 https://gcc.gnu.org/g:8412b8a269f159eb502e66e4ef99f17717d0cbce commit 8412b8a269f159eb502e66e4ef99f17717d0cbce Author: Alexandre Oliva Date: Mon Jun 20 20:43:58 2022 -0300 libstdc++: testsuite: fs rename to self may fail rtems6's rename() implementation errors with EEXIST when the rename-to filename exists, even when renaming a file to itself or when renaming a nonexisting file. Adjust expectations. for libstdc++-v3/ChangeLog * testsuite/27_io/filesystem/operations/rename.cc (test01): Accept EEXIST fail on self-rename, on rename of a nonexisting file, and on rename to existing file. Clean up p1 in case it remains. * testsuite/experimental/filesystem/operations/rename.cc (test01): Accept EEXIST fail on self-rename, and on rename to existing file. Clean up p1 in case it remains. Diff: --- libstdc++-v3/testsuite/27_io/filesystem/operations/rename.cc | 11 ++++++----- .../testsuite/experimental/filesystem/operations/rename.cc | 9 +++++---- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/rename.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/rename.cc index 936e3060412..2fb2068dfd3 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/operations/rename.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/rename.cc @@ -46,14 +46,14 @@ test01() ec = bad_ec; std::ofstream{p1}; // create file - fs::rename(p1, p1, ec); // no-op - VERIFY( !ec ); + fs::rename(p1, p1, ec); // no-op, but may fail + VERIFY( !ec || ec.value() == EEXIST ); VERIFY( is_regular_file(p1) ); ec.clear(); rename(p2, p1, ec); VERIFY( ec ); - VERIFY( ec.value() == ENOENT ); + VERIFY( ec.value() == ENOENT || ec.value() == EEXIST ); VERIFY( is_regular_file(p1) ); ec = bad_ec; @@ -65,10 +65,11 @@ test01() ec = bad_ec; std::ofstream{p1}; // create file fs::rename(p1, p2, ec); - VERIFY( !ec ); - VERIFY( !exists(p1) ); + VERIFY( !ec || ec.value() == EEXIST ); + VERIFY( !exists(p1) || ec ); VERIFY( is_regular_file(p2) ); + fs::remove(p1, ec); fs::remove(p2, ec); } diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/rename.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/rename.cc index 520d48ef8d8..d2175652a79 100644 --- a/libstdc++-v3/testsuite/experimental/filesystem/operations/rename.cc +++ b/libstdc++-v3/testsuite/experimental/filesystem/operations/rename.cc @@ -47,8 +47,8 @@ test01() ec = bad_ec; std::ofstream{p1}; // create file - fs::rename(p1, p1, ec); // no-op - VERIFY( !ec ); + fs::rename(p1, p1, ec); // no-op, but may fail + VERIFY( !ec || ec.value() == EEXIST ); VERIFY( is_regular_file(p1) ); ec.clear(); @@ -65,10 +65,11 @@ test01() ec = bad_ec; std::ofstream{p1}; // create file fs::rename(p1, p2, ec); - VERIFY( !ec ); - VERIFY( !exists(p1) ); + VERIFY( !ec || ec.value() == EEXIST ); + VERIFY( !exists(p1) || ec ); VERIFY( is_regular_file(p2) ); + fs::remove(p1, ec); fs::remove(p2, ec); }