提交 65952b24 编写于 作者: A Andrea Bolognani

tests: Unify data structure for vircaps2xmltest

If all we achieve is reducing the depth by one for a single
test case, the additional complexity (not to mention breaking
the principle of least surprise) is not worth it: let's use
simpler, more predictable code instead.

This basically reverts fec6e4c4 (with a few adjustments).
Signed-off-by: NAndrea Bolognani <abologna@redhat.com>
Reviewed-by: NMartin Kletzander <mkletzan@redhat.com>
上级 0a5a6f0d
...@@ -35,7 +35,6 @@ struct virCapabilitiesData { ...@@ -35,7 +35,6 @@ struct virCapabilitiesData {
virArch arch; virArch arch;
bool offlineMigrate; bool offlineMigrate;
bool liveMigrate; bool liveMigrate;
bool resctrl; /* Whether both resctrl and system sysfs are used */
}; };
static int static int
...@@ -46,24 +45,19 @@ test_virCapabilities(const void *opaque) ...@@ -46,24 +45,19 @@ test_virCapabilities(const void *opaque)
virCapsPtr caps = NULL; virCapsPtr caps = NULL;
char *capsXML = NULL; char *capsXML = NULL;
char *path = NULL; char *path = NULL;
char *dir = NULL; char *system = NULL;
char *resctrl = NULL; char *resctrl = NULL;
int ret = -1; int ret = -1;
/* if (virAsprintf(&system, "%s/vircaps2xmldata/linux-%s/system",
* We want to keep our directory structure clean, so if there's both resctrl abs_srcdir, data->filename) < 0)
* and system used, we need to use slightly different path; a subdir.
*/
if (virAsprintf(&dir, "%s/vircaps2xmldata/linux-%s%s",
abs_srcdir, data->filename,
data->resctrl ? "/system" : "") < 0)
goto cleanup; goto cleanup;
if (virAsprintf(&resctrl, "%s/vircaps2xmldata/linux-%s/resctrl", if (virAsprintf(&resctrl, "%s/vircaps2xmldata/linux-%s/resctrl",
abs_srcdir, data->filename) < 0) abs_srcdir, data->filename) < 0)
goto cleanup; goto cleanup;
virFileWrapperAddPrefix("/sys/devices/system", dir); virFileWrapperAddPrefix("/sys/devices/system", system);
virFileWrapperAddPrefix("/sys/fs/resctrl", resctrl); virFileWrapperAddPrefix("/sys/fs/resctrl", resctrl);
caps = virCapabilitiesNew(data->arch, data->offlineMigrate, data->liveMigrate); caps = virCapabilitiesNew(data->arch, data->offlineMigrate, data->liveMigrate);
...@@ -89,7 +83,7 @@ test_virCapabilities(const void *opaque) ...@@ -89,7 +83,7 @@ test_virCapabilities(const void *opaque)
ret = 0; ret = 0;
cleanup: cleanup:
VIR_FREE(dir); VIR_FREE(system);
VIR_FREE(resctrl); VIR_FREE(resctrl);
VIR_FREE(path); VIR_FREE(path);
VIR_FREE(capsXML); VIR_FREE(capsXML);
...@@ -102,27 +96,24 @@ mymain(void) ...@@ -102,27 +96,24 @@ mymain(void)
{ {
int ret = 0; int ret = 0;
#define DO_TEST_FULL(filename, arch, offlineMigrate, liveMigrate, resctrl) \ #define DO_TEST_FULL(filename, arch, offlineMigrate, liveMigrate) \
do { \ do { \
struct virCapabilitiesData data = {filename, arch, \ struct virCapabilitiesData data = {filename, arch, \
offlineMigrate, \ offlineMigrate, \
liveMigrate, resctrl}; \ liveMigrate}; \
if (virTestRun(filename, test_virCapabilities, &data) < 0) \ if (virTestRun(filename, test_virCapabilities, &data) < 0) \
ret = -1; \ ret = -1; \
} while (0) } while (0)
DO_TEST_FULL("basic", VIR_ARCH_X86_64, false, false, false); DO_TEST_FULL("basic", VIR_ARCH_X86_64, false, false);
DO_TEST_FULL("basic", VIR_ARCH_AARCH64, true, false, false); DO_TEST_FULL("basic", VIR_ARCH_AARCH64, true, false);
/* We say there is 'resctrl' even though there is none. This is special DO_TEST_FULL("caches", VIR_ARCH_X86_64, true, true);
* case because we want to use this test data for a negative tests for
* resctrl. */
DO_TEST_FULL("caches", VIR_ARCH_X86_64, true, true, true);
DO_TEST_FULL("resctrl", VIR_ARCH_X86_64, true, true, true); DO_TEST_FULL("resctrl", VIR_ARCH_X86_64, true, true);
DO_TEST_FULL("resctrl-cdp", VIR_ARCH_X86_64, true, true, true); DO_TEST_FULL("resctrl-cdp", VIR_ARCH_X86_64, true, true);
DO_TEST_FULL("resctrl-skx", VIR_ARCH_X86_64, true, true, true); DO_TEST_FULL("resctrl-skx", VIR_ARCH_X86_64, true, true);
DO_TEST_FULL("resctrl-skx-twocaches", VIR_ARCH_X86_64, true, true, true); DO_TEST_FULL("resctrl-skx-twocaches", VIR_ARCH_X86_64, true, true);
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册