[libvirt] [PATCH 5/7] tests: Rename LIBVIRT_FAKE_SYSFS_DIR to LIBVIRT_FAKE_ROOT_DIR

Andrea Bolognani abologna at redhat.com
Fri Dec 4 14:34:08 UTC 2015


The old name is no longer accurate, since now we're using its value as
the root of the fake filesystem.

No functional changes.
---
 tests/vircgroupmock.c  | 10 +++++-----
 tests/vircgrouptest.c  | 16 ++++++++--------
 tests/virhostdevtest.c | 16 ++++++++--------
 tests/virpcimock.c     |  6 +++---
 tests/virpcitest.c     | 16 ++++++++--------
 5 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/tests/vircgroupmock.c b/tests/vircgroupmock.c
index ead18b6..fb33af1 100644
--- a/tests/vircgroupmock.c
+++ b/tests/vircgroupmock.c
@@ -67,9 +67,9 @@ const char *fakedevicedir1 = FAKEDEVDIR1;
  *
  * In any open/acces/mkdir calls we look at path and if
  * it starts with /not/really/sys/fs/cgroup, we rewrite
- * the path to point at a temporary directory referred
- * to by LIBVIRT_FAKE_SYSFS_DIR env variable that is
- * set by the main test suite
+ * the path to point at a subdirectory of the temporary
+ * directory referred to by LIBVIRT_FAKE_ROOT_DIR env
+ * variable that is set by the main test suite
  *
  * In mkdir() calls, we simulate the cgroups behaviour
  * whereby creating the directory auto-creates a bunch
@@ -420,8 +420,8 @@ static void init_sysfs(void)
     if (fakerootdir && fakesysfsdir)
         return;
 
-    if (!(fakerootdir = getenv("LIBVIRT_FAKE_SYSFS_DIR"))) {
-        fprintf(stderr, "Missing LIBVIRT_FAKE_SYSFS_DIR env variable\n");
+    if (!(fakerootdir = getenv("LIBVIRT_FAKE_ROOT_DIR"))) {
+        fprintf(stderr, "Missing LIBVIRT_FAKE_ROOT_DIR env variable\n");
         abort();
     }
 
diff --git a/tests/vircgrouptest.c b/tests/vircgrouptest.c
index 731ecc4..7ea6e13 100644
--- a/tests/vircgrouptest.c
+++ b/tests/vircgrouptest.c
@@ -847,25 +847,25 @@ static int testCgroupGetBlkioIoDeviceServiced(const void *args ATTRIBUTE_UNUSED)
     return ret;
 }
 
-# define FAKESYSFSDIRTEMPLATE abs_builddir "/fakesysfsdir-XXXXXX"
+# define FAKEROOTDIRTEMPLATE abs_builddir "/fakerootdir-XXXXXX"
 
 static int
 mymain(void)
 {
     int ret = 0;
-    char *fakesysfsdir;
+    char *fakerootdir;
 
-    if (VIR_STRDUP_QUIET(fakesysfsdir, FAKESYSFSDIRTEMPLATE) < 0) {
+    if (VIR_STRDUP_QUIET(fakerootdir, FAKEROOTDIRTEMPLATE) < 0) {
         fprintf(stderr, "Out of memory\n");
         abort();
     }
 
-    if (!mkdtemp(fakesysfsdir)) {
-        fprintf(stderr, "Cannot create fakesysfsdir");
+    if (!mkdtemp(fakerootdir)) {
+        fprintf(stderr, "Cannot create fakerootdir");
         abort();
     }
 
-    setenv("LIBVIRT_FAKE_SYSFS_DIR", fakesysfsdir, 1);
+    setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1);
 
 # define DETECT_MOUNTS(file)                                            \
     do {                                                                \
@@ -937,9 +937,9 @@ mymain(void)
     unsetenv("VIR_CGROUP_MOCK_MODE");
 
     if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL)
-        virFileDeleteTree(fakesysfsdir);
+        virFileDeleteTree(fakerootdir);
 
-    VIR_FREE(fakesysfsdir);
+    VIR_FREE(fakerootdir);
 
     return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
 }
diff --git a/tests/virhostdevtest.c b/tests/virhostdevtest.c
index faebdd4..2a74976 100644
--- a/tests/virhostdevtest.c
+++ b/tests/virhostdevtest.c
@@ -410,25 +410,25 @@ testVirHostdevUpdateActivePCIHostdevs(const void *oaque ATTRIBUTE_UNUSED)
     return ret;
 }
 
-# define FAKESYSFSDIRTEMPLATE abs_builddir "/fakesysfsdir-XXXXXX"
+# define FAKEROOTDIRTEMPLATE abs_builddir "/fakerootdir-XXXXXX"
 
 static int
 mymain(void)
 {
     int ret = 0;
-    char *fakesysfsdir;
+    char *fakerootdir;
 
-    if (VIR_STRDUP_QUIET(fakesysfsdir, FAKESYSFSDIRTEMPLATE) < 0) {
+    if (VIR_STRDUP_QUIET(fakerootdir, FAKEROOTDIRTEMPLATE) < 0) {
         fprintf(stderr, "Out of memory\n");
         abort();
     }
 
-    if (!mkdtemp(fakesysfsdir)) {
-        fprintf(stderr, "Cannot create fakesysfsdir");
+    if (!mkdtemp(fakerootdir)) {
+        fprintf(stderr, "Cannot create fakerootdir");
         abort();
     }
 
-    setenv("LIBVIRT_FAKE_SYSFS_DIR", fakesysfsdir, 1);
+    setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1);
 
 # define DO_TEST(fnc)                                   \
     do {                                                \
@@ -458,9 +458,9 @@ mymain(void)
     myCleanup();
 
     if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL)
-        virFileDeleteTree(fakesysfsdir);
+        virFileDeleteTree(fakerootdir);
 
-    VIR_FREE(fakesysfsdir);
+    VIR_FREE(fakerootdir);
 
     return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
 }
diff --git a/tests/virpcimock.c b/tests/virpcimock.c
index f1517ce..9778783 100644
--- a/tests/virpcimock.c
+++ b/tests/virpcimock.c
@@ -71,7 +71,7 @@ char *fakesysfsdir;
  * The plan:
  *
  * Mock some file handling functions. Redirect them into a stub tree passed via
- * LIBVIRT_FAKE_SYSFS_DIR env variable. All files and links within stub tree is
+ * LIBVIRT_FAKE_ROOT_DIR env variable. All files and links within stub tree is
  * created by us. There are some actions that we must take if some special
  * files are written to. Here's the list of files we watch:
  *
@@ -804,8 +804,8 @@ init_env(void)
     if (fakerootdir && fakesysfsdir)
         return;
 
-    if (!(fakerootdir = getenv("LIBVIRT_FAKE_SYSFS_DIR")))
-        ABORT("Missing LIBVIRT_FAKE_SYSFS_DIR env variable\n");
+    if (!(fakerootdir = getenv("LIBVIRT_FAKE_ROOT_DIR")))
+        ABORT("Missing LIBVIRT_FAKE_ROOT_DIR env variable\n");
 
     if (virAsprintfQuiet(&fakesysfsdir, "%s%s",
                          fakerootdir, PCI_SYSFS_PREFIX) < 0)
diff --git a/tests/virpcitest.c b/tests/virpcitest.c
index d4d3253..f1c5369 100644
--- a/tests/virpcitest.c
+++ b/tests/virpcitest.c
@@ -350,25 +350,25 @@ testVirPCIDeviceUnbind(const void *opaque)
     return ret;
 }
 
-# define FAKESYSFSDIRTEMPLATE abs_builddir "/fakesysfsdir-XXXXXX"
+# define FAKEROOTDIRTEMPLATE abs_builddir "/fakerootdir-XXXXXX"
 
 static int
 mymain(void)
 {
     int ret = 0;
-    char *fakesysfsdir;
+    char *fakerootdir;
 
-    if (VIR_STRDUP_QUIET(fakesysfsdir, FAKESYSFSDIRTEMPLATE) < 0) {
+    if (VIR_STRDUP_QUIET(fakerootdir, FAKEROOTDIRTEMPLATE) < 0) {
         VIR_TEST_DEBUG("Out of memory\n");
         abort();
     }
 
-    if (!mkdtemp(fakesysfsdir)) {
-        VIR_TEST_DEBUG("Cannot create fakesysfsdir");
+    if (!mkdtemp(fakerootdir)) {
+        VIR_TEST_DEBUG("Cannot create fakerootdir");
         abort();
     }
 
-    setenv("LIBVIRT_FAKE_SYSFS_DIR", fakesysfsdir, 1);
+    setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1);
 
 # define DO_TEST(fnc)                                   \
     do {                                                \
@@ -445,9 +445,9 @@ mymain(void)
     DO_TEST_PCI_DRIVER(0, 0x0a, 3, 0, NULL);
 
     if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL)
-        virFileDeleteTree(fakesysfsdir);
+        virFileDeleteTree(fakerootdir);
 
-    VIR_FREE(fakesysfsdir);
+    VIR_FREE(fakerootdir);
 
     return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
 }
-- 
2.5.0




More information about the libvir-list mailing list