fix
[oweals/gnunet.git] / src / transport / test_plugin_transport.c
index e3ab5fd561792e64fcb4874b08d17acaea78ff48..db988fbe9dac31f3473d1e5466a04e95328aa5a2 100644 (file)
@@ -88,6 +88,11 @@ struct GNUNET_TRANSPORT_PluginEnvironment env;
  */
 struct GNUNET_TRANSPORT_PluginFunctions *api;
 
+/**
+ * Helper handler
+ */
+struct GNUNET_HELPER_Handle *suid_helper;
+
 /**
  * Timeout task
  */
@@ -147,6 +152,12 @@ end ()
   GNUNET_STATISTICS_destroy (stats, GNUNET_NO);
   stats = NULL;
 
+  if (NULL != suid_helper)
+  {
+    GNUNET_HELPER_stop (suid_helper);
+    suid_helper = NULL;
+  }
+
   ok = 0;
 }
 
@@ -190,6 +201,12 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
     stats = NULL;
   }
 
+  if (NULL != suid_helper)
+  {
+    GNUNET_HELPER_stop (suid_helper);
+    suid_helper = NULL;
+  }
+
   ok = 1;
 }
 
@@ -198,8 +215,8 @@ wait_end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   timeout_wait = GNUNET_SCHEDULER_NO_TASK;
   if (0 == addresses_reported)
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-              _("Plugin did not report any addresses, could not check plugin \n"));
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+              _("Plugin did not report any addresses, could not check address conversion functions\n"));
   end ();
 }
 
@@ -240,7 +257,8 @@ static void
 env_notify_address (void *cls,
                     int add_remove,
                     const void *addr,
-                    size_t addrlen)
+                    size_t addrlen,
+                    const char *plugin)
 {
   struct AddressWrapper *w;
   char *a2s;
@@ -387,6 +405,12 @@ setup_plugin_environment ()
   env.session_end = &env_session_end;
 }
 
+static int
+handle_helper_message (void *cls, void *client,
+                       const struct GNUNET_MessageHeader *hdr)
+{
+  return GNUNET_OK;
+}
 
 /**
  * Runs the test.
@@ -464,6 +488,21 @@ run (void *cls, char *const *args, const char *cfgfile,
   if (NULL != sep)
       sep[0] = '\0';
 
+  /* Hack for WLAN: start a second helper */
+  if (0 == strcmp (plugin, "wlan"))
+  {
+    char * helper_argv[3];
+    helper_argv[0] = (char *) "gnunet-helper-transport-wlan-dummy";
+    helper_argv[1] = (char *) "2";
+    helper_argv[2] = NULL;
+    suid_helper = GNUNET_HELPER_start ("gnunet-helper-transport-wlan-dummy",
+                                       helper_argv,
+                                       &handle_helper_message,
+                                       NULL,
+                                       NULL);
+  }
+
+
   /* Loading plugin */
   GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Loading transport plugin %s\n"), plugin);
   GNUNET_asprintf (&libname, "libgnunet_plugin_transport_%s", plugin);