This removes a little duplication right away, and more
importantly will allow us to perform some interesting
refactoring later on.
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
tests/qemucapabilitiestest.c | 15 +++++++++------
tests/qemucaps2xmltest.c | 13 +++++++++----
2 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/tests/qemucapabilitiestest.c b/tests/qemucapabilitiestest.c
index 0f875f9e24..e3c6681dd4 100644
--- a/tests/qemucapabilitiestest.c
+++ b/tests/qemucapabilitiestest.c
@@ -35,6 +35,7 @@ typedef struct _testQemuData testQemuData;
typedef testQemuData *testQemuDataPtr;
struct _testQemuData {
virQEMUDriver driver;
+ const char *dataDir;
const char *archName;
const char *base;
int ret;
@@ -47,6 +48,8 @@ testQemuDataInit(testQemuDataPtr data)
if (qemuTestDriverInit(&data->driver) < 0)
return -1;
+ data->dataDir = abs_srcdir "/qemucapabilitiesdata";
+
data->ret = 0;
return 0;
@@ -73,10 +76,10 @@ testQemuCaps(const void *opaque)
unsigned int fakeMicrocodeVersion = 0;
const char *p;
- if (virAsprintf(&repliesFile, "%s/qemucapabilitiesdata/%s.%s.replies",
- abs_srcdir, data->base, data->archName) < 0 ||
- virAsprintf(&capsFile, "%s/qemucapabilitiesdata/%s.%s.xml",
- abs_srcdir, data->base, data->archName) < 0)
+ if (virAsprintf(&repliesFile, "%s/%s.%s.replies",
+ data->dataDir, data->base, data->archName) < 0 ||
+ virAsprintf(&capsFile, "%s/%s.%s.xml",
+ data->dataDir, data->base, data->archName) < 0)
goto cleanup;
if (!(mon = qemuMonitorTestNewFromFileFull(repliesFile, &data->driver,
NULL)))
@@ -141,8 +144,8 @@ testQemuCapsCopy(const void *opaque)
virQEMUCapsPtr copy = NULL;
char *actual = NULL;
- if (virAsprintf(&capsFile, "%s/qemucapabilitiesdata/%s.%s.xml",
- abs_srcdir, data->base, data->archName) < 0)
+ if (virAsprintf(&capsFile, "%s/%s.%s.xml",
+ data->dataDir, data->base, data->archName) < 0)
goto cleanup;
if (!(caps = virCapabilitiesNew(virArchFromString(data->archName),
diff --git a/tests/qemucaps2xmltest.c b/tests/qemucaps2xmltest.c
index e9b0b11e35..46d2ce8b44 100644
--- a/tests/qemucaps2xmltest.c
+++ b/tests/qemucaps2xmltest.c
@@ -28,6 +28,8 @@
typedef struct _testQemuData testQemuData;
typedef testQemuData *testQemuDataPtr;
struct _testQemuData {
+ const char *inputDir;
+ const char *outputDir;
const char *base;
const char *archName;
int ret;
@@ -36,6 +38,9 @@ struct _testQemuData {
static int
testQemuDataInit(testQemuDataPtr data)
{
+ data->inputDir = abs_srcdir "/qemucapabilitiesdata";
+ data->outputDir = abs_srcdir "/qemucaps2xmloutdata";
+
data->ret = 0;
return 0;
@@ -142,12 +147,12 @@ testQemuCapsXML(const void *opaque)
char *capsXml = NULL;
virCapsPtr capsProvided = NULL;
- if (virAsprintf(&xmlFile, "%s/qemucaps2xmloutdata/caps.%s.xml",
- abs_srcdir, data->archName) < 0)
+ if (virAsprintf(&xmlFile, "%s/caps.%s.xml",
+ data->outputDir, data->archName) < 0)
goto cleanup;
- if (virAsprintf(&capsFile, "%s/qemucapabilitiesdata/%s.%s.xml",
- abs_srcdir, data->base, data->archName) < 0)
+ if (virAsprintf(&capsFile, "%s/%s.%s.xml",
+ data->inputDir, data->base, data->archName) < 0)
goto cleanup;
if (virTestLoadFile(capsFile, &capsData) < 0)
--
2.20.1