]> xenbits.xensource.com Git - libvirt.git/commitdiff
tests: deterministichash: Make hash tables arch-independent
authorPeter Krempa <pkrempa@redhat.com>
Wed, 2 Aug 2017 15:23:51 +0000 (17:23 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 3 Aug 2017 07:54:36 +0000 (09:54 +0200)
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.

tests/qemumonitorjsondata/qemumonitorjson-nodename-relative.result
tests/qemumonitorjsondata/qemumonitorjson-nodename-same-backing.result
tests/virdeterministichashmock.c
tests/virmacmaptestdata/simple2.json

index 6c0c77618c78e82bb8fb5d40a15f7d711d457940..5288319d30eb8db5a14eb8c30cb5e795d60c2e97 100644 (file)
@@ -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'
index 87431f7ca29f14b35ae321f68d5a588ac7ce1dc1..7b12a1746aef2b397ef41c0d42a3fbde465e825f 100644 (file)
@@ -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'
index d01f1c9e46c727b2d466204edaa153e5cecbb417..cd80cfcb526f8af21966ed49d9ae0c75c20278bf 100644 (file)
 
 #include <config.h>
 
-#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 = key;
+    uint32_t h = 0;
+    size_t i;
+
+    for (i = 0; i < len; i++)
+        h += k[i];
+
+    return h;
 }
index 91b2cde0cdb92ed8f0e5b715da44d40af7ce1d86..52132c241e967b4cf1b20f02efd0b0b618b0f8e4 100644 (file)
@@ -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"
     ]
   }
 ]