[PATCH 2/2] tests: Add unit tests for internal CPU APIs

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

 



---
 tests/Makefile.am                                  |   12 +-
 tests/cputest.c                                    |  610 ++++++++++++++++++++
 tests/cputestdata/x86-baseline-1-result.xml        |    5 +
 tests/cputestdata/x86-baseline-1.xml               |   20 +
 tests/cputestdata/x86-baseline-2-result.xml        |    4 +
 tests/cputestdata/x86-baseline-2.xml               |   22 +
 .../x86-baseline-incompatible-vendors.xml          |   14 +
 .../cputestdata/x86-baseline-no-vendor-result.xml  |    5 +
 tests/cputestdata/x86-baseline-no-vendor.xml       |   12 +
 .../x86-baseline-some-vendors-result.xml           |    3 +
 tests/cputestdata/x86-baseline-some-vendors.xml    |   13 +
 tests/cputestdata/x86-bogus-feature.xml            |    4 +
 tests/cputestdata/x86-bogus-model.xml              |    3 +
 tests/cputestdata/x86-bogus-vendor.xml             |    4 +
 tests/cputestdata/x86-exact-disable-extra.xml      |    4 +
 tests/cputestdata/x86-exact-disable.xml            |    4 +
 tests/cputestdata/x86-exact-disable2.xml           |    5 +
 tests/cputestdata/x86-exact-forbid-extra.xml       |    4 +
 tests/cputestdata/x86-exact-forbid.xml             |    4 +
 tests/cputestdata/x86-exact-force.xml              |    4 +
 tests/cputestdata/x86-exact-require-extra.xml      |    4 +
 tests/cputestdata/x86-exact-require.xml            |    4 +
 tests/cputestdata/x86-exact.xml                    |    3 +
 tests/cputestdata/x86-guest.xml                    |   18 +
 .../cputestdata/x86-host+guest,model486-result.xml |   37 ++
 .../x86-host+guest,models,Penryn-result.xml        |   13 +
 .../x86-host+guest,models,qemu64-result.xml        |   14 +
 tests/cputestdata/x86-host+guest,models-result.xml |   13 +
 tests/cputestdata/x86-host+guest-result.xml        |   11 +
 tests/cputestdata/x86-host+guest.xml               |   17 +
 tests/cputestdata/x86-host+min.xml                 |   17 +
 .../cputestdata/x86-host+nehalem-force-result.xml  |    4 +
 tests/cputestdata/x86-host+pentium3.xml            |   27 +
 .../x86-host+strict-force-extra-result.xml         |   19 +
 tests/cputestdata/x86-host-amd-fake.xml            |   20 +
 tests/cputestdata/x86-host-amd.xml                 |   18 +
 .../x86-host-better+pentium3,core2duo-result.xml   |   21 +
 .../x86-host-better+pentium3,pentium3-result.xml   |   30 +
 .../x86-host-better+pentium3-result.xml            |   18 +
 tests/cputestdata/x86-host-better.xml              |   20 +
 tests/cputestdata/x86-host-incomp-arch.xml         |    6 +
 tests/cputestdata/x86-host-no-vendor.xml           |   19 +
 tests/cputestdata/x86-host-worse+guest-result.xml  |    9 +
 tests/cputestdata/x86-host-worse.xml               |    6 +
 tests/cputestdata/x86-host.xml                     |   20 +
 tests/cputestdata/x86-min.xml                      |    3 +
 tests/cputestdata/x86-nehalem-force.xml            |    6 +
 tests/cputestdata/x86-pentium3-amd.xml             |    4 +
 tests/cputestdata/x86-pentium3.xml                 |    3 +
 tests/cputestdata/x86-strict-disable.xml           |   18 +
 tests/cputestdata/x86-strict-force-extra.xml       |   18 +
 tests/cputestdata/x86-strict-full.xml              |   17 +
 tests/cputestdata/x86-strict.xml                   |    3 +
 53 files changed, 1215 insertions(+), 1 deletions(-)
 create mode 100644 tests/cputest.c
 create mode 100644 tests/cputestdata/x86-baseline-1-result.xml
 create mode 100644 tests/cputestdata/x86-baseline-1.xml
 create mode 100644 tests/cputestdata/x86-baseline-2-result.xml
 create mode 100644 tests/cputestdata/x86-baseline-2.xml
 create mode 100644 tests/cputestdata/x86-baseline-incompatible-vendors.xml
 create mode 100644 tests/cputestdata/x86-baseline-no-vendor-result.xml
 create mode 100644 tests/cputestdata/x86-baseline-no-vendor.xml
 create mode 100644 tests/cputestdata/x86-baseline-some-vendors-result.xml
 create mode 100644 tests/cputestdata/x86-baseline-some-vendors.xml
 create mode 100644 tests/cputestdata/x86-bogus-feature.xml
 create mode 100644 tests/cputestdata/x86-bogus-model.xml
 create mode 100644 tests/cputestdata/x86-bogus-vendor.xml
 create mode 100644 tests/cputestdata/x86-exact-disable-extra.xml
 create mode 100644 tests/cputestdata/x86-exact-disable.xml
 create mode 100644 tests/cputestdata/x86-exact-disable2.xml
 create mode 100644 tests/cputestdata/x86-exact-forbid-extra.xml
 create mode 100644 tests/cputestdata/x86-exact-forbid.xml
 create mode 100644 tests/cputestdata/x86-exact-force.xml
 create mode 100644 tests/cputestdata/x86-exact-require-extra.xml
 create mode 100644 tests/cputestdata/x86-exact-require.xml
 create mode 100644 tests/cputestdata/x86-exact.xml
 create mode 100644 tests/cputestdata/x86-guest.xml
 create mode 100644 tests/cputestdata/x86-host+guest,model486-result.xml
 create mode 100644 tests/cputestdata/x86-host+guest,models,Penryn-result.xml
 create mode 100644 tests/cputestdata/x86-host+guest,models,qemu64-result.xml
 create mode 100644 tests/cputestdata/x86-host+guest,models-result.xml
 create mode 100644 tests/cputestdata/x86-host+guest-result.xml
 create mode 100644 tests/cputestdata/x86-host+guest.xml
 create mode 100644 tests/cputestdata/x86-host+min.xml
 create mode 100644 tests/cputestdata/x86-host+nehalem-force-result.xml
 create mode 100644 tests/cputestdata/x86-host+pentium3.xml
 create mode 100644 tests/cputestdata/x86-host+strict-force-extra-result.xml
 create mode 100644 tests/cputestdata/x86-host-amd-fake.xml
 create mode 100644 tests/cputestdata/x86-host-amd.xml
 create mode 100644 tests/cputestdata/x86-host-better+pentium3,core2duo-result.xml
 create mode 100644 tests/cputestdata/x86-host-better+pentium3,pentium3-result.xml
 create mode 100644 tests/cputestdata/x86-host-better+pentium3-result.xml
 create mode 100644 tests/cputestdata/x86-host-better.xml
 create mode 100644 tests/cputestdata/x86-host-incomp-arch.xml
 create mode 100644 tests/cputestdata/x86-host-no-vendor.xml
 create mode 100644 tests/cputestdata/x86-host-worse+guest-result.xml
 create mode 100644 tests/cputestdata/x86-host-worse.xml
 create mode 100644 tests/cputestdata/x86-host.xml
 create mode 100644 tests/cputestdata/x86-min.xml
 create mode 100644 tests/cputestdata/x86-nehalem-force.xml
 create mode 100644 tests/cputestdata/x86-pentium3-amd.xml
 create mode 100644 tests/cputestdata/x86-pentium3.xml
 create mode 100644 tests/cputestdata/x86-strict-disable.xml
 create mode 100644 tests/cputestdata/x86-strict-force-extra.xml
 create mode 100644 tests/cputestdata/x86-strict-full.xml
 create mode 100644 tests/cputestdata/x86-strict.xml

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 77b6fb9..021670e 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -69,7 +69,8 @@ EXTRA_DIST =		\
 	domainsnapshotschematest \
 	domainsnapshotxml2xmlout \
 	domainsnapshotxml2xmlin \
-	qemuhelpdata
+	qemuhelpdata \
+	cputestdata
 
 check_PROGRAMS = virshtest conftest sockettest \
         nodeinfotest qparamtest virbuftest
@@ -111,6 +112,8 @@ check_PROGRAMS += nodedevxml2xmltest
 
 check_PROGRAMS += interfacexml2xmltest
 
+check_PROGRAMS += cputest
+
 test_scripts = \
 	capabilityschematest \
 	interfaceschematest \
@@ -196,6 +199,8 @@ TESTS += nodedevxml2xmltest
 
 TESTS += interfacexml2xmltest
 
+TESTS += cputest
+
 path_add = $$abs_top_builddir/src$(PATH_SEPARATOR)$$abs_top_builddir/daemon$(PATH_SEPARATOR)$$abs_top_builddir/tools
 
 # NB, automake < 1.10 does not provide the real
@@ -326,6 +331,11 @@ interfacexml2xmltest_SOURCES = \
 	testutils.c testutils.h
 interfacexml2xmltest_LDADD = $(LDADDS)
 
+cputest_SOURCES = \
+	cputest.c \
+	testutils.c testutils.h
+cputest_LDADD = $(LDADDS)
+
 virshtest_SOURCES = \
 	virshtest.c \
 	testutils.c testutils.h
diff --git a/tests/cputest.c b/tests/cputest.c
new file mode 100644
index 0000000..d9e6dad
--- /dev/null
+++ b/tests/cputest.c
@@ -0,0 +1,610 @@
+#include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+
+#include <sys/types.h>
+#include <fcntl.h>
+
+#include "internal.h"
+#include "xml.h"
+#include "memory.h"
+#include "buf.h"
+#include "testutils.h"
+#include "cpu_conf.h"
+#include "cpu/cpu.h"
+#include "cpu/cpu_map.h"
+
+static const char *progname;
+static const char *abs_srcdir;
+static const char *abs_top_srcdir;
+
+#define VIR_FROM_THIS VIR_FROM_CPU
+#define MAX_FILE 4096
+
+enum compResultShadow {
+    ERROR           = VIR_CPU_COMPARE_ERROR,
+    INCOMPATIBLE    = VIR_CPU_COMPARE_INCOMPATIBLE,
+    IDENTICAL       = VIR_CPU_COMPARE_IDENTICAL,
+    SUPERSET        = VIR_CPU_COMPARE_SUPERSET
+};
+
+enum cpuTestBoolWithError {
+    FAIL    = -1,
+    NO      = 0,
+    YES     = 1
+};
+
+enum api {
+    API_COMPARE,
+    API_GUEST_DATA,
+    API_BASELINE,
+    API_UPDATE,
+    API_HAS_FEATURE
+};
+
+static const char *apis[] = {
+    "compare",
+    "guest data",
+    "baseline",
+    "update",
+    "has feature"
+};
+
+struct data {
+    const char *arch;
+    enum api api;
+    const char *host;
+    const char *name;
+    const char **models;
+    const char *modelsName;
+    unsigned int nmodels;
+    const char *preferred;
+    int result;
+};
+
+
+static virCPUDefPtr
+cpuTestLoadXML(const char *arch, const char *name)
+{
+    char xml[PATH_MAX];
+    xmlDocPtr doc = NULL;
+    xmlXPathContextPtr ctxt = NULL;
+    virCPUDefPtr cpu = NULL;
+
+    snprintf(xml, PATH_MAX,
+             "%s/cputestdata/%s-%s.xml",
+             abs_srcdir, arch, name);
+
+    if (!(doc = virXMLParseFile(xml)) ||
+        !(ctxt = xmlXPathNewContext(doc)))
+        goto cleanup;
+
+    ctxt->node = xmlDocGetRootElement(doc);
+    cpu = virCPUDefParseXML(ctxt->node, ctxt, VIR_CPU_TYPE_AUTO);
+
+cleanup:
+    xmlXPathFreeContext(ctxt);
+    xmlFreeDoc(doc);
+    return cpu;
+}
+
+
+static virCPUDefPtr *
+cpuTestLoadMultiXML(const char *arch,
+                    const char *name,
+                    unsigned int *count)
+{
+    char xml[PATH_MAX];
+    xmlDocPtr doc = NULL;
+    xmlXPathContextPtr ctxt = NULL;
+    xmlNodePtr *nodes = NULL;
+    virCPUDefPtr *cpus = NULL;
+    int n;
+    int i;
+
+    snprintf(xml, PATH_MAX,
+             "%s/cputestdata/%s-%s.xml",
+             abs_srcdir, arch, name);
+
+    if (!(doc = virXMLParseFile(xml)) ||
+        !(ctxt = xmlXPathNewContext(doc)))
+        goto error;
+
+    ctxt->node = xmlDocGetRootElement(doc);
+
+    n = virXPathNodeSet("/cpuTest/cpu", ctxt, &nodes);
+    if (n <= 0 || !(cpus = calloc(n, sizeof(virCPUDefPtr))))
+        goto error;
+
+    for (i = 0; i < n; i++) {
+        ctxt->node = nodes[i];
+        cpus[i] = virCPUDefParseXML(nodes[i], ctxt, VIR_CPU_TYPE_HOST);
+        if (!cpus[i])
+            goto error;
+    }
+
+    *count = n;
+
+cleanup:
+    free(nodes);
+    xmlXPathFreeContext(ctxt);
+    xmlFreeDoc(doc);
+    return cpus;
+
+error:
+    if (cpus) {
+        for (i = 0; i < n; i++)
+            virCPUDefFree(cpus[i]);
+        free(cpus);
+        cpus = NULL;
+    }
+    goto cleanup;
+}
+
+
+static int
+cpuTestCompareXML(const char *arch,
+                  const virCPUDefPtr cpu,
+                  const char *name)
+{
+    char xml[PATH_MAX];
+    char expected[MAX_FILE];
+    char *expectedPtr = &(expected[0]);
+    char *actual = NULL;
+    int ret = -1;
+
+    snprintf(xml, PATH_MAX,
+             "%s/cputestdata/%s-%s.xml",
+             abs_srcdir, arch, name);
+
+    if (virtTestLoadFile(xml, &expectedPtr, MAX_FILE) < 0)
+        goto cleanup;
+
+    if (!(actual = virCPUDefFormat(cpu, NULL, 0)))
+        goto cleanup;
+
+    if (STRNEQ(expected, actual)) {
+        virtTestDifference(stderr, expected, actual);
+        goto cleanup;
+    }
+
+    ret = 0;
+
+cleanup:
+    free(actual);
+    return ret;
+}
+
+
+static const char *
+cpuTestCompResStr(virCPUCompareResult result)
+{
+    switch (result) {
+    case VIR_CPU_COMPARE_ERROR:         return "ERROR";
+    case VIR_CPU_COMPARE_INCOMPATIBLE:  return "INCOMPATIBLE";
+    case VIR_CPU_COMPARE_IDENTICAL:     return "IDENTICAL";
+    case VIR_CPU_COMPARE_SUPERSET:      return "SUPERSET";
+    }
+
+    return "unknown";
+}
+
+
+static const char *
+cpuTestBoolWithErrorStr(enum cpuTestBoolWithError result)
+{
+    switch (result) {
+    case FAIL:  return "FAIL";
+    case NO:    return "NO";
+    case YES:   return "YES";
+    }
+
+    return "unknown";
+}
+
+
+static int
+cpuTestCompare(const void *arg)
+{
+    const struct data *data = arg;
+    int ret = -1;
+    virCPUDefPtr host = NULL;
+    virCPUDefPtr cpu = NULL;
+    virCPUCompareResult result;
+
+    if (!(host = cpuTestLoadXML(data->arch, data->host)) ||
+        !(cpu = cpuTestLoadXML(data->arch, data->name)))
+        goto cleanup;
+
+    result = cpuCompare(host, cpu);
+    if (data->result == VIR_CPU_COMPARE_ERROR)
+        virResetLastError();
+
+    if (data->result != result) {
+        if (virTestGetVerbose()) {
+            fprintf(stderr, "\nExpected result %s, got %s\n",
+                    cpuTestCompResStr(data->result),
+                    cpuTestCompResStr(result));
+            /* Pad to line up with test name ... in virTestRun */
+            fprintf(stderr, "%74s", "... ");
+        }
+        goto cleanup;
+    }
+
+    ret = 0;
+
+cleanup:
+    virCPUDefFree(host);
+    virCPUDefFree(cpu);
+    return ret;
+}
+
+
+static int
+cpuTestGuestData(const void *arg)
+{
+    const struct data *data = arg;
+    int ret = -1;
+    virCPUDefPtr host = NULL;
+    virCPUDefPtr cpu = NULL;
+    virCPUDefPtr guest = NULL;
+    union cpuData *guestData = NULL;
+    virCPUCompareResult cmpResult;
+    virBuffer buf = VIR_BUFFER_INITIALIZER;
+    char *result = NULL;
+
+    if (!(host = cpuTestLoadXML(data->arch, data->host)) ||
+        !(cpu = cpuTestLoadXML(data->arch, data->name)))
+        goto cleanup;
+
+    cmpResult = cpuGuestData(host, cpu, &guestData);
+    if (cmpResult == VIR_CPU_COMPARE_ERROR ||
+        cmpResult == VIR_CPU_COMPARE_INCOMPATIBLE)
+        goto cleanup;
+
+    if (VIR_ALLOC(guest) < 0 || !(guest->arch = strdup(host->arch)))
+        goto cleanup;
+
+    guest->type = VIR_CPU_TYPE_GUEST;
+    guest->match = VIR_CPU_MATCH_EXACT;
+    if (cpuDecode(guest, guestData, data->models,
+                  data->nmodels, data->preferred) < 0) {
+        if (data->result < 0) {
+            virResetLastError();
+            ret = 0;
+        }
+        goto cleanup;
+    }
+
+    virBufferVSprintf(&buf, "%s+%s", data->host, data->name);
+    if (data->nmodels)
+        virBufferVSprintf(&buf, ",%s", data->modelsName);
+    if (data->preferred)
+        virBufferVSprintf(&buf, ",%s", data->preferred);
+    virBufferAddLit(&buf, "-result");
+
+    if (virBufferError(&buf)) {
+        virBufferFreeAndReset(&buf);
+        goto cleanup;
+    }
+    result = virBufferContentAndReset(&buf);
+
+    ret = cpuTestCompareXML(data->arch, guest, result);
+
+cleanup:
+    VIR_FREE(result);
+    cpuDataFree(host->arch, guestData);
+    virCPUDefFree(host);
+    virCPUDefFree(cpu);
+    virCPUDefFree(guest);
+    return ret;
+}
+
+
+static int
+cpuTestBaseline(const void *arg)
+{
+    const struct data *data = arg;
+    int ret = -1;
+    virCPUDefPtr *cpus = NULL;
+    virCPUDefPtr baseline = NULL;
+    unsigned int ncpus = 0;
+    char result[PATH_MAX];
+    unsigned int i;
+
+    if (!(cpus = cpuTestLoadMultiXML(data->arch, data->name, &ncpus)))
+        goto cleanup;
+
+    baseline = cpuBaseline(cpus, ncpus, NULL, 0);
+    if (data->result < 0) {
+        virResetLastError();
+        if (!baseline)
+            ret = 0;
+        else if (virTestGetVerbose()) {
+            fprintf(stderr, "\n%-70s... ",
+                    "cpuBaseline was expected to fail but it succeeded");
+        }
+        goto cleanup;
+    }
+    if (!baseline)
+        goto cleanup;
+
+    snprintf(result, PATH_MAX, "%s-result", data->name);
+    if (cpuTestCompareXML(data->arch, baseline, result) < 0)
+        goto cleanup;
+
+    for (i = 0; i < ncpus; i++) {
+        virCPUCompareResult cmp;
+
+        cmp = cpuCompare(cpus[i], baseline);
+        if (cmp != VIR_CPU_COMPARE_SUPERSET &&
+            cmp != VIR_CPU_COMPARE_IDENTICAL) {
+            if (virTestGetVerbose()) {
+                fprintf(stderr,
+                        "\nbaseline CPU is incompatible with CPU %u\n", i);
+                fprintf(stderr, "%74s", "... ");
+            }
+            ret = -1;
+            goto cleanup;
+        }
+    }
+
+    ret = 0;
+
+cleanup:
+    if (cpus) {
+        for (i = 0; i < ncpus; i++)
+            virCPUDefFree(cpus[i]);
+        free(cpus);
+    }
+    virCPUDefFree(baseline);
+    return ret;
+}
+
+
+static int
+cpuTestUpdate(const void *arg)
+{
+    const struct data *data = arg;
+    int ret = -1;
+    virCPUDefPtr host = NULL;
+    virCPUDefPtr cpu = NULL;
+    char result[PATH_MAX];
+
+    if (!(host = cpuTestLoadXML(data->arch, data->host)) ||
+        !(cpu = cpuTestLoadXML(data->arch, data->name)))
+        goto cleanup;
+
+    if (cpuUpdate(cpu, host) < 0)
+        goto cleanup;
+
+    snprintf(result, PATH_MAX, "%s+%s", data->host, data->name);
+    ret = cpuTestCompareXML(data->arch, cpu, result);
+
+cleanup:
+    virCPUDefFree(host);
+    virCPUDefFree(cpu);
+    return ret;
+}
+
+
+static int
+cpuTestHasFeature(const void *arg)
+{
+    const struct data *data = arg;
+    int ret = -1;
+    virCPUDefPtr host = NULL;
+    union cpuData *hostData = NULL;
+    int result;
+
+    if (!(host = cpuTestLoadXML(data->arch, data->host)))
+        goto cleanup;
+
+    if (cpuEncode(host->arch, host, NULL, &hostData,
+                  NULL, NULL, NULL, NULL) < 0)
+        goto cleanup;
+
+    result = cpuHasFeature(host->arch, hostData, data->name);
+    if (data->result == -1)
+        virResetLastError();
+
+    if (data->result != result) {
+        if (virTestGetVerbose()) {
+            fprintf(stderr, "\nExpected result %s, got %s\n",
+                    cpuTestBoolWithErrorStr(data->result),
+                    cpuTestBoolWithErrorStr(result));
+            /* Pad to line up with test name ... in virTestRun */
+            fprintf(stderr, "%74s", "... ");
+        }
+        goto cleanup;
+    }
+
+    ret = 0;
+
+cleanup:
+    if (host)
+        cpuDataFree(host->arch, hostData);
+    virCPUDefFree(host);
+    return ret;
+}
+
+
+static int (*cpuTest[])(const void *) = {
+    cpuTestCompare,
+    cpuTestGuestData,
+    cpuTestBaseline,
+    cpuTestUpdate,
+    cpuTestHasFeature
+};
+
+
+static int
+cpuTestRun(const char *name, const struct data *data)
+{
+    char label[PATH_MAX];
+
+    snprintf(label, PATH_MAX, "CPU %s(%s): %s",
+             apis[data->api], data->arch, name);
+
+    free(virtTestLogContentAndReset());
+
+    if (virtTestRun(label, 1, cpuTest[data->api], data) < 0) {
+        if (virTestGetDebug()) {
+            char *log;
+            if ((log = virtTestLogContentAndReset()) &&
+                 strlen(log) > 0)
+                fprintf(stderr, "\n%s\n", log);
+            free(log);
+        }
+        return -1;
+    }
+
+    return 0;
+}
+
+
+static const char *model486[]   = { "486" };
+static const char *nomodel[]    = { "nomodel" };
+static const char *models[]     = { "qemu64", "core2duo", "Nehalem" };
+
+static int
+mymain(int argc, char **argv)
+{
+    int ret = 0;
+    char cwd[PATH_MAX];
+    char map[PATH_MAX];
+
+    progname = argv[0];
+
+    if (argc > 1) {
+        fprintf(stderr, "Usage: %s\n", progname);
+        return EXIT_FAILURE;
+    }
+
+    abs_srcdir = getenv("abs_srcdir");
+    if (!abs_srcdir)
+        abs_srcdir = getcwd(cwd, sizeof(cwd));
+
+    abs_top_srcdir = getenv("abs_top_srcdir");
+    if (!abs_top_srcdir)
+        abs_top_srcdir = "..";
+
+    snprintf(map, PATH_MAX, "%s/src/cpu/cpu_map.xml", abs_top_srcdir);
+    if (cpuMapOverride(map) < 0)
+        return EXIT_FAILURE;
+
+#define DO_TEST(arch, api, name, host, cpu,                             \
+                models, nmodels, preferred, result)                     \
+    do {                                                                \
+        struct data data = {                                            \
+            arch, api, host, cpu, models,                               \
+            models == NULL ? NULL : #models,                            \
+            nmodels, preferred, result    \
+        };                                                              \
+        if (cpuTestRun(name, &data) < 0)                                \
+            ret = -1;                                                   \
+    } while (0)
+
+#define DO_TEST_COMPARE(arch, host, cpu, result)                        \
+    DO_TEST(arch, API_COMPARE,                                          \
+            host "/" cpu " (" #result ")",                              \
+            host, cpu, NULL, 0, NULL, result)
+
+#define DO_TEST_UPDATE(arch, host, cpu, result)                         \
+    do {                                                                \
+        DO_TEST(arch, API_UPDATE,                                       \
+                cpu " on " host,                                        \
+                host, cpu, NULL, 0, NULL, 0);                           \
+        DO_TEST_COMPARE(arch, host, host "+" cpu, result);              \
+    } while (0)
+
+#define DO_TEST_BASELINE(arch, name, result)                            \
+    DO_TEST(arch, API_BASELINE, name, NULL, "baseline-" name,           \
+            NULL, 0, NULL, result)
+
+#define DO_TEST_HASFEATURE(arch, host, feature, result)                 \
+    DO_TEST(arch, API_HAS_FEATURE,                                      \
+            host "/" feature " (" #result ")",                          \
+            host, feature, NULL, 0, NULL, result)
+
+#define DO_TEST_GUESTDATA(arch, host, cpu, models, preferred, result)   \
+    DO_TEST(arch, API_GUEST_DATA,                                       \
+            host "/" cpu " (" #models ", pref=" #preferred ")",         \
+            host, cpu, models,                                          \
+            models == NULL ? 0 : sizeof(models) / sizeof(char *),       \
+            preferred, result)
+
+    /* host to host comparison */
+    DO_TEST_COMPARE("x86", "host", "host", IDENTICAL);
+    DO_TEST_COMPARE("x86", "host", "host-better", INCOMPATIBLE);
+    DO_TEST_COMPARE("x86", "host", "host-worse", SUPERSET);
+    DO_TEST_COMPARE("x86", "host", "host-amd-fake", INCOMPATIBLE);
+    DO_TEST_COMPARE("x86", "host", "host-incomp-arch", INCOMPATIBLE);
+    DO_TEST_COMPARE("x86", "host", "host-no-vendor", IDENTICAL);
+    DO_TEST_COMPARE("x86", "host-no-vendor", "host", INCOMPATIBLE);
+
+    /* guest to host comparison */
+    DO_TEST_COMPARE("x86", "host", "bogus-model", ERROR);
+    DO_TEST_COMPARE("x86", "host", "bogus-feature", ERROR);
+    DO_TEST_COMPARE("x86", "host", "min", SUPERSET);
+    DO_TEST_COMPARE("x86", "host", "pentium3", SUPERSET);
+    DO_TEST_COMPARE("x86", "host", "exact", SUPERSET);
+    DO_TEST_COMPARE("x86", "host", "exact-forbid", INCOMPATIBLE);
+    DO_TEST_COMPARE("x86", "host", "exact-forbid-extra", SUPERSET);
+    DO_TEST_COMPARE("x86", "host", "exact-disable", SUPERSET);
+    DO_TEST_COMPARE("x86", "host", "exact-disable2", SUPERSET);
+    DO_TEST_COMPARE("x86", "host", "exact-disable-extra", SUPERSET);
+    DO_TEST_COMPARE("x86", "host", "exact-require", SUPERSET);
+    DO_TEST_COMPARE("x86", "host", "exact-require-extra", INCOMPATIBLE);
+    DO_TEST_COMPARE("x86", "host", "exact-force", SUPERSET);
+    DO_TEST_COMPARE("x86", "host", "strict", INCOMPATIBLE);
+    DO_TEST_COMPARE("x86", "host", "strict-full", IDENTICAL);
+    DO_TEST_COMPARE("x86", "host", "strict-disable", IDENTICAL);
+    DO_TEST_COMPARE("x86", "host", "strict-force-extra", IDENTICAL);
+    DO_TEST_COMPARE("x86", "host", "guest", SUPERSET);
+    DO_TEST_COMPARE("x86", "host", "pentium3-amd", INCOMPATIBLE);
+    DO_TEST_COMPARE("x86", "host-amd", "pentium3-amd", SUPERSET);
+    DO_TEST_COMPARE("x86", "host-worse", "nehalem-force", IDENTICAL);
+
+    /* guest updates for migration
+     * automatically compares host CPU with the result */
+    DO_TEST_UPDATE("x86", "host", "min", IDENTICAL);
+    DO_TEST_UPDATE("x86", "host", "pentium3", IDENTICAL);
+    DO_TEST_UPDATE("x86", "host", "guest", SUPERSET);
+
+    /* computing baseline CPUs */
+    DO_TEST_BASELINE("x86", "incompatible-vendors", -1);
+    DO_TEST_BASELINE("x86", "no-vendor", 0);
+    DO_TEST_BASELINE("x86", "some-vendors", 0);
+    DO_TEST_BASELINE("x86", "1", 0);
+    DO_TEST_BASELINE("x86", "2", 0);
+
+    /* CPU features */
+    DO_TEST_HASFEATURE("x86", "host", "vmx", YES);
+    DO_TEST_HASFEATURE("x86", "host", "lm", YES);
+    DO_TEST_HASFEATURE("x86", "host", "sse4.1", YES);
+    DO_TEST_HASFEATURE("x86", "host", "3dnowext", NO);
+    DO_TEST_HASFEATURE("x86", "host", "skinit", NO);
+    DO_TEST_HASFEATURE("x86", "host", "foo", FAIL);
+
+    /* computing guest data and decoding the data into a guest CPU XML */
+    DO_TEST_GUESTDATA("x86", "host", "guest", NULL, NULL, 0);
+    DO_TEST_GUESTDATA("x86", "host-better", "pentium3", NULL, NULL, 0);
+    DO_TEST_GUESTDATA("x86", "host-better", "pentium3", NULL, "pentium3", 0);
+    DO_TEST_GUESTDATA("x86", "host-better", "pentium3", NULL, "core2duo", 0);
+    DO_TEST_GUESTDATA("x86", "host-worse", "guest", NULL, NULL, 0);
+    DO_TEST_GUESTDATA("x86", "host", "strict-force-extra", NULL, NULL, 0);
+    DO_TEST_GUESTDATA("x86", "host", "nehalem-force", NULL, NULL, 0);
+    DO_TEST_GUESTDATA("x86", "host", "guest", model486, NULL, 0);
+    DO_TEST_GUESTDATA("x86", "host", "guest", models, NULL, 0);
+    DO_TEST_GUESTDATA("x86", "host", "guest", models, "Penryn", 0);
+    DO_TEST_GUESTDATA("x86", "host", "guest", models, "qemu64", 0);
+    DO_TEST_GUESTDATA("x86", "host", "guest", nomodel, NULL, -1);
+
+    return (ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+
+VIRT_TEST_MAIN(mymain)
diff --git a/tests/cputestdata/x86-baseline-1-result.xml b/tests/cputestdata/x86-baseline-1-result.xml
new file mode 100644
index 0000000..e376f74
--- /dev/null
+++ b/tests/cputestdata/x86-baseline-1-result.xml
@@ -0,0 +1,5 @@
+<cpu match='exact'>
+  <model>Conroe</model>
+  <vendor>Intel</vendor>
+  <feature policy='disable' name='lahf_lm'/>
+</cpu>
diff --git a/tests/cputestdata/x86-baseline-1.xml b/tests/cputestdata/x86-baseline-1.xml
new file mode 100644
index 0000000..509e6a8
--- /dev/null
+++ b/tests/cputestdata/x86-baseline-1.xml
@@ -0,0 +1,20 @@
+<cpuTest>
+<cpu>
+  <arch>x86_64</arch>
+  <model>Penryn</model>
+  <vendor>Intel</vendor>
+  <topology sockets='2' cores='4' threads='1'/>
+</cpu>
+<cpu>
+  <arch>x86_64</arch>
+  <model>Conroe</model>
+  <vendor>Intel</vendor>
+  <topology sockets='1' cores='1' threads='1'/>
+</cpu>
+<cpu>
+  <arch>x86_64</arch>
+  <model>core2duo</model>
+  <vendor>Intel</vendor>
+  <topology sockets='1' cores='1' threads='1'/>
+</cpu>
+</cpuTest>
diff --git a/tests/cputestdata/x86-baseline-2-result.xml b/tests/cputestdata/x86-baseline-2-result.xml
new file mode 100644
index 0000000..3fd0551
--- /dev/null
+++ b/tests/cputestdata/x86-baseline-2-result.xml
@@ -0,0 +1,4 @@
+<cpu match='exact'>
+  <model>core2duo</model>
+  <feature policy='disable' name='nx'/>
+</cpu>
diff --git a/tests/cputestdata/x86-baseline-2.xml b/tests/cputestdata/x86-baseline-2.xml
new file mode 100644
index 0000000..055223f
--- /dev/null
+++ b/tests/cputestdata/x86-baseline-2.xml
@@ -0,0 +1,22 @@
+<cpuTest>
+<cpu>
+  <arch>x86_64</arch>
+  <model>core2duo</model>
+  <topology sockets='1' cores='2' threads='1'/>
+</cpu>
+<cpu>
+  <arch>x86_64</arch>
+  <model>pentiumpro</model>
+  <topology sockets='1' cores='2' threads='1'/>
+  <feature name='mtrr'/>
+  <feature name='clflush'/>
+  <feature name='mca'/>
+  <feature name='vme'/>
+  <feature name='pse36'/>
+  <feature name='pni'/>
+  <feature name='monitor'/>
+  <feature name='ssse3'/>
+  <feature name='lm'/>
+  <feature name='syscall'/>
+</cpu>
+</cpuTest>
diff --git a/tests/cputestdata/x86-baseline-incompatible-vendors.xml b/tests/cputestdata/x86-baseline-incompatible-vendors.xml
new file mode 100644
index 0000000..ead1fbf
--- /dev/null
+++ b/tests/cputestdata/x86-baseline-incompatible-vendors.xml
@@ -0,0 +1,14 @@
+<cpuTest>
+<cpu>
+  <arch>x86_64</arch>
+  <model>Penryn</model>
+  <vendor>Intel</vendor>
+  <topology sockets='2' cores='4' threads='1'/>
+</cpu>
+<cpu>
+  <arch>x86_64</arch>
+  <model>Opteron_G3</model>
+  <vendor>AMD</vendor>
+  <topology sockets='1' cores='1' threads='1'/>
+</cpu>
+</cpuTest>
diff --git a/tests/cputestdata/x86-baseline-no-vendor-result.xml b/tests/cputestdata/x86-baseline-no-vendor-result.xml
new file mode 100644
index 0000000..0fc0892
--- /dev/null
+++ b/tests/cputestdata/x86-baseline-no-vendor-result.xml
@@ -0,0 +1,5 @@
+<cpu match='exact'>
+  <model>Opteron_G2</model>
+  <feature policy='disable' name='svm'/>
+  <feature policy='disable' name='rdtscp'/>
+</cpu>
diff --git a/tests/cputestdata/x86-baseline-no-vendor.xml b/tests/cputestdata/x86-baseline-no-vendor.xml
new file mode 100644
index 0000000..84605a4
--- /dev/null
+++ b/tests/cputestdata/x86-baseline-no-vendor.xml
@@ -0,0 +1,12 @@
+<cpuTest>
+<cpu>
+  <arch>x86_64</arch>
+  <model>Penryn</model>
+  <topology sockets='2' cores='4' threads='1'/>
+</cpu>
+<cpu>
+  <arch>x86_64</arch>
+  <model>Opteron_G3</model>
+  <topology sockets='1' cores='1' threads='1'/>
+</cpu>
+</cpuTest>
diff --git a/tests/cputestdata/x86-baseline-some-vendors-result.xml b/tests/cputestdata/x86-baseline-some-vendors-result.xml
new file mode 100644
index 0000000..2ddfcc5
--- /dev/null
+++ b/tests/cputestdata/x86-baseline-some-vendors-result.xml
@@ -0,0 +1,3 @@
+<cpu match='exact'>
+  <model>Opteron_G1</model>
+</cpu>
diff --git a/tests/cputestdata/x86-baseline-some-vendors.xml b/tests/cputestdata/x86-baseline-some-vendors.xml
new file mode 100644
index 0000000..816ed6b
--- /dev/null
+++ b/tests/cputestdata/x86-baseline-some-vendors.xml
@@ -0,0 +1,13 @@
+<cpuTest>
+<cpu>
+  <arch>x86_64</arch>
+  <model>Opteron_G1</model>
+  <topology sockets='2' cores='4' threads='1'/>
+</cpu>
+<cpu>
+  <arch>x86_64</arch>
+  <model>Opteron_G3</model>
+  <vendor>AMD</vendor>
+  <topology sockets='1' cores='1' threads='1'/>
+</cpu>
+</cpuTest>
diff --git a/tests/cputestdata/x86-bogus-feature.xml b/tests/cputestdata/x86-bogus-feature.xml
new file mode 100644
index 0000000..5a11814
--- /dev/null
+++ b/tests/cputestdata/x86-bogus-feature.xml
@@ -0,0 +1,4 @@
+<cpu match='minimum'>
+  <model>Penryn</model>
+  <feature name='bogus' policy='optional'/>
+</cpu>
diff --git a/tests/cputestdata/x86-bogus-model.xml b/tests/cputestdata/x86-bogus-model.xml
new file mode 100644
index 0000000..f39392f
--- /dev/null
+++ b/tests/cputestdata/x86-bogus-model.xml
@@ -0,0 +1,3 @@
+<cpu match='minimum'>
+  <model>Bogus</model>
+</cpu>
diff --git a/tests/cputestdata/x86-bogus-vendor.xml b/tests/cputestdata/x86-bogus-vendor.xml
new file mode 100644
index 0000000..2ffdefe
--- /dev/null
+++ b/tests/cputestdata/x86-bogus-vendor.xml
@@ -0,0 +1,4 @@
+<cpu match='minimum'>
+  <model>Penryn</model>
+  <vendor>Bogus</vendor>
+</cpu>
diff --git a/tests/cputestdata/x86-exact-disable-extra.xml b/tests/cputestdata/x86-exact-disable-extra.xml
new file mode 100644
index 0000000..c84bd5b
--- /dev/null
+++ b/tests/cputestdata/x86-exact-disable-extra.xml
@@ -0,0 +1,4 @@
+<cpu match='exact'>
+  <model>Penryn</model>
+  <feature name='3dnowext' policy='disable'/>
+</cpu>
diff --git a/tests/cputestdata/x86-exact-disable.xml b/tests/cputestdata/x86-exact-disable.xml
new file mode 100644
index 0000000..202eb27
--- /dev/null
+++ b/tests/cputestdata/x86-exact-disable.xml
@@ -0,0 +1,4 @@
+<cpu match='exact'>
+  <model>Penryn</model>
+  <feature name='vmx' policy='disable'/>
+</cpu>
diff --git a/tests/cputestdata/x86-exact-disable2.xml b/tests/cputestdata/x86-exact-disable2.xml
new file mode 100644
index 0000000..9baa58b
--- /dev/null
+++ b/tests/cputestdata/x86-exact-disable2.xml
@@ -0,0 +1,5 @@
+<cpu match='exact'>
+  <model>Nehalem</model>
+  <feature name='popcnt' policy='disable'/>
+  <feature name='sse4.2' policy='disable'/>
+</cpu>
diff --git a/tests/cputestdata/x86-exact-forbid-extra.xml b/tests/cputestdata/x86-exact-forbid-extra.xml
new file mode 100644
index 0000000..0a261ad
--- /dev/null
+++ b/tests/cputestdata/x86-exact-forbid-extra.xml
@@ -0,0 +1,4 @@
+<cpu match='exact'>
+  <model>Penryn</model>
+  <feature name='3dnowext' policy='forbid'/>
+</cpu>
diff --git a/tests/cputestdata/x86-exact-forbid.xml b/tests/cputestdata/x86-exact-forbid.xml
new file mode 100644
index 0000000..d9660ca
--- /dev/null
+++ b/tests/cputestdata/x86-exact-forbid.xml
@@ -0,0 +1,4 @@
+<cpu match='exact'>
+  <model>Penryn</model>
+  <feature name='vmx' policy='forbid'/>
+</cpu>
diff --git a/tests/cputestdata/x86-exact-force.xml b/tests/cputestdata/x86-exact-force.xml
new file mode 100644
index 0000000..c0fa127
--- /dev/null
+++ b/tests/cputestdata/x86-exact-force.xml
@@ -0,0 +1,4 @@
+<cpu match='exact'>
+  <model>Penryn</model>
+  <feature name='3dnowext' policy='force'/>
+</cpu>
diff --git a/tests/cputestdata/x86-exact-require-extra.xml b/tests/cputestdata/x86-exact-require-extra.xml
new file mode 100644
index 0000000..5e89cda
--- /dev/null
+++ b/tests/cputestdata/x86-exact-require-extra.xml
@@ -0,0 +1,4 @@
+<cpu match='exact'>
+  <model>Penryn</model>
+  <feature name='3dnowext' policy='require'/>
+</cpu>
diff --git a/tests/cputestdata/x86-exact-require.xml b/tests/cputestdata/x86-exact-require.xml
new file mode 100644
index 0000000..2d196df
--- /dev/null
+++ b/tests/cputestdata/x86-exact-require.xml
@@ -0,0 +1,4 @@
+<cpu match='exact'>
+  <model>Penryn</model>
+  <feature name='sse4.1' policy='require'/>
+</cpu>
diff --git a/tests/cputestdata/x86-exact.xml b/tests/cputestdata/x86-exact.xml
new file mode 100644
index 0000000..18b7ef4
--- /dev/null
+++ b/tests/cputestdata/x86-exact.xml
@@ -0,0 +1,3 @@
+<cpu match='exact'>
+  <model>Penryn</model>
+</cpu>
diff --git a/tests/cputestdata/x86-guest.xml b/tests/cputestdata/x86-guest.xml
new file mode 100644
index 0000000..d8685e6
--- /dev/null
+++ b/tests/cputestdata/x86-guest.xml
@@ -0,0 +1,18 @@
+<cpu match='exact'>
+  <model>Penryn</model>
+  <topology sockets='2' cores='4' threads='1'/>
+  <!--feature name='sse4.1' policy='optional'/-->
+  <feature name='dca' policy='optional'/>
+  <feature name='xtpr' policy='optional'/>
+  <feature name='sse4.2' policy='optional'/>
+  <feature name='3dnow' policy='optional'/>
+  <feature name='ssse3' policy='optional'/>
+  <feature name='vmx' policy='disable'/>
+  <feature name='ds_cpl' policy='disable'/>
+  <feature name='sse' policy='disable'/>
+  <feature name='monitor' policy='force'/>
+  <feature name='pbe' policy='force'/>
+  <feature name='3dnowext' policy='force'/>
+  <feature name='svm' policy='force'/>
+  <feature name='popcnt' policy='forbid'/>
+</cpu>
diff --git a/tests/cputestdata/x86-host+guest,model486-result.xml b/tests/cputestdata/x86-host+guest,model486-result.xml
new file mode 100644
index 0000000..fb1bb4b
--- /dev/null
+++ b/tests/cputestdata/x86-host+guest,model486-result.xml
@@ -0,0 +1,37 @@
+<cpu match='exact'>
+  <arch>x86_64</arch>
+  <model>486</model>
+  <feature policy='require' name='svm'/>
+  <feature policy='require' name='lahf_lm'/>
+  <feature policy='require' name='3dnowext'/>
+  <feature policy='require' name='lm'/>
+  <feature policy='require' name='nx'/>
+  <feature policy='require' name='syscall'/>
+  <feature policy='require' name='sse4.1'/>
+  <feature policy='require' name='dca'/>
+  <feature policy='require' name='xtpr'/>
+  <feature policy='require' name='cx16'/>
+  <feature policy='require' name='ssse3'/>
+  <feature policy='require' name='monitor'/>
+  <feature policy='require' name='pni'/>
+  <feature policy='require' name='pbe'/>
+  <feature policy='require' name='sse2'/>
+  <feature policy='require' name='fxsr'/>
+  <feature policy='require' name='mmx'/>
+  <feature policy='require' name='clflush'/>
+  <feature policy='require' name='pse36'/>
+  <feature policy='require' name='pat'/>
+  <feature policy='require' name='cmov'/>
+  <feature policy='require' name='mca'/>
+  <feature policy='require' name='pge'/>
+  <feature policy='require' name='mtrr'/>
+  <feature policy='require' name='sep'/>
+  <feature policy='require' name='apic'/>
+  <feature policy='require' name='cx8'/>
+  <feature policy='require' name='mce'/>
+  <feature policy='require' name='pae'/>
+  <feature policy='require' name='msr'/>
+  <feature policy='require' name='tsc'/>
+  <feature policy='require' name='de'/>
+  <feature policy='disable' name='vme'/>
+</cpu>
diff --git a/tests/cputestdata/x86-host+guest,models,Penryn-result.xml b/tests/cputestdata/x86-host+guest,models,Penryn-result.xml
new file mode 100644
index 0000000..9559465
--- /dev/null
+++ b/tests/cputestdata/x86-host+guest,models,Penryn-result.xml
@@ -0,0 +1,13 @@
+<cpu match='exact'>
+  <arch>x86_64</arch>
+  <model>Nehalem</model>
+  <feature policy='require' name='svm'/>
+  <feature policy='require' name='3dnowext'/>
+  <feature policy='require' name='dca'/>
+  <feature policy='require' name='xtpr'/>
+  <feature policy='require' name='monitor'/>
+  <feature policy='require' name='pbe'/>
+  <feature policy='disable' name='popcnt'/>
+  <feature policy='disable' name='sse4.2'/>
+  <feature policy='disable' name='sse'/>
+</cpu>
diff --git a/tests/cputestdata/x86-host+guest,models,qemu64-result.xml b/tests/cputestdata/x86-host+guest,models,qemu64-result.xml
new file mode 100644
index 0000000..b41863e
--- /dev/null
+++ b/tests/cputestdata/x86-host+guest,models,qemu64-result.xml
@@ -0,0 +1,14 @@
+<cpu match='exact'>
+  <arch>x86_64</arch>
+  <model>qemu64</model>
+  <feature policy='require' name='lahf_lm'/>
+  <feature policy='require' name='3dnowext'/>
+  <feature policy='require' name='sse4.1'/>
+  <feature policy='require' name='dca'/>
+  <feature policy='require' name='xtpr'/>
+  <feature policy='require' name='cx16'/>
+  <feature policy='require' name='ssse3'/>
+  <feature policy='require' name='monitor'/>
+  <feature policy='require' name='pbe'/>
+  <feature policy='disable' name='sse'/>
+</cpu>
diff --git a/tests/cputestdata/x86-host+guest,models-result.xml b/tests/cputestdata/x86-host+guest,models-result.xml
new file mode 100644
index 0000000..9559465
--- /dev/null
+++ b/tests/cputestdata/x86-host+guest,models-result.xml
@@ -0,0 +1,13 @@
+<cpu match='exact'>
+  <arch>x86_64</arch>
+  <model>Nehalem</model>
+  <feature policy='require' name='svm'/>
+  <feature policy='require' name='3dnowext'/>
+  <feature policy='require' name='dca'/>
+  <feature policy='require' name='xtpr'/>
+  <feature policy='require' name='monitor'/>
+  <feature policy='require' name='pbe'/>
+  <feature policy='disable' name='popcnt'/>
+  <feature policy='disable' name='sse4.2'/>
+  <feature policy='disable' name='sse'/>
+</cpu>
diff --git a/tests/cputestdata/x86-host+guest-result.xml b/tests/cputestdata/x86-host+guest-result.xml
new file mode 100644
index 0000000..544a388
--- /dev/null
+++ b/tests/cputestdata/x86-host+guest-result.xml
@@ -0,0 +1,11 @@
+<cpu match='exact'>
+  <arch>x86_64</arch>
+  <model>Penryn</model>
+  <feature policy='require' name='svm'/>
+  <feature policy='require' name='3dnowext'/>
+  <feature policy='require' name='dca'/>
+  <feature policy='require' name='xtpr'/>
+  <feature policy='require' name='monitor'/>
+  <feature policy='require' name='pbe'/>
+  <feature policy='disable' name='sse'/>
+</cpu>
diff --git a/tests/cputestdata/x86-host+guest.xml b/tests/cputestdata/x86-host+guest.xml
new file mode 100644
index 0000000..c3fca87
--- /dev/null
+++ b/tests/cputestdata/x86-host+guest.xml
@@ -0,0 +1,17 @@
+<cpu match='exact'>
+  <model>Penryn</model>
+  <topology sockets='2' cores='4' threads='1'/>
+  <feature policy='require' name='dca'/>
+  <feature policy='require' name='xtpr'/>
+  <feature policy='disable' name='sse4.2'/>
+  <feature policy='disable' name='3dnow'/>
+  <feature policy='require' name='ssse3'/>
+  <feature policy='disable' name='vmx'/>
+  <feature policy='disable' name='ds_cpl'/>
+  <feature policy='disable' name='sse'/>
+  <feature policy='force' name='monitor'/>
+  <feature policy='force' name='pbe'/>
+  <feature policy='force' name='3dnowext'/>
+  <feature policy='force' name='svm'/>
+  <feature policy='forbid' name='popcnt'/>
+</cpu>
diff --git a/tests/cputestdata/x86-host+min.xml b/tests/cputestdata/x86-host+min.xml
new file mode 100644
index 0000000..d22c7b6
--- /dev/null
+++ b/tests/cputestdata/x86-host+min.xml
@@ -0,0 +1,17 @@
+<cpu match='exact'>
+  <model>Penryn</model>
+  <feature policy='require' name='dca'/>
+  <feature policy='require' name='xtpr'/>
+  <feature policy='require' name='tm2'/>
+  <feature policy='require' name='est'/>
+  <feature policy='require' name='vmx'/>
+  <feature policy='require' name='ds_cpl'/>
+  <feature policy='require' name='monitor'/>
+  <feature policy='require' name='pbe'/>
+  <feature policy='require' name='tm'/>
+  <feature policy='require' name='ht'/>
+  <feature policy='require' name='ss'/>
+  <feature policy='require' name='acpi'/>
+  <feature policy='require' name='ds'/>
+  <feature policy='require' name='vme'/>
+</cpu>
diff --git a/tests/cputestdata/x86-host+nehalem-force-result.xml b/tests/cputestdata/x86-host+nehalem-force-result.xml
new file mode 100644
index 0000000..162685f
--- /dev/null
+++ b/tests/cputestdata/x86-host+nehalem-force-result.xml
@@ -0,0 +1,4 @@
+<cpu match='exact'>
+  <arch>x86_64</arch>
+  <model>Nehalem</model>
+</cpu>
diff --git a/tests/cputestdata/x86-host+pentium3.xml b/tests/cputestdata/x86-host+pentium3.xml
new file mode 100644
index 0000000..d141d9e
--- /dev/null
+++ b/tests/cputestdata/x86-host+pentium3.xml
@@ -0,0 +1,27 @@
+<cpu match='exact'>
+  <model>pentium3</model>
+  <feature policy='require' name='lahf_lm'/>
+  <feature policy='require' name='lm'/>
+  <feature policy='require' name='nx'/>
+  <feature policy='require' name='syscall'/>
+  <feature policy='require' name='sse4.1'/>
+  <feature policy='require' name='dca'/>
+  <feature policy='require' name='xtpr'/>
+  <feature policy='require' name='cx16'/>
+  <feature policy='require' name='ssse3'/>
+  <feature policy='require' name='tm2'/>
+  <feature policy='require' name='est'/>
+  <feature policy='require' name='vmx'/>
+  <feature policy='require' name='ds_cpl'/>
+  <feature policy='require' name='monitor'/>
+  <feature policy='require' name='pni'/>
+  <feature policy='require' name='pbe'/>
+  <feature policy='require' name='tm'/>
+  <feature policy='require' name='ht'/>
+  <feature policy='require' name='ss'/>
+  <feature policy='require' name='sse2'/>
+  <feature policy='require' name='acpi'/>
+  <feature policy='require' name='ds'/>
+  <feature policy='require' name='clflush'/>
+  <feature policy='require' name='apic'/>
+</cpu>
diff --git a/tests/cputestdata/x86-host+strict-force-extra-result.xml b/tests/cputestdata/x86-host+strict-force-extra-result.xml
new file mode 100644
index 0000000..e47933c
--- /dev/null
+++ b/tests/cputestdata/x86-host+strict-force-extra-result.xml
@@ -0,0 +1,19 @@
+<cpu match='exact'>
+  <arch>x86_64</arch>
+  <model>Penryn</model>
+  <feature policy='require' name='3dnow'/>
+  <feature policy='require' name='dca'/>
+  <feature policy='require' name='xtpr'/>
+  <feature policy='require' name='tm2'/>
+  <feature policy='require' name='est'/>
+  <feature policy='require' name='vmx'/>
+  <feature policy='require' name='ds_cpl'/>
+  <feature policy='require' name='monitor'/>
+  <feature policy='require' name='pbe'/>
+  <feature policy='require' name='tm'/>
+  <feature policy='require' name='ht'/>
+  <feature policy='require' name='ss'/>
+  <feature policy='require' name='acpi'/>
+  <feature policy='require' name='ds'/>
+  <feature policy='require' name='vme'/>
+</cpu>
diff --git a/tests/cputestdata/x86-host-amd-fake.xml b/tests/cputestdata/x86-host-amd-fake.xml
new file mode 100644
index 0000000..c81990a
--- /dev/null
+++ b/tests/cputestdata/x86-host-amd-fake.xml
@@ -0,0 +1,20 @@
+<cpu>
+  <arch>x86_64</arch>
+  <model>Penryn</model>
+  <vendor>AMD</vendor>
+  <topology sockets='1' cores='4' threads='1'/>
+  <feature name='dca'/>
+  <feature name='xtpr'/>
+  <feature name='tm2'/>
+  <feature name='est'/>
+  <feature name='vmx'/>
+  <feature name='ds_cpl'/>
+  <feature name='monitor'/>
+  <feature name='pbe'/>
+  <feature name='tm'/>
+  <feature name='ht'/>
+  <feature name='ss'/>
+  <feature name='acpi'/>
+  <feature name='ds'/>
+  <feature name='vme'/>
+</cpu>
diff --git a/tests/cputestdata/x86-host-amd.xml b/tests/cputestdata/x86-host-amd.xml
new file mode 100644
index 0000000..e662829
--- /dev/null
+++ b/tests/cputestdata/x86-host-amd.xml
@@ -0,0 +1,18 @@
+<cpu>
+  <arch>x86_64</arch>
+  <model>Opteron_G3</model>
+  <vendor>AMD</vendor>
+  <topology sockets='8' cores='1' threads='1'/>
+  <feature name='osvw'/>
+  <feature name='3dnowprefetch'/>
+  <feature name='cr8legacy'/>
+  <feature name='extapic'/>
+  <feature name='cmp_legacy'/>
+  <feature name='3dnow'/>
+  <feature name='3dnowext'/>
+  <feature name='pdpe1gb'/>
+  <feature name='fxsr_opt'/>
+  <feature name='mmxext'/>
+  <feature name='ht'/>
+  <feature name='vme'/>
+</cpu>
diff --git a/tests/cputestdata/x86-host-better+pentium3,core2duo-result.xml b/tests/cputestdata/x86-host-better+pentium3,core2duo-result.xml
new file mode 100644
index 0000000..c2d8ddd
--- /dev/null
+++ b/tests/cputestdata/x86-host-better+pentium3,core2duo-result.xml
@@ -0,0 +1,21 @@
+<cpu match='exact'>
+  <arch>x86_64</arch>
+  <model>core2duo</model>
+  <feature policy='require' name='lahf_lm'/>
+  <feature policy='require' name='popcnt'/>
+  <feature policy='require' name='sse4.2'/>
+  <feature policy='require' name='sse4.1'/>
+  <feature policy='require' name='dca'/>
+  <feature policy='require' name='xtpr'/>
+  <feature policy='require' name='cx16'/>
+  <feature policy='require' name='tm2'/>
+  <feature policy='require' name='est'/>
+  <feature policy='require' name='vmx'/>
+  <feature policy='require' name='ds_cpl'/>
+  <feature policy='require' name='pbe'/>
+  <feature policy='require' name='tm'/>
+  <feature policy='require' name='ht'/>
+  <feature policy='require' name='ss'/>
+  <feature policy='require' name='acpi'/>
+  <feature policy='require' name='ds'/>
+</cpu>
diff --git a/tests/cputestdata/x86-host-better+pentium3,pentium3-result.xml b/tests/cputestdata/x86-host-better+pentium3,pentium3-result.xml
new file mode 100644
index 0000000..6e246a8
--- /dev/null
+++ b/tests/cputestdata/x86-host-better+pentium3,pentium3-result.xml
@@ -0,0 +1,30 @@
+<cpu match='exact'>
+  <arch>x86_64</arch>
+  <model>pentium3</model>
+  <feature policy='require' name='lahf_lm'/>
+  <feature policy='require' name='lm'/>
+  <feature policy='require' name='nx'/>
+  <feature policy='require' name='syscall'/>
+  <feature policy='require' name='popcnt'/>
+  <feature policy='require' name='sse4.2'/>
+  <feature policy='require' name='sse4.1'/>
+  <feature policy='require' name='dca'/>
+  <feature policy='require' name='xtpr'/>
+  <feature policy='require' name='cx16'/>
+  <feature policy='require' name='ssse3'/>
+  <feature policy='require' name='tm2'/>
+  <feature policy='require' name='est'/>
+  <feature policy='require' name='vmx'/>
+  <feature policy='require' name='ds_cpl'/>
+  <feature policy='require' name='monitor'/>
+  <feature policy='require' name='pni'/>
+  <feature policy='require' name='pbe'/>
+  <feature policy='require' name='tm'/>
+  <feature policy='require' name='ht'/>
+  <feature policy='require' name='ss'/>
+  <feature policy='require' name='sse2'/>
+  <feature policy='require' name='acpi'/>
+  <feature policy='require' name='ds'/>
+  <feature policy='require' name='clflush'/>
+  <feature policy='require' name='apic'/>
+</cpu>
diff --git a/tests/cputestdata/x86-host-better+pentium3-result.xml b/tests/cputestdata/x86-host-better+pentium3-result.xml
new file mode 100644
index 0000000..b918363
--- /dev/null
+++ b/tests/cputestdata/x86-host-better+pentium3-result.xml
@@ -0,0 +1,18 @@
+<cpu match='exact'>
+  <arch>x86_64</arch>
+  <model>Nehalem</model>
+  <feature policy='require' name='dca'/>
+  <feature policy='require' name='xtpr'/>
+  <feature policy='require' name='tm2'/>
+  <feature policy='require' name='est'/>
+  <feature policy='require' name='vmx'/>
+  <feature policy='require' name='ds_cpl'/>
+  <feature policy='require' name='monitor'/>
+  <feature policy='require' name='pbe'/>
+  <feature policy='require' name='tm'/>
+  <feature policy='require' name='ht'/>
+  <feature policy='require' name='ss'/>
+  <feature policy='require' name='acpi'/>
+  <feature policy='require' name='ds'/>
+  <feature policy='require' name='vme'/>
+</cpu>
diff --git a/tests/cputestdata/x86-host-better.xml b/tests/cputestdata/x86-host-better.xml
new file mode 100644
index 0000000..8340f11
--- /dev/null
+++ b/tests/cputestdata/x86-host-better.xml
@@ -0,0 +1,20 @@
+<cpu>
+  <arch>x86_64</arch>
+  <model>Nehalem</model>
+  <vendor>Intel</vendor>
+  <topology sockets='2' cores='4' threads='1'/>
+  <feature name='dca'/>
+  <feature name='xtpr'/>
+  <feature name='tm2'/>
+  <feature name='est'/>
+  <feature name='vmx'/>
+  <feature name='ds_cpl'/>
+  <feature name='monitor'/>
+  <feature name='pbe'/>
+  <feature name='tm'/>
+  <feature name='ht'/>
+  <feature name='ss'/>
+  <feature name='acpi'/>
+  <feature name='ds'/>
+  <feature name='vme'/>
+</cpu>
diff --git a/tests/cputestdata/x86-host-incomp-arch.xml b/tests/cputestdata/x86-host-incomp-arch.xml
new file mode 100644
index 0000000..f7c064e
--- /dev/null
+++ b/tests/cputestdata/x86-host-incomp-arch.xml
@@ -0,0 +1,6 @@
+<cpu>
+  <arch>ia64</arch>
+  <model>Penryn</model>
+  <vendor>Intel</vendor>
+  <topology sockets='1' cores='4' threads='1'/>
+</cpu>
diff --git a/tests/cputestdata/x86-host-no-vendor.xml b/tests/cputestdata/x86-host-no-vendor.xml
new file mode 100644
index 0000000..efb0a44
--- /dev/null
+++ b/tests/cputestdata/x86-host-no-vendor.xml
@@ -0,0 +1,19 @@
+<cpu>
+  <arch>x86_64</arch>
+  <model>Penryn</model>
+  <topology sockets='2' cores='4' threads='1'/>
+  <feature name='dca'/>
+  <feature name='xtpr'/>
+  <feature name='tm2'/>
+  <feature name='est'/>
+  <feature name='vmx'/>
+  <feature name='ds_cpl'/>
+  <feature name='monitor'/>
+  <feature name='pbe'/>
+  <feature name='tm'/>
+  <feature name='ht'/>
+  <feature name='ss'/>
+  <feature name='acpi'/>
+  <feature name='ds'/>
+  <feature name='vme'/>
+</cpu>
diff --git a/tests/cputestdata/x86-host-worse+guest-result.xml b/tests/cputestdata/x86-host-worse+guest-result.xml
new file mode 100644
index 0000000..036177a
--- /dev/null
+++ b/tests/cputestdata/x86-host-worse+guest-result.xml
@@ -0,0 +1,9 @@
+<cpu match='exact'>
+  <arch>x86_64</arch>
+  <model>Penryn</model>
+  <feature policy='require' name='svm'/>
+  <feature policy='require' name='3dnowext'/>
+  <feature policy='require' name='monitor'/>
+  <feature policy='require' name='pbe'/>
+  <feature policy='disable' name='sse'/>
+</cpu>
diff --git a/tests/cputestdata/x86-host-worse.xml b/tests/cputestdata/x86-host-worse.xml
new file mode 100644
index 0000000..dcf4670
--- /dev/null
+++ b/tests/cputestdata/x86-host-worse.xml
@@ -0,0 +1,6 @@
+<cpu>
+  <arch>x86_64</arch>
+  <model>Penryn</model>
+  <vendor>Intel</vendor>
+  <topology sockets='2' cores='4' threads='1'/>
+</cpu>
diff --git a/tests/cputestdata/x86-host.xml b/tests/cputestdata/x86-host.xml
new file mode 100644
index 0000000..f1c163d
--- /dev/null
+++ b/tests/cputestdata/x86-host.xml
@@ -0,0 +1,20 @@
+<cpu>
+  <arch>x86_64</arch>
+  <model>Penryn</model>
+  <vendor>Intel</vendor>
+  <topology sockets='2' cores='4' threads='1'/>
+  <feature name='dca'/>
+  <feature name='xtpr'/>
+  <feature name='tm2'/>
+  <feature name='est'/>
+  <feature name='vmx'/>
+  <feature name='ds_cpl'/>
+  <feature name='monitor'/>
+  <feature name='pbe'/>
+  <feature name='tm'/>
+  <feature name='ht'/>
+  <feature name='ss'/>
+  <feature name='acpi'/>
+  <feature name='ds'/>
+  <feature name='vme'/>
+</cpu>
diff --git a/tests/cputestdata/x86-min.xml b/tests/cputestdata/x86-min.xml
new file mode 100644
index 0000000..795645d
--- /dev/null
+++ b/tests/cputestdata/x86-min.xml
@@ -0,0 +1,3 @@
+<cpu match='minimum'>
+  <model>Penryn</model>
+</cpu>
diff --git a/tests/cputestdata/x86-nehalem-force.xml b/tests/cputestdata/x86-nehalem-force.xml
new file mode 100644
index 0000000..4084b87
--- /dev/null
+++ b/tests/cputestdata/x86-nehalem-force.xml
@@ -0,0 +1,6 @@
+<cpu match='exact'>
+  <model>Penryn</model>
+  <feature name='popcnt' policy='force'/>
+  <feature name='sse4.2' policy='force'/>
+</cpu>
+
diff --git a/tests/cputestdata/x86-pentium3-amd.xml b/tests/cputestdata/x86-pentium3-amd.xml
new file mode 100644
index 0000000..5fd73e4
--- /dev/null
+++ b/tests/cputestdata/x86-pentium3-amd.xml
@@ -0,0 +1,4 @@
+<cpu match='exact'>
+  <model>pentium3</model>
+  <vendor>AMD</vendor>
+</cpu>
diff --git a/tests/cputestdata/x86-pentium3.xml b/tests/cputestdata/x86-pentium3.xml
new file mode 100644
index 0000000..187e83d
--- /dev/null
+++ b/tests/cputestdata/x86-pentium3.xml
@@ -0,0 +1,3 @@
+<cpu match='minimum'>
+  <model>pentium3</model>
+</cpu>
diff --git a/tests/cputestdata/x86-strict-disable.xml b/tests/cputestdata/x86-strict-disable.xml
new file mode 100644
index 0000000..f2bac1a
--- /dev/null
+++ b/tests/cputestdata/x86-strict-disable.xml
@@ -0,0 +1,18 @@
+<cpu match='strict'>
+  <model>Penryn</model>
+  <feature name='dca' policy='require'/>
+  <feature name='xtpr' policy='require'/>
+  <feature name='tm2' policy='require'/>
+  <feature name='est' policy='require'/>
+  <feature name='vmx' policy='require'/>
+  <feature name='ds_cpl' policy='require'/>
+  <feature name='monitor' policy='disable'/>
+  <feature name='pbe' policy='require'/>
+  <feature name='tm' policy='require'/>
+  <feature name='ht' policy='require'/>
+  <feature name='ss' policy='disable'/>
+  <feature name='acpi' policy='require'/>
+  <feature name='ds' policy='require'/>
+  <feature name='vme' policy='require'/>
+  <feature name='3dnow' policy='disable'/>
+</cpu>
diff --git a/tests/cputestdata/x86-strict-force-extra.xml b/tests/cputestdata/x86-strict-force-extra.xml
new file mode 100644
index 0000000..dbae38c
--- /dev/null
+++ b/tests/cputestdata/x86-strict-force-extra.xml
@@ -0,0 +1,18 @@
+<cpu match='strict'>
+  <model>Penryn</model>
+  <feature name='dca' policy='require'/>
+  <feature name='xtpr' policy='require'/>
+  <feature name='tm2' policy='require'/>
+  <feature name='est' policy='require'/>
+  <feature name='vmx' policy='require'/>
+  <feature name='ds_cpl' policy='require'/>
+  <feature name='monitor' policy='require'/>
+  <feature name='pbe' policy='require'/>
+  <feature name='tm' policy='require'/>
+  <feature name='ht' policy='require'/>
+  <feature name='ss' policy='require'/>
+  <feature name='acpi' policy='require'/>
+  <feature name='ds' policy='require'/>
+  <feature name='vme' policy='require'/>
+  <feature name='3dnow' policy='force'/>
+</cpu>
diff --git a/tests/cputestdata/x86-strict-full.xml b/tests/cputestdata/x86-strict-full.xml
new file mode 100644
index 0000000..2dbe250
--- /dev/null
+++ b/tests/cputestdata/x86-strict-full.xml
@@ -0,0 +1,17 @@
+<cpu match='strict'>
+  <model>Penryn</model>
+  <feature name='dca' policy='require'/>
+  <feature name='xtpr' policy='require'/>
+  <feature name='tm2' policy='require'/>
+  <feature name='est' policy='require'/>
+  <feature name='vmx' policy='require'/>
+  <feature name='ds_cpl' policy='require'/>
+  <feature name='monitor' policy='require'/>
+  <feature name='pbe' policy='require'/>
+  <feature name='tm' policy='require'/>
+  <feature name='ht' policy='require'/>
+  <feature name='ss' policy='require'/>
+  <feature name='acpi' policy='require'/>
+  <feature name='ds' policy='require'/>
+  <feature name='vme' policy='require'/>
+</cpu>
diff --git a/tests/cputestdata/x86-strict.xml b/tests/cputestdata/x86-strict.xml
new file mode 100644
index 0000000..a64c262
--- /dev/null
+++ b/tests/cputestdata/x86-strict.xml
@@ -0,0 +1,3 @@
+<cpu match='strict'>
+  <model>Penryn</model>
+</cpu>
-- 
1.7.3.2

--
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]