Re: [libvirt] [PATCH 5/8] tests: Move code from DO_TEST() to doCapsTest()

2019-03-13 Thread Peter Krempa
On Thu, Mar 07, 2019 at 16:44:34 +0100, Andrea Bolognani wrote:
> This removes the awkard escaping and will allow us to perform
> some interesting refactoring later on.
> 
> Signed-off-by: Andrea Bolognani 
> ---
>  tests/qemucapabilitiestest.c | 40 +---
>  tests/qemucaps2xmltest.c | 28 ++---
>  2 files changed, 49 insertions(+), 19 deletions(-)
> 
> diff --git a/tests/qemucapabilitiestest.c b/tests/qemucapabilitiestest.c
> index 222ac05d79..b4ed081d3e 100644
> --- a/tests/qemucapabilitiestest.c
> +++ b/tests/qemucapabilitiestest.c
> @@ -176,6 +176,32 @@ testQemuCapsCopy(const void *opaque)
>  }
>  
>  
> +static int
> +doCapsTest(const char *base,
> +   const char *archName,
> +   testQemuDataPtr data)
> +{
> +VIR_AUTOFREE(char *) title = NULL;
> +VIR_AUTOFREE(char *) copyTitle = NULL;
> +
> +if (virAsprintf(, "%s (%s)", base, archName) < 0 ||
> +virAsprintf(, "copy %s (%s)", base, archName) < 0) {
> +return -1;
> +}

Single line body.

> +
> +data->base = base;
> +data->archName = archName;
> +
> +if (virTestRun(title, testQemuCaps, data) < 0)
> +data->ret = -1;
> +
> +if (virTestRun(copyTitle, testQemuCapsCopy, data) < 0)
> +data->ret = -1;
> +
> +return 0;
> +}

ACK



signature.asc
Description: PGP signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 5/8] tests: Move code from DO_TEST() to doCapsTest()

2019-03-07 Thread Andrea Bolognani
This removes the awkard escaping and will allow us to perform
some interesting refactoring later on.

Signed-off-by: Andrea Bolognani 
---
 tests/qemucapabilitiestest.c | 40 +---
 tests/qemucaps2xmltest.c | 28 ++---
 2 files changed, 49 insertions(+), 19 deletions(-)

diff --git a/tests/qemucapabilitiestest.c b/tests/qemucapabilitiestest.c
index 222ac05d79..b4ed081d3e 100644
--- a/tests/qemucapabilitiestest.c
+++ b/tests/qemucapabilitiestest.c
@@ -176,6 +176,32 @@ testQemuCapsCopy(const void *opaque)
 }
 
 
+static int
+doCapsTest(const char *base,
+   const char *archName,
+   testQemuDataPtr data)
+{
+VIR_AUTOFREE(char *) title = NULL;
+VIR_AUTOFREE(char *) copyTitle = NULL;
+
+if (virAsprintf(, "%s (%s)", base, archName) < 0 ||
+virAsprintf(, "copy %s (%s)", base, archName) < 0) {
+return -1;
+}
+
+data->base = base;
+data->archName = archName;
+
+if (virTestRun(title, testQemuCaps, data) < 0)
+data->ret = -1;
+
+if (virTestRun(copyTitle, testQemuCapsCopy, data) < 0)
+data->ret = -1;
+
+return 0;
+}
+
+
 static int
 mymain(void)
 {
@@ -196,18 +222,8 @@ mymain(void)
 
 #define DO_TEST(arch, name) \
 do { \
-VIR_AUTOFREE(char *) title = NULL; \
-VIR_AUTOFREE(char *) copyTitle = NULL; \
-if (virAsprintf(, "%s (%s)", name, arch) < 0 || \
-virAsprintf(, "copy %s (%s)", name, arch) < 0) { \
-return -EXIT_FAILURE; \
-} \
-data.archName = arch; \
-data.base = name; \
-if (virTestRun(title, testQemuCaps, ) < 0) \
-data.ret = -1; \
-if (virTestRun(copyTitle, testQemuCapsCopy, ) < 0) \
-data.ret = -1; \
+if (doCapsTest(name, arch, ) < 0) \
+return EXIT_FAILURE; \
 } while (0)
 
 /* Keep this in sync with qemucaps2xmltest */
diff --git a/tests/qemucaps2xmltest.c b/tests/qemucaps2xmltest.c
index be460b42f8..4f9cfc459e 100644
--- a/tests/qemucaps2xmltest.c
+++ b/tests/qemucaps2xmltest.c
@@ -178,6 +178,25 @@ testQemuCapsXML(const void *opaque)
 return ret;
 }
 
+static int
+doCapsTest(const char *base,
+   const char *archName,
+   testQemuDataPtr data)
+{
+VIR_AUTOFREE(char *) title = NULL;
+
+if (virAsprintf(, "%s (%s)", base, archName) < 0)
+return -1;
+
+data->base = base;
+data->archName = archName;
+
+if (virTestRun(title, testQemuCapsXML, data) < 0)
+data->ret = -1;
+
+return 0;
+}
+
 static int
 mymain(void)
 {
@@ -198,13 +217,8 @@ mymain(void)
 
 #define DO_TEST(arch, name) \
 do { \
-VIR_AUTOFREE(char *) title = NULL; \
-if (virAsprintf(, "%s (%s)", name, arch) < 0) \
-return -EXIT_FAILURE; \
-data.archName = arch; \
-data.base = name; \
-if (virTestRun(title, testQemuCapsXML, ) < 0) \
-data.ret = -1; \
+if (doCapsTest(name, arch, ) < 0) \
+return EXIT_FAILURE; \
 } while (0)
 
 /* Keep this in sync with qemucapabilitiestest */
-- 
2.20.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list