docs: Reword virDomainGetEmulatorPinInfo description
[libvirt.git] / tests / vircaps2xmltest.c
blob36e6b4b155c32096f9d3fb07e8a1f35af0eb4ffb
1 /*
2 * Copyright (C) Red Hat, Inc. 2014
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library. If not, see
16 * <http://www.gnu.org/licenses/>.
19 #include <config.h>
21 #include "testutils.h"
22 #include "capabilities.h"
23 #include "virfilewrapper.h"
26 #define VIR_FROM_THIS VIR_FROM_NONE
28 struct virCapabilitiesData {
29 const char *filename;
30 virArch arch;
31 bool offlineMigrate;
32 bool liveMigrate;
35 static int
36 test_virCapabilities(const void *opaque)
38 struct virCapabilitiesData *data = (struct virCapabilitiesData *) opaque;
39 const char *archStr = virArchToString(data->arch);
40 g_autoptr(virCaps) caps = NULL;
41 g_autofree char *capsXML = NULL;
42 g_autofree char *path = NULL;
43 g_autofree char *system = NULL;
44 g_autofree char *resctrl = NULL;
46 system = g_strdup_printf("%s/vircaps2xmldata/linux-%s/system", abs_srcdir,
47 data->filename);
49 resctrl = g_strdup_printf("%s/vircaps2xmldata/linux-%s/resctrl", abs_srcdir,
50 data->filename);
52 virFileWrapperAddPrefix("/sys/devices/system", system);
53 virFileWrapperAddPrefix("/sys/fs/resctrl", resctrl);
54 caps = virCapabilitiesNew(data->arch, data->offlineMigrate, data->liveMigrate);
56 if (!caps)
57 return -1;
59 if (!(caps->host.numa = virCapabilitiesHostNUMANewHost()))
60 return -1;
62 if (virCapabilitiesInitCaches(caps) < 0)
63 return -1;
65 virFileWrapperClearPrefixes();
67 if (!(capsXML = virCapabilitiesFormatXML(caps)))
68 return -1;
70 path = g_strdup_printf("%s/vircaps2xmldata/vircaps-%s-%s.xml", abs_srcdir,
71 archStr, data->filename);
73 if (virTestCompareToFile(capsXML, path) < 0)
74 return -1;
76 return 0;
79 static int
80 mymain(void)
82 int ret = 0;
84 #define DO_TEST_FULL(filename, arch, offlineMigrate, liveMigrate) \
85 do { \
86 struct virCapabilitiesData data = {filename, arch, \
87 offlineMigrate, \
88 liveMigrate}; \
89 if (virTestRun(filename, test_virCapabilities, &data) < 0) \
90 ret = -1; \
91 } while (0)
93 DO_TEST_FULL("basic", VIR_ARCH_X86_64, false, false);
94 DO_TEST_FULL("basic", VIR_ARCH_AARCH64, true, false);
95 DO_TEST_FULL("basic-dies", VIR_ARCH_X86_64, false, false);
96 DO_TEST_FULL("basic-clusters", VIR_ARCH_AARCH64, false, false);
98 DO_TEST_FULL("caches", VIR_ARCH_X86_64, true, true);
100 DO_TEST_FULL("hmat", VIR_ARCH_X86_64, true, true);
102 DO_TEST_FULL("resctrl", VIR_ARCH_X86_64, true, true);
103 DO_TEST_FULL("resctrl-cmt", VIR_ARCH_X86_64, true, true);
104 DO_TEST_FULL("resctrl-cdp", VIR_ARCH_X86_64, true, true);
105 DO_TEST_FULL("resctrl-skx", VIR_ARCH_X86_64, true, true);
106 DO_TEST_FULL("resctrl-skx-twocaches", VIR_ARCH_X86_64, true, true);
107 DO_TEST_FULL("resctrl-fake-feature", VIR_ARCH_X86_64, true, true);
109 DO_TEST_FULL("resctrl-amd", VIR_ARCH_X86_64, true, true);
110 DO_TEST_FULL("resctrl-mba_MBps", VIR_ARCH_X86_64, true, true);
112 return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
115 VIR_TEST_MAIN_PRELOAD(mymain, VIR_TEST_MOCK("virnuma"))