]> xenbits.xensource.com Git - libvirt.git/commitdiff
tests: qemuhelp: convert to virTestLoadFilePath
authorPeter Krempa <pkrempa@redhat.com>
Tue, 25 Jul 2017 13:13:33 +0000 (15:13 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 27 Jul 2017 07:37:21 +0000 (09:37 +0200)
As a sample usage of the new helper convert the calls in qemuhelptest to
the new helper.

Reviewed-by: Eric Blake <eblake@redhat.com>
tests/qemuhelptest.c

index 7485d2dcd9072cd72ec28080b0a7561eb1ad2c22..1a6e7092fd1ed290cc267b55c4b9343b0d05ff33 100644 (file)
@@ -44,7 +44,6 @@ static void printMismatchedFlags(virQEMUCapsPtr got,
 static int testHelpStrParsing(const void *data)
 {
     const struct testInfo *info = data;
-    char *path = NULL;
     char *help = NULL;
     unsigned int version, kvm_version;
     bool is_kvm;
@@ -53,10 +52,7 @@ static int testHelpStrParsing(const void *data)
     char *got = NULL;
     char *expected = NULL;
 
-    if (virAsprintf(&path, "%s/qemuhelpdata/%s", abs_srcdir, info->name) < 0)
-        return -1;
-
-    if (virTestLoadFile(path, &help) < 0)
+    if (!(help = virTestLoadFilePath("qemuhelpdata/", info->name, NULL)))
         goto cleanup;
 
     if (!(flags = virQEMUCapsNew()))
@@ -76,13 +72,8 @@ static int testHelpStrParsing(const void *data)
         virQEMUCapsSet(flags, QEMU_CAPS_MONITOR_JSON);
 # endif
 
-    VIR_FREE(path);
     VIR_FREE(help);
-    if (virAsprintf(&path, "%s/qemuhelpdata/%s-device", abs_srcdir,
-                    info->name) < 0)
-        goto cleanup;
-
-    if (virTestLoadFile(path, &help) < 0)
+    if (!(help = virTestLoadFilePath("qemuhelpdata/", info->name, "-device", NULL)))
         goto cleanup;
 
     if (virQEMUCapsParseDeviceStr(flags, help) < 0)
@@ -125,7 +116,6 @@ static int testHelpStrParsing(const void *data)
 
     ret = 0;
  cleanup:
-    VIR_FREE(path);
     VIR_FREE(help);
     virObjectUnref(flags);
     VIR_FREE(got);