From: Jonathan Wakely Date: Tue, 9 Nov 2021 10:31:18 +0000 (+0000) Subject: libstdc++: Make spurious std::random_device FAIL less likely X-Git-Tag: basepoints/gcc-13~3258 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8d2d0a6c4391e462555db6d33b2cc00f3da0932f;p=thirdparty%2Fgcc.git libstdc++: Make spurious std::random_device FAIL less likely 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. --- diff --git a/libstdc++-v3/testsuite/26_numerics/random/random_device/cons/token.cc b/libstdc++-v3/testsuite/26_numerics/random/random_device/cons/token.cc index d6ac3a37c64d..07713e5c67fa 100644 --- a/libstdc++-v3/testsuite/26_numerics/random/random_device/cons/token.cc +++ b/libstdc++-v3/testsuite/26_numerics/random/random_device/cons/token.cc @@ -42,7 +42,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 }