Re: [PATCH 17/26] cputest: Test CPU signatures

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Feb 27, 2019 at 02:29:07PM +0100, Jiri Denemark wrote:
The signature computation code is not too complicated and it will likely
never change so testing it is not very important. We do it mostly for a
nice side effect of easily accessible signature numbers for all CPU
data files.

Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
---
tests/cputest.c                               | 92 +++++++++++++++++++
tests/cputestdata/x86_64-cpuid-A10-5800K.sig  |  4 +

[ many diffstat, such files ]

create mode 100644 tests/cputestdata/x86_64-cpuid-Xeon-W3520.sig
create mode 100644 tests/cputestdata/x86_64-cpuid-Xeon-X5460.sig

diff --git a/tests/cputest.c b/tests/cputest.c
index 19caf41bf3..5b1bdc11c6 100644
--- a/tests/cputest.c
+++ b/tests/cputest.c
@@ -32,6 +32,7 @@
#include "testutils.h"
#include "cpu_conf.h"
#include "cpu/cpu.h"
+#include "cpu/cpu_x86.h"
#include "cpu/cpu_map.h"
#include "virstring.h"

@@ -642,6 +643,68 @@ cpuTestGuestCPUID(const void *arg)
}


+static int
+cpuTestCompareSignature(const struct data *data,
+                        virCPUDataPtr hostData)
+{
+    unsigned long signature;
+    unsigned int family;
+    unsigned int model;
+    unsigned int stepping;
+    char *result = NULL;
+    char *sigStr = NULL;

Could have used VIR_AUTOFREE

+    int ret = -1;
+
+    signature = virCPUx86DataGetSignature(hostData, &family, &model, &stepping);
+
+    if (virAsprintf(&result, "%s/cputestdata/%s-cpuid-%s.sig",
+                    abs_srcdir, virArchToString(data->arch), data->host) < 0)
+        goto cleanup;
+
+    if (virAsprintf(&sigStr,
+                    "%1$06lx\n"
+                    "family:   %2$2u (0x%2$02x)\n"
+                    "model:    %3$2u (0x%3$02x)\n"
+                    "stepping: %4$2u (0x%4$02x)\n",

$3u to nicely align numbers greater than 0x63

+                    signature, family, model, stepping) < 0)
+        goto cleanup;
+
+    ret = virTestCompareToFile(sigStr, result);
+
+ cleanup:
+    VIR_FREE(result);
+    VIR_FREE(sigStr);
+    return ret;
+}
+
+

Reviewed-by: Ján Tomko <jtomko@xxxxxxxxxx>

Jano

Attachment: signature.asc
Description: PGP signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux