]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Make spurious std::random_device FAIL less likely
authorJonathan Wakely <jwakely@redhat.com>
Tue, 9 Nov 2021 10:31:18 +0000 (10:31 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Tue, 26 Apr 2022 11:07:39 +0000 (12:07 +0100)
It's possible that independent reads from /dev/random and /dev/urandom
could produce the same value by chance. Retry if that happens. The
chances of it happening twice are miniscule.

libstdc++-v3/ChangeLog:

* testsuite/26_numerics/random/random_device/cons/token.cc:
Retry if random devices produce the same value.

(cherry picked from commit 8d2d0a6c4391e462555db6d33b2cc00f3da0932f)

libstdc++-v3/testsuite/26_numerics/random/random_device/cons/token.cc

index 42887703b752b5ff3caa2225c13bfb66b57c09a7..5797571584b40208eb0079012bf5f3307d8f010d 100644 (file)
@@ -41,7 +41,7 @@ test02()
 #ifdef _GLIBCXX_USE_DEV_RANDOM
   std::random_device x1("/dev/urandom");
   std::random_device x2("/dev/random");
-  VERIFY( x1() != x2() );
+  VERIFY( x1() != x2() || x1() != x2() );
 #endif
 }