From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oa1-x35.google.com (mail-oa1-x35.google.com [IPv6:2001:4860:4864:20::35]) by sourceware.org (Postfix) with ESMTPS id 5B2813858C5E for ; Wed, 14 Jun 2023 22:50:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5B2813858C5E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-oa1-x35.google.com with SMTP id 586e51a60fabf-1a5229df1f2so5353282fac.3 for ; Wed, 14 Jun 2023 15:50:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1686783038; x=1689375038; h=mime-version:user-agent:message-id:date:errors-to:organization :subject:to:from:from:to:cc:subject:date:message-id:reply-to; bh=P+whGu1kOEqKo79KPuRaWz5MCEMVwBu46qE/o+1cjQk=; b=dZHGM2Mo7U5Qgj/auZNxvJatrlt1NR0tI2/s4AQ/iWoS1sehkAa/Kv4zF3IXgcOEJV hMun/pV0bf6VAo1q9zjRLQaID2NJTvomr/weyhyIyHZZRayedIa36HlVyZ3kxYTDGtm/ epPam8gP5fbP8LiI9Ldb6Unk+XoxVtc9jY+gH+w/sJmar82eBugOAgC1ZyvgWMZZ5uw2 CIJv0mn2Tqi1oC+wb+ECCsz3dbABWGgtAXpm4A4RU5GhgI1HzUT6wkmfbygWbMIbfVRO +qcsIBWo/LmiaxNEIU9N+OSBGlGE5Yfb2g68H3r31gbGfNLVK113tjU+IL6i1sGO8ilg flUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686783038; x=1689375038; h=mime-version:user-agent:message-id:date:errors-to:organization :subject:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=P+whGu1kOEqKo79KPuRaWz5MCEMVwBu46qE/o+1cjQk=; b=CJBynqEV4kkYNUxpW4SW4Cc3RhblZSnEvSIjzFO+ptUVuSFMjAKt+gs2rCt0lpx2Gs 3qxCboEspZhDusSFMPqlAER/GSbGyYorF8jVovNUEyk2W3+37X9QecuSwDXoFhl7MeK5 r9ShDeh1HXkk/IrPuzTBuhBVvIlWm9tSi0SpCS06VeENqzSWPhob579woohnQ04mU7dt IWN+qS1ZBWupwVnYPCNimXlaHRlzC+iUtovU9ruu+YeFQ8AflOIP8j1J3n39gdK2SsM/ xnQ9PHEHZ90c7BRSygOx1ncVSolcRLYoyIyL8M+B+vikNvlwrCvnY1dNNeUa4M/hciow vTqw== X-Gm-Message-State: AC+VfDznCkzIW/AAJN5pWhsLUEuaD4Ra9wCVhhvDNjX9FFHjhRujshRQ cItcBWwcWbnLjVOvZOMDH7x08rszBxnJy8rnvvQ= X-Google-Smtp-Source: ACHHUZ4dqwMROtf9WIUtrEh0hNB/s7rOPdXADBDlI4fIVg8sl+Yqp/mD9Y5/uXCa6qBblBBrs4FJPw== X-Received: by 2002:a05:6870:87c2:b0:1a2:8e53:c418 with SMTP id s2-20020a05687087c200b001a28e53c418mr12051006oam.57.1686783038686; Wed, 14 Jun 2023 15:50:38 -0700 (PDT) Received: from free.home ([2804:7f1:2080:2b05:3128:ead8:cd43:416f]) by smtp.gmail.com with ESMTPSA id v10-20020a056870424a00b001a993936e88sm486303oac.47.2023.06.14.15.50.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jun 2023 15:50:38 -0700 (PDT) Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id 35EMoUdx411015 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 14 Jun 2023 19:50:31 -0300 From: Alexandre Oliva To: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org Subject: [libstdc++] [testsuite] expect zero entropy matching implementation Organization: Free thinker, does not speak for AdaCore Errors-To: aoliva@lxoliva.fsfla.org Date: Wed, 14 Jun 2023 19:50:30 -0300 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.84 X-Spam-Status: No, score=-13.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: random_device::get_entropy() returns 0.0 when _GLIBCXX_USE_DEV_RANDOM is not defined, but the test expects otherwise. Adjust. Regstrapped on x86_64-linux-gnu, also tested on aarch64-rtems6. Ok to install? 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. --- .../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 9f529f5d81410..3e6872c8a613f 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(); -- Alexandre Oliva, happy hacker https://FSFLA.org/blogs/lxo/ Free Software Activist GNU Toolchain Engineer Disinformation flourishes because many people care deeply about injustice but very few check the facts. Ask me about