public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/aoliva/heads/testme)] libstdc++: testsuite: fs rename to self may fail
@ 2022-06-21  0:16 Alexandre Oliva
  0 siblings, 0 replies; 3+ messages in thread
From: Alexandre Oliva @ 2022-06-21  0:16 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:8412b8a269f159eb502e66e4ef99f17717d0cbce

commit 8412b8a269f159eb502e66e4ef99f17717d0cbce
Author: Alexandre Oliva <oliva@adacore.com>
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);
 }


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [gcc(refs/users/aoliva/heads/testme)] libstdc++: testsuite: fs rename to self may fail
@ 2022-06-22  5:23 Alexandre Oliva
  0 siblings, 0 replies; 3+ messages in thread
From: Alexandre Oliva @ 2022-06-22  5:23 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:bd87f617f926dea987c283be6dceeaee96e881a2

commit bd87f617f926dea987c283be6dceeaee96e881a2
Author: Alexandre Oliva <oliva@adacore.com>
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);
 }


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [gcc(refs/users/aoliva/heads/testme)] libstdc++: testsuite: fs rename to self may fail
@ 2022-06-21  0:09 Alexandre Oliva
  0 siblings, 0 replies; 3+ messages in thread
From: Alexandre Oliva @ 2022-06-21  0:09 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:bbc315d3d3053779a08b96e91b14294a4137b735

commit bbc315d3d3053779a08b96e91b14294a4137b735
Author: Alexandre Oliva <oliva@adacore.com>
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.
    
    TN: V527-033

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);
 }


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-06-22  5:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-21  0:16 [gcc(refs/users/aoliva/heads/testme)] libstdc++: testsuite: fs rename to self may fail Alexandre Oliva
  -- strict thread matches above, loose matches on Subject: below --
2022-06-22  5:23 Alexandre Oliva
2022-06-21  0:09 Alexandre Oliva

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).