gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r21853 - in gnunet/src: include testing


From: gnunet
Subject: [GNUnet-SVN] r21853 - in gnunet/src: include testing
Date: Sun, 10 Jun 2012 13:38:46 +0200

Author: grothoff
Date: 2012-06-10 13:38:46 +0200 (Sun, 10 Jun 2012)
New Revision: 21853

Modified:
   gnunet/src/include/gnunet_testing_lib-new.h
   gnunet/src/testing/testing.c
Log:
-adding helper function to determine plugin names to testing

Modified: gnunet/src/include/gnunet_testing_lib-new.h
===================================================================
--- gnunet/src/include/gnunet_testing_lib-new.h 2012-06-10 11:18:59 UTC (rev 
21852)
+++ gnunet/src/include/gnunet_testing_lib-new.h 2012-06-10 11:38:46 UTC (rev 
21853)
@@ -73,7 +73,6 @@
                              const char *controller);
 
 
-
 /**
  * Free system resources.
  *
@@ -225,6 +224,7 @@
  * should self-terminate by invoking 'GNUNET_SCHEDULER_shutdown'.
  *
  * @param tmppath path for storing temporary data for the test
+ *        also used to setup the program name for logging
  * @param cfgfilename name of the configuration file to use;
  *         use NULL to only run with defaults
  * @param tm main function of the testcase
@@ -238,7 +238,6 @@
                         void *tm_cls);
 
 
-
 /**
  * Start a single service (no ARM, except of course if the given
  * service name is 'arm') and run a test using the testing library.
@@ -251,6 +250,7 @@
  * and if that service doesn't itself depend on other services.
  *
  * @param tmppath path for storing temporary data for the test
+ *        also used to setup the program name for logging
  * @param service_name name of the service to run
  * @param cfgfilename name of the configuration file to use;
  *         use NULL to only run with defaults
@@ -267,6 +267,23 @@
 
 
 
+/**
+ * Sometimes we use the binary name to determine which specific
+ * test to run.  In those cases, the string after the last "_"
+ * in 'argv[0]' specifies a string that determines the configuration
+ * file or plugin to use.  
+ *
+ * This function returns the respective substring, taking care
+ * of issues such as binaries ending in '.exe' on W32.
+ *
+ * @param argv0 the name of the binary
+ * @return string between the last '_' and the '.exe' (or the end of the 
string),
+ *         NULL if argv0 has no '_' 
+ */
+char *
+GNUNET_TESTING_get_testname_from_underscore (const char *argv0);
+
+
 #if 0                           /* keep Emacsens' auto-indent happy */
 {
 #endif

Modified: gnunet/src/testing/testing.c
===================================================================
--- gnunet/src/testing/testing.c        2012-06-10 11:18:59 UTC (rev 21852)
+++ gnunet/src/testing/testing.c        2012-06-10 11:38:46 UTC (rev 21853)
@@ -877,6 +877,7 @@
  * should self-terminate by invoking 'GNUNET_SCHEDULER_shutdown'.
  *
  * @param tmppath path for storing temporary data for the test
+ *        also used to setup the program name for logging
  * @param cfgfilename name of the configuration file to use;
  *         use NULL to only run with defaults
  * @param tm main function of the testcase
@@ -943,7 +944,8 @@
  * This function is useful if the testcase is for a single service
  * and if that service doesn't itself depend on other services.
  *
- * @param tmppath path for storing temporary data for the test
+ * @param tmppath path for storing temporary data for the test,
+ *        also used to setup the program name for logging
  * @param service_name name of the service to run
  * @param cfgfilename name of the configuration file to use;
  *         use NULL to only run with defaults
@@ -963,6 +965,9 @@
   struct GNUNET_TESTING_Peer *peer;
   struct GNUNET_CONFIGURATION_Handle *cfg;
 
+  GNUNET_log_setup (tmppath,
+                    "WARNING",
+                    NULL);
   system = GNUNET_TESTING_system_create (tmppath, "127.0.0.1");
   if (NULL == system)
     return 1;
@@ -1010,4 +1015,37 @@
 }
 
 
+/**
+ * Sometimes we use the binary name to determine which specific
+ * test to run.  In those cases, the string after the last "_"
+ * in 'argv[0]' specifies a string that determines the configuration
+ * file or plugin to use.  
+ *
+ * This function returns the respective substring, taking care
+ * of issues such as binaries ending in '.exe' on W32.
+ *
+ * @param argv0 the name of the binary
+ * @return string between the last '_' and the '.exe' (or the end of the 
string),
+ *         NULL if argv0 has no '_' 
+ */
+char *
+GNUNET_TESTING_get_testname_from_underscore (const char *argv0)
+{
+  size_t slen = strlen (argv0) + 1;
+  char sbuf[slen];
+  char *ret;
+  char *dot;
+
+  memcpy (sbuf, argv0, slen);
+  ret = strrchr (sbuf, '_');
+  if (NULL == ret)
+    return NULL;
+  ret++; /* skip underscore */
+  dot = strchr (ret, '.');
+  if (NULL != dot)
+    *dot = '\0';
+  return GNUNET_strdup (ret);
+}
+
+
 /* end of testing.c */




reply via email to

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