gettimeofday: port recent C++ fix to Emacs
[gnulib.git] / tests / test-copy-file.c
index a1c7893..cc2a6ac 100644 (file)
@@ -1,5 +1,5 @@
 /* Test of copying of files.
-   Copyright (C) 2008 Free Software Foundation, Inc.
+   Copyright (C) 2008-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
 
 #include "copy-file.h"
 
-#include <stdio.h>
 #include <stdlib.h>
 
 #include "progname.h"
-
-#define ASSERT(expr) \
-  do                                                                        \
-    {                                                                       \
-      if (!(expr))                                                          \
-        {                                                                   \
-          fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
-          fflush (stderr);                                                  \
-          abort ();                                                         \
-        }                                                                   \
-    }                                                                       \
-  while (0)
+#include "macros.h"
 
 int
 main (int argc, char *argv[])
 {
   const char *file1;
   const char *file2;
+  int null_stderr;
 
   set_program_name (argv[0]);
 
@@ -49,8 +38,12 @@ main (int argc, char *argv[])
 
   file1 = argv[1];
   file2 = argv[2];
+  null_stderr = (getenv ("NO_STDERR_OUTPUT") != NULL);
 
-  copy_file_preserving (file1, file2);
+  if (null_stderr)
+    ASSERT (qcopy_file_preserving (file1, file2) == 0);
+  else
+    copy_file_preserving (file1, file2);
 
   return 0;
 }