From nobody Thu May 2 04:42:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1533209852321335.0952963488751; Thu, 2 Aug 2018 04:37:32 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 54FACC04F4C4; Thu, 2 Aug 2018 11:37:29 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 99CEF6F117; Thu, 2 Aug 2018 11:37:28 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 8D10B18037ED; Thu, 2 Aug 2018 11:37:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w72BbPjZ023501 for ; Thu, 2 Aug 2018 07:37:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id 485AD2026D69; Thu, 2 Aug 2018 11:37:25 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.42.22.189]) by smtp.corp.redhat.com (Postfix) with ESMTP id 83AE42026D66; Thu, 2 Aug 2018 11:37:24 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 2 Aug 2018 12:37:21 +0100 Message-Id: <20180802113721.15864-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Cc: Michal Privoznik , Bjoern Walk , Pino Toscano Subject: [libvirt] [PATCH] tests: mock virRandomBits to make it endian stable X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 02 Aug 2018 11:37:30 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 virRandomBits is implemented in terms of virRandomBytes. Although we mock virRandomBytes to give a stable value, this is not sufficient to make virRandomBits give a stable value. The result of virRandomBits will vary depending on endianness. Thus we mock virRandomBits to return a stable value directly. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Boris Fiuczynski Reviewed-by: Eric Blake Tested-by: Boris Fiuczynski --- tests/virrandommock.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/virrandommock.c b/tests/virrandommock.c index 99a55a576a..3079b8bacb 100644 --- a/tests/virrandommock.c +++ b/tests/virrandommock.c @@ -44,6 +44,14 @@ virRandomBytes(unsigned char *buf, return 0; } =20 +uint64_t virRandomBits(int nbits) +{ + /* Chosen by a fair roll of a 2^64 sided dice */ + uint64_t ret =3D 0x0706050403020100; + if (nbits < 64) + ret &=3D ((1ULL << nbits) - 1); + return ret; +} =20 int virRandomGenerateWWN(char **wwn, const char *virt_type ATTRIBUTE_UNUSED) --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list