fixes to build
[oweals/gnunet.git] / src / testing / testing_group.c
index c76f3b54d5021d0126b51dae506bc505c199ed5a..78100e446a0d2f4c6cc6251bb745a204c847d494 100644 (file)
@@ -4,7 +4,7 @@
 
       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
@@ -365,6 +365,11 @@ struct GNUNET_TESTING_PeerGroup
    * How many peers are being started right now?
    */
   unsigned int starting;
+
+  /**
+   * How many peers have already been started?
+   */
+  unsigned int started;
 };
 
 struct UpdateContext
@@ -493,7 +498,7 @@ GNUNET_TESTING_topology_get(enum GNUNET_TESTING_Topology *topology, char * topol
     return GNUNET_NO;
   while (topology_strings[curr] != NULL)
     {
-      if (strcmp(topology_strings[curr], topology_string) == 0)
+      if (strcasecmp(topology_strings[curr], topology_string) == 0)
        {
          *topology = curr;
          return GNUNET_YES;
@@ -515,8 +520,8 @@ GNUNET_TESTING_topology_get(enum GNUNET_TESTING_Topology *topology, char * topol
  *         topology option, GNUNET_NO if not
  */
 int
-GNUNET_TESTING_topology_option_get(enum GNUNET_TESTING_TopologyOption *topology_option, 
-                                  char * topology_string)
+GNUNET_TESTING_topology_option_get (enum GNUNET_TESTING_TopologyOption *topology_option,
+                                   char * topology_string)
 {
   /**
    * Options for connecting a topology as strings.
@@ -559,7 +564,7 @@ GNUNET_TESTING_topology_option_get(enum GNUNET_TESTING_TopologyOption *topology_
     return GNUNET_NO;
   while (NULL != topology_option_strings[curr])
     {
-      if (strcmp(topology_option_strings[curr], topology_string) == 0)
+      if (strcasecmp(topology_option_strings[curr], topology_string) == 0)
        {
          *topology_option = curr;
          return GNUNET_YES;
@@ -2850,7 +2855,14 @@ static void internal_hostkey_callback (void *cls,
 {
   struct InternalStartContext *internal_context = cls;
   internal_context->peer->pg->starting--;
-  internal_context->hostkey_callback(internal_context->hostkey_cls, id, d, emsg);
+  internal_context->peer->pg->started++;
+  if (internal_context->hostkey_callback != NULL)
+    internal_context->hostkey_callback(internal_context->hostkey_cls, id, d, emsg);
+  else if (internal_context->peer->pg->started == internal_context->peer->pg->total)
+    {
+      internal_context->peer->pg->started = 0; /* Internal startup may use this counter! */
+      GNUNET_TESTING_daemons_continue_startup(internal_context->peer->pg);
+    }
 }
 
 /**
@@ -2871,7 +2883,8 @@ static void internal_startup_callback (void *cls,
 {
   struct InternalStartContext *internal_context = cls;
   internal_context->peer->pg->starting--;
-  internal_context->start_cb(internal_context->start_cb_cls, id, cfg, d, emsg);
+  if (internal_context->start_cb != NULL)
+    internal_context->start_cb(internal_context->start_cb_cls, id, cfg, d, emsg);
 }
 
 static void
@@ -3566,7 +3579,7 @@ GNUNET_TESTING_daemons_stop (struct GNUNET_TESTING_PeerGroup *pg,
   shutdown_cb = NULL;
   shutdown_ctx = NULL;
 
-  if ((cb != NULL) && (pg->total > 0))
+  if (cb != NULL)
     {
       shutdown_ctx = GNUNET_malloc(sizeof(struct ShutdownContext));
       shutdown_ctx->cb = cb;