public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/aoliva/heads/testme)] libstdc++: testsuite: avoid predictable mkstemp
@ 2022-06-22  5:23 Alexandre Oliva
  0 siblings, 0 replies; 4+ messages in thread
From: Alexandre Oliva @ 2022-06-22  5:23 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

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

commit afa34f737d69e76cc8e2109667e219662f6981c9
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Mon Jun 20 19:44:50 2022 -0300

    libstdc++: testsuite: avoid predictable mkstemp
    
    This patch was originally meant to reduce the likelihood that
    nonexistent_path() returns the same pathname for from and to.
    
    It was prompted by a target system with a non-random implementation of
    mkstemp, that returns a predictable sequence of filenames and selects
    the first one that isn't already taken.
    
    That turned out not to be enough: nonexistent_path adds a suffix to
    the filename chosen by mkstemp and removes the file it created, so
    mkstemp may very well insist on the same basename, and the case that
    doesn't use mkstemp doesn't even check whether the file already
    exists.
    
    Anyway, by the time I realized this wasn't enough, I'd already
    implemented some of the changes, and I figured I might as well
    contribute them, even though they don't really solve any problem, and
    even if they did, they'd be just a partial solution.
    
    
    for  libstdc++-v3/ChangeLog
    
            * testsuite/27_io/filesystem/operations/copy.cc (test02):
            Select TO after creating FROM.
            (test03, test04): Likewise.
            * testsuite/experimental/filesystem/operations/copy.cc
            (test02, test03, test04): Likewise.

Diff:
---
 libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc        | 7 ++++---
 libstdc++-v3/testsuite/experimental/filesystem/operations/copy.cc | 7 ++++---
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc
index b936e04493b..f3081f4b64e 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc
@@ -73,7 +73,6 @@ test02()
 
   const std::error_code bad_ec = make_error_code(std::errc::invalid_argument);
   auto from = __gnu_test::nonexistent_path();
-  auto to = __gnu_test::nonexistent_path();
   std::error_code ec;
 
   ec = bad_ec;
@@ -81,6 +80,7 @@ test02()
   VERIFY( !ec );
   VERIFY( fs::exists(from) );
 
+  auto to = __gnu_test::nonexistent_path();
   ec = bad_ec;
   fs::copy(from, to, fs::copy_options::skip_symlinks, ec);
   VERIFY( !ec );
@@ -117,12 +117,13 @@ void
 test03()
 {
   auto from = __gnu_test::nonexistent_path();
-  auto to = __gnu_test::nonexistent_path();
 
   // test empty file
   std::ofstream{from};
   VERIFY( fs::exists(from) );
   VERIFY( fs::file_size(from) == 0 );
+
+  auto to = __gnu_test::nonexistent_path();
   fs::copy(from, to);
   VERIFY( fs::exists(to) );
   VERIFY( fs::file_size(to) == 0 );
@@ -145,11 +146,11 @@ test04()
 {
   const std::error_code bad_ec = make_error_code(std::errc::invalid_argument);
   auto from = __gnu_test::nonexistent_path();
-  auto to = __gnu_test::nonexistent_path();
   std::error_code ec;
 
   create_directories(from/"a/b/c");
 
+  auto to = __gnu_test::nonexistent_path();
   {
     __gnu_test::scoped_file f(to);
     copy(from, to, ec);
diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/copy.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/copy.cc
index 5cd6b483c26..ca38328c5da 100644
--- a/libstdc++-v3/testsuite/experimental/filesystem/operations/copy.cc
+++ b/libstdc++-v3/testsuite/experimental/filesystem/operations/copy.cc
@@ -73,7 +73,6 @@ test02()
 #endif
 
   auto from = __gnu_test::nonexistent_path();
-  auto to = __gnu_test::nonexistent_path();
   std::error_code ec, bad = std::make_error_code(std::errc::invalid_argument);
 
   ec = bad;
@@ -81,6 +80,7 @@ test02()
   VERIFY( !ec );
   VERIFY( fs::exists(from) );
 
+  auto to = __gnu_test::nonexistent_path();
   ec = bad;
   fs::copy(from, to, fs::copy_options::skip_symlinks, ec);
   VERIFY( !ec );
@@ -116,12 +116,13 @@ void
 test03()
 {
   auto from = __gnu_test::nonexistent_path();
-  auto to = __gnu_test::nonexistent_path();
 
   // test empty file
   std::ofstream{from.c_str()};
   VERIFY( fs::exists(from) );
   VERIFY( fs::file_size(from) == 0 );
+
+  auto to = __gnu_test::nonexistent_path();
   fs::copy(from, to);
   VERIFY( fs::exists(to) );
   VERIFY( fs::file_size(to) == 0 );
@@ -143,11 +144,11 @@ void
 test04()
 {
   auto from = __gnu_test::nonexistent_path();
-  auto to = __gnu_test::nonexistent_path();
   std::error_code ec;
 
   create_directories(from/"a/b/c");
 
+  auto to = __gnu_test::nonexistent_path();
   {
     __gnu_test::scoped_file f(to);
     copy(from, to, ec);


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

* [gcc(refs/users/aoliva/heads/testme)] libstdc++: testsuite: avoid predictable mkstemp
@ 2022-06-23  5:10 Alexandre Oliva
  0 siblings, 0 replies; 4+ messages in thread
From: Alexandre Oliva @ 2022-06-23  5:10 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:440c1eca48826c94d0353d644a5bf35ff106819a

commit 440c1eca48826c94d0353d644a5bf35ff106819a
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Mon Jun 20 19:44:50 2022 -0300

    libstdc++: testsuite: avoid predictable mkstemp
    
    This patch was originally meant to reduce the likelihood that
    nonexistent_path() returns the same pathname for from and to.
    
    It was prompted by a target system with a non-random implementation of
    mkstemp, that returns a predictable sequence of filenames and selects
    the first one that isn't already taken.
    
    That turned out not to be enough: nonexistent_path adds a suffix to
    the filename chosen by mkstemp and removes the file it created, so
    mkstemp may very well insist on the same basename, and the case that
    doesn't use mkstemp doesn't even check whether the file already
    exists.
    
    Anyway, by the time I realized this wasn't enough, I'd already
    implemented some of the changes, and I figured I might as well
    contribute them, even though they don't really solve any problem, and
    even if they did, they'd be just a partial solution.
    
    
    for  libstdc++-v3/ChangeLog
    
            * testsuite/27_io/filesystem/operations/copy.cc (test02):
            Select TO after creating FROM.
            (test03, test04): Likewise.
            * testsuite/experimental/filesystem/operations/copy.cc
            (test02, test03, test04): Likewise.

Diff:
---
 libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc        | 7 ++++---
 libstdc++-v3/testsuite/experimental/filesystem/operations/copy.cc | 7 ++++---
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc
index b936e04493b..f3081f4b64e 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc
@@ -73,7 +73,6 @@ test02()
 
   const std::error_code bad_ec = make_error_code(std::errc::invalid_argument);
   auto from = __gnu_test::nonexistent_path();
-  auto to = __gnu_test::nonexistent_path();
   std::error_code ec;
 
   ec = bad_ec;
@@ -81,6 +80,7 @@ test02()
   VERIFY( !ec );
   VERIFY( fs::exists(from) );
 
+  auto to = __gnu_test::nonexistent_path();
   ec = bad_ec;
   fs::copy(from, to, fs::copy_options::skip_symlinks, ec);
   VERIFY( !ec );
@@ -117,12 +117,13 @@ void
 test03()
 {
   auto from = __gnu_test::nonexistent_path();
-  auto to = __gnu_test::nonexistent_path();
 
   // test empty file
   std::ofstream{from};
   VERIFY( fs::exists(from) );
   VERIFY( fs::file_size(from) == 0 );
+
+  auto to = __gnu_test::nonexistent_path();
   fs::copy(from, to);
   VERIFY( fs::exists(to) );
   VERIFY( fs::file_size(to) == 0 );
@@ -145,11 +146,11 @@ test04()
 {
   const std::error_code bad_ec = make_error_code(std::errc::invalid_argument);
   auto from = __gnu_test::nonexistent_path();
-  auto to = __gnu_test::nonexistent_path();
   std::error_code ec;
 
   create_directories(from/"a/b/c");
 
+  auto to = __gnu_test::nonexistent_path();
   {
     __gnu_test::scoped_file f(to);
     copy(from, to, ec);
diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/copy.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/copy.cc
index 5cd6b483c26..ca38328c5da 100644
--- a/libstdc++-v3/testsuite/experimental/filesystem/operations/copy.cc
+++ b/libstdc++-v3/testsuite/experimental/filesystem/operations/copy.cc
@@ -73,7 +73,6 @@ test02()
 #endif
 
   auto from = __gnu_test::nonexistent_path();
-  auto to = __gnu_test::nonexistent_path();
   std::error_code ec, bad = std::make_error_code(std::errc::invalid_argument);
 
   ec = bad;
@@ -81,6 +80,7 @@ test02()
   VERIFY( !ec );
   VERIFY( fs::exists(from) );
 
+  auto to = __gnu_test::nonexistent_path();
   ec = bad;
   fs::copy(from, to, fs::copy_options::skip_symlinks, ec);
   VERIFY( !ec );
@@ -116,12 +116,13 @@ void
 test03()
 {
   auto from = __gnu_test::nonexistent_path();
-  auto to = __gnu_test::nonexistent_path();
 
   // test empty file
   std::ofstream{from.c_str()};
   VERIFY( fs::exists(from) );
   VERIFY( fs::file_size(from) == 0 );
+
+  auto to = __gnu_test::nonexistent_path();
   fs::copy(from, to);
   VERIFY( fs::exists(to) );
   VERIFY( fs::file_size(to) == 0 );
@@ -143,11 +144,11 @@ void
 test04()
 {
   auto from = __gnu_test::nonexistent_path();
-  auto to = __gnu_test::nonexistent_path();
   std::error_code ec;
 
   create_directories(from/"a/b/c");
 
+  auto to = __gnu_test::nonexistent_path();
   {
     __gnu_test::scoped_file f(to);
     copy(from, to, ec);


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

* [gcc(refs/users/aoliva/heads/testme)] libstdc++: testsuite: avoid predictable mkstemp
@ 2022-06-21  0:16 Alexandre Oliva
  0 siblings, 0 replies; 4+ messages in thread
From: Alexandre Oliva @ 2022-06-21  0:16 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:2714fc431bb40212cdc8da86e6c1d271e6141106

commit 2714fc431bb40212cdc8da86e6c1d271e6141106
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Mon Jun 20 19:44:50 2022 -0300

    libstdc++: testsuite: avoid predictable mkstemp
    
    This patch was originally meant to reduce the likelihood that
    nonexistent_path() returns the same pathname for from and to.
    
    It was prompted by a target system with a non-random implementation of
    mkstemp, that returns a predictable sequence of filenames and selects
    the first one that isn't already taken.
    
    That turned out not to be enough: nonexistent_path adds a suffix to
    the filename chosen by mkstemp and removes the file it created, so
    mkstemp may very well insist on the same basename, and the case that
    doesn't use mkstemp doesn't even check whether the file already
    exists.
    
    Anyway, by the time I realized this wasn't enough, I'd already
    implemented some of the changes, and I figured I might as well
    contribute them, even though they don't really solve any problem, and
    even if they did, they'd be just a partial solution.
    
    
    for  libstdc++-v3/ChangeLog
    
            * testsuite/27_io/filesystem/operations/copy.cc (test02):
            Select TO after creating FROM.
            (test03, test04): Likewise.
            * testsuite/experimental/filesystem/operations/copy.cc
            (test02, test03, test04): Likewise.

Diff:
---
 libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc        | 7 ++++---
 libstdc++-v3/testsuite/experimental/filesystem/operations/copy.cc | 7 ++++---
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc
index b936e04493b..f3081f4b64e 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc
@@ -73,7 +73,6 @@ test02()
 
   const std::error_code bad_ec = make_error_code(std::errc::invalid_argument);
   auto from = __gnu_test::nonexistent_path();
-  auto to = __gnu_test::nonexistent_path();
   std::error_code ec;
 
   ec = bad_ec;
@@ -81,6 +80,7 @@ test02()
   VERIFY( !ec );
   VERIFY( fs::exists(from) );
 
+  auto to = __gnu_test::nonexistent_path();
   ec = bad_ec;
   fs::copy(from, to, fs::copy_options::skip_symlinks, ec);
   VERIFY( !ec );
@@ -117,12 +117,13 @@ void
 test03()
 {
   auto from = __gnu_test::nonexistent_path();
-  auto to = __gnu_test::nonexistent_path();
 
   // test empty file
   std::ofstream{from};
   VERIFY( fs::exists(from) );
   VERIFY( fs::file_size(from) == 0 );
+
+  auto to = __gnu_test::nonexistent_path();
   fs::copy(from, to);
   VERIFY( fs::exists(to) );
   VERIFY( fs::file_size(to) == 0 );
@@ -145,11 +146,11 @@ test04()
 {
   const std::error_code bad_ec = make_error_code(std::errc::invalid_argument);
   auto from = __gnu_test::nonexistent_path();
-  auto to = __gnu_test::nonexistent_path();
   std::error_code ec;
 
   create_directories(from/"a/b/c");
 
+  auto to = __gnu_test::nonexistent_path();
   {
     __gnu_test::scoped_file f(to);
     copy(from, to, ec);
diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/copy.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/copy.cc
index 5cd6b483c26..ca38328c5da 100644
--- a/libstdc++-v3/testsuite/experimental/filesystem/operations/copy.cc
+++ b/libstdc++-v3/testsuite/experimental/filesystem/operations/copy.cc
@@ -73,7 +73,6 @@ test02()
 #endif
 
   auto from = __gnu_test::nonexistent_path();
-  auto to = __gnu_test::nonexistent_path();
   std::error_code ec, bad = std::make_error_code(std::errc::invalid_argument);
 
   ec = bad;
@@ -81,6 +80,7 @@ test02()
   VERIFY( !ec );
   VERIFY( fs::exists(from) );
 
+  auto to = __gnu_test::nonexistent_path();
   ec = bad;
   fs::copy(from, to, fs::copy_options::skip_symlinks, ec);
   VERIFY( !ec );
@@ -116,12 +116,13 @@ void
 test03()
 {
   auto from = __gnu_test::nonexistent_path();
-  auto to = __gnu_test::nonexistent_path();
 
   // test empty file
   std::ofstream{from.c_str()};
   VERIFY( fs::exists(from) );
   VERIFY( fs::file_size(from) == 0 );
+
+  auto to = __gnu_test::nonexistent_path();
   fs::copy(from, to);
   VERIFY( fs::exists(to) );
   VERIFY( fs::file_size(to) == 0 );
@@ -143,11 +144,11 @@ void
 test04()
 {
   auto from = __gnu_test::nonexistent_path();
-  auto to = __gnu_test::nonexistent_path();
   std::error_code ec;
 
   create_directories(from/"a/b/c");
 
+  auto to = __gnu_test::nonexistent_path();
   {
     __gnu_test::scoped_file f(to);
     copy(from, to, ec);


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

* [gcc(refs/users/aoliva/heads/testme)] libstdc++: testsuite: avoid predictable mkstemp
@ 2022-06-21  0:08 Alexandre Oliva
  0 siblings, 0 replies; 4+ messages in thread
From: Alexandre Oliva @ 2022-06-21  0:08 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:1dfb4c0c76dd063cd9ccfa42beaf83fde29b8a5e

commit 1dfb4c0c76dd063cd9ccfa42beaf83fde29b8a5e
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Mon Jun 20 19:44:50 2022 -0300

    libstdc++: testsuite: avoid predictable mkstemp
    
    This patch was originally meant to reduce the likelihood that
    nonexistent_path() returns the same pathname for from and to.
    
    It was prompted by a target system with a non-random implementation of
    mkstemp, that returns a predictable sequence of filenames and selects
    the first one that isn't already taken.
    
    That turned out not to be enough: nonexistent_path adds a suffix to
    the filename chosen by mkstemp and removes the file it created, so
    mkstemp may very well insist on the same basename, and the case that
    doesn't use mkstemp doesn't even check whether the file already
    exists.
    
    Anyway, by the time I realized this wasn't enough, I'd already
    implemented some of the changes, and I figured I might as well
    contribute them, even though they don't really solve any problem, and
    even if they did, they'd be just a partial solution.
    
    
    for  libstdc++-v3/ChangeLog
    
            * testsuite/27_io/filesystem/operations/copy.cc (test02):
            Select TO after creating FROM.
            (test03, test04): Likewise.
            * testsuite/experimental/filesystem/operations/copy.cc
            (test02, test03, test04): Likewise.
    
    TN: V531-029

Diff:
---
 libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc        | 7 ++++---
 libstdc++-v3/testsuite/experimental/filesystem/operations/copy.cc | 7 ++++---
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc
index b936e04493b..f3081f4b64e 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc
@@ -73,7 +73,6 @@ test02()
 
   const std::error_code bad_ec = make_error_code(std::errc::invalid_argument);
   auto from = __gnu_test::nonexistent_path();
-  auto to = __gnu_test::nonexistent_path();
   std::error_code ec;
 
   ec = bad_ec;
@@ -81,6 +80,7 @@ test02()
   VERIFY( !ec );
   VERIFY( fs::exists(from) );
 
+  auto to = __gnu_test::nonexistent_path();
   ec = bad_ec;
   fs::copy(from, to, fs::copy_options::skip_symlinks, ec);
   VERIFY( !ec );
@@ -117,12 +117,13 @@ void
 test03()
 {
   auto from = __gnu_test::nonexistent_path();
-  auto to = __gnu_test::nonexistent_path();
 
   // test empty file
   std::ofstream{from};
   VERIFY( fs::exists(from) );
   VERIFY( fs::file_size(from) == 0 );
+
+  auto to = __gnu_test::nonexistent_path();
   fs::copy(from, to);
   VERIFY( fs::exists(to) );
   VERIFY( fs::file_size(to) == 0 );
@@ -145,11 +146,11 @@ test04()
 {
   const std::error_code bad_ec = make_error_code(std::errc::invalid_argument);
   auto from = __gnu_test::nonexistent_path();
-  auto to = __gnu_test::nonexistent_path();
   std::error_code ec;
 
   create_directories(from/"a/b/c");
 
+  auto to = __gnu_test::nonexistent_path();
   {
     __gnu_test::scoped_file f(to);
     copy(from, to, ec);
diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/copy.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/copy.cc
index 5cd6b483c26..ca38328c5da 100644
--- a/libstdc++-v3/testsuite/experimental/filesystem/operations/copy.cc
+++ b/libstdc++-v3/testsuite/experimental/filesystem/operations/copy.cc
@@ -73,7 +73,6 @@ test02()
 #endif
 
   auto from = __gnu_test::nonexistent_path();
-  auto to = __gnu_test::nonexistent_path();
   std::error_code ec, bad = std::make_error_code(std::errc::invalid_argument);
 
   ec = bad;
@@ -81,6 +80,7 @@ test02()
   VERIFY( !ec );
   VERIFY( fs::exists(from) );
 
+  auto to = __gnu_test::nonexistent_path();
   ec = bad;
   fs::copy(from, to, fs::copy_options::skip_symlinks, ec);
   VERIFY( !ec );
@@ -116,12 +116,13 @@ void
 test03()
 {
   auto from = __gnu_test::nonexistent_path();
-  auto to = __gnu_test::nonexistent_path();
 
   // test empty file
   std::ofstream{from.c_str()};
   VERIFY( fs::exists(from) );
   VERIFY( fs::file_size(from) == 0 );
+
+  auto to = __gnu_test::nonexistent_path();
   fs::copy(from, to);
   VERIFY( fs::exists(to) );
   VERIFY( fs::file_size(to) == 0 );
@@ -143,11 +144,11 @@ void
 test04()
 {
   auto from = __gnu_test::nonexistent_path();
-  auto to = __gnu_test::nonexistent_path();
   std::error_code ec;
 
   create_directories(from/"a/b/c");
 
+  auto to = __gnu_test::nonexistent_path();
   {
     __gnu_test::scoped_file f(to);
     copy(from, to, ec);


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

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

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-22  5:23 [gcc(refs/users/aoliva/heads/testme)] libstdc++: testsuite: avoid predictable mkstemp Alexandre Oliva
  -- strict thread matches above, loose matches on Subject: below --
2022-06-23  5:10 Alexandre Oliva
2022-06-21  0:16 Alexandre Oliva
2022-06-21  0:08 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).