coverity warning fixes
authorNathan S. Evans <evans@in.tum.de>
Thu, 29 Apr 2010 09:19:29 +0000 (09:19 +0000)
committerNathan S. Evans <evans@in.tum.de>
Thu, 29 Apr 2010 09:19:29 +0000 (09:19 +0000)
src/testing/test_testing_topology.c

index 77f99018d56a56cda9b2447fb8c5a6a6b9a7e8f5..784c850f35639a2458a7678bc1689b4e8e07fb52 100644 (file)
@@ -25,7 +25,7 @@
 #include "gnunet_testing_lib.h"
 #include "gnunet_core_service.h"
 
-#define VERBOSE GNUNET_NO
+#define VERBOSE GNUNET_YES
 
 /**
  * How long until we fail the whole testcase?
@@ -83,6 +83,8 @@ static int transmit_ready_called;
 
 static enum GNUNET_TESTING_Topology topology;
 
+static char *test_directory;
+
 #define MTYPE 12345
 
 struct GNUNET_TestMessage
@@ -592,6 +594,12 @@ run (void *cls,
               "Starting daemons based on config file %s\n", cfgfile);
 #endif
 
+  if (GNUNET_YES != GNUNET_CONFIGURATION_get_value_string(cfg, "paths", "servicehome", &test_directory))
+    {
+      ok = 404;
+      return;
+    }
+
   if (GNUNET_YES ==
       GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "topology",
                                              &topology_num))
@@ -625,6 +633,7 @@ check ()
   char *config_file_name;
   GNUNET_asprintf(&binary_name, "test-testing-topology-%s", topology_string);
   GNUNET_asprintf(&config_file_name, "test_testing_data_topology_%s.conf", topology_string);
+  int ret;
   char *const argv[] = {binary_name,
     "-c",
     config_file_name,
@@ -636,9 +645,13 @@ check ()
   struct GNUNET_GETOPT_CommandLineOption options[] = {
     GNUNET_GETOPT_OPTION_END
   };
-  GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
+  ret = GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
                       argv, binary_name, "nohelp",
                       options, &run, &ok);
+  if (ret != GNUNET_OK)
+    {
+      GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "`test-testing-topology-%s': Failed with error code %d\n", topology_string, ret);
+    }
   GNUNET_free(binary_name);
   GNUNET_free(config_file_name);
   return ok;
@@ -676,7 +689,10 @@ main (int argc, char *argv[])
    * Need to remove base directory, subdirectories taken care
    * of by the testing framework.
    */
-  GNUNET_DISK_directory_remove ("/tmp/test-gnunet-testing");
+  if (GNUNET_DISK_directory_remove (test_directory) != GNUNET_OK)
+    {
+      GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Failed to remove testing directory %s\n", test_directory);
+    }
   GNUNET_free(our_binary_name);
   return ret;
 }