mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
tests: testQemuCapsIterate: Pass prefix and version to callback
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@redhat.com> Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user