diff --git a/tests/vircaps2xmldata/vircaps-aarch64-basic.xml b/tests/vircaps2xmldata/vircaps-aarch64-basic.xml new file mode 100644 index 0000000000000000000000000000000000000000..ce156a364e1ce9daf910af0e745ccad589bdf2a9 --- /dev/null +++ b/tests/vircaps2xmldata/vircaps-aarch64-basic.xml @@ -0,0 +1,64 @@ + + + + + aarch64 + + + + + + + + 1048576 + 2048 + 4096 + 6144 + + + + + + + + + 2097152 + 4096 + 6144 + 8192 + + + + + + + + + 3145728 + 6144 + 8192 + 10240 + + + + + + + + + 4194304 + 8192 + 10240 + 12288 + + + + + + + + + + + + diff --git a/tests/vircaps2xmldata/vircaps-basic-4-4-2G.xml b/tests/vircaps2xmldata/vircaps-basic-4-4-2G.xml deleted file mode 100644 index 8694f87d1f94ce10d87db6346607f53e3146566a..0000000000000000000000000000000000000000 --- a/tests/vircaps2xmldata/vircaps-basic-4-4-2G.xml +++ /dev/null @@ -1,74 +0,0 @@ - - - - - x86_64 - - - - - - 2097152 - - - - - - - - - - - - - - - 2097152 - - - - - - - - - - - - - - - 2097152 - - - - - - - - - - - - - - - 2097152 - - - - - - - - - - - - - - - - - - diff --git a/tests/vircaps2xmldata/vircaps-x86_64-basic.xml b/tests/vircaps2xmldata/vircaps-x86_64-basic.xml new file mode 100644 index 0000000000000000000000000000000000000000..1f2c6659a5cb5f25d33622662794bf8e416437dc --- /dev/null +++ b/tests/vircaps2xmldata/vircaps-x86_64-basic.xml @@ -0,0 +1,62 @@ + + + + + x86_64 + + + + + + 1048576 + 2048 + 4096 + 6144 + + + + + + + + + 2097152 + 4096 + 6144 + 8192 + + + + + + + + + 3145728 + 6144 + 8192 + 10240 + + + + + + + + + 4194304 + 8192 + 10240 + 12288 + + + + + + + + + + + + diff --git a/tests/vircaps2xmldata/vircaps-x86_64-caches.xml b/tests/vircaps2xmldata/vircaps-x86_64-caches.xml new file mode 100644 index 0000000000000000000000000000000000000000..88f2ec62277e64d13bca198399dd271debef5495 --- /dev/null +++ b/tests/vircaps2xmldata/vircaps-x86_64-caches.xml @@ -0,0 +1,33 @@ + + + + + x86_64 + + + + + + + + + 1048576 + 2048 + 4096 + 6144 + + + + + + + + + + + + + + + + diff --git a/tests/vircaps2xmltest.c b/tests/vircaps2xmltest.c index 3e9e06bc0967fd62b18fd51b30a2bc42c307ae67..4dccd452cc82d5bdb53cccf5fceb0bca4f7b1acc 100644 --- a/tests/vircaps2xmltest.c +++ b/tests/vircaps2xmltest.c @@ -25,99 +25,51 @@ #include "testutils.h" #include "capabilities.h" #include "virbitmap.h" +#include "virsysfspriv.h" #define VIR_FROM_THIS VIR_FROM_NONE -static virCapsPtr -buildVirCapabilities(int max_cells, - int max_cpus_in_cell, - int max_mem_in_cell) -{ - virCapsPtr caps; - virCapsHostNUMACellCPUPtr cell_cpus = NULL; - virCapsHostNUMACellSiblingInfoPtr siblings = NULL; - int core_id, cell_id, nsiblings; - int id; - size_t i; - - if ((caps = virCapabilitiesNew(VIR_ARCH_X86_64, false, false)) == NULL) - goto error; - - id = 0; - for (cell_id = 0; cell_id < max_cells; cell_id++) { - if (VIR_ALLOC_N(cell_cpus, max_cpus_in_cell) < 0) - goto error; - - for (core_id = 0; core_id < max_cpus_in_cell; core_id++) { - cell_cpus[core_id].id = id; - cell_cpus[core_id].socket_id = cell_id; - cell_cpus[core_id].core_id = id + core_id; - if (!(cell_cpus[core_id].siblings = - virBitmapNew(max_cpus_in_cell))) - goto error; - ignore_value(virBitmapSetBit(cell_cpus[core_id].siblings, id)); - } - id++; - - if (VIR_ALLOC_N(siblings, max_cells) < 0) - goto error; - nsiblings = max_cells; - - for (i = 0; i < nsiblings; i++) { - siblings[i].node = i; - /* Some magical constants, see virNumaGetDistances() - * for their description. */ - siblings[i].distance = cell_id == i ? 10 : 20; - } - - if (virCapabilitiesAddHostNUMACell(caps, cell_id, - max_mem_in_cell, - max_cpus_in_cell, cell_cpus, - nsiblings, siblings, - 0, NULL) < 0) - goto error; - - cell_cpus = NULL; - siblings = NULL; - } - - return caps; - - error: - virCapabilitiesClearHostNUMACellCPUTopology(cell_cpus, max_cpus_in_cell); - VIR_FREE(cell_cpus); - VIR_FREE(siblings); - virObjectUnref(caps); - return NULL; -} +#ifdef __linux__ - -struct virCapabilitiesFormatData { +struct virCapabilitiesData { const char *filename; - int max_cells; - int max_cpus_in_cell; - int max_mem_in_cell; + virArch arch; + bool offlineMigrate; + bool liveMigrate; }; static int -test_virCapabilitiesFormat(const void *opaque) +test_virCapabilities(const void *opaque) { - struct virCapabilitiesFormatData *data = (struct virCapabilitiesFormatData *) opaque; + struct virCapabilitiesData *data = (struct virCapabilitiesData *) opaque; + const char *archStr = virArchToString(data->arch); virCapsPtr caps = NULL; char *capsXML = NULL; char *path = NULL; + char *dir = NULL; int ret = -1; - if (!(caps = buildVirCapabilities(data->max_cells, data->max_cpus_in_cell, - data->max_mem_in_cell))) + if (virAsprintf(&dir, "%s/vircaps2xmldata/linux-%s", + abs_srcdir, data->filename) < 0) + goto cleanup; + + virSysfsSetSystemPath(dir); + caps = virCapabilitiesNew(data->arch, data->offlineMigrate, data->liveMigrate); + + if (!caps) + goto cleanup; + + if (virCapabilitiesInitNUMA(caps) < 0) goto cleanup; + virSysfsSetSystemPath(NULL); + if (!(capsXML = virCapabilitiesFormatXML(caps))) goto cleanup; - if (virAsprintf(&path, "%s/vircaps2xmldata/vircaps-%s.xml", - abs_srcdir, data->filename) < 0) + if (virAsprintf(&path, "%s/vircaps2xmldata/vircaps-%s-%s.xml", + abs_srcdir, archStr, data->filename) < 0) goto cleanup; if (virTestCompareToFile(capsXML, path) < 0) @@ -126,6 +78,7 @@ test_virCapabilitiesFormat(const void *opaque) ret = 0; cleanup: + VIR_FREE(dir); VIR_FREE(path); VIR_FREE(capsXML); virObjectUnref(caps); @@ -137,19 +90,33 @@ mymain(void) { int ret = 0; -#define DO_TEST(filename, max_cells, \ - max_cpus_in_cell, max_mem_in_cell) \ - do { \ - struct virCapabilitiesFormatData data = {filename, max_cells, \ - max_cpus_in_cell, \ - max_mem_in_cell}; \ - if (virTestRun(filename, test_virCapabilitiesFormat, &data) < 0) \ - ret = -1; \ +# define DO_TEST_FULL(filename, arch, offlineMigrate, liveMigrate) \ + do { \ + struct virCapabilitiesData data = {filename, arch, \ + offlineMigrate, \ + liveMigrate}; \ + if (virTestRun(filename, test_virCapabilities, &data) < 0) \ + ret = -1; \ } while (0) - DO_TEST("basic-4-4-2G", 4, 4, 2*1024*1024); +# define DO_TEST(filename, arch) DO_TEST_FULL(filename, arch, true, true) + + DO_TEST_FULL("basic", VIR_ARCH_X86_64, false, false); + DO_TEST_FULL("basic", VIR_ARCH_AARCH64, true, false); + + DO_TEST("caches", VIR_ARCH_X86_64); return ret; } -VIRT_TEST_MAIN(mymain) +VIRT_TEST_MAIN_PRELOAD(mymain, abs_builddir "/.libs/virnumamock.so") + +#else /* !__linux__ */ + +int +main(void) +{ + return EXIT_AM_SKIP; +} + +#endif /* !__linux__ */