changeset 12517:013b270a78b9

tests: don't require debug system() to pass 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>
author Eric Blake <ebb9@byu.net>
date Tue, 29 Dec 2009 06:58:18 -0700
parents 94cbe360f46e
children b5e42ef33b49
files 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
diffstat 35 files changed, 83 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,43 @@
+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
--- a/tests/test-areadlink-with-size.c
+++ b/tests/test-areadlink-with-size.c
@@ -39,7 +39,7 @@
 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);
 }
--- a/tests/test-areadlink.c
+++ b/tests/test-areadlink.c
@@ -46,7 +46,7 @@
 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);
 }
--- a/tests/test-areadlinkat-with-size.c
+++ b/tests/test-areadlinkat-with-size.c
@@ -50,7 +50,7 @@
   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);
--- a/tests/test-areadlinkat.c
+++ b/tests/test-areadlinkat.c
@@ -50,7 +50,7 @@
   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);
--- a/tests/test-canonicalize-lgpl.c
+++ b/tests/test-canonicalize-lgpl.c
@@ -55,7 +55,7 @@
      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);
--- a/tests/test-canonicalize.c
+++ b/tests/test-canonicalize.c
@@ -46,7 +46,7 @@
      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);
--- a/tests/test-chown.c
+++ b/tests/test-chown.c
@@ -42,7 +42,7 @@
 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);
 }
--- a/tests/test-fchownat.c
+++ b/tests/test-fchownat.c
@@ -63,7 +63,7 @@
   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);
--- a/tests/test-fdutimensat.c
+++ b/tests/test-fdutimensat.c
@@ -84,7 +84,7 @@
   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);
--- a/tests/test-fstatat.c
+++ b/tests/test-fstatat.c
@@ -60,6 +60,10 @@
 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);
--- a/tests/test-futimens.c
+++ b/tests/test-futimens.c
@@ -44,7 +44,7 @@
 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);
 }
--- a/tests/test-lchown.c
+++ b/tests/test-lchown.c
@@ -42,7 +42,7 @@
 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);
 }
--- a/tests/test-link.c
+++ b/tests/test-link.c
@@ -40,7 +40,7 @@
 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);
 }
--- a/tests/test-linkat.c
+++ b/tests/test-linkat.c
@@ -81,7 +81,7 @@
   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);
--- a/tests/test-lstat.c
+++ b/tests/test-lstat.c
@@ -52,5 +52,8 @@
 int
 main (void)
 {
+  /* Remove any leftovers from a previous partial run.  */
+  system ("rm -rf " BASE "*");
+
   return test_lstat_func (do_lstat, true);
 }
--- a/tests/test-lstat.h
+++ b/tests/test-lstat.h
@@ -28,9 +28,6 @@
   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);
--- a/tests/test-mkdir.c
+++ b/tests/test-mkdir.c
@@ -40,7 +40,7 @@
 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);
 }
--- a/tests/test-mkdirat.c
+++ b/tests/test-mkdirat.c
@@ -51,7 +51,7 @@
   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);
--- a/tests/test-mkfifo.c
+++ b/tests/test-mkfifo.c
@@ -40,7 +40,7 @@
 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);
 }
--- a/tests/test-mkfifoat.c
+++ b/tests/test-mkfifoat.c
@@ -72,7 +72,7 @@
   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);
--- a/tests/test-mknod.c
+++ b/tests/test-mknod.c
@@ -47,7 +47,7 @@
 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.  */
--- a/tests/test-readlink.c
+++ b/tests/test-readlink.c
@@ -41,7 +41,7 @@
 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);
 }
--- a/tests/test-remove.c
+++ b/tests/test-remove.c
@@ -38,7 +38,7 @@
 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);
--- a/tests/test-rename.c
+++ b/tests/test-rename.c
@@ -39,7 +39,7 @@
 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);
 }
--- a/tests/test-renameat.c
+++ b/tests/test-renameat.c
@@ -57,7 +57,7 @@
   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);
--- a/tests/test-rmdir.c
+++ b/tests/test-rmdir.c
@@ -39,5 +39,8 @@
 int
 main (void)
 {
+  /* Remove any leftovers from a previous partial run.  */
+  system ("rm -rf " BASE "*");
+
   return test_rmdir_func (rmdir, true);
 }
--- a/tests/test-rmdir.h
+++ b/tests/test-rmdir.h
@@ -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);
--- a/tests/test-symlink.c
+++ b/tests/test-symlink.c
@@ -40,7 +40,7 @@
 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);
 }
--- a/tests/test-symlinkat.c
+++ b/tests/test-symlinkat.c
@@ -64,7 +64,7 @@
   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);
--- a/tests/test-unlink.c
+++ b/tests/test-unlink.c
@@ -41,5 +41,8 @@
 int
 main (void)
 {
+  /* Remove any leftovers from a previous partial run.  */
+  system ("rm -rf " BASE "*");
+
   return test_unlink_func (unlink, true);
 }
--- a/tests/test-unlink.h
+++ b/tests/test-unlink.h
@@ -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);
--- a/tests/test-unlinkat.c
+++ b/tests/test-unlinkat.c
@@ -60,6 +60,10 @@
   /* 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);
--- a/tests/test-utimens.c
+++ b/tests/test-utimens.c
@@ -66,7 +66,7 @@
   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);
--- a/tests/test-utimensat.c
+++ b/tests/test-utimensat.c
@@ -66,7 +66,7 @@
   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);