only run malicious tests if malicious features are enabled
[oweals/gnunet.git] / src / arm / test_gnunet_service_arm.c
index 700e7ca19412f2e6d7e6dc55a89ea4d66dbc075c..55903c4990661d8797e942cf798076e59b190bda 100644 (file)
@@ -47,6 +47,8 @@ static int asked_for_a_list;
 
 static struct GNUNET_ARM_Handle *arm;
 
+static const char hostname[] = "www.gnu.org"; /* any domain should do */
+
 
 static void
 trigger_disconnect (void *cls)
@@ -114,7 +116,7 @@ hostname_resolve_cb (void *cls,
   if (NULL == addr)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                "Failed to resolve our own hostname!\n");
+                "Failed to resolve hostname!\n");
     GNUNET_break (0);
     ret = 3;
     GNUNET_ARM_request_service_stop (arm,
@@ -144,13 +146,14 @@ arm_start_cb (void *cls,
   GNUNET_break (status == GNUNET_ARM_REQUEST_SENT_OK);
   GNUNET_break (result == GNUNET_ARM_RESULT_STARTING);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Trying to resolve our own hostname!\n");
+              "Trying to resolve a hostname via the resolver service!\n");
   /* connect to the resolver service */
   if (NULL ==
-      GNUNET_RESOLVER_hostname_resolve (AF_UNSPEC,
-                                        TIMEOUT,
-                                        &hostname_resolve_cb,
-                                        NULL))
+      GNUNET_RESOLVER_ip_get (hostname,
+                             AF_UNSPEC,
+                             TIMEOUT,
+                             &hostname_resolve_cb,
+                             NULL))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                 "Unable initiate connection to resolver service\n");
@@ -193,30 +196,7 @@ main (int argc, char *av[])
   static struct GNUNET_GETOPT_CommandLineOption options[] = {
     GNUNET_GETOPT_OPTION_END
   };
-  char hostname[GNUNET_OS_get_hostname_max_length () + 1];
 
-  if (0 != gethostname (hostname, sizeof (hostname) - 1))
-  {
-    GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
-                         "gethostname");
-    FPRINTF (stderr,
-             "%s",
-             "Failed to determine my own hostname, testcase not run.\n");
-    return 77;
-  }
-  if ( (0 == strcmp (hostname,
-                    "localhost")) ||
-       (0 == strcmp (hostname,
-                    "ipv6-localnet")) )
-  {
-    /* we cannot use 'localhost' as this would not trigger the
-       resolver service (see resolver_api.c); so in this case,
-       we fall back to (ab)using gnu.org. */
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-               "Falling back to `www.gnu.org'\n");
-    strcpy (hostname,
-           "www.gnu.org");
-  }
   /* trigger DNS lookup */
 #if HAVE_GETADDRINFO
   {
@@ -226,7 +206,7 @@ main (int argc, char *av[])
     if (0 != (ret = getaddrinfo (hostname, NULL, NULL, &ai)))
     {
       FPRINTF (stderr,
-               "Failed to resolve my hostname `%s', testcase not run.\n",
+               "Failed to resolve `%s', testcase not run.\n",
                hostname);
       return 77;
     }
@@ -242,7 +222,7 @@ main (int argc, char *av[])
     if (NULL == host)
       {
         FPRINTF (stderr,
-                 "Failed to resolve my hostname `%s', testcase not run.\n",
+                 "Failed to resolve `%s', testcase not run.\n",
                  hostname);
         return 77;
       }
@@ -255,7 +235,7 @@ main (int argc, char *av[])
     if (NULL == host)
       {
         FPRINTF (stderr,
-                 "Failed to resolve my hostname `%s', testcase not run.\n",
+                 "Failed to resolve `%s', testcase not run.\n",
                  hostname);
         return 77;
       }