tests: don't require debug system() to pass
authorEric Blake <ebb9@byu.net>
Tue, 29 Dec 2009 13:58:18 +0000 (06:58 -0700)
committerEric Blake <ebb9@byu.net>
Tue, 29 Dec 2009 14:03:05 +0000 (07:03 -0700)
When running a cross-compilation to mingw on a Linux host,
but without a valid mingw rm executable, the debug-only
system() call would fail.  This is not fatal to the test,
since the call is merely a debugging aid if a prior call to
the test encountered a failure and left garbage; in general,
the tests should pass and the system() call have nothing to
clean in the first place.  Also, the system() call only
needs to happen once at startup, not once per iteration
into the tests performed by .h files.

* tests/test-lstat.h (test_lstat_func): Move debug cleanup...
* tests/test-rmdir.h (test_rmdir_func): Likewise.
* tests/test-unlink.h (test_unlink_func): Likewise.
* tests/test-fstatat.c (main): ...into callers.
* tests/test-lstat.c (main): Likewise.
* tests/test-rmdir.c (main): Likewise.
* tests/test-unlink.c (main): Likewise.
* tests/test-unlinkat.c (main): Likewise.
* tests/test-areadlink-with-size.c (main): Don't require a
debug-only system call to pass, aiding cross-testing to mingw.
* tests/test-areadlink.c (main): Likewise.
* tests/test-areadlinkat-with-size.c (main): Likewise.
* tests/test-areadlinkat.c (main): Likewise.
* tests/test-canonicalize-lgpl.c (main): Likewise.
* tests/test-canonicalize.c (main): Likewise.
* tests/test-chown.c (main): Likewise.
* tests/test-fchownat.c (main): Likewise.
* tests/test-lchown.c (main): Likewise.
* tests/test-fdutimensat.c (main): Likewise.
* tests/test-futimens.c (main): Likewise.
* tests/test-link.c (main): Likewise.
* tests/test-linkat.c (main): Likewise.
* tests/test-mkdir.c (main): Likewise.
* tests/test-mkdirat.c (main): Likewise.
* tests/test-mkfifo.c (main): Likewise.
* tests/test-mkfifoat.c (main): Likewise.
* tests/test-mknod.c (main): Likewise.
* tests/test-readlink.c (main): Likewise.
* tests/test-remove.c (main): Likewise.
* tests/test-rename.c (main): Likewise.
* tests/test-renameat.c (main): Likewise.
* tests/test-symlink.c (main): Likewise.
* tests/test-symlinkat.c (main): Likewise.
* tests/test-utimens.c (main): Likewise.
* tests/test-utimensat.c (main): Likewise.

Signed-off-by: Eric Blake <ebb9@byu.net>
35 files changed:
ChangeLog
tests/test-areadlink-with-size.c
tests/test-areadlink.c
tests/test-areadlinkat-with-size.c
tests/test-areadlinkat.c
tests/test-canonicalize-lgpl.c
tests/test-canonicalize.c
tests/test-chown.c
tests/test-fchownat.c
tests/test-fdutimensat.c
tests/test-fstatat.c
tests/test-futimens.c
tests/test-lchown.c
tests/test-link.c
tests/test-linkat.c
tests/test-lstat.c
tests/test-lstat.h
tests/test-mkdir.c
tests/test-mkdirat.c
tests/test-mkfifo.c
tests/test-mkfifoat.c
tests/test-mknod.c
tests/test-readlink.c
tests/test-remove.c
tests/test-rename.c
tests/test-renameat.c
tests/test-rmdir.c
tests/test-rmdir.h
tests/test-symlink.c
tests/test-symlinkat.c
tests/test-unlink.c
tests/test-unlink.h
tests/test-unlinkat.c
tests/test-utimens.c
tests/test-utimensat.c

index 60a9b56..41ef6f7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,44 @@
 2009-12-29  Simon Josefsson  <simon@josefsson.org>
+       and Eric Blake  <ebb9@byu.net>
+
+       tests: don't require debug system() to pass
+       * tests/test-lstat.h (test_lstat_func): Move debug cleanup...
+       * tests/test-rmdir.h (test_rmdir_func): Likewise.
+       * tests/test-unlink.h (test_unlink_func): Likewise.
+       * tests/test-fstatat.c (main): ...into callers.
+       * tests/test-lstat.c (main): Likewise.
+       * tests/test-rmdir.c (main): Likewise.
+       * tests/test-unlink.c (main): Likewise.
+       * tests/test-unlinkat.c (main): Likewise.
+       * tests/test-areadlink-with-size.c (main): Don't require a
+       debug-only system call to pass, aiding cross-testing to mingw.
+       * tests/test-areadlink.c (main): Likewise.
+       * tests/test-areadlinkat-with-size.c (main): Likewise.
+       * tests/test-areadlinkat.c (main): Likewise.
+       * tests/test-canonicalize-lgpl.c (main): Likewise.
+       * tests/test-canonicalize.c (main): Likewise.
+       * tests/test-chown.c (main): Likewise.
+       * tests/test-fchownat.c (main): Likewise.
+       * tests/test-lchown.c (main): Likewise.
+       * tests/test-fdutimensat.c (main): Likewise.
+       * tests/test-futimens.c (main): Likewise.
+       * tests/test-link.c (main): Likewise.
+       * tests/test-linkat.c (main): Likewise.
+       * tests/test-mkdir.c (main): Likewise.
+       * tests/test-mkdirat.c (main): Likewise.
+       * tests/test-mkfifo.c (main): Likewise.
+       * tests/test-mkfifoat.c (main): Likewise.
+       * tests/test-mknod.c (main): Likewise.
+       * tests/test-readlink.c (main): Likewise.
+       * tests/test-remove.c (main): Likewise.
+       * tests/test-rename.c (main): Likewise.
+       * tests/test-renameat.c (main): Likewise.
+       * tests/test-symlink.c (main): Likewise.
+       * tests/test-symlinkat.c (main): Likewise.
+       * tests/test-utimens.c (main): Likewise.
+       * tests/test-utimensat.c (main): Likewise.
+
+2009-12-29  Simon Josefsson  <simon@josefsson.org>
 
        * modules/selinux-h (selinux/selinux.h, selinux/context.h): Depend
        on $(UNUSED_PARAMETER_H) to avoid build failure.
index 8b7ff63..d5f4a0d 100644 (file)
@@ -39,7 +39,7 @@ int
 main (void)
 {
   /* Remove any leftovers from a previous partial run.  */
-  ASSERT (system ("rm -rf " BASE "*") == 0);
+  system ("rm -rf " BASE "*");
 
   return test_areadlink (areadlink_with_size, true);
 }
index 2e8aaa5..272a614 100644 (file)
@@ -46,7 +46,7 @@ int
 main (void)
 {
   /* Remove any leftovers from a previous partial run.  */
-  ASSERT (system ("rm -rf " BASE "*") == 0);
+  system ("rm -rf " BASE "*");
 
   return test_areadlink (do_areadlink, true);
 }
index 67252a7..113c6b4 100644 (file)
@@ -50,7 +50,7 @@ main (void)
   int result;
 
   /* Remove any leftovers from a previous partial run.  */
-  ASSERT (system ("rm -rf " BASE "*") == 0);
+  system ("rm -rf " BASE "*");
 
   /* Basic tests.  */
   result = test_areadlink (do_areadlinkat_with_size, false);
index 54e0745..68d7f58 100644 (file)
@@ -50,7 +50,7 @@ main (void)
   int result;
 
   /* Remove any leftovers from a previous partial run.  */
-  ASSERT (system ("rm -rf " BASE "*") == 0);
+  system ("rm -rf " BASE "*");
 
   /* Basic tests.  */
   result = test_areadlink (do_areadlinkat, false);
index e35d921..2425921 100644 (file)
@@ -55,7 +55,7 @@ main (void)
      any leftovers from a previous partial run.  */
   {
     int fd;
-    ASSERT (system ("rm -rf " BASE " ise") == 0);
+    system ("rm -rf " BASE " ise");
     ASSERT (mkdir (BASE, 0700) == 0);
     fd = creat (BASE "/tra", 0600);
     ASSERT (0 <= fd);
index 5830267..b09c1ca 100644 (file)
@@ -46,7 +46,7 @@ main (void)
      any leftovers from a previous partial run.  */
   {
     int fd;
-    ASSERT (system ("rm -rf " BASE " ise") == 0);
+    system ("rm -rf " BASE " ise");
     ASSERT (mkdir (BASE, 0700) == 0);
     fd = creat (BASE "/tra", 0600);
     ASSERT (0 <= fd);
index 3974903..15a6d75 100644 (file)
@@ -42,7 +42,7 @@ int
 main (void)
 {
   /* Remove any leftovers from a previous partial run.  */
-  ASSERT (system ("rm -rf " BASE "*") == 0);
+  system ("rm -rf " BASE "*");
 
   return test_chown (chown, true);
 }
index a6d177d..f7c5827 100644 (file)
@@ -63,7 +63,7 @@ main (void)
   int result2; /* Skip because of no lchown support.  */
 
   /* Clean up any trash from prior testsuite runs.  */
-  ASSERT (system ("rm -rf " BASE "*") == 0);
+  system ("rm -rf " BASE "*");
 
   /* Basic tests.  */
   result1 = test_chown (do_chown, true);
index ad0eca9..0e76661 100644 (file)
@@ -84,7 +84,7 @@ main (void)
   int fd;
 
   /* Clean up any trash from prior testsuite runs.  */
-  ASSERT (system ("rm -rf " BASE "*") == 0);
+  system ("rm -rf " BASE "*");
 
   /* Basic tests.  */
   result1 = test_utimens (do_utimens, true);
index e6abe38..6160e16 100644 (file)
@@ -60,6 +60,10 @@ int
 main (void)
 {
   int result;
+
+  /* Remove any leftovers from a previous partial run.  */
+  system ("rm -rf " BASE "*");
+
   result = test_stat_func (do_stat, false);
   ASSERT (test_lstat_func (do_lstat, false) == result);
   dfd = open (".", O_RDONLY);
index 0ee1fe0..af553a9 100644 (file)
@@ -44,7 +44,7 @@ int
 main (void)
 {
   /* Clean up any trash from prior testsuite runs.  */
-  ASSERT (system ("rm -rf " BASE "*") == 0);
+  system ("rm -rf " BASE "*");
 
   return test_futimens (futimens, true);
 }
index 24b7ece..0c0aa11 100644 (file)
@@ -42,7 +42,7 @@ int
 main (void)
 {
   /* Remove any leftovers from a previous partial run.  */
-  ASSERT (system ("rm -rf " BASE "*") == 0);
+  system ("rm -rf " BASE "*");
 
   return test_lchown (lchown, true);
 }
index 817c464..9c1ce36 100644 (file)
@@ -40,7 +40,7 @@ int
 main (void)
 {
   /* Remove any garbage left from previous partial runs.  */
-  ASSERT (system ("rm -rf " BASE "*") == 0);
+  system ("rm -rf " BASE "*");
 
   return test_link (link, true);
 }
index 98165c0..efe5109 100644 (file)
@@ -81,7 +81,7 @@ main (void)
   int result;
 
   /* Clean up any trash from prior testsuite runs.  */
-  ASSERT (system ("rm -rf " BASE "*") == 0);
+  system ("rm -rf " BASE "*");
 
   /* Test basic link functionality, without mentioning symlinks.  */
   result = test_link (do_link, true);
index 1940a21..bff40eb 100644 (file)
@@ -52,5 +52,8 @@ do_lstat (char const *name, struct stat *st)
 int
 main (void)
 {
+  /* Remove any leftovers from a previous partial run.  */
+  system ("rm -rf " BASE "*");
+
   return test_lstat_func (do_lstat, true);
 }
index 3828316..071626a 100644 (file)
@@ -28,9 +28,6 @@ test_lstat_func (int (*func) (char const *, struct stat *), bool print)
   struct stat st1;
   struct stat st2;
 
-  /* Remove any leftovers from a previous partial run.  */
-  ASSERT (system ("rm -rf " BASE "*") == 0);
-
   /* Test for common directories.  */
   ASSERT (func (".", &st1) == 0);
   ASSERT (func ("./", &st2) == 0);
index 379e90c..6be4486 100644 (file)
@@ -40,7 +40,7 @@ int
 main (void)
 {
   /* Clean up any trash from prior testsuite runs.  */
-  ASSERT (system ("rm -rf " BASE "*") == 0);
+  system ("rm -rf " BASE "*");
 
   return test_mkdir (mkdir, true);
 }
index d3180e6..fe0da25 100644 (file)
@@ -51,7 +51,7 @@ main (void)
   int result;
 
   /* Clean up any trash from prior testsuite runs.  */
-  ASSERT (system ("rm -rf " BASE "*") == 0);
+  system ("rm -rf " BASE "*");
 
   /* Test basic mkdir functionality.  */
   result = test_mkdir (do_mkdir, false);
index 4b4c93b..fc36412 100644 (file)
@@ -40,7 +40,7 @@ int
 main (void)
 {
   /* Remove any leftovers from a previous partial run.  */
-  ASSERT (system ("rm -rf " BASE "*") == 0);
+  system ("rm -rf " BASE "*");
 
   return test_mkfifo (mkfifo, true);
 }
index ef3e817..0b20181 100644 (file)
@@ -72,7 +72,7 @@ main (void)
   int result;
 
   /* Remove any leftovers from a previous partial run.  */
-  ASSERT (system ("rm -rf " BASE "*") == 0);
+  system ("rm -rf " BASE "*");
 
   /* Basic tests.  */
   result = test_mkfifo (do_mkfifoat, true);
index a62df6d..ed16b50 100644 (file)
@@ -47,7 +47,7 @@ int
 main (void)
 {
   /* Remove any leftovers from a previous partial run.  */
-  ASSERT (system ("rm -rf " BASE "*") == 0);
+  system ("rm -rf " BASE "*");
 
   /* We can only portably test creation of fifos.  Anything else
      requires root privileges and knowledge of device numbers.  */
index 4ec0fcd..ed30c1d 100644 (file)
@@ -41,7 +41,7 @@ int
 main (void)
 {
   /* Remove any leftovers from a previous partial run.  */
-  ASSERT (system ("rm -rf " BASE "*") == 0);
+  system ("rm -rf " BASE "*");
 
   return test_readlink (readlink, true);
 }
index 4bcc2ec..5428e37 100644 (file)
@@ -38,7 +38,7 @@ int
 main (void)
 {
   /* Remove any leftovers from a previous partial run.  */
-  ASSERT (system ("rm -rf " BASE "*") == 0);
+  system ("rm -rf " BASE "*");
 
   /* Setup.  */
   ASSERT (mkdir (BASE "dir", 0700) == 0);
index 797cc94..17cd025 100644 (file)
@@ -39,7 +39,7 @@ int
 main (void)
 {
   /* Remove any garbage left from previous partial runs.  */
-  ASSERT (system ("rm -rf " BASE "*") == 0);
+  system ("rm -rf " BASE "*");
 
   return test_rename (rename, true);
 }
index de84fa6..a22af04 100644 (file)
@@ -57,7 +57,7 @@ main (void)
   int result;
 
   /* Clean up any trash from prior testsuite runs.  */
-  ASSERT (system ("rm -rf " BASE "*") == 0);
+  system ("rm -rf " BASE "*");
 
   /* Test basic rename functionality, using current directory.  */
   result = test_rename (do_rename, false);
index 9ca88e2..a270ca7 100644 (file)
@@ -39,5 +39,8 @@ SIGNATURE_CHECK (rmdir, int, (char const *));
 int
 main (void)
 {
+  /* Remove any leftovers from a previous partial run.  */
+  system ("rm -rf " BASE "*");
+
   return test_rmdir_func (rmdir, true);
 }
index 5f1e955..19c6961 100644 (file)
@@ -25,9 +25,6 @@
 static int
 test_rmdir_func (int (*func) (char const *name), bool print)
 {
-  /* Remove any leftovers from a previous partial run.  */
-  ASSERT (system ("rm -rf " BASE "*") == 0);
-
   /* Setup.  */
   ASSERT (mkdir (BASE "dir", 0700) == 0);
   ASSERT (close (creat (BASE "dir/file", 0600)) == 0);
index c84b2bc..f066ee3 100644 (file)
@@ -40,7 +40,7 @@ int
 main (void)
 {
   /* Remove any leftovers from a previous partial run.  */
-  ASSERT (system ("rm -rf " BASE "*") == 0);
+  system ("rm -rf " BASE "*");
 
   return test_symlink (symlink, true);
 }
index 714dd98..be59d5d 100644 (file)
@@ -64,7 +64,7 @@ main (void)
   int result;
 
   /* Remove any leftovers from a previous partial run.  */
-  ASSERT (system ("rm -rf " BASE "*") == 0);
+  system ("rm -rf " BASE "*");
 
   /* Perform same checks as counterpart functions.  */
   result = test_readlink (do_readlink, false);
index 1525802..b87f7d6 100644 (file)
@@ -41,5 +41,8 @@ SIGNATURE_CHECK (unlink, int, (char const *));
 int
 main (void)
 {
+  /* Remove any leftovers from a previous partial run.  */
+  system ("rm -rf " BASE "*");
+
   return test_unlink_func (unlink, true);
 }
index e65057d..05be29c 100644 (file)
@@ -25,9 +25,6 @@
 static int
 test_unlink_func (int (*func) (char const *name), bool print)
 {
-  /* Remove any leftovers from a previous partial run.  */
-  ASSERT (system ("rm -rf " BASE "*") == 0);
-
   /* Setup.  */
   ASSERT (mkdir (BASE "dir", 0700) == 0);
   ASSERT (close (creat (BASE "dir/file", 0600)) == 0);
index 3d7f118..bd2b48a 100644 (file)
@@ -60,6 +60,10 @@ main (void)
   /* FIXME: Add tests of fd other than ".".  */
   int result1;
   int result2;
+
+  /* Remove any leftovers from a previous partial run.  */
+  system ("rm -rf " BASE "*");
+
   result1 = test_rmdir_func (rmdirat, false);
   result2 = test_unlink_func (unlinker, false);
   ASSERT (result1 == result2);
index 618d941..dccaacc 100644 (file)
@@ -66,7 +66,7 @@ main (void)
   int result3; /* Skip because of no lutimens support.  */
 
   /* Clean up any trash from prior testsuite runs.  */
-  ASSERT (system ("rm -rf " BASE "*") == 0);
+  system ("rm -rf " BASE "*");
 
   result1 = test_utimens (utimens, true);
   ASSERT (test_utimens (do_fdutimens, false) == result1);
index ba4c22d..45aa8c3 100644 (file)
@@ -66,7 +66,7 @@ main (void)
   int fd;
 
   /* Clean up any trash from prior testsuite runs.  */
-  ASSERT (system ("rm -rf " BASE "*") == 0);
+  system ("rm -rf " BASE "*");
 
   /* Basic tests.  */
   result1 = test_utimens (do_utimensat, true);