public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/aoliva/heads/testme)] [libstdc++] [testsuite] expect zero entropy matching implementation
@ 2023-06-23 20:12 Alexandre Oliva
  0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Oliva @ 2023-06-23 20:12 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:36a0ffc5acb8bb5ecb583f41095964d2b62f71f5

commit 36a0ffc5acb8bb5ecb583f41095964d2b62f71f5
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Fri Jun 23 17:09:49 2023 -0300

    [libstdc++] [testsuite] expect zero entropy matching implementation
    
    random_device::get_entropy() returns 0.0 when _GLIBCXX_USE_DEV_RANDOM
    is not defined, but the test expects otherwise.  Adjust.
    
    
    for  libstdc++-v3/ChangeLog
    
            * testsuite/26_numerics/random/random_device/entropy.cc:
            Expect get_entropy to return zero when _GLIBCXX_USE_DEV_RANDOM
            is not defined.

Diff:
---
 .../testsuite/26_numerics/random/random_device/entropy.cc         | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/testsuite/26_numerics/random/random_device/entropy.cc b/libstdc++-v3/testsuite/26_numerics/random/random_device/entropy.cc
index 9f529f5d814..3e6872c8a61 100644
--- a/libstdc++-v3/testsuite/26_numerics/random/random_device/entropy.cc
+++ b/libstdc++-v3/testsuite/26_numerics/random/random_device/entropy.cc
@@ -13,7 +13,13 @@ test01()
       VERIFY( std::random_device(token).entropy() == 0.0 );
 
   using result_type = std::random_device::result_type;
+#ifdef _GLIBCXX_USE_DEV_RANDOM
   const double max = std::numeric_limits<result_type>::digits;
+#else
+  // random_device::entropy() always returns 0.0 when
+  // _GLIBCXX_USE_DEV_RANDOM is not defined.
+  const double max = 0.0;
+#endif
 
   for (auto token : { "/dev/random", "/dev/urandom" })
     if (__gnu_test::random_device_available(token))
@@ -30,7 +36,7 @@ test01()
       VERIFY( entropy == max );
     }
 
-    for (auto token : { "getentropy", "arc4random" })
+  for (auto token : { "getentropy", "arc4random" })
     if (__gnu_test::random_device_available(token))
     {
       const double entropy = std::random_device(token).entropy();

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

* [gcc(refs/users/aoliva/heads/testme)] [libstdc++] [testsuite] expect zero entropy matching implementation
@ 2023-06-14 19:17 Alexandre Oliva
  0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Oliva @ 2023-06-14 19:17 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

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

commit ee4bf43778b2b1b1a743d0ade40ba44ccf27a4ca
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Wed Jun 14 16:16:17 2023 -0300

    [libstdc++] [testsuite] expect zero entropy matching implementation
    
    random_device::get_entropy() returns 0.0 when _GLIBCXX_USE_DEV_RANDOM
    is not defined, but the test expects otherwise.  Adjust.
    
    
    for  libstdc++-v3/ChangeLog
    
            * testsuite/26_numerics/random/random_device/entropy.cc:
            Expect get_entropy to return zero when _GLIBCXX_USE_DEV_RANDOM
            is not defined.
    
    TN: W609-009

Diff:
---
 .../testsuite/26_numerics/random/random_device/entropy.cc         | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/testsuite/26_numerics/random/random_device/entropy.cc b/libstdc++-v3/testsuite/26_numerics/random/random_device/entropy.cc
index 9f529f5d814..3e6872c8a61 100644
--- a/libstdc++-v3/testsuite/26_numerics/random/random_device/entropy.cc
+++ b/libstdc++-v3/testsuite/26_numerics/random/random_device/entropy.cc
@@ -13,7 +13,13 @@ test01()
       VERIFY( std::random_device(token).entropy() == 0.0 );
 
   using result_type = std::random_device::result_type;
+#ifdef _GLIBCXX_USE_DEV_RANDOM
   const double max = std::numeric_limits<result_type>::digits;
+#else
+  // random_device::entropy() always returns 0.0 when
+  // _GLIBCXX_USE_DEV_RANDOM is not defined.
+  const double max = 0.0;
+#endif
 
   for (auto token : { "/dev/random", "/dev/urandom" })
     if (__gnu_test::random_device_available(token))
@@ -30,7 +36,7 @@ test01()
       VERIFY( entropy == max );
     }
 
-    for (auto token : { "getentropy", "arc4random" })
+  for (auto token : { "getentropy", "arc4random" })
     if (__gnu_test::random_device_available(token))
     {
       const double entropy = std::random_device(token).entropy();

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

end of thread, other threads:[~2023-06-23 20:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-23 20:12 [gcc(refs/users/aoliva/heads/testme)] [libstdc++] [testsuite] expect zero entropy matching implementation Alexandre Oliva
  -- strict thread matches above, loose matches on Subject: below --
2023-06-14 19:17 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).