From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2140) id 58A183858023; Fri, 23 Jun 2023 20:12:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 58A183858023 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687551146; bh=jFm/2HWp+V+IdJOiqIwjCZDKjd0aNcPk9z2f72hAd/I=; h=From:To:Subject:Date:From; b=Xt8LafrFCms2y/T8n097dF9viiCyhi7nlhTqt7GxP4iWqevd14QiDMF6rgfG6laui AfDwzPHCIEof+M8hsnvrmxOQDCLEnnEOB4tFbpX5C7WLplvAsokavfH0LvwAB26ReP 9U/4cYz59wbONTMQbMtplKKiprDsILn1yPoMmA2A= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Alexandre Oliva To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc(refs/users/aoliva/heads/testme)] [libstdc++] [testsuite] expect zero entropy matching implementation X-Act-Checkin: gcc X-Git-Author: Alexandre Oliva X-Git-Refname: refs/users/aoliva/heads/testme X-Git-Oldrev: 660efbd2dec8c46bffe9430e743a39a3dcc86b9e X-Git-Newrev: 36a0ffc5acb8bb5ecb583f41095964d2b62f71f5 Message-Id: <20230623201226.58A183858023@sourceware.org> Date: Fri, 23 Jun 2023 20:12:26 +0000 (GMT) List-Id: https://gcc.gnu.org/g:36a0ffc5acb8bb5ecb583f41095964d2b62f71f5 commit 36a0ffc5acb8bb5ecb583f41095964d2b62f71f5 Author: Alexandre Oliva 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::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();