-fix #3870
[oweals/gnunet.git] / src / util / test_configuration.c
index 609f797bdb734d297e7f72327f1a67f3ca6401d4..bbee2de92d16028f2d142a83db6cccf6dc272784 100644 (file)
@@ -1,10 +1,10 @@
 /*
      This file is part of GNUnet.
 /*
      This file is part of GNUnet.
-     (C) 2003, 2004, 2005, 2006, 2007 Christian Grothoff (and other contributing authors)
+     Copyright (C) 2003, 2004, 2005, 2006, 2007 Christian Grothoff (and other contributing authors)
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
 
      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 2, or (at your
+     by the Free Software Foundation; either version 3, or (at your
      option) any later version.
 
      GNUnet is distributed in the hope that it will be useful, but
      option) any later version.
 
      GNUnet is distributed in the hope that it will be useful, but
  */
 
 #include "platform.h"
  */
 
 #include "platform.h"
-#include "gnunet_common.h"
-#include "gnunet_configuration_lib.h"
-#include "gnunet_disk_lib.h"
+#include "gnunet_util_lib.h"
 
 
-#define DEBUG GNUNET_NO
 
 /* Test Configuration Diffs Options */
 enum
 
 /* Test Configuration Diffs Options */
 enum
@@ -40,14 +37,12 @@ enum
   ADD_NEW_ENTRY,
   REMOVE_SECTION,
   REMOVE_ENTRY,
   ADD_NEW_ENTRY,
   REMOVE_SECTION,
   REMOVE_ENTRY,
-  COMPARE
-#if DEBUG
-    , PRINT
-#endif
+  COMPARE,
+  PRINT
 };
 
 static struct GNUNET_CONFIGURATION_Handle *cfg;
 };
 
 static struct GNUNET_CONFIGURATION_Handle *cfg;
-static struct GNUNET_CONFIGURATION_Handle *cfgDefault;
+static struct GNUNET_CONFIGURATION_Handle *cfg_default;
 
 struct DiffsCBData
 {
 
 struct DiffsCBData
 {
@@ -75,77 +70,81 @@ initDiffsCBData (struct DiffsCBData *cbData)
  * and comparing configuration
 */
 static void
  * and comparing configuration
 */
 static void
-diffsCallBack (void *cls,
-              const char *section, const char *option, const char *value)
+diffsCallBack (void *cls, const char *section, const char *option,
+               const char *value)
 {
   struct DiffsCBData *cbData = cls;
   int cbOption = cbData->callBackOption;
 
   switch (cbOption)
 {
   struct DiffsCBData *cbData = cls;
   int cbOption = cbData->callBackOption;
 
   switch (cbOption)
+  {
+  case EDIT_SECTION:
+    if (NULL == cbData->section)
+      cbData->section = section;
+    if (strcmp (cbData->section, section) == 0)
     {
     {
-    case EDIT_SECTION:
-      if (NULL == cbData->section)
-       cbData->section = section;
-      if (strcmp (cbData->section, section) == 0)
-       {
-         GNUNET_CONFIGURATION_set_value_string (cbData->cfg, section, option,
-                                                "new-value");
-         GNUNET_CONFIGURATION_set_value_string (cbData->cfgDiffs, section,
-                                                option, "new-value");
-       }
-      break;
-    case EDIT_ALL:
       GNUNET_CONFIGURATION_set_value_string (cbData->cfg, section, option,
       GNUNET_CONFIGURATION_set_value_string (cbData->cfg, section, option,
-                                            "new-value");
+                                             "new-value");
+      GNUNET_CONFIGURATION_set_value_string (cbData->cfgDiffs, section, option,
+                                             "new-value");
+    }
+    break;
+  case EDIT_ALL:
+    GNUNET_CONFIGURATION_set_value_string (cbData->cfg, section, option,
+                                           "new-value");
+    GNUNET_CONFIGURATION_set_value_string (cbData->cfgDiffs, section, option,
+                                           "new-value");
+    break;
+  case ADD_NEW_ENTRY:
+  {
+    static int hit = 0;
+
+    if (hit == 0)
+    {
+      hit = 1;
+      GNUNET_CONFIGURATION_set_value_string (cbData->cfg, section, "new-key",
+                                             "new-value");
       GNUNET_CONFIGURATION_set_value_string (cbData->cfgDiffs, section,
       GNUNET_CONFIGURATION_set_value_string (cbData->cfgDiffs, section,
-                                            option, "new-value");
-      break;
-    case ADD_NEW_ENTRY:
-      {
-       static int hit = 0;
-       if (hit == 0)
-         {
-           hit = 1;
-           GNUNET_CONFIGURATION_set_value_string (cbData->cfg, section,
-                                                  "new-key", "new-value");
-           GNUNET_CONFIGURATION_set_value_string (cbData->cfgDiffs, section,
-                                                  "new-key", "new-value");
-         }
-       break;
-      }
-    case COMPARE:
-      {
-       int ret;
-       char *diffValue;
-       ret =
-         GNUNET_CONFIGURATION_get_value_string (cbData->cfgDiffs, section,
-                                                option, &diffValue);
-       if (NULL != diffValue)
-         {
-           if (ret == GNUNET_SYSERR || strcmp (diffValue, value) != 0)
-             cbData->status = 1;
-         }
-       else
-         cbData->status = 1;
-       break;
-      }
-#if DEBUG
-    case PRINT:
-      if (NULL == cbData->section)
-       {
-         cbData->section = section;
-         printf ("\nSection: %s\n", section);
-       }
-      else if (strcmp (cbData->section, section) != 0)
-       {
-         cbData->section = section;
-         printf ("\nSection: %s\n", section);
-       }
-      printf ("%s = %s\n", option, value);
-#endif
-    default:
-      break;
+                                             "new-key", "new-value");
     }
     }
+    break;
+  }
+  case COMPARE:
+  {
+    int ret;
+    char *diffValue;
+
+    diffValue = NULL;
+    ret =
+        GNUNET_CONFIGURATION_get_value_string (cbData->cfgDiffs, section,
+                                               option, &diffValue);
+    if (NULL != diffValue)
+    {
+      if (ret == GNUNET_SYSERR || strcmp (diffValue, value) != 0)
+        cbData->status = 1;
+    }
+    else
+      cbData->status = 1;
+    GNUNET_free_non_null (diffValue);
+    break;
+  }
+#if 0
+  case PRINT:
+    if (NULL == cbData->section)
+    {
+      cbData->section = section;
+      printf ("\nSection: %s\n", section);
+    }
+    else if (strcmp (cbData->section, section) != 0)
+    {
+      cbData->section = section;
+      printf ("\nSection: %s\n", section);
+    }
+    printf ("%s = %s\n", option, value);
+#endif
+  default:
+    break;
+  }
 }
 
 
 }
 
 
@@ -153,43 +152,45 @@ static struct GNUNET_CONFIGURATION_Handle *
 editConfiguration (struct GNUNET_CONFIGURATION_Handle *cfg, int option)
 {
   struct DiffsCBData diffsCB;
 editConfiguration (struct GNUNET_CONFIGURATION_Handle *cfg, int option)
 {
   struct DiffsCBData diffsCB;
+
   initDiffsCBData (&diffsCB);
   diffsCB.cfgDiffs = GNUNET_CONFIGURATION_create ();
 
   switch (option)
   initDiffsCBData (&diffsCB);
   diffsCB.cfgDiffs = GNUNET_CONFIGURATION_create ();
 
   switch (option)
+  {
+  case EDIT_SECTION:
+  case EDIT_ALL:
+  case ADD_NEW_ENTRY:
+    diffsCB.callBackOption = option;
+    diffsCB.cfg = cfg;
+    GNUNET_CONFIGURATION_iterate (cfg, diffsCallBack, &diffsCB);
+    break;
+  case EDIT_NOTHING:
+    /* Do nothing */
+    break;
+  case ADD_NEW_SECTION:
+  {
+    int i;
+    char *key;
+
+    for (i = 0; i < 5; i++)
     {
     {
-    case EDIT_SECTION:
-    case EDIT_ALL:
-    case ADD_NEW_ENTRY:
-      diffsCB.callBackOption = option;
-      diffsCB.cfg = cfg;
-      GNUNET_CONFIGURATION_iterate (cfg, diffsCallBack, &diffsCB);
-      break;
-    case EDIT_NOTHING:
-      /* Do nothing */
-      break;
-    case ADD_NEW_SECTION:
-      {
-       int i;
-       char *key;
-       for (i = 0; i < 5; i++)
-         {
-           GNUNET_asprintf (&key, "key%d", i);
-           GNUNET_CONFIGURATION_set_value_string (cfg, "new-section", key,
-                                                  "new-value");
-           GNUNET_CONFIGURATION_set_value_string (diffsCB.cfgDiffs,
-                                                  "new-section", key,
-                                                  "new-value");
-         }
-       break;
-      }
-    case REMOVE_SECTION:
-      break;
-    case REMOVE_ENTRY:
-      break;
-    default:
-      break;
+      GNUNET_asprintf (&key, "key%d", i);
+      GNUNET_CONFIGURATION_set_value_string (cfg, "new-section", key,
+                                             "new-value");
+      GNUNET_CONFIGURATION_set_value_string (diffsCB.cfgDiffs, "new-section",
+                                             key, "new-value");
+      GNUNET_free (key);
     }
     }
+    break;
+  }
+  case REMOVE_SECTION:
+    break;
+  case REMOVE_ENTRY:
+    break;
+  default:
+    break;
+  }
 
   return diffsCB.cfgDiffs;
 }
 
   return diffsCB.cfgDiffs;
 }
@@ -198,7 +199,7 @@ editConfiguration (struct GNUNET_CONFIGURATION_Handle *cfg, int option)
  * Checking configuration diffs
  */
 static int
  * Checking configuration diffs
  */
 static int
-checkDiffs (struct GNUNET_CONFIGURATION_Handle *cfgDefault, int option)
+checkDiffs (struct GNUNET_CONFIGURATION_Handle *cfg_default, int option)
 {
   struct GNUNET_CONFIGURATION_Handle *cfg;
   struct GNUNET_CONFIGURATION_Handle *cfgDiffs;
 {
   struct GNUNET_CONFIGURATION_Handle *cfg;
   struct GNUNET_CONFIGURATION_Handle *cfgDiffs;
@@ -209,36 +210,44 @@ checkDiffs (struct GNUNET_CONFIGURATION_Handle *cfgDefault, int option)
   initDiffsCBData (&cbData);
 
   cfg = GNUNET_CONFIGURATION_create ();
   initDiffsCBData (&cbData);
 
   cfg = GNUNET_CONFIGURATION_create ();
-  GNUNET_CONFIGURATION_load (cfg, NULL);
+  /* load defaults */
+  GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (cfg, NULL));
 
   /* Modify configuration and save it */
   cfgDiffs = editConfiguration (cfg, option);
 
   /* Modify configuration and save it */
   cfgDiffs = editConfiguration (cfg, option);
-  diffsFileName =
-    GNUNET_DISK_mktemp ("gnunet-test-configurations-diffs.conf");
-  GNUNET_CONFIGURATION_write_diffs (cfgDefault, cfg, diffsFileName);
+  diffsFileName = GNUNET_DISK_mktemp ("gnunet-test-configurations-diffs.conf");
+  if (diffsFileName == NULL)
+  {
+    GNUNET_break (0);
+    GNUNET_CONFIGURATION_destroy (cfg);
+    GNUNET_CONFIGURATION_destroy (cfgDiffs);
+    return 1;
+  }
+  GNUNET_CONFIGURATION_write_diffs (cfg_default, cfg, diffsFileName);
   GNUNET_CONFIGURATION_destroy (cfg);
 
   /* Compare the dumped configuration with modifications done */
   cfg = GNUNET_CONFIGURATION_create ();
   GNUNET_CONFIGURATION_destroy (cfg);
 
   /* Compare the dumped configuration with modifications done */
   cfg = GNUNET_CONFIGURATION_create ();
-  GNUNET_CONFIGURATION_parse (cfg, diffsFileName);
-  remove (diffsFileName);
+  GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_parse (cfg, diffsFileName));
+  if (0 != remove (diffsFileName))
+    GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "remove", diffsFileName);
   cbData.callBackOption = COMPARE;
   cbData.cfgDiffs = cfgDiffs;
   GNUNET_CONFIGURATION_iterate (cfg, diffsCallBack, &cbData);
   cbData.callBackOption = COMPARE;
   cbData.cfgDiffs = cfgDiffs;
   GNUNET_CONFIGURATION_iterate (cfg, diffsCallBack, &cbData);
-  if ((ret = cbData.status) == 1)
-    {
-      fprintf (stderr,
-              "Incorrect Configuration Diffs: Diffs may contain data not actually edited\n");
-      goto housekeeping;
-    }
+  if (1 == (ret = cbData.status))
+  {
+    FPRINTF (stderr, "%s",
+             "Incorrect Configuration Diffs: Diffs may contain data not actually edited\n");
+    goto housekeeping;
+  }
   cbData.cfgDiffs = cfg;
   GNUNET_CONFIGURATION_iterate (cfgDiffs, diffsCallBack, &cbData);
   if ((ret = cbData.status) == 1)
   cbData.cfgDiffs = cfg;
   GNUNET_CONFIGURATION_iterate (cfgDiffs, diffsCallBack, &cbData);
   if ((ret = cbData.status) == 1)
-    fprintf (stderr,
-            "Incorrect Configuration Diffs: Data may be missing in diffs\n");
+    FPRINTF (stderr, "%s",
+             "Incorrect Configuration Diffs: Data may be missing in diffs\n");
 
 housekeeping:
 
 housekeeping:
-#if DEBUG
+#if 0
   cbData.section = NULL;
   cbData.callBackOption = PRINT;
   printf ("\nExpected Diffs:\n");
   cbData.section = NULL;
   cbData.callBackOption = PRINT;
   printf ("\nExpected Diffs:\n");
@@ -249,6 +258,7 @@ housekeeping:
 #endif
   GNUNET_CONFIGURATION_destroy (cfg);
   GNUNET_CONFIGURATION_destroy (cfgDiffs);
 #endif
   GNUNET_CONFIGURATION_destroy (cfg);
   GNUNET_CONFIGURATION_destroy (cfgDiffs);
+  GNUNET_free (diffsFileName);
   return ret;
 }
 
   return ret;
 }
 
@@ -259,50 +269,77 @@ testConfig ()
   char *c;
   unsigned long long l;
 
   char *c;
   unsigned long long l;
 
-  if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_get_value_string (cfg, "test", "b", &c))
+  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, "test", "b", &c))
     return 1;
   if (0 != strcmp ("b", c))
     return 1;
   if (0 != strcmp ("b", c))
-    {
-      fprintf (stderr, "Got `%s'\n", c);
-      GNUNET_free (c);
-      return 2;
-    }
+  {
+    FPRINTF (stderr, "Got `%s'\n", c);
+    GNUNET_free (c);
+    return 2;
+  }
   GNUNET_free (c);
   GNUNET_free (c);
-  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg,
-                                                         "test", "five", &l))
+  if (GNUNET_OK !=
+      GNUNET_CONFIGURATION_get_value_number (cfg, "test", "five", &l))
+  {
+    GNUNET_break (0);
     return 3;
     return 3;
+  }
   if (5 != l)
   if (5 != l)
+  {
+    GNUNET_break (0);
     return 4;
     return 4;
+  }
   GNUNET_CONFIGURATION_set_value_string (cfg, "more", "c", "YES");
   if (GNUNET_NO == GNUNET_CONFIGURATION_get_value_yesno (cfg, "more", "c"))
   GNUNET_CONFIGURATION_set_value_string (cfg, "more", "c", "YES");
   if (GNUNET_NO == GNUNET_CONFIGURATION_get_value_yesno (cfg, "more", "c"))
+  {
+    GNUNET_break (0);
     return 5;
     return 5;
+  }
   GNUNET_CONFIGURATION_set_value_number (cfg, "NUMBERS", "TEN", 10);
   if (GNUNET_OK !=
       GNUNET_CONFIGURATION_get_value_string (cfg, "NUMBERS", "TEN", &c))
   GNUNET_CONFIGURATION_set_value_number (cfg, "NUMBERS", "TEN", 10);
   if (GNUNET_OK !=
       GNUNET_CONFIGURATION_get_value_string (cfg, "NUMBERS", "TEN", &c))
+  {
+    GNUNET_break (0);
     return 6;
     return 6;
+  }
   if (0 != strcmp (c, "10"))
   if (0 != strcmp (c, "10"))
-    {
-      GNUNET_free (c);
-      return 7;
-    }
+  {
+    GNUNET_free (c);
+    GNUNET_break (0);
+    return 7;
+  }
   GNUNET_free (c);
 
   if (GNUNET_OK !=
       GNUNET_CONFIGURATION_get_value_filename (cfg, "last", "test", &c))
   GNUNET_free (c);
 
   if (GNUNET_OK !=
       GNUNET_CONFIGURATION_get_value_filename (cfg, "last", "test", &c))
+  {
+    GNUNET_break (0);
     return 8;
     return 8;
+  }
 #ifndef MINGW
   if (0 != strcmp (c, "/hello/world"))
 #else
 #define HI "\\hello\\world"
   if (strstr (c, HI) != c + strlen (c) - strlen (HI))
 #endif
 #ifndef MINGW
   if (0 != strcmp (c, "/hello/world"))
 #else
 #define HI "\\hello\\world"
   if (strstr (c, HI) != c + strlen (c) - strlen (HI))
 #endif
-    {
-      GNUNET_free (c);
-      return 9;
-    }
+  {
+    GNUNET_break (0);
+    GNUNET_free (c);
+    return 9;
+  }
   GNUNET_free (c);
 
   GNUNET_free (c);
 
+  if (GNUNET_OK !=
+      GNUNET_CONFIGURATION_get_value_size (cfg, "last", "size", &l))
+  {
+    GNUNET_break (0);
+    return 10;
+  }
+  if (l != 512 * 1024)
+  {
+    GNUNET_break (0);
+    return 11;
+  }
   return 0;
 }
 
   return 0;
 }
 
@@ -320,10 +357,11 @@ check (void *data, const char *fn)
   int *idx = data;
 
   if (0 == strcmp (want[*idx], fn))
   int *idx = data;
 
   if (0 == strcmp (want[*idx], fn))
-    {
-      (*idx)++;
-      return GNUNET_OK;
-    }
+  {
+    (*idx)++;
+    return GNUNET_OK;
+  }
+  GNUNET_break (0);
   return GNUNET_SYSERR;
 }
 
   return GNUNET_SYSERR;
 }
 
@@ -333,64 +371,85 @@ testConfigFilenames ()
   int idx;
 
   idx = 0;
   int idx;
 
   idx = 0;
-  if (3 != GNUNET_CONFIGURATION_iterate_value_filenames (cfg,
-                                                        "FILENAMES",
-                                                        "test",
-                                                        &check, &idx))
+  if (3 !=
+      GNUNET_CONFIGURATION_iterate_value_filenames (cfg, "FILENAMES", "test",
+                                                    &check, &idx))
+  {
+    GNUNET_break (0);
     return 8;
     return 8;
+  }
   if (idx != 3)
     return 16;
   if (GNUNET_OK !=
   if (idx != 3)
     return 16;
   if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_remove_value_filename (cfg,
-                                                 "FILENAMES",
-                                                 "test", "/File Name"))
+      GNUNET_CONFIGURATION_remove_value_filename (cfg, "FILENAMES", "test",
+                                                  "/File Name"))
+  {
+    GNUNET_break (0);
     return 24;
     return 24;
+  }
 
   if (GNUNET_NO !=
 
   if (GNUNET_NO !=
-      GNUNET_CONFIGURATION_remove_value_filename (cfg,
-                                                 "FILENAMES",
-                                                 "test", "/File Name"))
+      GNUNET_CONFIGURATION_remove_value_filename (cfg, "FILENAMES", "test",
+                                                  "/File Name"))
+  {
+    GNUNET_break (0);
     return 32;
     return 32;
+  }
   if (GNUNET_NO !=
   if (GNUNET_NO !=
-      GNUNET_CONFIGURATION_remove_value_filename (cfg,
-                                                 "FILENAMES",
-                                                 "test", "Stuff"))
+      GNUNET_CONFIGURATION_remove_value_filename (cfg, "FILENAMES", "test",
+                                                  "Stuff"))
+  {
+    GNUNET_break (0);
     return 40;
     return 40;
+  }
 
   if (GNUNET_NO !=
 
   if (GNUNET_NO !=
-      GNUNET_CONFIGURATION_append_value_filename (cfg,
-                                                 "FILENAMES",
-                                                 "test", "/Hello"))
+      GNUNET_CONFIGURATION_append_value_filename (cfg, "FILENAMES", "test",
+                                                  "/Hello"))
+  {
+    GNUNET_break (0);
     return 48;
     return 48;
+  }
   if (GNUNET_NO !=
   if (GNUNET_NO !=
-      GNUNET_CONFIGURATION_append_value_filename (cfg,
-                                                 "FILENAMES",
-                                                 "test", "/World"))
+      GNUNET_CONFIGURATION_append_value_filename (cfg, "FILENAMES", "test",
+                                                  "/World"))
+  {
+    GNUNET_break (0);
     return 56;
     return 56;
+  }
 
   if (GNUNET_YES !=
 
   if (GNUNET_YES !=
-      GNUNET_CONFIGURATION_append_value_filename (cfg,
-                                                 "FILENAMES",
-                                                 "test", "/File 1"))
+      GNUNET_CONFIGURATION_append_value_filename (cfg, "FILENAMES", "test",
+                                                  "/File 1"))
+  {
+    GNUNET_break (0);
     return 64;
     return 64;
+  }
 
   if (GNUNET_YES !=
 
   if (GNUNET_YES !=
-      GNUNET_CONFIGURATION_append_value_filename (cfg,
-                                                 "FILENAMES",
-                                                 "test", "/File 2"))
+      GNUNET_CONFIGURATION_append_value_filename (cfg, "FILENAMES", "test",
+                                                  "/File 2"))
+  {
+    GNUNET_break (0);
     return 72;
     return 72;
+  }
 
   idx = 0;
   want[1] = "/World";
   want[2] = "/File 1";
   want[3] = "/File 2";
 
   idx = 0;
   want[1] = "/World";
   want[2] = "/File 1";
   want[3] = "/File 2";
-  if (4 != GNUNET_CONFIGURATION_iterate_value_filenames (cfg,
-                                                        "FILENAMES",
-                                                        "test",
-                                                        &check, &idx))
+  if (4 !=
+      GNUNET_CONFIGURATION_iterate_value_filenames (cfg, "FILENAMES", "test",
+                                                    &check, &idx))
+  {
+    GNUNET_break (0);
     return 80;
     return 80;
+  }
   if (idx != 4)
   if (idx != 4)
+  {
+    GNUNET_break (0);
     return 88;
     return 88;
+  }
   return 0;
 }
 
   return 0;
 }
 
@@ -406,81 +465,85 @@ main (int argc, char *argv[])
   GNUNET_assert (cfg != NULL);
   if (GNUNET_OK !=
       GNUNET_CONFIGURATION_parse (cfg, "test_configuration_data.conf"))
   GNUNET_assert (cfg != NULL);
   if (GNUNET_OK !=
       GNUNET_CONFIGURATION_parse (cfg, "test_configuration_data.conf"))
-    {
-      fprintf (stderr, "Failed to parse configuration file\n");
-      GNUNET_CONFIGURATION_destroy (cfg);
-      return 1;
-    }
+  {
+    FPRINTF (stderr, "%s",  "Failed to parse configuration file\n");
+    GNUNET_CONFIGURATION_destroy (cfg);
+    return 1;
+  }
   failureCount += testConfig ();
   failureCount += testConfig ();
-  failureCount += 2 * testConfigFilenames ();
+  if (failureCount > 0)
+    goto error;
+
+  failureCount = testConfigFilenames ();
+  if (failureCount > 0)
+    goto error;
 
   if (GNUNET_OK != GNUNET_CONFIGURATION_write (cfg, "/tmp/gnunet-test.conf"))
 
   if (GNUNET_OK != GNUNET_CONFIGURATION_write (cfg, "/tmp/gnunet-test.conf"))
-    {
-      fprintf (stderr, "Failed to write configuration file\n");
-      GNUNET_CONFIGURATION_destroy (cfg);
-      return 1;
-    }
+  {
+    FPRINTF (stderr, "%s",  "Failed to write configuration file\n");
+    GNUNET_CONFIGURATION_destroy (cfg);
+    return 1;
+  }
   GNUNET_CONFIGURATION_destroy (cfg);
   GNUNET_assert (0 == UNLINK ("/tmp/gnunet-test.conf"));
 
   cfg = GNUNET_CONFIGURATION_create ();
   if (GNUNET_OK !=
       GNUNET_CONFIGURATION_load (cfg, "test_configuration_data.conf"))
   GNUNET_CONFIGURATION_destroy (cfg);
   GNUNET_assert (0 == UNLINK ("/tmp/gnunet-test.conf"));
 
   cfg = GNUNET_CONFIGURATION_create ();
   if (GNUNET_OK !=
       GNUNET_CONFIGURATION_load (cfg, "test_configuration_data.conf"))
-    {
-      GNUNET_break (0);
-      GNUNET_CONFIGURATION_destroy (cfg);
-      return 1;
-    }
-  if ((GNUNET_OK !=
-       GNUNET_CONFIGURATION_get_value_string (cfg, "TESTING", "WEAKRANDOM",
-                                             &c))
-      || (0 != strcmp (c, "YES")))
-    {
-      GNUNET_CONFIGURATION_destroy (cfg);
-      return 1;
-    }
-  GNUNET_free (c);
-  if ((GNUNET_OK !=
-       GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS", "SERVICEHOME",
-                                             &c))
-      || (0 != strcmp (c, "/var/lib/gnunet/")))
-    {
-      GNUNET_CONFIGURATION_destroy (cfg);
-      return 1;
-    }
+  {
+    GNUNET_break (0);
+    GNUNET_CONFIGURATION_destroy (cfg);
+    return 1;
+  }
+  if (GNUNET_OK !=
+      GNUNET_CONFIGURATION_get_value_string (cfg, "TESTING", "WEAKRANDOM", &c))
+  {
+    GNUNET_break (0);
+    GNUNET_CONFIGURATION_destroy (cfg);
+    return 1;
+  }
+  if (0 != strcmp (c, "YES"))
+  {
+    GNUNET_break (0);
+    GNUNET_free (c);
+    GNUNET_CONFIGURATION_destroy (cfg);
+    return 1;
+  }
+
   GNUNET_free (c);
   GNUNET_CONFIGURATION_destroy (cfg);
 
   /* Testing configuration diffs */
   GNUNET_free (c);
   GNUNET_CONFIGURATION_destroy (cfg);
 
   /* Testing configuration diffs */
-  cfgDefault = GNUNET_CONFIGURATION_create ();
-  if (GNUNET_OK != GNUNET_CONFIGURATION_load (cfgDefault, NULL))
-    {
-      GNUNET_break (0);
-      GNUNET_CONFIGURATION_destroy (cfgDefault);
-      return 1;
-    }
+  cfg_default = GNUNET_CONFIGURATION_create ();
+  if (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg_default, NULL))
+  {
+    GNUNET_break (0);
+    GNUNET_CONFIGURATION_destroy (cfg_default);
+    return 1;
+  }
 
   /* Nothing changed in the new configuration */
 
   /* Nothing changed in the new configuration */
-  failureCount += checkDiffs (cfgDefault, EDIT_NOTHING);
+  failureCount += checkDiffs (cfg_default, EDIT_NOTHING);
 
   /* Modify all entries of the last section */
 
   /* Modify all entries of the last section */
-  failureCount += checkDiffs (cfgDefault, EDIT_SECTION);
+  failureCount += checkDiffs (cfg_default, EDIT_SECTION);
 
   /* Add a new section */
 
   /* Add a new section */
-  failureCount += checkDiffs (cfgDefault, ADD_NEW_SECTION);
+  failureCount += checkDiffs (cfg_default, ADD_NEW_SECTION);
 
   /* Add a new entry to the last section */
 
   /* Add a new entry to the last section */
-  failureCount += checkDiffs (cfgDefault, ADD_NEW_ENTRY);
+  failureCount += checkDiffs (cfg_default, ADD_NEW_ENTRY);
 
   /* Modify all entries in the configuration */
 
   /* Modify all entries in the configuration */
-  failureCount += checkDiffs (cfgDefault, EDIT_ALL);
+  failureCount += checkDiffs (cfg_default, EDIT_ALL);
 
 
-  GNUNET_CONFIGURATION_destroy (cfgDefault);
+  GNUNET_CONFIGURATION_destroy (cfg_default);
 
 
+error:
   if (failureCount != 0)
   if (failureCount != 0)
-    {
-      fprintf (stderr, "Test failed: %u\n", failureCount);
-      return 1;
-    }
+  {
+    FPRINTF (stderr, "Test failed: %u\n", failureCount);
+    return 1;
+  }
   return 0;
 }
   return 0;
 }