1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-22 17:34:18 +03:00

tests: testQemuCapsIterate: Pass suffix to callback

Right now users need to hardcode the suffix, which is not a big
deal since they're the ones who passed it to testQemuCapsIterate()
in the first place; however, since we're already passing most of
the information to the callback and we're going to add more later
on, it makes sense to be consistent and pass the suffix too.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
Andrea Bolognani 2019-10-22 15:44:37 +02:00
parent 51495a4d73
commit 5a45ed9c96
4 changed files with 22 additions and 6 deletions

View File

@ -38,6 +38,7 @@ struct _testQemuData {
const char *inputDir;
const char *outputDir;
const char *archName;
const char *suffix;
const char *base;
int ret;
};
@ -77,8 +78,9 @@ testQemuCaps(const void *opaque)
unsigned int fakeMicrocodeVersion = 0;
const char *p;
if (virAsprintf(&repliesFile, "%s/%s.%s.replies",
data->inputDir, data->base, data->archName) < 0 ||
if (virAsprintf(&repliesFile, "%s/%s.%s.%s",
data->inputDir, data->base,
data->archName, data->suffix) < 0 ||
virAsprintf(&capsFile, "%s/%s.%s.xml",
data->outputDir, data->base, data->archName) < 0)
goto cleanup;
@ -182,6 +184,7 @@ static int
doCapsTest(const char *inputDir,
const char *base,
const char *archName,
const char *suffix,
void *opaque)
{
testQemuDataPtr data = (testQemuDataPtr) opaque;
@ -196,6 +199,7 @@ doCapsTest(const char *inputDir,
data->inputDir = inputDir;
data->base = base;
data->archName = archName;
data->suffix = suffix;
if (virTestRun(title, testQemuCaps, data) < 0)
data->ret = -1;

View File

@ -33,6 +33,7 @@ struct _testQemuData {
const char *outputDir;
const char *base;
const char *archName;
const char *suffix;
int ret;
};
@ -145,8 +146,9 @@ testQemuCapsXML(const void *opaque)
data->outputDir, data->archName) < 0)
goto cleanup;
if (virAsprintf(&capsFile, "%s/%s.%s.xml",
data->inputDir, data->base, data->archName) < 0)
if (virAsprintf(&capsFile, "%s/%s.%s.%s",
data->inputDir, data->base,
data->archName, data->suffix) < 0)
goto cleanup;
if (virTestLoadFile(capsFile, &capsData) < 0)
@ -176,6 +178,7 @@ static int
doCapsTest(const char *inputDir,
const char *base,
const char *archName,
const char *suffix,
void *opaque)
{
testQemuDataPtr data = (testQemuDataPtr) opaque;
@ -187,6 +190,7 @@ doCapsTest(const char *inputDir,
data->inputDir = inputDir;
data->base = base;
data->archName = archName;
data->suffix = suffix;
if (virTestRun(title, testQemuCapsXML, data) < 0)
data->ret = -1;

View File

@ -936,9 +936,16 @@ testQemuCapsIterate(const char *suffix,
archName[0] = '\0';
archName++;
/* Run the user-provided callback */
if (callback(TEST_QEMU_CAPS_PATH, base, archName, opaque) < 0)
/* Run the user-provided callback.
*
* We skip the dot that, as verified earlier, starts the suffix
* to make it nicer to rebuild the original file name from inside
* the callback.
*/
if (callback(TEST_QEMU_CAPS_PATH, base,
archName, suffix + 1, opaque) < 0) {
goto cleanup;
}
}
if (rc < 0)

View File

@ -99,6 +99,7 @@ virHashTablePtr testQemuGetLatestCaps(void);
typedef int (*testQemuCapsIterateCallback)(const char *inputDir,
const char *base,
const char *archName,
const char *suffix,
void *opaque);
int testQemuCapsIterate(const char *suffix,
testQemuCapsIterateCallback callback,