]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
tests: scsihost: Use fakerootdir instead of fakesysfsdir
authorAndrea Bolognani <abologna@redhat.com>
Fri, 4 Dec 2015 13:12:33 +0000 (14:12 +0100)
committerAndrea Bolognani <abologna@redhat.com>
Wed, 9 Dec 2015 14:22:59 +0000 (15:22 +0100)
This updates the test program to make it consistent with recent changes
to the mock libraries, and also opens up the possibility of mocking more
than just /sys in the future.

tests/scsihosttest.c

index eb5f522623e8e40b11e27e66de3f4f1f1eef81ec..ab3b0aec42487da9b5537bddd4ab6e7c24491d40 100644 (file)
@@ -244,21 +244,27 @@ testVirFindSCSIHostByPCI(const void *data ATTRIBUTE_UNUSED)
     return ret;
 }
 
-# define FAKESYSFSDIRTEMPLATE abs_builddir "/fakesysfsdir-XXXXXX"
+# define FAKEROOTDIRTEMPLATE abs_builddir "/fakerootdir-XXXXXX"
 
 static int
 mymain(void)
 {
     int ret = -1;
+    char *fakerootdir = NULL;
     char *fakesysfsdir = NULL;
 
-    if (VIR_STRDUP_QUIET(fakesysfsdir, FAKESYSFSDIRTEMPLATE) < 0) {
+    if (VIR_STRDUP_QUIET(fakerootdir, FAKEROOTDIRTEMPLATE) < 0) {
         fprintf(stderr, "Out of memory\n");
         goto cleanup;
     }
 
-    if (!mkdtemp(fakesysfsdir)) {
-        fprintf(stderr, "Cannot create fakesysfsdir");
+    if (!mkdtemp(fakerootdir)) {
+        fprintf(stderr, "Cannot create fakerootdir");
+        goto cleanup;
+    }
+
+    if (virAsprintfQuiet(&fakesysfsdir, "%s/sys", fakerootdir) < 0) {
+        fprintf(stderr, "Out of memory\n");
         goto cleanup;
     }
 
@@ -290,7 +296,8 @@ mymain(void)
 
  cleanup:
     if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL)
-        virFileDeleteTree(fakesysfsdir);
+        virFileDeleteTree(fakerootdir);
+    VIR_FREE(fakerootdir);
     VIR_FREE(fakesysfsdir);
     VIR_FREE(scsihost_class_path);
     return ret;