gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r15663 - gnunet/src/transport


From: gnunet
Subject: [GNUnet-SVN] r15663 - gnunet/src/transport
Date: Thu, 16 Jun 2011 14:35:26 +0200

Author: wachs
Date: 2011-06-16 14:35:26 +0200 (Thu, 16 Jun 2011)
New Revision: 15663

Added:
   gnunet/src/transport/transport-testing.h
Modified:
   gnunet/src/transport/test_transport_api.c
   gnunet/src/transport/test_transport_api_reliability.c
   gnunet/src/transport/test_transport_api_unreliability.c
Log:
clean up in transport tests


Modified: gnunet/src/transport/test_transport_api.c
===================================================================
--- gnunet/src/transport/test_transport_api.c   2011-06-16 12:32:58 UTC (rev 
15662)
+++ gnunet/src/transport/test_transport_api.c   2011-06-16 12:35:26 UTC (rev 
15663)
@@ -35,6 +35,7 @@
 #include "gnunet_scheduler_lib.h"
 #include "gnunet_transport_service.h"
 #include "transport.h"
+#include "transport-testing.h"
 
 #define VERBOSE GNUNET_NO
 
@@ -54,16 +55,6 @@
 
 #define MTYPE 12345
 
-struct PeerContext
-{
-  struct GNUNET_CONFIGURATION_Handle *cfg;
-  struct GNUNET_TRANSPORT_Handle *th;
-  struct GNUNET_PeerIdentity id;
-#if START_ARM
-  struct GNUNET_OS_Process *arm_proc;
-#endif
-};
-
 static struct PeerContext p1;
 
 static struct PeerContext p2;
@@ -276,6 +267,12 @@
            const char *cfgname)
 {
   p->cfg = GNUNET_CONFIGURATION_create ();
+
+  GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
+  if (GNUNET_CONFIGURATION_have_value (p->cfg,"PATHS", "SERVICEHOME"))
+      GNUNET_CONFIGURATION_get_value_string (p->cfg, "PATHS", "SERVICEHOME", 
&p->servicehome);
+  GNUNET_DISK_directory_remove (p->servicehome);
+
 #if START_ARM
   p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
                                         "gnunet-service-arm",
@@ -284,8 +281,11 @@
 #endif
                                         "-c", cfgname, NULL);
 #endif
-  GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
 
+
+  if (GNUNET_CONFIGURATION_have_value (p->cfg,"PATHS", "SERVICEHOME"))
+      GNUNET_CONFIGURATION_get_value_string (p->cfg, "PATHS", "SERVICEHOME", 
&p->servicehome);
+
   if (is_https)
     {
       struct stat sbuf;
@@ -514,6 +514,14 @@
       GNUNET_free(cert_file_p1);
       GNUNET_free(cert_file_p2);
     }
+
+  if ((p1.servicehome != NULL) && (p2.servicehome != NULL))
+  {
+    GNUNET_DISK_directory_remove (p1.servicehome);
+    GNUNET_DISK_directory_remove (p2.servicehome);
+    GNUNET_free(p1.servicehome);
+    GNUNET_free(p2.servicehome);
+  }
   return ok;
 }
 
@@ -668,7 +676,8 @@
                       "`%s' not properly installed, cannot run NAT test!\n",
                      "gnunet-nat-server");
           return 0;
-        }
+        }      GNUNET_free(p1.servicehome);
+        GNUNET_free(p2.servicehome);
     }
   else if (strstr(argv[0], "udp") != NULL)
     {
@@ -696,16 +705,6 @@
     }
 
   ret = check ();
-  if (is_multi_protocol)
-  {
-         GNUNET_DISK_directory_remove 
("/tmp/test-gnunetd-transport-multi-peer-1/");
-         GNUNET_DISK_directory_remove 
("/tmp/test-gnunetd-transport-multi-peer-2/");
-  }
-  else
-  {
-         GNUNET_DISK_directory_remove ("/tmp/test-gnunetd-transport-peer-1");
-         GNUNET_DISK_directory_remove ("/tmp/test-gnunetd-transport-peer-2");
-  }
 
   return ret;
 }

Modified: gnunet/src/transport/test_transport_api_reliability.c
===================================================================
--- gnunet/src/transport/test_transport_api_reliability.c       2011-06-16 
12:32:58 UTC (rev 15662)
+++ gnunet/src/transport/test_transport_api_reliability.c       2011-06-16 
12:35:26 UTC (rev 15663)
@@ -36,6 +36,7 @@
 #include "gnunet_transport_service.h"
 #include "gauger.h"
 #include "transport.h"
+#include "transport-testing.h"
 
 #define VERBOSE GNUNET_NO
 
@@ -57,16 +58,6 @@
 
 #define MTYPE 12345
 
-struct PeerContext
-{
-  struct GNUNET_CONFIGURATION_Handle *cfg;
-  struct GNUNET_TRANSPORT_Handle *th;
-  struct GNUNET_PeerIdentity id;
-#if START_ARM
-  struct GNUNET_OS_Process *arm_proc;
-#endif
-};
-
 static struct PeerContext p1;
 
 static struct PeerContext p2;
@@ -438,6 +429,11 @@
 setup_peer (struct PeerContext *p, const char *cfgname)
 {
   p->cfg = GNUNET_CONFIGURATION_create ();
+  GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
+  if (GNUNET_CONFIGURATION_have_value (p->cfg,"PATHS", "SERVICEHOME"))
+      GNUNET_CONFIGURATION_get_value_string (p->cfg, "PATHS", "SERVICEHOME", 
&p->servicehome);
+  GNUNET_DISK_directory_remove (p->servicehome);
+
 #if START_ARM
   p->arm_proc = GNUNET_OS_start_process (NULL, NULL,
                                        "gnunet-service-arm",
@@ -447,7 +443,6 @@
 #endif
                                         "-c", cfgname, NULL);
 #endif
-  GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
 
   if (is_https)
     {
@@ -462,11 +457,11 @@
          if (0 == stat (key_file_p1, &sbuf ))
            {
              if (0 == remove(key_file_p1))
-               GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+               GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                            "Successfully removed existing private key file 
`%s'\n",
                            key_file_p1);
              else
-               GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+               GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                            "Failed to remove private key file `%s'\n",
                            key_file_p1);
            }
@@ -477,11 +472,11 @@
          if (0 == stat (cert_file_p1, &sbuf ))
            {
              if (0 == remove(cert_file_p1))
-               GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 
+               GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                            "Successfully removed existing certificate file 
`%s'\n",
                            cert_file_p1);
              else
-               GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 
+               GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                            "Failed to remove existing certificate file `%s'\n",
                            cert_file_p1);
            }
@@ -496,11 +491,11 @@
          if (0 == stat (key_file_p2, &sbuf ))
            {
              if (0 == remove(key_file_p2))
-               GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+               GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                            "Successfully removed existing private key file 
`%s'\n",
                            key_file_p2);
              else
-               GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+               GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                            "Failed to remove private key file `%s'\n",
                            key_file_p2);
            }
@@ -511,11 +506,11 @@
          if (0 == stat (cert_file_p2, &sbuf ))
            {
              if (0 == remove(cert_file_p2))
-               GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+               GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                            "Successfully removed existing certificate file 
`%s'\n",
                            cert_file_p2);
              else
-               GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+               GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                            "Failed to remove existing certificate file `%s'\n",
                            cert_file_p2);
            }
@@ -798,6 +793,8 @@
     GNUNET_free(key_file_p2);
     GNUNET_free(cert_file_p1);
     GNUNET_free(cert_file_p2);
+    GNUNET_free(p1.servicehome);
+    GNUNET_free(p2.servicehome);
   }
 
   return ok;
@@ -812,9 +809,6 @@
   return GNUNET_SYSERR;
 #endif
 
-  GNUNET_DISK_directory_remove ("/tmp/test-gnunetd-transport-peer-1");
-  GNUNET_DISK_directory_remove ("/tmp/test-gnunetd-transport-peer-2");
-
   if (strstr(argv[0], "tcp_nat") != NULL)
     {
       is_tcp_nat = GNUNET_YES;
@@ -857,8 +851,8 @@
 #endif
                     NULL);
   ret = check ();
-  GNUNET_DISK_directory_remove ("/tmp/test-gnunetd-transport-peer-1");
-  GNUNET_DISK_directory_remove ("/tmp/test-gnunetd-transport-peer-2");
+  GNUNET_DISK_directory_remove (p1.servicehome);
+  GNUNET_DISK_directory_remove (p2.servicehome);
   return ret;
 }
 

Modified: gnunet/src/transport/test_transport_api_unreliability.c
===================================================================
--- gnunet/src/transport/test_transport_api_unreliability.c     2011-06-16 
12:32:58 UTC (rev 15662)
+++ gnunet/src/transport/test_transport_api_unreliability.c     2011-06-16 
12:35:26 UTC (rev 15663)
@@ -37,6 +37,7 @@
 #include "gnunet_transport_service.h"
 #include "gauger.h"
 #include "transport.h"
+#include "transport-testing.h"
 
 #define VERBOSE GNUNET_NO
 
@@ -60,16 +61,6 @@
 
 #define MTYPE 12345
 
-struct PeerContext
-{
-  struct GNUNET_CONFIGURATION_Handle *cfg;
-  struct GNUNET_TRANSPORT_Handle *th;
-  struct GNUNET_PeerIdentity id;
-#if START_ARM
-  struct GNUNET_OS_Process *arm_proc;
-#endif
-};
-
 static struct PeerContext p1;
 
 static struct PeerContext p2;
@@ -533,6 +524,13 @@
 setup_peer (struct PeerContext *p, const char *cfgname)
 {
   p->cfg = GNUNET_CONFIGURATION_create ();
+
+  GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
+  if (GNUNET_CONFIGURATION_have_value (p->cfg,"PATHS", "SERVICEHOME"))
+      GNUNET_CONFIGURATION_get_value_string (p->cfg, "PATHS", "SERVICEHOME", 
&p->servicehome);
+  GNUNET_DISK_directory_remove (p->servicehome);
+
+
 #if START_ARM
   p->arm_proc = GNUNET_OS_start_process (NULL, NULL,
                                        "gnunet-service-arm",
@@ -542,65 +540,7 @@
 #endif
                                         "-c", cfgname, NULL);
 #endif
-  GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
 
-  if (is_https)
-  {
-         struct stat sbuf;
-         if (p==&p1)
-         {
-                 if (GNUNET_CONFIGURATION_have_value (p->cfg,
-                                                                               
           "transport-https", "KEY_FILE"))
-                               GNUNET_CONFIGURATION_get_value_string (p->cfg, 
"transport-https", "KEY_FILE", &key_file_p1);
-                 if (key_file_p1 == NULL)
-                         GNUNET_asprintf(&key_file_p1,"https_p1.key");
-                 if (0 == stat (key_file_p1, &sbuf ))
-                 {
-                         if (0 == remove(key_file_p1))
-                             GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 
"Successfully removed existing private key file `%s'\n",key_file_p1);
-                         else
-                                 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed 
to remove private key file `%s'\n",key_file_p1);
-                 }
-                 if (GNUNET_CONFIGURATION_have_value 
(p->cfg,"transport-https", "CERT_FILE"))
-                         GNUNET_CONFIGURATION_get_value_string (p->cfg, 
"transport-https", "CERT_FILE", &cert_file_p1);
-                 if (cert_file_p1 == NULL)
-                         GNUNET_asprintf(&cert_file_p1,"https_p1.cert");
-                 if (0 == stat (cert_file_p1, &sbuf ))
-                 {
-                         if (0 == remove(cert_file_p1))
-                             GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 
"Successfully removed existing certificate file `%s'\n",cert_file_p1);
-                         else
-                                 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed 
to remove existing certificate file `%s'\n",cert_file_p1);
-                 }
-         }
-         else if (p==&p2)
-         {
-                 if (GNUNET_CONFIGURATION_have_value (p->cfg,
-                                                                               
           "transport-https", "KEY_FILE"))
-                               GNUNET_CONFIGURATION_get_value_string (p->cfg, 
"transport-https", "KEY_FILE", &key_file_p2);
-                 if (key_file_p2 == NULL)
-                         GNUNET_asprintf(&key_file_p2,"https_p2.key");
-                 if (0 == stat (key_file_p2, &sbuf ))
-                 {
-                         if (0 == remove(key_file_p2))
-                             GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 
"Successfully removed existing private key file `%s'\n",key_file_p2);
-                         else
-                                 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed 
to remove private key file `%s'\n",key_file_p2);
-                 }
-                 if (GNUNET_CONFIGURATION_have_value 
(p->cfg,"transport-https", "CERT_FILE"))
-                         GNUNET_CONFIGURATION_get_value_string (p->cfg, 
"transport-https", "CERT_FILE", &cert_file_p2);
-                 if (cert_file_p2 == NULL)
-                         GNUNET_asprintf(&cert_file_p2,"https_p2.cert");
-                 if (0 == stat (cert_file_p2, &sbuf ))
-                 {
-                         if (0 == remove(cert_file_p2))
-                             GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 
"Successfully removed existing certificate file `%s'\n",cert_file_p2);
-                         else
-                                 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed 
to remove existing certificate file `%s'\n",cert_file_p2);
-                 }
-         }
-  }
-
   p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL,
                                     p,
                                     &notify_receive,
@@ -864,7 +804,16 @@
     GNUNET_free(cert_file_p2);
   }
 
+  if ((p1.servicehome != NULL) && (p2.servicehome != NULL))
+  {
+    GNUNET_DISK_directory_remove (p1.servicehome);
+    GNUNET_DISK_directory_remove (p2.servicehome);
+    GNUNET_free(p1.servicehome);
+    GNUNET_free(p2.servicehome);
+  }
   return ok;
+
+  return ok;
 }
 
 
@@ -921,8 +870,7 @@
 #endif
                     NULL);
   ret = check ();
-  GNUNET_DISK_directory_remove ("/tmp/test-gnunetd-transport-peer-1");
-  GNUNET_DISK_directory_remove ("/tmp/test-gnunetd-transport-peer-2");
+
   GNUNET_free_non_null(test_name);
   return ret;
 }

Added: gnunet/src/transport/transport-testing.h
===================================================================
--- gnunet/src/transport/transport-testing.h                            (rev 0)
+++ gnunet/src/transport/transport-testing.h    2011-06-16 12:35:26 UTC (rev 
15663)
@@ -0,0 +1,37 @@
+/*
+     This file is part of GNUnet.
+     (C) 2006, 2009 Christian Grothoff (and other contributing authors)
+
+     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
+     option) any later version.
+
+     GNUnet is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     General Public License for more details.
+
+     You should have received a copy of the GNU General Public License
+     along with GNUnet; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+     Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file transport_testing.h
+ * @brief testing lib for transport service
+ *
+ * @author Matthias Wachs
+ */
+
+struct PeerContext
+{
+  struct GNUNET_CONFIGURATION_Handle *cfg;
+  struct GNUNET_TRANSPORT_Handle *th;
+  struct GNUNET_PeerIdentity id;
+  struct GNUNET_OS_Process *arm_proc;
+  char * servicehome;
+};
+
+/* end of transport_testing.h */




reply via email to

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