-fix
[oweals/gnunet.git] / src / gns / test_gns_proxy.c
index 9b0e8c76d046bd97b5400dd10e2a36890623bfee..5e3d09d68f1ac6a46f88a1f0c5d06382ce35f91d 100644 (file)
@@ -32,7 +32,7 @@
 #include "gnunet_os_lib.h"
 
 #define PORT 8080
-#define TEST_DOMAIN "www.gnunet"
+#define TEST_DOMAIN "www.gads"
 
 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 300)
 
@@ -135,11 +135,21 @@ do_shutdown ()
   GNUNET_free_non_null (url);
 
   if (NULL != tmp_cfgfile)
-    remove (tmp_cfgfile);
-
+    {
+      if (0 != remove (tmp_cfgfile))
+       GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "remove", tmp_cfgfile);
+      GNUNET_free (tmp_cfgfile);
+      tmp_cfgfile = NULL;
+    }
   if (NULL != proxy_proc)
-    GNUNET_OS_process_kill (proxy_proc, 9);
+    {
+      (void) GNUNET_OS_process_kill (proxy_proc, SIGKILL);
+      GNUNET_assert (GNUNET_OK == GNUNET_OS_process_wait (proxy_proc));
+      GNUNET_OS_process_destroy (proxy_proc);
+      proxy_proc = NULL;
+    }
   url = NULL;
+  GNUNET_SCHEDULER_shutdown ();
 }
 
 
@@ -383,6 +393,7 @@ run (void *cls,
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                 "Failed to write tmp cfg\n");
+    do_shutdown ();
     return;
   }
   
@@ -394,7 +405,13 @@ run (void *cls,
                                         "gnunet-gns-proxy",
                                         "-c", tmp_cfgfile, NULL);
 
-  GNUNET_assert (NULL != proxy_proc);
+  if (NULL == proxy_proc)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Unable to start proxy\n");
+    do_shutdown ();
+    return;
+  }
   
   if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns",
                                                             "ZONEKEY",
@@ -428,6 +445,18 @@ int
 main (int argc, char *const *argv)
 {
 
+  if (GNUNET_SYSERR == GNUNET_OS_check_helper_binary ("gnunet-gns-proxy"))
+  {
+    fprintf (stderr, "Proxy binary not in PATH... skipping!\n");
+    return 0;
+  }
+
+  if (GNUNET_YES != GNUNET_OS_check_helper_binary ("gnunet-helper-dns"))
+  {
+    fprintf (stderr, "DNS helper binary has wrong permissions... skipping!\n");
+    return 0;
+  }
+
   GNUNET_CRYPTO_setup_hostkey ("test_gns_proxy.conf");
   
   if (0 != curl_global_init (CURL_GLOBAL_WIN32))