Skip 'zerofree' test if the command doesn't exist in the appliance.
authorRichard Jones <rjones@trick.home.annexia.org>
Tue, 19 May 2009 11:29:04 +0000 (12:29 +0100)
committerRichard Jones <rjones@trick.home.annexia.org>
Tue, 19 May 2009 11:29:04 +0000 (12:29 +0100)
Makefile.am
src/generator.ml
tests.c

index 50c9e7d..c035977 100644 (file)
@@ -105,6 +105,7 @@ tests_LDADD = $(top_builddir)/src/libguestfs.la
 TESTS = tests
 TESTS_ENVIRONMENT = \
        SKIP_TEST_COMMAND=$(shell ldd test-command | grep -sq 'not a dynamic executable' || echo 1) \
 TESTS = tests
 TESTS_ENVIRONMENT = \
        SKIP_TEST_COMMAND=$(shell ldd test-command | grep -sq 'not a dynamic executable' || echo 1) \
+       SKIP_ZEROFREE=$(shell test -x initramfs/usr/sbin/zerofree || echo 1) \
        $(VG)
 
 $(TESTS): $(INITRAMFS) $(VMLINUZ)
        $(VG)
 
 $(TESTS): $(INITRAMFS) $(VMLINUZ)
index 01a2309..e6199a4 100755 (executable)
@@ -1998,7 +1998,7 @@ This runs C<hexdump -C> on the given C<path>.  The result is
 the human-readable, canonical hex dump of the file.");
 
   ("zerofree", (RErr, [String "device"]), 97, [],
 the human-readable, canonical hex dump of the file.");
 
   ("zerofree", (RErr, [String "device"]), 97, [],
-   [InitNone, Always, TestOutput (
+   [InitNone, Unless (env_is_true "SKIP_ZEROFREE"), TestOutput (
       [["sfdisk"; "/dev/sda"; "0"; "0"; "0"; ","];
        ["mkfs"; "ext3"; "/dev/sda1"];
        ["mount"; "/dev/sda1"; "/"];
       [["sfdisk"; "/dev/sda"; "0"; "0"; "0"; ","];
        ["mkfs"; "ext3"; "/dev/sda1"];
        ["mount"; "/dev/sda1"; "/"];
diff --git a/tests.c b/tests.c
index 19a3775..a4e7d47 100644 (file)
--- a/tests.c
+++ b/tests.c
@@ -643,8 +643,15 @@ static int test_lvresize_0 (void)
   return 0;
 }
 
   return 0;
 }
 
+static int test_zerofree_0_prereq (void)
+{
+  const char *str = getenv ("SKIP_ZEROFREE");
+  return str && strcmp (str, "1") == 0;
+}
+
 static int test_zerofree_0 (void)
 {
 static int test_zerofree_0 (void)
 {
+  if (! test_zerofree_0_prereq ()) {
   /* InitNone|InitEmpty for test_zerofree_0 */
   {
     char device[] = "/dev/sda";
   /* InitNone|InitEmpty for test_zerofree_0 */
   {
     char device[] = "/dev/sda";
@@ -755,6 +762,8 @@ static int test_zerofree_0 (void)
     }
     free (r);
   }
     }
     free (r);
   }
+  } else
+    printf ("%s skipped (reason: test prerequisite)\n", "test_zerofree_0");
   return 0;
 }
 
   return 0;
 }