[libvirt] [PATCH] tests: skip qemublocktest if building without YAJL

Daniel P. Berrangé berrange at redhat.com
Tue Sep 4 11:01:10 UTC 2018


If no JSON parser is available qemublocktest fails, so skip its execution.

Signed-off-by: Daniel P. Berrangé <berrange at redhat.com>
---

Pushed as a build fix for platforms without JSON parser installed

 tests/qemublocktest.c | 36 +++++++++++++++++++++++-------------
 1 file changed, 23 insertions(+), 13 deletions(-)

diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c
index 0c335abc5b..8e8773e6a8 100644
--- a/tests/qemublocktest.c
+++ b/tests/qemublocktest.c
@@ -19,17 +19,19 @@
 #include <stdlib.h>
 
 #include "testutils.h"
-#include "testutilsqemu.h"
-#include "testutilsqemuschema.h"
-#include "virstoragefile.h"
-#include "virstring.h"
-#include "virlog.h"
-#include "qemu/qemu_block.h"
-#include "qemu/qemu_qapi.h"
 
-#include "qemu/qemu_command.h"
+#if WITH_YAJL
+# include "testutilsqemu.h"
+# include "testutilsqemuschema.h"
+# include "virstoragefile.h"
+# include "virstring.h"
+# include "virlog.h"
+# include "qemu/qemu_block.h"
+# include "qemu/qemu_qapi.h"
 
-#define VIR_FROM_THIS VIR_FROM_NONE
+# include "qemu/qemu_command.h"
+
+# define VIR_FROM_THIS VIR_FROM_NONE
 
 VIR_LOG_INIT("tests.storagetest");
 
@@ -355,7 +357,7 @@ mymain(void)
 
     virTestCounterReset("qemu storage source xml->json->xml ");
 
-#define TEST_JSON_FORMAT(tpe, xmlstr) \
+# define TEST_JSON_FORMAT(tpe, xmlstr) \
     do { \
         xmljsonxmldata.type = tpe; \
         xmljsonxmldata.xml = xmlstr; \
@@ -364,7 +366,7 @@ mymain(void)
             ret = -1; \
     } while (0)
 
-#define TEST_JSON_FORMAT_NET(xmlstr)\
+# define TEST_JSON_FORMAT_NET(xmlstr) \
     TEST_JSON_FORMAT(VIR_STORAGE_TYPE_NETWORK, xmlstr)
 
     TEST_JSON_FORMAT(VIR_STORAGE_TYPE_FILE, "<source file='/path/to/file'/>\n");
@@ -417,7 +419,7 @@ mymain(void)
                          "  <host name='example.com' port='9999'/>\n"
                          "</source>\n");
 
-#define TEST_DISK_TO_JSON_FULL(nme, fl) \
+# define TEST_DISK_TO_JSON_FULL(nme, fl) \
     do { \
         diskxmljsondata.name = nme; \
         diskxmljsondata.props = NULL; \
@@ -435,7 +437,7 @@ mymain(void)
         testQemuDiskXMLToPropsClear(&diskxmljsondata); \
     } while (0)
 
-#define TEST_DISK_TO_JSON(nme) TEST_DISK_TO_JSON_FULL(nme, false)
+# define TEST_DISK_TO_JSON(nme) TEST_DISK_TO_JSON_FULL(nme, false)
 
     if (!(diskxmljsondata.schema = testQEMUSchemaLoad())) {
         ret = -1;
@@ -500,4 +502,12 @@ mymain(void)
     return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
 }
 
+#else
+static int
+mymain(void)
+{
+    return EXIT_AM_SKIP;
+}
+#endif
+
 VIR_TEST_MAIN(mymain)
-- 
2.17.1




More information about the libvir-list mailing list