From nobody Fri May 16 04:51:12 2025 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1501688362307784.6761695686639; Wed, 2 Aug 2017 08:39:22 -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 3D1227F3F9; Wed, 2 Aug 2017 15:39:20 +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 0F885808EA; Wed, 2 Aug 2017 15:39:20 +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 B5F4A180B467; Wed, 2 Aug 2017 15:39:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v72Fd4so032262 for ; Wed, 2 Aug 2017 11:39:04 -0400 Received: by smtp.corp.redhat.com (Postfix) id 470E97F760; Wed, 2 Aug 2017 15:39:04 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 949EF7F770; Wed, 2 Aug 2017 15:39:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3D1227F3F9 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 2 Aug 2017 17:39:03 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 3/3] tests: deterministichash: Make hash tables arch-independent 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: , MIME-Version: 1.0 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.25]); Wed, 02 Aug 2017 15:39:20 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" It turns out that our implementation of the hashing function is endian-dependent and thus if used on various architectures the testsuite may have different results. Work this around by mocking virHashCodeGen to something which does not use bit operations instead of just setting a deterministic seed. --- .../qemumonitorjson-nodename-relative.result | 24 +++++++++++-------= ---- .../qemumonitorjson-nodename-same-backing.result | 24 +++++++++++-------= ---- tests/virdeterministichashmock.c | 17 +++++++++++---- tests/virmacmaptestdata/simple2.json | 12 +++++------ 4 files changed, 43 insertions(+), 34 deletions(-) diff --git a/tests/qemumonitorjsondata/qemumonitorjson-nodename-relative.re= sult b/tests/qemumonitorjsondata/qemumonitorjson-nodename-relative.result index 6c0c77618..5288319d3 100644 --- a/tests/qemumonitorjsondata/qemumonitorjson-nodename-relative.result +++ b/tests/qemumonitorjsondata/qemumonitorjson-nodename-relative.result @@ -1,15 +1,3 @@ -drive-ide0-0-1 -filename : '/var/lib/libvirt/images/relsnap.qcow2' -format node : '#block1290' -format drv : 'qcow2' -storage node: '#block1107' -storage drv : 'file' - filename : '/var/lib/libvirt/images/base.qcow2' - format node : '#block927' - format drv : 'qcow2' - storage node: '#block800' - storage drv : 'file' - drive-ide0-0-0 filename : '/var/lib/libvirt/images/img3' format node : '#block118' @@ -31,3 +19,15 @@ storage drv : 'file' format drv : 'qcow2' storage node: '#block614' storage drv : 'file' + +drive-ide0-0-1 +filename : '/var/lib/libvirt/images/relsnap.qcow2' +format node : '#block1290' +format drv : 'qcow2' +storage node: '#block1107' +storage drv : 'file' + filename : '/var/lib/libvirt/images/base.qcow2' + format node : '#block927' + format drv : 'qcow2' + storage node: '#block800' + storage drv : 'file' diff --git a/tests/qemumonitorjsondata/qemumonitorjson-nodename-same-backin= g.result b/tests/qemumonitorjsondata/qemumonitorjson-nodename-same-backing.= result index 87431f7ca..7b12a1746 100644 --- a/tests/qemumonitorjsondata/qemumonitorjson-nodename-same-backing.result +++ b/tests/qemumonitorjsondata/qemumonitorjson-nodename-same-backing.result @@ -1,15 +1,3 @@ -drive-sata0-0-1 -filename : '/var/lib/libvirt/images/b.qcow2' -format node : '#block548' -format drv : 'qcow2' -storage node: '#block487' -storage drv : 'file' - filename : '/var/lib/libvirt/images/base.qcow2' - format node : '#block771' - format drv : 'qcow2' - storage node: '#block692' - storage drv : 'file' - drive-sata0-0-0 filename : '/var/lib/libvirt/images/a.qcow2' format node : '#block132' @@ -21,3 +9,15 @@ storage drv : 'file' format drv : 'qcow2' storage node: '#block224' storage drv : 'file' + +drive-sata0-0-1 +filename : '/var/lib/libvirt/images/b.qcow2' +format node : '#block548' +format drv : 'qcow2' +storage node: '#block487' +storage drv : 'file' + filename : '/var/lib/libvirt/images/base.qcow2' + format node : '#block771' + format drv : 'qcow2' + storage node: '#block692' + storage drv : 'file' diff --git a/tests/virdeterministichashmock.c b/tests/virdeterministichashm= ock.c index d01f1c9e4..cd80cfcb5 100644 --- a/tests/virdeterministichashmock.c +++ b/tests/virdeterministichashmock.c @@ -20,10 +20,19 @@ #include -#include "virrandom.h" +#include "util/virhashcode.h" -uint64_t virRandomBits(int nbits ATTRIBUTE_UNUSED) +uint32_t +virHashCodeGen(const void *key, + size_t len, + uint32_t seed ATTRIBUTE_UNUSED) { - return 4; /* chosen by fair dice roll. - guaranteed to be random. */ + const uint8_t *k =3D key; + uint32_t h =3D 0; + size_t i; + + for (i =3D 0; i < len; i++) + h +=3D k[i]; + + return h; } diff --git a/tests/virmacmaptestdata/simple2.json b/tests/virmacmaptestdata= /simple2.json index 91b2cde0c..52132c241 100644 --- a/tests/virmacmaptestdata/simple2.json +++ b/tests/virmacmaptestdata/simple2.json @@ -1,16 +1,16 @@ [ { - "domain": "f25", + "domain": "f24", "macs": [ - "00:11:22:33:44:55", - "aa:bb:cc:00:11:22" + "aa:bb:cc:dd:ee:ff", + "a1:b2:c3:d4:e5:f6" ] }, { - "domain": "f24", + "domain": "f25", "macs": [ - "aa:bb:cc:dd:ee:ff", - "a1:b2:c3:d4:e5:f6" + "00:11:22:33:44:55", + "aa:bb:cc:00:11:22" ] } ] --=20 2.13.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list