From patchwork Wed Jun 14 22:50:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 1795137 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=njUNxJqN; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QhLHn25NPz20WR for ; Thu, 15 Jun 2023 08:51:01 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4C54E3857C48 for ; Wed, 14 Jun 2023 22:50:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4C54E3857C48 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686783059; bh=P+whGu1kOEqKo79KPuRaWz5MCEMVwBu46qE/o+1cjQk=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=njUNxJqNt6ONhgqRm1M3uBAD814alPHd8Hr6JCv0584a+x5WwwWhL/9OPzcwBqkTm pvyII8N1z5gCHuz9m1OuMPflLkyvt73nQITBy+AFEI8jSSWxOvLra5o2Jfe2Bn4YMu H307d+6fvNxROpBiPWi9O+MZv2IPeA+nGtMxZfxg= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 Received: by mail-oa1-x35.google.com with SMTP id 586e51a60fabf-1a5229df1f2so5353282fac.3 for ; Wed, 14 Jun 2023 15:50:39 -0700 (PDT) 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 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 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 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Alexandre Oliva via Gcc-patches From: Alexandre Oliva Reply-To: Alexandre Oliva Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" 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();