tolerate additional IPv4 address now available for gnunet.org
[oweals/gnunet.git] / src / util / test_disk.c
index 055e155e96c5193b1d27545c6a510daca2d45e28..267d4d4f9300ebab4d2c7604117c4d5db5f28881 100644 (file)
@@ -2,20 +2,20 @@
      This file is part of GNUnet.
      Copyright (C) 2001, 2002, 2003, 2005, 2006, 2009 GNUnet e.V.
 
-     GNUnet is free software; you can redistribute it and/or modify
-     it under the terms of the GNU General Public License as published
-     by the Free Software Foundation; either version 3, or (at your
-     option) any later version.
+     GNUnet is free software: you can redistribute it and/or modify it
+     under the terms of the GNU Affero General Public License as published
+     by the Free Software Foundation, either version 3 of the License,
+     or (at your option) any later version.
 
      GNUnet is distributed in the hope that it will be useful, but
      WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-     General Public License for more details.
+     Affero General Public License for more details.
+    
+     You should have received a copy of the GNU Affero General Public License
+     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-     You should have received a copy of the GNU General Public License
-     along with GNUnet; see the file COPYING.  If not, write to the
-     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-     Boston, MA 02110-1301, USA.
+     SPDX-License-Identifier: AGPL3.0-or-later
 */
 
 /**
@@ -28,6 +28,7 @@
 
 #define TESTSTRING "Hello World\0"
 
+
 static int
 testReadWrite ()
 {
@@ -79,6 +80,7 @@ testReadWrite ()
   return 0;
 }
 
+
 static int
 testOpenClose ()
 {
@@ -104,6 +106,7 @@ testOpenClose ()
 
 static int ok;
 
+
 static int
 scan_callback (void *want, const char *filename)
 {
@@ -112,25 +115,49 @@ scan_callback (void *want, const char *filename)
   return GNUNET_OK;
 }
 
+
 static int
 testDirScan ()
 {
   if (GNUNET_OK !=
       GNUNET_DISK_directory_create ("test" DIR_SEPARATOR_STR "entry"))
+  {
+    GNUNET_break (0);
     return 1;
+  }
   if (GNUNET_OK !=
       GNUNET_DISK_directory_create ("test" DIR_SEPARATOR_STR "entry_more"))
+  {
+    GNUNET_break (0);
     return 1;
+  }
   GNUNET_DISK_directory_scan ("test", &scan_callback,
                               "test" DIR_SEPARATOR_STR "entry");
   if (GNUNET_OK != GNUNET_DISK_directory_remove ("test"))
+  {
+    GNUNET_break (0);
     return 1;
+  }
   if (ok < 2)
+  {
+    GNUNET_break (0);
     return 1;
+  }
   return 0;
 }
 
 
+static int
+iter_callback (void *cls,
+              const char *filename)
+{
+  int *i = cls;
+  
+  (*i)++;
+  return GNUNET_OK;
+}
+
+
 static int
 testDirIter ()
 {
@@ -138,15 +165,33 @@ testDirIter ()
 
   i = 0;
   if (GNUNET_OK != GNUNET_DISK_directory_create ("test/entry"))
+  {
+    GNUNET_break (0);
     return 1;
+  }
   if (GNUNET_OK != GNUNET_DISK_directory_create ("test/entry_many"))
+  {
+    GNUNET_break (0);
     return 1;
+  }
   if (GNUNET_OK != GNUNET_DISK_directory_create ("test/entry_more"))
+  {
+    GNUNET_break (0);
     return 1;
+  }
+  GNUNET_DISK_directory_scan ("test",
+                             &iter_callback,
+                              &i);
   if (GNUNET_OK != GNUNET_DISK_directory_remove ("test"))
+  {
+    GNUNET_break (0);
     return 1;
+  }
   if (i < 3)
+  {
+    GNUNET_break (0);
     return 1;
+  }
   return 0;
 }
 
@@ -183,19 +228,40 @@ static int
 testDirMani ()
 {
   if (GNUNET_OK != GNUNET_DISK_directory_create_for_file ("test/ing"))
+  {
+    GNUNET_break (0);
     return 1;
+  }
   if (GNUNET_NO != GNUNET_DISK_file_test ("test"))
+  {
+    GNUNET_break (0);
     return 1;
+  }
   if (GNUNET_NO != GNUNET_DISK_file_test ("test/ing"))
+  {
+    GNUNET_break (0);
     return 1;
+  }
   if (GNUNET_OK != GNUNET_DISK_directory_remove ("test"))
+  {
+    GNUNET_break (0);
     return 1;
+  }
   if (GNUNET_OK != GNUNET_DISK_directory_create ("test"))
+  {
+    GNUNET_break (0);
     return 1;
+  }
   if (GNUNET_YES != GNUNET_DISK_directory_test ("test", GNUNET_YES))
+  {
+    GNUNET_break (0);
     return 1;
+  }
   if (GNUNET_OK != GNUNET_DISK_directory_remove ("test"))
+  {
+    GNUNET_break (0);
     return 1;
+  }
   return 0;
 }
 
@@ -213,9 +279,11 @@ main (int argc, char *argv[])
   failureCount += testCanonicalize ();
   failureCount += testChangeOwner ();
   failureCount += testDirMani ();
-  if (failureCount != 0)
+  if (0 != failureCount)
   {
-    FPRINTF (stderr, "\n%u TESTS FAILED!\n", failureCount);
+    FPRINTF (stderr,
+            "\n%u TESTS FAILED!\n",
+            failureCount);
     return -1;
   }
   return 0;