mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
cputest: Test CPU signatures
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@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
61be05a00f
commit
dd08d27fc2
@ -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,62 @@ cpuTestGuestCPUID(const void *arg)
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
cpuTestCompareSignature(const struct data *data,
|
||||
virCPUDataPtr hostData)
|
||||
{
|
||||
VIR_AUTOFREE(char *) result = NULL;
|
||||
VIR_AUTOFREE(char *) sigStr = NULL;
|
||||
unsigned long signature;
|
||||
unsigned int family;
|
||||
unsigned int model;
|
||||
unsigned int stepping;
|
||||
|
||||
signature = virCPUx86DataGetSignature(hostData, &family, &model, &stepping);
|
||||
|
||||
if (virAsprintf(&result, "%s/cputestdata/%s-cpuid-%s.sig",
|
||||
abs_srcdir, virArchToString(data->arch), data->host) < 0)
|
||||
return -1;
|
||||
|
||||
if (virAsprintf(&sigStr,
|
||||
"%1$06lx\n"
|
||||
"family: %2$3u (0x%2$02x)\n"
|
||||
"model: %3$3u (0x%3$02x)\n"
|
||||
"stepping: %4$3u (0x%4$02x)\n",
|
||||
signature, family, model, stepping) < 0)
|
||||
return -1;
|
||||
|
||||
return virTestCompareToFile(sigStr, result);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
cpuTestCPUIDSignature(const void *arg)
|
||||
{
|
||||
const struct data *data = arg;
|
||||
virCPUDataPtr hostData = NULL;
|
||||
char *hostFile = NULL;
|
||||
char *host = NULL;
|
||||
int ret = -1;
|
||||
|
||||
if (virAsprintf(&hostFile, "%s/cputestdata/%s-cpuid-%s.xml",
|
||||
abs_srcdir, virArchToString(data->arch), data->host) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virTestLoadFile(hostFile, &host) < 0 ||
|
||||
!(hostData = virCPUDataParse(host)))
|
||||
goto cleanup;
|
||||
|
||||
ret = cpuTestCompareSignature(data, hostData);
|
||||
|
||||
cleanup:
|
||||
virCPUDataFree(hostData);
|
||||
VIR_FREE(hostFile);
|
||||
VIR_FREE(host);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
cpuTestUpdateLiveCompare(virArch arch,
|
||||
virCPUDefPtr actual,
|
||||
@ -863,6 +920,31 @@ cpuTestJSONCPUID(const void *arg)
|
||||
VIR_FREE(result);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
cpuTestJSONSignature(const void *arg)
|
||||
{
|
||||
const struct data *data = arg;
|
||||
virQEMUCapsPtr qemuCaps = NULL;
|
||||
virCPUDataPtr hostData = NULL;
|
||||
qemuMonitorCPUModelInfoPtr modelInfo;
|
||||
int ret = -1;
|
||||
|
||||
if (!(qemuCaps = cpuTestMakeQEMUCaps(data)))
|
||||
goto cleanup;
|
||||
|
||||
modelInfo = virQEMUCapsGetCPUModelInfo(qemuCaps, VIR_DOMAIN_VIRT_KVM);
|
||||
if (!(hostData = virQEMUCapsGetCPUModelX86Data(modelInfo, false)))
|
||||
goto cleanup;
|
||||
|
||||
ret = cpuTestCompareSignature(data, hostData);
|
||||
|
||||
cleanup:
|
||||
virObjectUnref(qemuCaps);
|
||||
virCPUDataFree(hostData);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@ -1008,6 +1090,8 @@ mymain(void)
|
||||
if (json != JSON_NONE) { \
|
||||
DO_TEST(arch, cpuTestJSONCPUID, host, host, \
|
||||
NULL, NULL, json, 0); \
|
||||
DO_TEST(arch, cpuTestJSONSignature, host, host, \
|
||||
NULL, NULL, 0, 0); \
|
||||
} \
|
||||
} while (0)
|
||||
#else
|
||||
@ -1020,6 +1104,8 @@ mymain(void)
|
||||
NULL, NULL, 0, 0); \
|
||||
DO_TEST(arch, cpuTestGuestCPUID, host, host, \
|
||||
NULL, NULL, json, 0); \
|
||||
DO_TEST(arch, cpuTestCPUIDSignature, host, host, \
|
||||
NULL, NULL, 0, 0); \
|
||||
DO_TEST_JSON(arch, host, json); \
|
||||
if (json != JSON_NONE) { \
|
||||
DO_TEST(arch, cpuTestUpdateLive, host, host, \
|
||||
|
4
tests/cputestdata/x86_64-cpuid-A10-5800K.sig
Normal file
4
tests/cputestdata/x86_64-cpuid-A10-5800K.sig
Normal file
@ -0,0 +1,4 @@
|
||||
610f01
|
||||
family: 21 (0x15)
|
||||
model: 16 (0x10)
|
||||
stepping: 1 (0x01)
|
4
tests/cputestdata/x86_64-cpuid-Atom-D510.sig
Normal file
4
tests/cputestdata/x86_64-cpuid-Atom-D510.sig
Normal file
@ -0,0 +1,4 @@
|
||||
0106ca
|
||||
family: 6 (0x06)
|
||||
model: 28 (0x1c)
|
||||
stepping: 10 (0x0a)
|
4
tests/cputestdata/x86_64-cpuid-Atom-N450.sig
Normal file
4
tests/cputestdata/x86_64-cpuid-Atom-N450.sig
Normal file
@ -0,0 +1,4 @@
|
||||
0106ca
|
||||
family: 6 (0x06)
|
||||
model: 28 (0x1c)
|
||||
stepping: 10 (0x0a)
|
4
tests/cputestdata/x86_64-cpuid-Core-i5-2500.sig
Normal file
4
tests/cputestdata/x86_64-cpuid-Core-i5-2500.sig
Normal file
@ -0,0 +1,4 @@
|
||||
0206a7
|
||||
family: 6 (0x06)
|
||||
model: 42 (0x2a)
|
||||
stepping: 7 (0x07)
|
4
tests/cputestdata/x86_64-cpuid-Core-i5-2540M.sig
Normal file
4
tests/cputestdata/x86_64-cpuid-Core-i5-2540M.sig
Normal file
@ -0,0 +1,4 @@
|
||||
0206a7
|
||||
family: 6 (0x06)
|
||||
model: 42 (0x2a)
|
||||
stepping: 7 (0x07)
|
4
tests/cputestdata/x86_64-cpuid-Core-i5-4670T.sig
Normal file
4
tests/cputestdata/x86_64-cpuid-Core-i5-4670T.sig
Normal file
@ -0,0 +1,4 @@
|
||||
0306c3
|
||||
family: 6 (0x06)
|
||||
model: 60 (0x3c)
|
||||
stepping: 3 (0x03)
|
4
tests/cputestdata/x86_64-cpuid-Core-i5-650.sig
Normal file
4
tests/cputestdata/x86_64-cpuid-Core-i5-650.sig
Normal file
@ -0,0 +1,4 @@
|
||||
020652
|
||||
family: 6 (0x06)
|
||||
model: 37 (0x25)
|
||||
stepping: 2 (0x02)
|
4
tests/cputestdata/x86_64-cpuid-Core-i5-6600.sig
Normal file
4
tests/cputestdata/x86_64-cpuid-Core-i5-6600.sig
Normal file
@ -0,0 +1,4 @@
|
||||
0506e3
|
||||
family: 6 (0x06)
|
||||
model: 94 (0x5e)
|
||||
stepping: 3 (0x03)
|
4
tests/cputestdata/x86_64-cpuid-Core-i7-2600-xsaveopt.sig
Normal file
4
tests/cputestdata/x86_64-cpuid-Core-i7-2600-xsaveopt.sig
Normal file
@ -0,0 +1,4 @@
|
||||
0206a7
|
||||
family: 6 (0x06)
|
||||
model: 42 (0x2a)
|
||||
stepping: 7 (0x07)
|
4
tests/cputestdata/x86_64-cpuid-Core-i7-2600.sig
Normal file
4
tests/cputestdata/x86_64-cpuid-Core-i7-2600.sig
Normal file
@ -0,0 +1,4 @@
|
||||
0206a7
|
||||
family: 6 (0x06)
|
||||
model: 42 (0x2a)
|
||||
stepping: 7 (0x07)
|
4
tests/cputestdata/x86_64-cpuid-Core-i7-3520M.sig
Normal file
4
tests/cputestdata/x86_64-cpuid-Core-i7-3520M.sig
Normal file
@ -0,0 +1,4 @@
|
||||
0306a9
|
||||
family: 6 (0x06)
|
||||
model: 58 (0x3a)
|
||||
stepping: 9 (0x09)
|
4
tests/cputestdata/x86_64-cpuid-Core-i7-3740QM.sig
Normal file
4
tests/cputestdata/x86_64-cpuid-Core-i7-3740QM.sig
Normal file
@ -0,0 +1,4 @@
|
||||
0306a9
|
||||
family: 6 (0x06)
|
||||
model: 58 (0x3a)
|
||||
stepping: 9 (0x09)
|
4
tests/cputestdata/x86_64-cpuid-Core-i7-3770.sig
Normal file
4
tests/cputestdata/x86_64-cpuid-Core-i7-3770.sig
Normal file
@ -0,0 +1,4 @@
|
||||
0306a9
|
||||
family: 6 (0x06)
|
||||
model: 58 (0x3a)
|
||||
stepping: 9 (0x09)
|
4
tests/cputestdata/x86_64-cpuid-Core-i7-4510U.sig
Normal file
4
tests/cputestdata/x86_64-cpuid-Core-i7-4510U.sig
Normal file
@ -0,0 +1,4 @@
|
||||
040651
|
||||
family: 6 (0x06)
|
||||
model: 69 (0x45)
|
||||
stepping: 1 (0x01)
|
4
tests/cputestdata/x86_64-cpuid-Core-i7-4600U.sig
Normal file
4
tests/cputestdata/x86_64-cpuid-Core-i7-4600U.sig
Normal file
@ -0,0 +1,4 @@
|
||||
040651
|
||||
family: 6 (0x06)
|
||||
model: 69 (0x45)
|
||||
stepping: 1 (0x01)
|
4
tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat.sig
Normal file
4
tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat.sig
Normal file
@ -0,0 +1,4 @@
|
||||
0306d4
|
||||
family: 6 (0x06)
|
||||
model: 61 (0x3d)
|
||||
stepping: 4 (0x04)
|
4
tests/cputestdata/x86_64-cpuid-Core-i7-5600U-ibrs.sig
Normal file
4
tests/cputestdata/x86_64-cpuid-Core-i7-5600U-ibrs.sig
Normal file
@ -0,0 +1,4 @@
|
||||
0306d4
|
||||
family: 6 (0x06)
|
||||
model: 61 (0x3d)
|
||||
stepping: 4 (0x04)
|
4
tests/cputestdata/x86_64-cpuid-Core-i7-5600U.sig
Normal file
4
tests/cputestdata/x86_64-cpuid-Core-i7-5600U.sig
Normal file
@ -0,0 +1,4 @@
|
||||
0306d4
|
||||
family: 6 (0x06)
|
||||
model: 61 (0x3d)
|
||||
stepping: 4 (0x04)
|
4
tests/cputestdata/x86_64-cpuid-Core-i7-7600U.sig
Normal file
4
tests/cputestdata/x86_64-cpuid-Core-i7-7600U.sig
Normal file
@ -0,0 +1,4 @@
|
||||
0806e9
|
||||
family: 6 (0x06)
|
||||
model: 142 (0x8e)
|
||||
stepping: 9 (0x09)
|
4
tests/cputestdata/x86_64-cpuid-Core-i7-7700.sig
Normal file
4
tests/cputestdata/x86_64-cpuid-Core-i7-7700.sig
Normal file
@ -0,0 +1,4 @@
|
||||
0906e9
|
||||
family: 6 (0x06)
|
||||
model: 158 (0x9e)
|
||||
stepping: 9 (0x09)
|
4
tests/cputestdata/x86_64-cpuid-Core-i7-8700.sig
Normal file
4
tests/cputestdata/x86_64-cpuid-Core-i7-8700.sig
Normal file
@ -0,0 +1,4 @@
|
||||
0906ea
|
||||
family: 6 (0x06)
|
||||
model: 158 (0x9e)
|
||||
stepping: 10 (0x0a)
|
4
tests/cputestdata/x86_64-cpuid-Core2-E6850.sig
Normal file
4
tests/cputestdata/x86_64-cpuid-Core2-E6850.sig
Normal file
@ -0,0 +1,4 @@
|
||||
0006fb
|
||||
family: 6 (0x06)
|
||||
model: 15 (0x0f)
|
||||
stepping: 11 (0x0b)
|
4
tests/cputestdata/x86_64-cpuid-Core2-Q9500.sig
Normal file
4
tests/cputestdata/x86_64-cpuid-Core2-Q9500.sig
Normal file
@ -0,0 +1,4 @@
|
||||
01067a
|
||||
family: 6 (0x06)
|
||||
model: 23 (0x17)
|
||||
stepping: 10 (0x0a)
|
@ -0,0 +1,4 @@
|
||||
800f12
|
||||
family: 23 (0x17)
|
||||
model: 1 (0x01)
|
||||
stepping: 2 (0x02)
|
4
tests/cputestdata/x86_64-cpuid-EPYC-7601-32-Core.sig
Normal file
4
tests/cputestdata/x86_64-cpuid-EPYC-7601-32-Core.sig
Normal file
@ -0,0 +1,4 @@
|
||||
800f12
|
||||
family: 23 (0x17)
|
||||
model: 1 (0x01)
|
||||
stepping: 2 (0x02)
|
4
tests/cputestdata/x86_64-cpuid-FX-8150.sig
Normal file
4
tests/cputestdata/x86_64-cpuid-FX-8150.sig
Normal file
@ -0,0 +1,4 @@
|
||||
600f12
|
||||
family: 21 (0x15)
|
||||
model: 1 (0x01)
|
||||
stepping: 2 (0x02)
|
4
tests/cputestdata/x86_64-cpuid-Opteron-1352.sig
Normal file
4
tests/cputestdata/x86_64-cpuid-Opteron-1352.sig
Normal file
@ -0,0 +1,4 @@
|
||||
100f23
|
||||
family: 16 (0x10)
|
||||
model: 2 (0x02)
|
||||
stepping: 3 (0x03)
|
4
tests/cputestdata/x86_64-cpuid-Opteron-2350.sig
Normal file
4
tests/cputestdata/x86_64-cpuid-Opteron-2350.sig
Normal file
@ -0,0 +1,4 @@
|
||||
100f23
|
||||
family: 16 (0x10)
|
||||
model: 2 (0x02)
|
||||
stepping: 3 (0x03)
|
4
tests/cputestdata/x86_64-cpuid-Opteron-6234.sig
Normal file
4
tests/cputestdata/x86_64-cpuid-Opteron-6234.sig
Normal file
@ -0,0 +1,4 @@
|
||||
600f12
|
||||
family: 21 (0x15)
|
||||
model: 1 (0x01)
|
||||
stepping: 2 (0x02)
|
4
tests/cputestdata/x86_64-cpuid-Opteron-6282.sig
Normal file
4
tests/cputestdata/x86_64-cpuid-Opteron-6282.sig
Normal file
@ -0,0 +1,4 @@
|
||||
600f12
|
||||
family: 21 (0x15)
|
||||
model: 1 (0x01)
|
||||
stepping: 2 (0x02)
|
4
tests/cputestdata/x86_64-cpuid-Pentium-P6100.sig
Normal file
4
tests/cputestdata/x86_64-cpuid-Pentium-P6100.sig
Normal file
@ -0,0 +1,4 @@
|
||||
020655
|
||||
family: 6 (0x06)
|
||||
model: 37 (0x25)
|
||||
stepping: 5 (0x05)
|
4
tests/cputestdata/x86_64-cpuid-Phenom-B95.sig
Normal file
4
tests/cputestdata/x86_64-cpuid-Phenom-B95.sig
Normal file
@ -0,0 +1,4 @@
|
||||
100f42
|
||||
family: 16 (0x10)
|
||||
model: 4 (0x04)
|
||||
stepping: 2 (0x02)
|
@ -0,0 +1,4 @@
|
||||
800f11
|
||||
family: 23 (0x17)
|
||||
model: 1 (0x01)
|
||||
stepping: 1 (0x01)
|
4
tests/cputestdata/x86_64-cpuid-Xeon-5110.sig
Normal file
4
tests/cputestdata/x86_64-cpuid-Xeon-5110.sig
Normal file
@ -0,0 +1,4 @@
|
||||
0006f6
|
||||
family: 6 (0x06)
|
||||
model: 15 (0x0f)
|
||||
stepping: 6 (0x06)
|
4
tests/cputestdata/x86_64-cpuid-Xeon-E3-1245-v5.sig
Normal file
4
tests/cputestdata/x86_64-cpuid-Xeon-E3-1245-v5.sig
Normal file
@ -0,0 +1,4 @@
|
||||
0506e3
|
||||
family: 6 (0x06)
|
||||
model: 94 (0x5e)
|
||||
stepping: 3 (0x03)
|
4
tests/cputestdata/x86_64-cpuid-Xeon-E5-2609-v3.sig
Normal file
4
tests/cputestdata/x86_64-cpuid-Xeon-E5-2609-v3.sig
Normal file
@ -0,0 +1,4 @@
|
||||
0306f2
|
||||
family: 6 (0x06)
|
||||
model: 63 (0x3f)
|
||||
stepping: 2 (0x02)
|
4
tests/cputestdata/x86_64-cpuid-Xeon-E5-2623-v4.sig
Normal file
4
tests/cputestdata/x86_64-cpuid-Xeon-E5-2623-v4.sig
Normal file
@ -0,0 +1,4 @@
|
||||
0406f1
|
||||
family: 6 (0x06)
|
||||
model: 79 (0x4f)
|
||||
stepping: 1 (0x01)
|
4
tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-v3.sig
Normal file
4
tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-v3.sig
Normal file
@ -0,0 +1,4 @@
|
||||
0306f2
|
||||
family: 6 (0x06)
|
||||
model: 63 (0x3f)
|
||||
stepping: 2 (0x02)
|
4
tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-v4.sig
Normal file
4
tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-v4.sig
Normal file
@ -0,0 +1,4 @@
|
||||
0406f1
|
||||
family: 6 (0x06)
|
||||
model: 79 (0x4f)
|
||||
stepping: 1 (0x01)
|
4
tests/cputestdata/x86_64-cpuid-Xeon-E5-2650-v3.sig
Normal file
4
tests/cputestdata/x86_64-cpuid-Xeon-E5-2650-v3.sig
Normal file
@ -0,0 +1,4 @@
|
||||
0306f2
|
||||
family: 6 (0x06)
|
||||
model: 63 (0x3f)
|
||||
stepping: 2 (0x02)
|
4
tests/cputestdata/x86_64-cpuid-Xeon-E5-2650-v4.sig
Normal file
4
tests/cputestdata/x86_64-cpuid-Xeon-E5-2650-v4.sig
Normal file
@ -0,0 +1,4 @@
|
||||
0406f1
|
||||
family: 6 (0x06)
|
||||
model: 79 (0x4f)
|
||||
stepping: 1 (0x01)
|
4
tests/cputestdata/x86_64-cpuid-Xeon-E5-2650.sig
Normal file
4
tests/cputestdata/x86_64-cpuid-Xeon-E5-2650.sig
Normal file
@ -0,0 +1,4 @@
|
||||
0206d7
|
||||
family: 6 (0x06)
|
||||
model: 45 (0x2d)
|
||||
stepping: 7 (0x07)
|
4
tests/cputestdata/x86_64-cpuid-Xeon-E7-4820.sig
Normal file
4
tests/cputestdata/x86_64-cpuid-Xeon-E7-4820.sig
Normal file
@ -0,0 +1,4 @@
|
||||
0206f2
|
||||
family: 6 (0x06)
|
||||
model: 47 (0x2f)
|
||||
stepping: 2 (0x02)
|
4
tests/cputestdata/x86_64-cpuid-Xeon-E7-4830.sig
Normal file
4
tests/cputestdata/x86_64-cpuid-Xeon-E7-4830.sig
Normal file
@ -0,0 +1,4 @@
|
||||
0206f2
|
||||
family: 6 (0x06)
|
||||
model: 47 (0x2f)
|
||||
stepping: 2 (0x02)
|
4
tests/cputestdata/x86_64-cpuid-Xeon-E7-8890-v3.sig
Normal file
4
tests/cputestdata/x86_64-cpuid-Xeon-E7-8890-v3.sig
Normal file
@ -0,0 +1,4 @@
|
||||
0306f4
|
||||
family: 6 (0x06)
|
||||
model: 63 (0x3f)
|
||||
stepping: 4 (0x04)
|
4
tests/cputestdata/x86_64-cpuid-Xeon-E7540.sig
Normal file
4
tests/cputestdata/x86_64-cpuid-Xeon-E7540.sig
Normal file
@ -0,0 +1,4 @@
|
||||
0206e6
|
||||
family: 6 (0x06)
|
||||
model: 46 (0x2e)
|
||||
stepping: 6 (0x06)
|
4
tests/cputestdata/x86_64-cpuid-Xeon-Gold-5115.sig
Normal file
4
tests/cputestdata/x86_64-cpuid-Xeon-Gold-5115.sig
Normal file
@ -0,0 +1,4 @@
|
||||
050654
|
||||
family: 6 (0x06)
|
||||
model: 85 (0x55)
|
||||
stepping: 4 (0x04)
|
4
tests/cputestdata/x86_64-cpuid-Xeon-Gold-6148.sig
Normal file
4
tests/cputestdata/x86_64-cpuid-Xeon-Gold-6148.sig
Normal file
@ -0,0 +1,4 @@
|
||||
050654
|
||||
family: 6 (0x06)
|
||||
model: 85 (0x55)
|
||||
stepping: 4 (0x04)
|
4
tests/cputestdata/x86_64-cpuid-Xeon-W3520.sig
Normal file
4
tests/cputestdata/x86_64-cpuid-Xeon-W3520.sig
Normal file
@ -0,0 +1,4 @@
|
||||
0106a5
|
||||
family: 6 (0x06)
|
||||
model: 26 (0x1a)
|
||||
stepping: 5 (0x05)
|
4
tests/cputestdata/x86_64-cpuid-Xeon-X5460.sig
Normal file
4
tests/cputestdata/x86_64-cpuid-Xeon-X5460.sig
Normal file
@ -0,0 +1,4 @@
|
||||
010676
|
||||
family: 6 (0x06)
|
||||
model: 23 (0x17)
|
||||
stepping: 6 (0x06)
|
Loading…
Reference in New Issue
Block a user