'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(a)redhat.com>
---
tests/domaincapstest.c | 5 +++++
tests/qemucapabilitiesdata/README.rst | 17 ++++++++++++++++-
tests/qemucapabilitiesnumbering.c | 5 ++++-
tests/qemucapabilitiestest.c | 15 +++++++++------
tests/qemucaps2xmltest.c | 9 ++++++---
tests/testutilsqemu.c | 12 +++++++++++-
tests/testutilsqemu.h | 1 +
7 files changed, 52 insertions(+), 12 deletions(-)
diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c
index fbbed40c96..20163e0a72 100644
--- a/tests/domaincapstest.c
+++ b/tests/domaincapstest.c
@@ -312,11 +312,16 @@ doTestQemu(const char *inputDir G_GNUC_UNUSED,
const char *prefix G_GNUC_UNUSED,
const char *version,
const char *arch,
+ const char *variant,
const char *suffix G_GNUC_UNUSED,
void *opaque)
{
int ret = 0;
+ /* currently variant tests are not handled here */
+ if (STRNEQ(variant, ""))
+ return 0;
+
if (STREQ(arch, "x86_64")) {
/* For x86_64 we test three combinations:
*
diff --git a/tests/qemucapabilitiesdata/README.rst
b/tests/qemucapabilitiesdata/README.rst
index 0bf6c97284..749d59becf 100644
--- a/tests/qemucapabilitiesdata/README.rst
+++ b/tests/qemucapabilitiesdata/README.rst
@@ -17,7 +17,7 @@ Naming
Files in this directory have the following naming scheme::
- caps_$QEMUVERSION_$ARCHITECTURE.$SUFFIX
+ caps_$QEMUVERSION_$ARCHITECTURE$VARIANT.$SUFFIX
``$QEMUVERSION``
@@ -32,6 +32,21 @@ Files in this directory have the following naming scheme::
``.replies`` for the dump of the QMP communication used to probe qemu.
``.xml`` for the generated capability dump
+``$VARIANT``
+
+ The variant name is an arbitrary string starting with the '+' sign, 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.
+
+Known test variants
+-------------------
+
+This section will contain a list of variants that are used in the test suite.
+
Usage in tests
==============
diff --git a/tests/qemucapabilitiesnumbering.c b/tests/qemucapabilitiesnumbering.c
index 6814011351..6f33321e17 100644
--- a/tests/qemucapabilitiesnumbering.c
+++ b/tests/qemucapabilitiesnumbering.c
@@ -221,10 +221,13 @@ iterateCapsFile(const char *inputDir,
const char *prefix,
const char *version,
const char *archName,
+ const char *variant,
const char *suffix,
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);
}
diff --git a/tests/qemucapabilitiestest.c b/tests/qemucapabilitiestest.c
index 379fe427d8..081f14a6c3 100644
--- a/tests/qemucapabilitiestest.c
+++ b/tests/qemucapabilitiestest.c
@@ -39,6 +39,7 @@ struct _testQemuData {
const char *prefix;
const char *version;
const char *archName;
+ const char *variant;
const char *suffix;
int ret;
};
@@ -78,12 +79,12 @@ testQemuCaps(const void *opaque)
unsigned int fakeMicrocodeVersion = 0;
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->archName, data->suffix);
- capsFile = g_strdup_printf("%s/%s_%s_%s.xml",
+ data->archName, data->variant, data->suffix);
+ capsFile = g_strdup_printf("%s/%s_%s_%s%s.xml",
data->outputDir, data->prefix, data->version,
- data->archName);
+ data->archName, data->variant);
if (!(mon = qemuMonitorTestNewFromFileFull(repliesFile, &data->driver, NULL,
NULL)))
@@ -142,9 +143,9 @@ testQemuCapsCopy(const void *opaque)
g_autoptr(virQEMUCaps) copy = 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->archName);
+ data->archName, data->variant);
if (!(orig = qemuTestParseCapabilitiesArch(
virArchFromString(data->archName), capsFile)))
@@ -167,6 +168,7 @@ doCapsTest(const char *inputDir,
const char *prefix,
const char *version,
const char *archName,
+ const char *variant,
const char *suffix,
void *opaque)
{
@@ -181,6 +183,7 @@ doCapsTest(const char *inputDir,
data->prefix = prefix;
data->version = version;
data->archName = archName;
+ data->variant = variant,
data->suffix = suffix;
if (virTestRun(title, testQemuCaps, data) < 0)
diff --git a/tests/qemucaps2xmltest.c b/tests/qemucaps2xmltest.c
index 2c40dcb114..2c5cb1b68b 100644
--- a/tests/qemucaps2xmltest.c
+++ b/tests/qemucaps2xmltest.c
@@ -33,6 +33,7 @@ struct _testQemuData {
const char *prefix;
const char *version;
const char *archName;
+ const char *variant;
const char *suffix;
int ret;
};
@@ -122,11 +123,11 @@ testQemuCapsXML(const void *opaque)
g_autofree char *capsXml = 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->archName, data->suffix);
+ data->archName, data->variant, data->suffix);
if (virTestLoadFile(capsFile, &capsData) < 0)
return -1;
@@ -149,6 +150,7 @@ doCapsTest(const char *inputDir,
const char *prefix,
const char *version,
const char *archName,
+ const char *variant,
const char *suffix,
void *opaque)
{
@@ -161,6 +163,7 @@ doCapsTest(const char *inputDir,
data->prefix = prefix;
data->version = version;
data->archName = archName;
+ data->variant = variant;
data->suffix = suffix;
if (virTestRun(title, testQemuCapsXML, data) < 0)
diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
index 917cdc02a3..7f2aca5221 100644
--- a/tests/testutilsqemu.c
+++ b/tests/testutilsqemu.c
@@ -834,6 +834,8 @@ testQemuCapsIterate(const char *suffix,
g_autofree char *tmp = g_strdup(ent->d_name);
char *version = NULL;
char *archName = NULL;
+ g_autofree char *variant = NULL;
+ char *var;
/* Strip the trailing suffix, moving on if it's not present */
if (!virStringStripSuffix(tmp, suffix))
@@ -857,6 +859,14 @@ testQemuCapsIterate(const char *suffix,
archName[0] = '\0';
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.
*
* We skip the dot that, as verified earlier, starts the suffix
@@ -864,7 +874,7 @@ testQemuCapsIterate(const char *suffix,
* the callback.
*/
if (callback(TEST_QEMU_CAPS_PATH, "caps", version,
- archName, suffix + 1, opaque) < 0)
+ archName, variant, suffix + 1, opaque) < 0)
fail = true;
}
diff --git a/tests/testutilsqemu.h b/tests/testutilsqemu.h
index 11bdd2fd2f..d75dfee839 100644
--- a/tests/testutilsqemu.h
+++ b/tests/testutilsqemu.h
@@ -143,6 +143,7 @@ typedef int (*testQemuCapsIterateCallback)(const char *inputDir,
const char *prefix,
const char *version,
const char *archName,
+ const char *variant,
const char *suffix,
void *opaque);
int testQemuCapsIterate(const char *suffix,
--
2.39.2