gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r18496 - in gnunet/src: include testing


From: gnunet
Subject: [GNUnet-SVN] r18496 - in gnunet/src: include testing
Date: Wed, 7 Dec 2011 16:34:26 +0100

Author: wachs
Date: 2011-12-07 16:34:26 +0100 (Wed, 07 Dec 2011)
New Revision: 18496

Modified:
   gnunet/src/include/gnunet_testing_lib.h
   gnunet/src/testing/gnunet-testing.c
   gnunet/src/testing/testing_group.c
Log:


Modified: gnunet/src/include/gnunet_testing_lib.h
===================================================================
--- gnunet/src/include/gnunet_testing_lib.h     2011-12-07 15:33:04 UTC (rev 
18495)
+++ gnunet/src/include/gnunet_testing_lib.h     2011-12-07 15:34:26 UTC (rev 
18496)
@@ -614,7 +614,30 @@
                             int delete_files, int allow_restart);
 
 
+
 /**
+ * Create a new configuration using the given configuration
+ * as a template; however, each PORT in the existing cfg
+ * must be renumbered by incrementing "*port".  If we run
+ * out of "*port" numbers, return NULL.
+ *
+ * @param cfg template configuration
+ * @param off the current peer offset
+ * @param port port numbers to use, update to reflect
+ *             port numbers that were used
+ * @param upnum number to make unix domain socket names unique
+ * @param hostname hostname of the controlling host, to allow control 
connections from
+ * @param fdnum number used to offset the unix domain socket for grouped 
processes
+ *              (such as statistics or peerinfo, which can be shared among 
others)
+ *
+ * @return new configuration, NULL on error
+ */
+struct GNUNET_CONFIGURATION_Handle *
+GNUNET_TESTING_create_cfg (const struct GNUNET_CONFIGURATION_Handle *cfg, 
uint32_t off,
+             uint16_t * port, uint32_t * upnum, const char *hostname,
+             uint32_t * fdnum);
+
+/**
  * Changes the configuration of a GNUnet daemon.
  *
  * @param d the daemon that should be modified

Modified: gnunet/src/testing/gnunet-testing.c
===================================================================
--- gnunet/src/testing/gnunet-testing.c 2011-12-07 15:33:04 UTC (rev 18495)
+++ gnunet/src/testing/gnunet-testing.c 2011-12-07 15:34:26 UTC (rev 18496)
@@ -43,12 +43,56 @@
 static int
 create_unique_cfgs (const char * template, const unsigned int no)
 {
+  int fail = GNUNET_NO;
+
+  uint16_t port = 20000;
+  uint32_t upnum = 1;
+  uint32_t fdnum = 1;
+
   if (GNUNET_NO == GNUNET_DISK_file_test(template))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Configuration template `%s': file 
not found\n", create_cfg_template);
     return 1;
   }
-  return 0;
+
+  int cur = 0;
+  char * cur_file;
+  struct GNUNET_CONFIGURATION_Handle *cfg_tmpl = GNUNET_CONFIGURATION_create();
+  struct GNUNET_CONFIGURATION_Handle *cfg_new = NULL;
+
+  if (GNUNET_OK != GNUNET_CONFIGURATION_load(cfg_tmpl, create_cfg_template))
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not load template `%s'\n", 
create_cfg_template);
+    GNUNET_CONFIGURATION_destroy(cfg_tmpl);
+
+    return 1;
+  }
+
+  while (cur < no)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Creating configuration no. %u \n", 
cur);
+    GNUNET_asprintf(&cur_file,"%04u-%s",cur, create_cfg_template);
+    cfg_new = GNUNET_TESTING_create_cfg(cfg_tmpl, cur, &port, &upnum, NULL, 
&fdnum);
+
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Writing configuration no. %u to file 
`%s' \n", cur, cur_file);
+    if (GNUNET_OK != GNUNET_CONFIGURATION_write(cfg_new, cur_file))
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to write configuration no. 
%u \n", cur);
+      fail = GNUNET_YES;
+    }
+
+
+    GNUNET_free (cur_file);
+    if (fail == GNUNET_YES)
+      break;
+    cur ++;
+  }
+
+  GNUNET_CONFIGURATION_destroy(cfg_tmpl);
+  if (fail == GNUNET_NO)
+    return 0;
+  else
+    return 1;
 }
 
 /**

Modified: gnunet/src/testing/testing_group.c
===================================================================
--- gnunet/src/testing/testing_group.c  2011-12-07 15:33:04 UTC (rev 18495)
+++ gnunet/src/testing/testing_group.c  2011-12-07 15:34:26 UTC (rev 18496)
@@ -1435,8 +1435,8 @@
  *
  * @return new configuration, NULL on error
  */
-static struct GNUNET_CONFIGURATION_Handle *
-make_config (const struct GNUNET_CONFIGURATION_Handle *cfg, uint32_t off,
+struct GNUNET_CONFIGURATION_Handle *
+GNUNET_TESTING_create_cfg (const struct GNUNET_CONFIGURATION_Handle *cfg, 
uint32_t off,
              uint16_t * port, uint32_t * upnum, const char *hostname,
              uint32_t * fdnum)
 {
@@ -1540,6 +1540,7 @@
   }
   else
   {
+
     GNUNET_CONFIGURATION_set_value_string (uc.ret, "transport-tcp",
                                            "USE_LOCALADDR", "YES");
     GNUNET_CONFIGURATION_set_value_string (uc.ret, "transport-udp",
@@ -1550,7 +1551,7 @@
                                            "127.0.0.1");
     GNUNET_CONFIGURATION_set_value_string (uc.ret, "nat", "EXTERNAL_ADDRESS",
                                            "127.0.0.1");
-    GNUNET_CONFIGURATION_set_value_string (uc.ret, "disablev6", "BINDTO",
+    GNUNET_CONFIGURATION_set_value_string (uc.ret, "nat", "disablev6",
                                            "YES");
   }
 
@@ -6159,7 +6160,7 @@
       username = pg->hosts[off % hostcnt].username;
       sshport = pg->hosts[off % hostcnt].sshport;
       pcfg =
-          make_config (cfg, off, &pg->hosts[off % hostcnt].minport, &upnum,
+          GNUNET_TESTING_create_cfg (cfg, off, &pg->hosts[off % 
hostcnt].minport, &upnum,
                        hostname, &fdnum);
     }
     else
@@ -6167,7 +6168,7 @@
       hostname = NULL;
       username = NULL;
       sshport = 0;
-      pcfg = make_config (cfg, off, &minport, &upnum, hostname, &fdnum);
+      pcfg = GNUNET_TESTING_create_cfg (cfg, off, &minport, &upnum, hostname, 
&fdnum);
     }
 
     if (NULL == pcfg)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]