gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r16657 - gnunet/src/transport
Date: Wed, 31 Aug 2011 15:48:59 +0200

Author: wachs
Date: 2011-08-31 15:48:59 +0200 (Wed, 31 Aug 2011)
New Revision: 16657

Modified:
   gnunet/src/transport/test_transport_api.c
   gnunet/src/transport/test_transport_api_multiaddress.c
   gnunet/src/transport/test_transport_api_reliability.c
   gnunet/src/transport/test_transport_api_unreliability.c
   gnunet/src/transport/transport-testing.c
   gnunet/src/transport/transport-testing.h
Log:
moving code to generate cfg name used in every test to testing lib


Modified: gnunet/src/transport/test_transport_api.c
===================================================================
--- gnunet/src/transport/test_transport_api.c   2011-08-31 12:52:37 UTC (rev 
16656)
+++ gnunet/src/transport/test_transport_api.c   2011-08-31 13:48:59 UTC (rev 
16657)
@@ -233,6 +233,7 @@
                                                NULL);
 }
 
+
 static int
 check ()
 {
@@ -273,30 +274,8 @@
 #endif
                     NULL);
 
-  char *pch = strdup (argv[0]);
-  char *backup = pch;
-  char *filename = NULL;
-  char *dotexe;
   int nat_res;
 
-  /* get executable filename */
-  pch = strtok (pch, "/");
-  while (pch != NULL)
-  {
-    pch = strtok (NULL, "/");
-    if (pch != NULL)
-      filename = pch;
-  }
-  /* remove "lt-" */
-  filename = strstr (filename, "tes");
-  if (NULL != (dotexe = strstr (filename, ".exe")))
-    dotexe[0] = '\0';
-
-  /* create cfg filename */
-  GNUNET_asprintf (&cfg_file_p1, "%s_peer1.conf", filename);
-  GNUNET_asprintf (&cfg_file_p2, "%s_peer2.conf", filename);
-  GNUNET_free (backup);
-
   if ((strstr (argv[0], "tcp_nat") != NULL) ||
       (strstr (argv[0], "udp_nat") != NULL))
   {
@@ -315,6 +294,10 @@
     }
 
   }
+
+  GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1);
+  GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p2, 2);
+
   ret = check ();
 
   GNUNET_free (cfg_file_p1);

Modified: gnunet/src/transport/test_transport_api_multiaddress.c
===================================================================
--- gnunet/src/transport/test_transport_api_multiaddress.c      2011-08-31 
12:52:37 UTC (rev 16656)
+++ gnunet/src/transport/test_transport_api_multiaddress.c      2011-08-31 
13:48:59 UTC (rev 16657)
@@ -289,30 +289,8 @@
 #endif
                     NULL);
 
-  char *pch = strdup (argv[0]);
-  char *backup = pch;
-  char *filename = NULL;
-  char *dotexe;
   int nat_res;
 
-  /* get executable filename */
-  pch = strtok (pch, "/");
-  while (pch != NULL)
-  {
-    pch = strtok (NULL, "/");
-    if (pch != NULL)
-      filename = pch;
-  }
-  /* remove "lt-" */
-  filename = strstr (filename, "tes");
-  if (NULL != (dotexe = strstr (filename, ".exe")))
-    dotexe[0] = '\0';
-
-  /* create cfg filename */
-  GNUNET_asprintf (&cfg_file_p1, "%s_peer1.conf", filename);
-  GNUNET_asprintf (&cfg_file_p2, "%s_peer2.conf", filename);
-  GNUNET_free (backup);
-
   if ((strstr (argv[0], "tcp_nat") != NULL) ||
       (strstr (argv[0], "udp_nat") != NULL))
   {
@@ -331,6 +309,10 @@
     }
 
   }
+
+  GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1);
+  GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p2, 2);
+
   ret = check ();
 
   GNUNET_free (cfg_file_p1);

Modified: gnunet/src/transport/test_transport_api_reliability.c
===================================================================
--- gnunet/src/transport/test_transport_api_reliability.c       2011-08-31 
12:52:37 UTC (rev 16656)
+++ gnunet/src/transport/test_transport_api_reliability.c       2011-08-31 
13:48:59 UTC (rev 16657)
@@ -436,10 +436,6 @@
   if (NULL != (dotexe = strstr (filename, ".exe")))
     dotexe[0] = '\0';
 
-  /* create cfg filename */
-  GNUNET_asprintf (&cfg_file_p1, "%s_peer1.conf", filename);
-  GNUNET_asprintf (&cfg_file_p2, "%s_peer2.conf", filename);
-
   split = strstr (src_name, ".");
   if (split != NULL)
   {
@@ -469,10 +465,15 @@
       return 0;
     }
   }
+
+  GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1);
+  GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p2, 2);
+
   ret = check ();
 
   GNUNET_free (cfg_file_p1);
   GNUNET_free (cfg_file_p2);
+
   GNUNET_free_non_null (test_name);
 
   return ret;

Modified: gnunet/src/transport/test_transport_api_unreliability.c
===================================================================
--- gnunet/src/transport/test_transport_api_unreliability.c     2011-08-31 
12:52:37 UTC (rev 16656)
+++ gnunet/src/transport/test_transport_api_unreliability.c     2011-08-31 
13:48:59 UTC (rev 16657)
@@ -499,10 +499,6 @@
   if (NULL != (dotexe = strstr (filename, ".exe")))
     dotexe[0] = '\0';
 
-  /* create cfg filename */
-  GNUNET_asprintf (&cfg_file_p1, "%s_peer1.conf", filename);
-  GNUNET_asprintf (&cfg_file_p2, "%s_peer2.conf", filename);
-
   split = strstr (src_name, ".");
   if (split != NULL)
   {
@@ -532,10 +528,15 @@
       return 0;
     }
   }
+
+  GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1);
+  GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p2, 2);
+
   ret = check ();
 
   GNUNET_free (cfg_file_p1);
   GNUNET_free (cfg_file_p2);
+
   GNUNET_free_non_null (test_name);
 
   return ret;

Modified: gnunet/src/transport/transport-testing.c
===================================================================
--- gnunet/src/transport/transport-testing.c    2011-08-31 12:52:37 UTC (rev 
16656)
+++ gnunet/src/transport/transport-testing.c    2011-08-31 13:48:59 UTC (rev 
16657)
@@ -341,5 +341,45 @@
   GNUNET_free (cc);
 }
 
+/*
+ * Some utility functions
+ */
 
+/**
+ * this function takes the filename (e.g. argv[0), removes a "lt-"-prefix and
+ * if existing ".exe"-prefix and adds the peer-number
+ * @param file filename of the test, e.g. argv[0]
+ * @param cfgname where to write the result
+ * @param count peer number
+ */
+void
+GNUNET_TRANSPORT_TESTING_get_config_name (const char *file, char **cfgname,
+                                          int count)
+{
+  char *pch = strdup (file);
+  char *backup = pch;
+  char *filename = NULL;
+  char *dotexe;
+
+
+  /* get executable filename */
+  pch = strtok (pch, "/");
+  while (pch != NULL)
+  {
+    pch = strtok (NULL, "/");
+    if (pch != NULL)
+      filename = pch;
+  }
+  /* remove "lt-" */
+  filename = strstr (filename, "tes");
+  if (NULL != (dotexe = strstr (filename, ".exe")))
+    dotexe[0] = '\0';
+
+  /* create cfg filename */
+  GNUNET_asprintf (cfgname, "%s_peer%u.conf", filename, count);
+
+  GNUNET_free (backup);
+}
+
+
 /* end of transport_testing.h */

Modified: gnunet/src/transport/transport-testing.h
===================================================================
--- gnunet/src/transport/transport-testing.h    2011-08-31 12:52:37 UTC (rev 
16656)
+++ gnunet/src/transport/transport-testing.h    2011-08-31 13:48:59 UTC (rev 
16657)
@@ -118,4 +118,19 @@
 void
 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (void *cc);
 
+/*
+ * Some utility functions
+ */
+
+/**
+ * this function takes the filename (e.g. argv[0), removes a "lt-"-prefix and
+ * if existing ".exe"-prefix and adds the peer-number
+ * @param file filename of the test, e.g. argv[0]
+ * @param cfgname where to write the result
+ * @param count peer number
+ */
+void
+GNUNET_TRANSPORT_TESTING_get_config_name (const char *file, char **cfgname,
+                                          int count);
+
 /* end of transport_testing.h */




reply via email to

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