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:
Jiri Denemark 2019-02-25 10:05:34 +01:00
parent 61be05a00f
commit dd08d27fc2
51 changed files with 286 additions and 0 deletions

View File

@ -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, \

View File

@ -0,0 +1,4 @@
610f01
family: 21 (0x15)
model: 16 (0x10)
stepping: 1 (0x01)

View File

@ -0,0 +1,4 @@
0106ca
family: 6 (0x06)
model: 28 (0x1c)
stepping: 10 (0x0a)

View File

@ -0,0 +1,4 @@
0106ca
family: 6 (0x06)
model: 28 (0x1c)
stepping: 10 (0x0a)

View File

@ -0,0 +1,4 @@
0206a7
family: 6 (0x06)
model: 42 (0x2a)
stepping: 7 (0x07)

View File

@ -0,0 +1,4 @@
0206a7
family: 6 (0x06)
model: 42 (0x2a)
stepping: 7 (0x07)

View File

@ -0,0 +1,4 @@
0306c3
family: 6 (0x06)
model: 60 (0x3c)
stepping: 3 (0x03)

View File

@ -0,0 +1,4 @@
020652
family: 6 (0x06)
model: 37 (0x25)
stepping: 2 (0x02)

View File

@ -0,0 +1,4 @@
0506e3
family: 6 (0x06)
model: 94 (0x5e)
stepping: 3 (0x03)

View File

@ -0,0 +1,4 @@
0206a7
family: 6 (0x06)
model: 42 (0x2a)
stepping: 7 (0x07)

View File

@ -0,0 +1,4 @@
0206a7
family: 6 (0x06)
model: 42 (0x2a)
stepping: 7 (0x07)

View File

@ -0,0 +1,4 @@
0306a9
family: 6 (0x06)
model: 58 (0x3a)
stepping: 9 (0x09)

View File

@ -0,0 +1,4 @@
0306a9
family: 6 (0x06)
model: 58 (0x3a)
stepping: 9 (0x09)

View File

@ -0,0 +1,4 @@
0306a9
family: 6 (0x06)
model: 58 (0x3a)
stepping: 9 (0x09)

View File

@ -0,0 +1,4 @@
040651
family: 6 (0x06)
model: 69 (0x45)
stepping: 1 (0x01)

View File

@ -0,0 +1,4 @@
040651
family: 6 (0x06)
model: 69 (0x45)
stepping: 1 (0x01)

View File

@ -0,0 +1,4 @@
0306d4
family: 6 (0x06)
model: 61 (0x3d)
stepping: 4 (0x04)

View File

@ -0,0 +1,4 @@
0306d4
family: 6 (0x06)
model: 61 (0x3d)
stepping: 4 (0x04)

View File

@ -0,0 +1,4 @@
0306d4
family: 6 (0x06)
model: 61 (0x3d)
stepping: 4 (0x04)

View File

@ -0,0 +1,4 @@
0806e9
family: 6 (0x06)
model: 142 (0x8e)
stepping: 9 (0x09)

View File

@ -0,0 +1,4 @@
0906e9
family: 6 (0x06)
model: 158 (0x9e)
stepping: 9 (0x09)

View File

@ -0,0 +1,4 @@
0906ea
family: 6 (0x06)
model: 158 (0x9e)
stepping: 10 (0x0a)

View File

@ -0,0 +1,4 @@
0006fb
family: 6 (0x06)
model: 15 (0x0f)
stepping: 11 (0x0b)

View File

@ -0,0 +1,4 @@
01067a
family: 6 (0x06)
model: 23 (0x17)
stepping: 10 (0x0a)

View File

@ -0,0 +1,4 @@
800f12
family: 23 (0x17)
model: 1 (0x01)
stepping: 2 (0x02)

View File

@ -0,0 +1,4 @@
800f12
family: 23 (0x17)
model: 1 (0x01)
stepping: 2 (0x02)

View File

@ -0,0 +1,4 @@
600f12
family: 21 (0x15)
model: 1 (0x01)
stepping: 2 (0x02)

View File

@ -0,0 +1,4 @@
100f23
family: 16 (0x10)
model: 2 (0x02)
stepping: 3 (0x03)

View File

@ -0,0 +1,4 @@
100f23
family: 16 (0x10)
model: 2 (0x02)
stepping: 3 (0x03)

View File

@ -0,0 +1,4 @@
600f12
family: 21 (0x15)
model: 1 (0x01)
stepping: 2 (0x02)

View File

@ -0,0 +1,4 @@
600f12
family: 21 (0x15)
model: 1 (0x01)
stepping: 2 (0x02)

View File

@ -0,0 +1,4 @@
020655
family: 6 (0x06)
model: 37 (0x25)
stepping: 5 (0x05)

View File

@ -0,0 +1,4 @@
100f42
family: 16 (0x10)
model: 4 (0x04)
stepping: 2 (0x02)

View File

@ -0,0 +1,4 @@
800f11
family: 23 (0x17)
model: 1 (0x01)
stepping: 1 (0x01)

View File

@ -0,0 +1,4 @@
0006f6
family: 6 (0x06)
model: 15 (0x0f)
stepping: 6 (0x06)

View File

@ -0,0 +1,4 @@
0506e3
family: 6 (0x06)
model: 94 (0x5e)
stepping: 3 (0x03)

View File

@ -0,0 +1,4 @@
0306f2
family: 6 (0x06)
model: 63 (0x3f)
stepping: 2 (0x02)

View File

@ -0,0 +1,4 @@
0406f1
family: 6 (0x06)
model: 79 (0x4f)
stepping: 1 (0x01)

View File

@ -0,0 +1,4 @@
0306f2
family: 6 (0x06)
model: 63 (0x3f)
stepping: 2 (0x02)

View File

@ -0,0 +1,4 @@
0406f1
family: 6 (0x06)
model: 79 (0x4f)
stepping: 1 (0x01)

View File

@ -0,0 +1,4 @@
0306f2
family: 6 (0x06)
model: 63 (0x3f)
stepping: 2 (0x02)

View File

@ -0,0 +1,4 @@
0406f1
family: 6 (0x06)
model: 79 (0x4f)
stepping: 1 (0x01)

View File

@ -0,0 +1,4 @@
0206d7
family: 6 (0x06)
model: 45 (0x2d)
stepping: 7 (0x07)

View File

@ -0,0 +1,4 @@
0206f2
family: 6 (0x06)
model: 47 (0x2f)
stepping: 2 (0x02)

View File

@ -0,0 +1,4 @@
0206f2
family: 6 (0x06)
model: 47 (0x2f)
stepping: 2 (0x02)

View File

@ -0,0 +1,4 @@
0306f4
family: 6 (0x06)
model: 63 (0x3f)
stepping: 4 (0x04)

View File

@ -0,0 +1,4 @@
0206e6
family: 6 (0x06)
model: 46 (0x2e)
stepping: 6 (0x06)

View File

@ -0,0 +1,4 @@
050654
family: 6 (0x06)
model: 85 (0x55)
stepping: 4 (0x04)

View File

@ -0,0 +1,4 @@
050654
family: 6 (0x06)
model: 85 (0x55)
stepping: 4 (0x04)

View File

@ -0,0 +1,4 @@
0106a5
family: 6 (0x06)
model: 26 (0x1a)
stepping: 5 (0x05)

View File

@ -0,0 +1,4 @@
010676
family: 6 (0x06)
model: 23 (0x17)
stepping: 6 (0x06)