[Libguestfs] [PATCH] test-charset-fidelity: allow to skip testing specific FSes

Pino Toscano ptoscano at redhat.com
Mon May 5 15:05:29 UTC 2014


Allow to skip testing the filesystem "foo" if the environment variable
SKIP_TEST_CHARSET_FIDELITY_foo=1 is set. This way it possible to not
test one or more filesystems without disabling the test altogether.
---
 tests/charsets/test-charset-fidelity.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/tests/charsets/test-charset-fidelity.c b/tests/charsets/test-charset-fidelity.c
index c669b9d..654ea0f 100644
--- a/tests/charsets/test-charset-fidelity.c
+++ b/tests/charsets/test-charset-fidelity.c
@@ -33,6 +33,8 @@
 #include "guestfs.h"
 #include "guestfs-internal-frontend.h"
 
+static const char ourenvvar[] = "SKIP_TEST_CHARSET_FIDELITY";
+
 struct filesystem {
   const char *fs_name;          /* Name of filesystem. */
   int fs_case_insensitive;      /* True if filesystem is case insensitive. */
@@ -78,7 +80,7 @@ main (int argc, char *argv[])
   struct filesystem *fs;
 
   /* Allow this test to be skipped. */
-  str = getenv ("SKIP_TEST_CHARSET_FIDELITY");
+  str = getenv (ourenvvar);
   if (str && STREQ (str, "1")) {
     printf ("%s: test skipped because environment variable is set.\n",
             program_name);
@@ -113,6 +115,8 @@ static void
 test_filesystem (guestfs_h *g, const struct filesystem *fs)
 {
   const char *feature[] = { fs->fs_feature, NULL };
+  char envvar[sizeof (ourenvvar) + 20];
+  char *str;
 
   if (fs->fs_feature && !guestfs_feature_available (g, (char **) feature)) {
     printf ("skipped test of %s because %s feature not available\n",
@@ -120,6 +124,14 @@ test_filesystem (guestfs_h *g, const struct filesystem *fs)
     return;
   }
 
+  snprintf (envvar, sizeof (envvar) - 1, "%s_%s", ourenvvar, fs->fs_name);
+  str = getenv (envvar);
+  if (str && STREQ (str, "1")) {
+    printf ("skipped test of %s because environment variable is set\n",
+            fs->fs_name);
+    return;
+  }
+
   printf ("testing charset fidelity on %s\n", fs->fs_name);
 
   make_filesystem (g, fs);
-- 
1.9.0




More information about the Libguestfs mailing list