mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 05:17:59 +03:00
tests: Add support for multiple variants of data for the same qemu version+architecture
'qemucapabilitiestest' and other users of the capability data can benefit from adding a discriminator string to have multiple instances for the same version+architecture tuple. This will in the future allow us to have specific capability versions for test cases which require a specific host feature or are based on a different operating system. Add the basic skeleton for parsing the variant string and passing it around into test cases. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
36a735c553
commit
2102a31bc2
@ -312,11 +312,16 @@ doTestQemu(const char *inputDir G_GNUC_UNUSED,
|
|||||||
const char *prefix G_GNUC_UNUSED,
|
const char *prefix G_GNUC_UNUSED,
|
||||||
const char *version,
|
const char *version,
|
||||||
const char *arch,
|
const char *arch,
|
||||||
|
const char *variant,
|
||||||
const char *suffix G_GNUC_UNUSED,
|
const char *suffix G_GNUC_UNUSED,
|
||||||
void *opaque)
|
void *opaque)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
/* currently variant tests are not handled here */
|
||||||
|
if (STRNEQ(variant, ""))
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (STREQ(arch, "x86_64")) {
|
if (STREQ(arch, "x86_64")) {
|
||||||
/* For x86_64 we test three combinations:
|
/* For x86_64 we test three combinations:
|
||||||
*
|
*
|
||||||
|
@ -22,6 +22,10 @@ Files in this directory have the following naming scheme::
|
|||||||
|
|
||||||
caps_$QEMUVERSION_$ARCHITECTURE.$SUFFIX
|
caps_$QEMUVERSION_$ARCHITECTURE.$SUFFIX
|
||||||
|
|
||||||
|
or::
|
||||||
|
|
||||||
|
caps_$QEMUVERSION_$ARCHITECTURE+$VARIANT.$SUFFIX
|
||||||
|
|
||||||
``$QEMUVERSION``
|
``$QEMUVERSION``
|
||||||
|
|
||||||
Numeric representation of the qemu version, e.g.: ``7.0.0``
|
Numeric representation of the qemu version, e.g.: ``7.0.0``
|
||||||
@ -35,6 +39,21 @@ Files in this directory have the following naming scheme::
|
|||||||
``.replies`` for the dump of the QMP communication used to probe qemu.
|
``.replies`` for the dump of the QMP communication used to probe qemu.
|
||||||
``.xml`` for the generated capability dump
|
``.xml`` for the generated capability dump
|
||||||
|
|
||||||
|
``$VARIANT``
|
||||||
|
|
||||||
|
The variant name is an optional arbitrary string, not containing any dot.
|
||||||
|
|
||||||
|
A variant is an additional named version of capabilities for given version and
|
||||||
|
architecture tuple. This allows for testing special cases which e.g. depend
|
||||||
|
on a specific host platform or operating system feature, which differs from
|
||||||
|
the main tests. Note that in the test code the variant name is an empty string
|
||||||
|
or includes the '+' sign for ease of use.
|
||||||
|
|
||||||
|
Known test variants
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
This section will contain a list of variants that are used in the test suite.
|
||||||
|
|
||||||
Usage in tests
|
Usage in tests
|
||||||
==============
|
==============
|
||||||
|
|
||||||
|
@ -221,10 +221,13 @@ iterateCapsFile(const char *inputDir,
|
|||||||
const char *prefix,
|
const char *prefix,
|
||||||
const char *version,
|
const char *version,
|
||||||
const char *archName,
|
const char *archName,
|
||||||
|
const char *variant,
|
||||||
const char *suffix,
|
const char *suffix,
|
||||||
void *opaque G_GNUC_UNUSED)
|
void *opaque G_GNUC_UNUSED)
|
||||||
{
|
{
|
||||||
g_autofree char *repliesFile = g_strdup_printf("%s/%s_%s_%s.%s", inputDir, prefix, version, archName, suffix);
|
g_autofree char *repliesFile = g_strdup_printf("%s/%s_%s_%s%s.%s",
|
||||||
|
inputDir, prefix, version,
|
||||||
|
archName, variant, suffix);
|
||||||
|
|
||||||
return virTestRun(repliesFile, testCapsFile, repliesFile);
|
return virTestRun(repliesFile, testCapsFile, repliesFile);
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,7 @@ struct _testQemuData {
|
|||||||
const char *prefix;
|
const char *prefix;
|
||||||
const char *version;
|
const char *version;
|
||||||
const char *archName;
|
const char *archName;
|
||||||
|
const char *variant;
|
||||||
const char *suffix;
|
const char *suffix;
|
||||||
int ret;
|
int ret;
|
||||||
};
|
};
|
||||||
@ -78,12 +79,12 @@ testQemuCaps(const void *opaque)
|
|||||||
unsigned int fakeMicrocodeVersion = 0;
|
unsigned int fakeMicrocodeVersion = 0;
|
||||||
const char *p;
|
const char *p;
|
||||||
|
|
||||||
repliesFile = g_strdup_printf("%s/%s_%s_%s.%s",
|
repliesFile = g_strdup_printf("%s/%s_%s_%s%s.%s",
|
||||||
data->inputDir, data->prefix, data->version,
|
data->inputDir, data->prefix, data->version,
|
||||||
data->archName, data->suffix);
|
data->archName, data->variant, data->suffix);
|
||||||
capsFile = g_strdup_printf("%s/%s_%s_%s.xml",
|
capsFile = g_strdup_printf("%s/%s_%s_%s%s.xml",
|
||||||
data->outputDir, data->prefix, data->version,
|
data->outputDir, data->prefix, data->version,
|
||||||
data->archName);
|
data->archName, data->variant);
|
||||||
|
|
||||||
if (!(mon = qemuMonitorTestNewFromFileFull(repliesFile, &data->driver, NULL,
|
if (!(mon = qemuMonitorTestNewFromFileFull(repliesFile, &data->driver, NULL,
|
||||||
NULL)))
|
NULL)))
|
||||||
@ -142,9 +143,9 @@ testQemuCapsCopy(const void *opaque)
|
|||||||
g_autoptr(virQEMUCaps) copy = NULL;
|
g_autoptr(virQEMUCaps) copy = NULL;
|
||||||
g_autofree char *actual = NULL;
|
g_autofree char *actual = NULL;
|
||||||
|
|
||||||
capsFile = g_strdup_printf("%s/%s_%s_%s.xml",
|
capsFile = g_strdup_printf("%s/%s_%s_%s%s.xml",
|
||||||
data->outputDir, data->prefix, data->version,
|
data->outputDir, data->prefix, data->version,
|
||||||
data->archName);
|
data->archName, data->variant);
|
||||||
|
|
||||||
if (!(orig = qemuTestParseCapabilitiesArch(
|
if (!(orig = qemuTestParseCapabilitiesArch(
|
||||||
virArchFromString(data->archName), capsFile)))
|
virArchFromString(data->archName), capsFile)))
|
||||||
@ -167,6 +168,7 @@ doCapsTest(const char *inputDir,
|
|||||||
const char *prefix,
|
const char *prefix,
|
||||||
const char *version,
|
const char *version,
|
||||||
const char *archName,
|
const char *archName,
|
||||||
|
const char *variant,
|
||||||
const char *suffix,
|
const char *suffix,
|
||||||
void *opaque)
|
void *opaque)
|
||||||
{
|
{
|
||||||
@ -181,6 +183,7 @@ doCapsTest(const char *inputDir,
|
|||||||
data->prefix = prefix;
|
data->prefix = prefix;
|
||||||
data->version = version;
|
data->version = version;
|
||||||
data->archName = archName;
|
data->archName = archName;
|
||||||
|
data->variant = variant,
|
||||||
data->suffix = suffix;
|
data->suffix = suffix;
|
||||||
|
|
||||||
if (virTestRun(title, testQemuCaps, data) < 0)
|
if (virTestRun(title, testQemuCaps, data) < 0)
|
||||||
|
@ -33,6 +33,7 @@ struct _testQemuData {
|
|||||||
const char *prefix;
|
const char *prefix;
|
||||||
const char *version;
|
const char *version;
|
||||||
const char *archName;
|
const char *archName;
|
||||||
|
const char *variant;
|
||||||
const char *suffix;
|
const char *suffix;
|
||||||
int ret;
|
int ret;
|
||||||
};
|
};
|
||||||
@ -122,11 +123,11 @@ testQemuCapsXML(const void *opaque)
|
|||||||
g_autofree char *capsXml = NULL;
|
g_autofree char *capsXml = NULL;
|
||||||
g_autoptr(virCaps) capsProvided = NULL;
|
g_autoptr(virCaps) capsProvided = NULL;
|
||||||
|
|
||||||
xmlFile = g_strdup_printf("%s/caps.%s.xml", data->outputDir, data->archName);
|
xmlFile = g_strdup_printf("%s/caps.%s%s.xml", data->outputDir, data->archName, data->variant);
|
||||||
|
|
||||||
capsFile = g_strdup_printf("%s/%s_%s_%s.%s",
|
capsFile = g_strdup_printf("%s/%s_%s_%s%s.%s",
|
||||||
data->inputDir, data->prefix, data->version,
|
data->inputDir, data->prefix, data->version,
|
||||||
data->archName, data->suffix);
|
data->archName, data->variant, data->suffix);
|
||||||
|
|
||||||
if (virTestLoadFile(capsFile, &capsData) < 0)
|
if (virTestLoadFile(capsFile, &capsData) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -149,6 +150,7 @@ doCapsTest(const char *inputDir,
|
|||||||
const char *prefix,
|
const char *prefix,
|
||||||
const char *version,
|
const char *version,
|
||||||
const char *archName,
|
const char *archName,
|
||||||
|
const char *variant,
|
||||||
const char *suffix,
|
const char *suffix,
|
||||||
void *opaque)
|
void *opaque)
|
||||||
{
|
{
|
||||||
@ -161,6 +163,7 @@ doCapsTest(const char *inputDir,
|
|||||||
data->prefix = prefix;
|
data->prefix = prefix;
|
||||||
data->version = version;
|
data->version = version;
|
||||||
data->archName = archName;
|
data->archName = archName;
|
||||||
|
data->variant = variant;
|
||||||
data->suffix = suffix;
|
data->suffix = suffix;
|
||||||
|
|
||||||
if (virTestRun(title, testQemuCapsXML, data) < 0)
|
if (virTestRun(title, testQemuCapsXML, data) < 0)
|
||||||
|
@ -834,6 +834,8 @@ testQemuCapsIterate(const char *suffix,
|
|||||||
g_autofree char *tmp = g_strdup(ent->d_name);
|
g_autofree char *tmp = g_strdup(ent->d_name);
|
||||||
char *version = NULL;
|
char *version = NULL;
|
||||||
char *archName = NULL;
|
char *archName = NULL;
|
||||||
|
g_autofree char *variant = NULL;
|
||||||
|
char *var;
|
||||||
|
|
||||||
/* Strip the trailing suffix, moving on if it's not present */
|
/* Strip the trailing suffix, moving on if it's not present */
|
||||||
if (!virStringStripSuffix(tmp, suffix))
|
if (!virStringStripSuffix(tmp, suffix))
|
||||||
@ -857,6 +859,14 @@ testQemuCapsIterate(const char *suffix,
|
|||||||
archName[0] = '\0';
|
archName[0] = '\0';
|
||||||
archName++;
|
archName++;
|
||||||
|
|
||||||
|
/* Find the 'variant' of the test and split it including the leading '+' */
|
||||||
|
if ((var = strchr(archName, '+'))) {
|
||||||
|
variant = g_strdup(var);
|
||||||
|
var[0] = '\0';
|
||||||
|
} else {
|
||||||
|
variant = g_strdup("");
|
||||||
|
}
|
||||||
|
|
||||||
/* Run the user-provided callback.
|
/* Run the user-provided callback.
|
||||||
*
|
*
|
||||||
* We skip the dot that, as verified earlier, starts the suffix
|
* We skip the dot that, as verified earlier, starts the suffix
|
||||||
@ -864,7 +874,7 @@ testQemuCapsIterate(const char *suffix,
|
|||||||
* the callback.
|
* the callback.
|
||||||
*/
|
*/
|
||||||
if (callback(TEST_QEMU_CAPS_PATH, "caps", version,
|
if (callback(TEST_QEMU_CAPS_PATH, "caps", version,
|
||||||
archName, suffix + 1, opaque) < 0)
|
archName, variant, suffix + 1, opaque) < 0)
|
||||||
fail = true;
|
fail = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,6 +143,7 @@ typedef int (*testQemuCapsIterateCallback)(const char *inputDir,
|
|||||||
const char *prefix,
|
const char *prefix,
|
||||||
const char *version,
|
const char *version,
|
||||||
const char *archName,
|
const char *archName,
|
||||||
|
const char *variant,
|
||||||
const char *suffix,
|
const char *suffix,
|
||||||
void *opaque);
|
void *opaque);
|
||||||
int testQemuCapsIterate(const char *suffix,
|
int testQemuCapsIterate(const char *suffix,
|
||||||
|
Loading…
Reference in New Issue
Block a user