Right now we're passing a "base" string that contains both,
separated by an underscore. Some changes that we're going to
introduce later will require us to have the version number on its
own, and instead of delegating the task of splitting the two apart
to the callback it make more sense to perform it upfront.
This change results in quite a bit of churn because we're now
using the version number only, without the prefix, to calculate
the dummy microcodeVersion.
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
.../caps_1.5.3.x86_64.xml | 2 +-
.../caps_1.6.0.x86_64.xml | 2 +-
.../caps_1.7.0.x86_64.xml | 2 +-
.../caps_2.1.1.x86_64.xml | 2 +-
.../caps_2.10.0.aarch64.xml | 2 +-
.../caps_2.10.0.ppc64.xml | 2 +-
.../caps_2.10.0.s390x.xml | 2 +-
.../caps_2.10.0.x86_64.xml | 2 +-
.../caps_2.11.0.s390x.xml | 2 +-
.../caps_2.11.0.x86_64.xml | 2 +-
.../caps_2.12.0.aarch64.xml | 2 +-
.../caps_2.12.0.ppc64.xml | 2 +-
.../caps_2.12.0.s390x.xml | 2 +-
.../caps_2.12.0.x86_64.xml | 2 +-
.../caps_2.4.0.x86_64.xml | 2 +-
.../caps_2.5.0.x86_64.xml | 2 +-
.../caps_2.6.0.aarch64.xml | 2 +-
.../qemucapabilitiesdata/caps_2.6.0.ppc64.xml | 2 +-
.../caps_2.6.0.x86_64.xml | 2 +-
.../qemucapabilitiesdata/caps_2.7.0.s390x.xml | 2 +-
.../caps_2.7.0.x86_64.xml | 2 +-
.../qemucapabilitiesdata/caps_2.8.0.s390x.xml | 2 +-
.../caps_2.8.0.x86_64.xml | 2 +-
.../qemucapabilitiesdata/caps_2.9.0.ppc64.xml | 2 +-
.../qemucapabilitiesdata/caps_2.9.0.s390x.xml | 2 +-
.../caps_2.9.0.x86_64.xml | 2 +-
.../qemucapabilitiesdata/caps_3.0.0.ppc64.xml | 2 +-
.../qemucapabilitiesdata/caps_3.0.0.s390x.xml | 2 +-
.../caps_3.0.0.x86_64.xml | 2 +-
.../qemucapabilitiesdata/caps_3.1.0.ppc64.xml | 2 +-
.../caps_3.1.0.x86_64.xml | 2 +-
.../caps_4.0.0.aarch64.xml | 2 +-
.../qemucapabilitiesdata/caps_4.0.0.ppc64.xml | 2 +-
.../qemucapabilitiesdata/caps_4.0.0.s390x.xml | 2 +-
.../caps_4.0.0.x86_64.xml | 2 +-
.../caps_4.1.0.x86_64.xml | 2 +-
.../caps_4.2.0.aarch64.xml | 2 +-
.../qemucapabilitiesdata/caps_4.2.0.ppc64.xml | 2 +-
.../caps_4.2.0.x86_64.xml | 2 +-
tests/qemucapabilitiestest.c | 29 +++++++++++--------
tests/qemucaps2xmltest.c | 15 ++++++----
tests/testutilsqemu.c | 16 ++++++----
tests/testutilsqemu.h | 3 +-
43 files changed, 78 insertions(+), 63 deletions(-)
diff --git a/tests/qemucapabilitiesdata/caps_1.5.3.x86_64.xml
b/tests/qemucapabilitiesdata/caps_1.5.3.x86_64.xml
index 780d75a513..8b573070d5 100644
--- a/tests/qemucapabilitiesdata/caps_1.5.3.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_1.5.3.x86_64.xml
@@ -85,7 +85,7 @@
<flag name='mch'/>
<version>1005003</version>
<kvmVersion>0</kvmVersion>
- <microcodeVersion>43100763</microcodeVersion>
+ <microcodeVersion>43100245</microcodeVersion>
<package></package>
<arch>x86_64</arch>
<cpu type='kvm' name='Opteron_G5'/>
[... many more changes exactly like this one ...]
diff --git a/tests/qemucapabilitiestest.c b/tests/qemucapabilitiestest.c
index cc2242df50..8fa4104f20 100644
--- a/tests/qemucapabilitiestest.c
+++ b/tests/qemucapabilitiestest.c
@@ -37,9 +37,10 @@ struct _testQemuData {
virQEMUDriver driver;
const char *inputDir;
const char *outputDir;
+ const char *prefix;
+ const char *version;
const char *archName;
const char *suffix;
- const char *base;
int ret;
};
@@ -78,11 +79,12 @@ testQemuCaps(const void *opaque)
unsigned int fakeMicrocodeVersion = 0;
const char *p;
- if (virAsprintf(&repliesFile, "%s/%s.%s.%s",
- data->inputDir, data->base,
+ if (virAsprintf(&repliesFile, "%s/%s_%s.%s.%s",
+ data->inputDir, data->prefix, data->version,
data->archName, data->suffix) < 0 ||
- virAsprintf(&capsFile, "%s/%s.%s.xml",
- data->outputDir, data->base, data->archName) < 0)
+ virAsprintf(&capsFile, "%s/%s_%s.%s.xml",
+ data->outputDir, data->prefix, data->version,
+ data->archName) < 0)
goto cleanup;
if (!(mon = qemuMonitorTestNewFromFileFull(repliesFile, &data->driver, NULL,
@@ -114,7 +116,7 @@ testQemuCaps(const void *opaque)
fakeMicrocodeVersion *= 100000;
- for (p = data->base; *p; p++)
+ for (p = data->version; *p; p++)
fakeMicrocodeVersion += *p;
virQEMUCapsSetMicrocodeVersion(capsActual, fakeMicrocodeVersion);
@@ -148,8 +150,9 @@ testQemuCapsCopy(const void *opaque)
virQEMUCapsPtr copy = NULL;
char *actual = NULL;
- if (virAsprintf(&capsFile, "%s/%s.%s.xml",
- data->outputDir, data->base, data->archName) < 0)
+ if (virAsprintf(&capsFile, "%s/%s_%s.%s.xml",
+ data->outputDir, data->prefix, data->version,
+ data->archName) < 0)
goto cleanup;
if (!(caps = virCapabilitiesNew(virArchFromString(data->archName),
@@ -182,7 +185,8 @@ testQemuCapsCopy(const void *opaque)
static int
doCapsTest(const char *inputDir,
- const char *base,
+ const char *prefix,
+ const char *version,
const char *archName,
const char *suffix,
void *opaque)
@@ -191,13 +195,14 @@ doCapsTest(const char *inputDir,
g_autofree char *title = NULL;
g_autofree char *copyTitle = NULL;
- if (virAsprintf(&title, "%s (%s)", base, archName) < 0 ||
- virAsprintf(©Title, "copy %s (%s)", base, archName) < 0) {
+ if (virAsprintf(&title, "%s (%s)", version, archName) < 0 ||
+ virAsprintf(©Title, "copy %s (%s)", version, archName) < 0)
{
return -1;
}
data->inputDir = inputDir;
- data->base = base;
+ data->prefix = prefix;
+ data->version = version;
data->archName = archName;
data->suffix = suffix;
diff --git a/tests/qemucaps2xmltest.c b/tests/qemucaps2xmltest.c
index 7a41e9cdd3..365efbe4b1 100644
--- a/tests/qemucaps2xmltest.c
+++ b/tests/qemucaps2xmltest.c
@@ -31,7 +31,8 @@ typedef testQemuData *testQemuDataPtr;
struct _testQemuData {
const char *inputDir;
const char *outputDir;
- const char *base;
+ const char *prefix;
+ const char *version;
const char *archName;
const char *suffix;
int ret;
@@ -146,8 +147,8 @@ testQemuCapsXML(const void *opaque)
data->outputDir, data->archName) < 0)
goto cleanup;
- if (virAsprintf(&capsFile, "%s/%s.%s.%s",
- data->inputDir, data->base,
+ if (virAsprintf(&capsFile, "%s/%s_%s.%s.%s",
+ data->inputDir, data->prefix, data->version,
data->archName, data->suffix) < 0)
goto cleanup;
@@ -176,7 +177,8 @@ testQemuCapsXML(const void *opaque)
static int
doCapsTest(const char *inputDir,
- const char *base,
+ const char *prefix,
+ const char *version,
const char *archName,
const char *suffix,
void *opaque)
@@ -184,11 +186,12 @@ doCapsTest(const char *inputDir,
testQemuDataPtr data = (testQemuDataPtr) opaque;
g_autofree char *title = NULL;
- if (virAsprintf(&title, "%s (%s)", base, archName) < 0)
+ if (virAsprintf(&title, "%s (%s)", version, archName) < 0)
return -1;
data->inputDir = inputDir;
- data->base = base;
+ data->prefix = prefix;
+ data->version = version;
data->archName = archName;
data->suffix = suffix;
diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
index 1f0270f488..54d6b1a0ac 100644
--- a/tests/testutilsqemu.c
+++ b/tests/testutilsqemu.c
@@ -917,22 +917,28 @@ testQemuCapsIterate(const char *suffix,
while ((rc = virDirRead(dir, &ent, TEST_QEMU_CAPS_PATH)) > 0) {
g_autofree char *tmp = g_strdup(ent->d_name);
- char *base = NULL;
+ char *version = NULL;
char *archName = NULL;
/* Strip the trailing suffix, moving on if it's not present */
if (!virStringStripSuffix(tmp, suffix))
continue;
+ /* Strip the leading prefix */
+ if (!(version = STRSKIP(tmp, "caps_"))) {
+ VIR_TEST_VERBOSE("malformed file name '%s'",
ent->d_name);
+ goto cleanup;
+ }
+
/* Find the last dot */
if (!(archName = strrchr(tmp, '.'))) {
VIR_TEST_VERBOSE("malformed file name '%s'",
ent->d_name);
goto cleanup;
}
- /* The base name is everything before the last dot, and
- * the architecture name everything after it */
- base = tmp;
+ /* The version number and the architecture name are separated by
+ * a dot: overwriting that dot with \0 results in both being usable
+ * as independent, null-terminated strings */
archName[0] = '\0';
archName++;
@@ -942,7 +948,7 @@ testQemuCapsIterate(const char *suffix,
* to make it nicer to rebuild the original file name from inside
* the callback.
*/
- if (callback(TEST_QEMU_CAPS_PATH, base,
+ if (callback(TEST_QEMU_CAPS_PATH, "caps", version,
archName, suffix + 1, opaque) < 0) {
goto cleanup;
}
diff --git a/tests/testutilsqemu.h b/tests/testutilsqemu.h
index 2c8c4960e9..714a95bb7a 100644
--- a/tests/testutilsqemu.h
+++ b/tests/testutilsqemu.h
@@ -97,7 +97,8 @@ char *testQemuGetLatestCapsForArch(const char *arch,
virHashTablePtr testQemuGetLatestCaps(void);
typedef int (*testQemuCapsIterateCallback)(const char *inputDir,
- const char *base,
+ const char *prefix,
+ const char *version,
const char *archName,
const char *suffix,
void *opaque);
--
2.21.0