gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r21852 - gnunet/src/datastore


From: gnunet
Subject: [GNUnet-SVN] r21852 - gnunet/src/datastore
Date: Sun, 10 Jun 2012 13:18:59 +0200

Author: grothoff
Date: 2012-06-10 13:18:59 +0200 (Sun, 10 Jun 2012)
New Revision: 21852

Modified:
   gnunet/src/datastore/Makefile.am
   gnunet/src/datastore/perf_datastore_api.c
   gnunet/src/datastore/perf_plugin_datastore.c
   gnunet/src/datastore/test_datastore_api.c
   gnunet/src/datastore/test_datastore_api_data_sqlite.conf
   gnunet/src/datastore/test_datastore_api_management.c
   gnunet/src/datastore/test_defaults.conf
   gnunet/src/datastore/test_plugin_datastore.c
Log:
-using testing in datastore tests

Modified: gnunet/src/datastore/Makefile.am
===================================================================
--- gnunet/src/datastore/Makefile.am    2012-06-10 10:51:12 UTC (rev 21851)
+++ gnunet/src/datastore/Makefile.am    2012-06-10 11:18:59 UTC (rev 21852)
@@ -141,18 +141,21 @@
 test_datastore_api_sqlite_SOURCES = \
  test_datastore_api.c
 test_datastore_api_sqlite_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
  $(top_builddir)/src/datastore/libgnunetdatastore.la \
  $(top_builddir)/src/util/libgnunetutil.la  
 
 test_datastore_api_management_sqlite_SOURCES = \
  test_datastore_api_management.c
 test_datastore_api_management_sqlite_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
  $(top_builddir)/src/datastore/libgnunetdatastore.la \
  $(top_builddir)/src/util/libgnunetutil.la  
 
 perf_datastore_api_sqlite_SOURCES = \
  perf_datastore_api.c
 perf_datastore_api_sqlite_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
  $(top_builddir)/src/datastore/libgnunetdatastore.la \
  $(top_builddir)/src/util/libgnunetutil.la  
 
@@ -170,18 +173,21 @@
 test_datastore_api_mysql_SOURCES = \
  test_datastore_api.c
 test_datastore_api_mysql_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
  $(top_builddir)/src/datastore/libgnunetdatastore.la \
  $(top_builddir)/src/util/libgnunetutil.la  
 
 test_datastore_api_management_mysql_SOURCES = \
  test_datastore_api_management.c
 test_datastore_api_management_mysql_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
  $(top_builddir)/src/datastore/libgnunetdatastore.la \
  $(top_builddir)/src/util/libgnunetutil.la  
 
 perf_datastore_api_mysql_SOURCES = \
  perf_datastore_api.c
 perf_datastore_api_mysql_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
  $(top_builddir)/src/datastore/libgnunetdatastore.la \
  $(top_builddir)/src/util/libgnunetutil.la  
 
@@ -199,18 +205,21 @@
 test_datastore_api_postgres_SOURCES = \
  test_datastore_api.c
 test_datastore_api_postgres_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
  $(top_builddir)/src/datastore/libgnunetdatastore.la \
  $(top_builddir)/src/util/libgnunetutil.la  
 
 test_datastore_api_management_postgres_SOURCES = \
  test_datastore_api_management.c
 test_datastore_api_management_postgres_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
  $(top_builddir)/src/datastore/libgnunetdatastore.la \
  $(top_builddir)/src/util/libgnunetutil.la  
 
 perf_datastore_api_postgres_SOURCES = \
  perf_datastore_api.c
 perf_datastore_api_postgres_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
  $(top_builddir)/src/datastore/libgnunetdatastore.la \
  $(top_builddir)/src/util/libgnunetutil.la  
 

Modified: gnunet/src/datastore/perf_datastore_api.c
===================================================================
--- gnunet/src/datastore/perf_datastore_api.c   2012-06-10 10:51:12 UTC (rev 
21851)
+++ gnunet/src/datastore/perf_datastore_api.c   2012-06-10 11:18:59 UTC (rev 
21852)
@@ -36,19 +36,14 @@
 #include "gnunet_util_lib.h"
 #include "gnunet_protocols.h"
 #include "gnunet_datastore_service.h"
+#include "gnunet_testing_lib-new.h"
 #include <gauger.h>
 
-#define VERBOSE GNUNET_NO
-
 /**
  * How long until we give up on transmitting the message?
  */
 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15)
 
-static const char *plugin_name;
-
-static struct GNUNET_DATASTORE_Handle *datastore;
-
 /**
  * Target datastore size (in bytes).
  */
@@ -81,8 +76,13 @@
 
 static struct GNUNET_TIME_Absolute start_time;
 
+static const char *plugin_name;
+
+static struct GNUNET_DATASTORE_Handle *datastore;
+
 static int ok;
 
+
 enum RunPhase
 {
   RP_DONE = 0,
@@ -103,13 +103,10 @@
 };
 
 
-
 static void
 run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
 
 
-
-
 static void
 check_success (void *cls, int success, struct GNUNET_TIME_Absolute 
min_expiration,  const char *msg)
 {
@@ -297,7 +294,7 @@
 
 
 static void
-run (void *cls, char *const *args, const char *cfgfile,
+run (void *cls, 
      const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   struct CpsRunContext *crc;
@@ -322,85 +319,29 @@
 }
 
 
-static int
-check ()
-{
-  struct GNUNET_OS_Process *proc;
-  char cfg_name[128];
-
-  char *const argv[] = {
-    "perf-datastore-api",
-    "-c",
-    cfg_name,
-#if VERBOSE
-    "-L", "DEBUG",
-#endif
-    NULL
-  };
-  struct GNUNET_GETOPT_CommandLineOption options[] = {
-    GNUNET_GETOPT_OPTION_END
-  };
-
-  GNUNET_snprintf (cfg_name, sizeof (cfg_name),
-                   "test_datastore_api_data_%s.conf", plugin_name);
-  proc =
-      GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
-                               "gnunet-service-arm",
-#if VERBOSE
-                               "-L", "DEBUG",
-#endif
-                               "-c", cfg_name, NULL);
-  GNUNET_assert (NULL != proc);
-  GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv,
-                      "perf-datastore-api", "nohelp", options, &run, NULL);
-  sleep (1);                    /* give datastore chance to process 'DROP' */
-  if (0 != GNUNET_OS_process_kill (proc, SIGTERM))
-  {
-    GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
-    ok = 1;
-  }
-  GNUNET_OS_process_wait (proc);
-  GNUNET_OS_process_destroy (proc);
-  proc = NULL;
-  return ok;
-}
-
-
 int
 main (int argc, char *argv[])
 {
-  int ret;
   char *pos;
-  char dir_name[128];
+  char cfg_name[128];
 
-  sleep (1);
   /* determine name of plugin to use */
   plugin_name = argv[0];
   while (NULL != (pos = strstr (plugin_name, "_")))
     plugin_name = pos + 1;
   if (NULL != (pos = strstr (plugin_name, ".")))
-    pos[0] = 0;
+    pos[0] = '\0';
   else
     pos = (char *) plugin_name;
-
-  GNUNET_snprintf (dir_name, sizeof (dir_name), 
"/tmp/test-gnunet-datastore-%s",
-                   plugin_name);
-  GNUNET_DISK_directory_remove (dir_name);
-  GNUNET_log_setup ("perf-datastore-api",
-#if VERBOSE
-                    "DEBUG",
-#else
-                    "WARNING",
-#endif
-                    NULL);
-  ret = check ();
-  if (pos != plugin_name)
-    pos[0] = '.';
-#if REPORT_ID
-  FPRINTF (stderr, "%s",  "\n");
-#endif
-  GNUNET_DISK_directory_remove (dir_name);
-  return ret;
+  GNUNET_snprintf (cfg_name, sizeof (cfg_name),
+                   "test_datastore_api_data_%s.conf", plugin_name);
+  if (0 !=
+      GNUNET_TESTING_peer_run ("perf-gnunet-datastore",
+                              cfg_name,
+                              &run,
+                              NULL))
+    return 1;
+  return ok;
 }
 
 /* end of perf_datastore_api.c */

Modified: gnunet/src/datastore/perf_plugin_datastore.c
===================================================================
--- gnunet/src/datastore/perf_plugin_datastore.c        2012-06-10 10:51:12 UTC 
(rev 21851)
+++ gnunet/src/datastore/perf_plugin_datastore.c        2012-06-10 11:18:59 UTC 
(rev 21852)
@@ -29,8 +29,6 @@
 #include "gnunet_datastore_plugin.h"
 #include <gauger.h>
 
-#define VERBOSE GNUNET_NO
-
 /**
  * Target datastore size (in bytes).  Realistic sizes are
  * more like 16 GB (not the default of 16 MB); however,
@@ -164,10 +162,9 @@
   memcpy (&i, &cdata[4], sizeof (i));
   hits[i / 8] |= (1 << (i % 8));
 
-#if VERBOSE
-  FPRINTF (stderr, "Found result type=%u, priority=%u, size=%u, expire=%llu\n",
-           type, priority, size, (unsigned long long) expiration.abs_value);
-#endif
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
+             "Found result type=%u, priority=%u, size=%u, expire=%llu\n",
+             type, priority, size, (unsigned long long) expiration.abs_value);
   crc->cnt++;
   if (crc->cnt == PUT_10 / 4 - 1)
   {
@@ -343,9 +340,8 @@
     GNUNET_break (0);
     crc->phase = RP_ERROR;
   }
-#if VERBOSE
-  FPRINTF (stderr, "In phase %d, iteration %u\n", crc->phase, crc->cnt);
-#endif
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
+             "In phase %d, iteration %u\n", crc->phase, crc->cnt);
   switch (crc->phase)
   {
   case RP_ERROR:
@@ -454,43 +450,22 @@
 }
 
 
-static int
-check ()
+int
+main (int argc, char *argv[])
 {
+  char *pos;
+  char dir_name[128];
   char cfg_name[128];
-
   char *const argv[] = {
     "perf-plugin-datastore",
     "-c",
     cfg_name,
-#if VERBOSE
-    "-L", "DEBUG",
-#endif
     NULL
   };
   struct GNUNET_GETOPT_CommandLineOption options[] = {
     GNUNET_GETOPT_OPTION_END
   };
 
-  GNUNET_snprintf (category, sizeof (category), "DATASTORE-%s", plugin_name);
-  GNUNET_snprintf (cfg_name, sizeof (cfg_name),
-                   "perf_plugin_datastore_data_%s.conf", plugin_name);
-  GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv,
-                      "perf-plugin-datastore", "nohelp", options, &run, NULL);
-  if (ok != 0)
-    FPRINTF (stderr, "Missed some testcases: %u\n", ok);
-  return ok;
-}
-
-
-int
-main (int argc, char *argv[])
-{
-  int ret;
-  char *pos;
-  char dir_name[128];
-
-  sleep (1);
   /* determine name of plugin to use */
   plugin_name = argv[0];
   while (NULL != (pos = strstr (plugin_name, "_")))
@@ -499,23 +474,24 @@
     pos[0] = 0;
   else
     pos = (char *) plugin_name;
-
   GNUNET_snprintf (dir_name, sizeof (dir_name), 
"/tmp/perf-gnunet-datastore-%s",
                    plugin_name);
   GNUNET_DISK_directory_remove (dir_name);
   GNUNET_log_setup ("perf-plugin-datastore",
-#if VERBOSE
-                    "DEBUG",
-#else
                     "WARNING",
-#endif
                     NULL);
-  ret = check ();
+  GNUNET_snprintf (category, sizeof (category), "DATASTORE-%s", plugin_name);
+  GNUNET_snprintf (cfg_name, sizeof (cfg_name),
+                   "perf_plugin_datastore_data_%s.conf", plugin_name);
+  GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv,
+                      "perf-plugin-datastore", "nohelp", options, &run, NULL);
+  if (ok != 0)
+    FPRINTF (stderr, "Missed some testcases: %u\n", ok);
   if (pos != plugin_name)
     pos[0] = '.';
   GNUNET_DISK_directory_remove (dir_name);
 
-  return ret;
+  return ok;
 }
 
 /* end of perf_plugin_datastore.c */

Modified: gnunet/src/datastore/test_datastore_api.c
===================================================================
--- gnunet/src/datastore/test_datastore_api.c   2012-06-10 10:51:12 UTC (rev 
21851)
+++ gnunet/src/datastore/test_datastore_api.c   2012-06-10 11:18:59 UTC (rev 
21852)
@@ -30,11 +30,9 @@
 #include "gnunet_util_lib.h"
 #include "gnunet_protocols.h"
 #include "gnunet_datastore_service.h"
+#include "gnunet_testing_lib-new.h"
 
-#define VERBOSE GNUNET_NO
 
-#define START_DATASTORE GNUNET_YES
-
 /**
  * How long until we give up on transmitting the message?
  */
@@ -314,16 +312,12 @@
   struct CpsRunContext *crc = cls;
 
   ok = (int) crc->phase;
-#if VERBOSE
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test in phase %u\n", crc->phase);
-#endif
   switch (crc->phase)
   {
   case RP_PUT:
-#if VERBOSE
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing `%s' number %u\n", "PUT",
                 crc->i);
-#endif
     GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key);
     GNUNET_DATASTORE_put (datastore, 0, &crc->key, get_size (crc->i),
                           get_data (crc->i), get_type (crc->i),
@@ -336,10 +330,8 @@
     break;
   case RP_GET:
     crc->i--;
-#if VERBOSE
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing `%s' number %u\n", "GET",
                 crc->i);
-#endif
     GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key);
     GNUNET_DATASTORE_get_key (datastore, crc->offset, &crc->key,
                               get_type (crc->i), 1, 1, TIMEOUT, &check_value,
@@ -347,10 +339,8 @@
     break;
   case RP_DEL:
     crc->i--;
-#if VERBOSE
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing `%s' number %u\n", "DEL",
                 crc->i);
-#endif
     crc->data = NULL;
     GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key);
     GNUNET_assert (NULL !=
@@ -359,10 +349,8 @@
                                              &delete_value, crc));
     break;
   case RP_DO_DEL:
-#if VERBOSE
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing `%s' number %u\n", 
"DO_DEL",
                 crc->i);
-#endif
     if (crc->i == 0)
     {
       crc->i = ITERATIONS;
@@ -379,10 +367,8 @@
     break;
   case RP_DELVALIDATE:
     crc->i--;
-#if VERBOSE
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing `%s' number %u\n",
                 "DEL-VALIDATE", crc->i);
-#endif
     GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key);
     GNUNET_assert (NULL !=
                    GNUNET_DATASTORE_get_key (datastore, crc->offset, &crc->key,
@@ -433,9 +419,7 @@
                                              &check_update, crc));
     break;
   case RP_DONE:
-#if VERBOSE
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Finished, disconnecting\n");
-#endif
     GNUNET_DATASTORE_disconnect (datastore, GNUNET_YES);
     GNUNET_free (crc);
     ok = 0;
@@ -479,7 +463,7 @@
 
 
 static void
-run (void *cls, char *const *args, const char *cfgfile,
+run (void *cls, 
      const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   struct CpsRunContext *crc;
@@ -504,88 +488,29 @@
 }
 
 
-static int
-check ()
-{
-  char cfg_name[128];
-
-#if START_DATASTORE
-  struct GNUNET_OS_Process *proc;
-#endif
-  char *const argv[] = {
-    "test-datastore-api",
-    "-c",
-    cfg_name,
-#if VERBOSE
-    "-L", "DEBUG",
-#endif
-    NULL
-  };
-  struct GNUNET_GETOPT_CommandLineOption options[] = {
-    GNUNET_GETOPT_OPTION_END
-  };
-  GNUNET_snprintf (cfg_name, sizeof (cfg_name),
-                   "test_datastore_api_data_%s.conf", plugin_name);
-#if START_DATASTORE
-  proc =
-    GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
-                               "gnunet-service-arm",
-#if VERBOSE
-                               "-L", "DEBUG",
-#endif
-                               "-c", cfg_name, NULL);
-#endif
-  GNUNET_assert (NULL != proc);
-  GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv,
-                      "test-datastore-api", "nohelp", options, &run, NULL);
-#if START_DATASTORE
-  sleep (1);                    /* give datastore chance to receive 'DROP' 
request */
-  if (0 != GNUNET_OS_process_kill (proc, SIGTERM))
-  {
-    GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
-    ok = 1;
-  }
-  GNUNET_OS_process_wait (proc);
-  GNUNET_OS_process_destroy (proc);
-  proc = NULL;
-#endif
-  if (ok != 0)
-    FPRINTF (stderr, "Missed some testcases: %u\n", ok);
-  return ok;
-}
-
 int
 main (int argc, char *argv[])
 {
-  int ret;
   char *pos;
-  char dir_name[128];
+  char cfg_name[128];
 
-  sleep (1);
   /* determine name of plugin to use */
   plugin_name = argv[0];
   while (NULL != (pos = strstr (plugin_name, "_")))
     plugin_name = pos + 1;
   if (NULL != (pos = strstr (plugin_name, ".")))
-    pos[0] = 0;
+    pos[0] = '\0';
   else
     pos = (char *) plugin_name;
-
-  GNUNET_snprintf (dir_name, sizeof (dir_name), 
"/tmp/test-gnunet-datastore-%s",
-                   plugin_name);
-  GNUNET_DISK_directory_remove (dir_name);
-  GNUNET_log_setup ("test-datastore-api",
-#if VERBOSE
-                    "DEBUG",
-#else
-                    "WARNING",
-#endif
-                    NULL);
-  ret = check ();
-  if (pos != plugin_name)
-    pos[0] = '.';
-  GNUNET_DISK_directory_remove (dir_name);
-  return ret;
+  GNUNET_snprintf (cfg_name, sizeof (cfg_name),
+                   "test_datastore_api_data_%s.conf", plugin_name);
+  if (0 !=
+      GNUNET_TESTING_peer_run ("test-gnunet-datastore",
+                              cfg_name,
+                              &run,
+                              NULL))
+    return 1;
+  return ok;
 }
 
 /* end of test_datastore_api.c */

Modified: gnunet/src/datastore/test_datastore_api_data_sqlite.conf
===================================================================
--- gnunet/src/datastore/test_datastore_api_data_sqlite.conf    2012-06-10 
10:51:12 UTC (rev 21851)
+++ gnunet/src/datastore/test_datastore_api_data_sqlite.conf    2012-06-10 
11:18:59 UTC (rev 21852)
@@ -19,6 +19,4 @@
 [datastore]
 QUOTA = 10 MB
 
-[fs]
-AUTOSTART = NO
 

Modified: gnunet/src/datastore/test_datastore_api_management.c
===================================================================
--- gnunet/src/datastore/test_datastore_api_management.c        2012-06-10 
10:51:12 UTC (rev 21851)
+++ gnunet/src/datastore/test_datastore_api_management.c        2012-06-10 
11:18:59 UTC (rev 21852)
@@ -22,13 +22,12 @@
  * @brief Test for the space management functions of the datastore 
implementation.
  * @author Christian Grothoff
  */
-
 #include "platform.h"
 #include "gnunet_util_lib.h"
 #include "gnunet_protocols.h"
 #include "gnunet_datastore_service.h"
+#include "gnunet_testing_lib-new.h"
 
-#define VERBOSE GNUNET_NO
 
 /**
  * How long until we give up on transmitting the message?
@@ -41,6 +40,27 @@
  */
 #define ITERATIONS 5000
 
+enum RunPhase
+{
+  RP_PUT,
+  RP_GET,
+  RP_DONE,
+  RP_GET_FAIL
+};
+
+
+struct CpsRunContext
+{
+  GNUNET_HashCode key;
+  int i;
+  int found;
+  const struct GNUNET_CONFIGURATION_Handle *cfg;
+  void *data;
+  enum RunPhase phase;
+  uint64_t offset;
+};
+
+
 static struct GNUNET_DATASTORE_Handle *datastore;
 
 static struct GNUNET_TIME_Absolute now;
@@ -49,6 +69,7 @@
 
 static const char *plugin_name;
 
+
 static size_t
 get_size (int i)
 {
@@ -96,27 +117,7 @@
   return av;
 }
 
-enum RunPhase
-{
-  RP_PUT,
-  RP_GET,
-  RP_DONE,
-  RP_GET_FAIL
-};
 
-
-struct CpsRunContext
-{
-  GNUNET_HashCode key;
-  int i;
-  int found;
-  const struct GNUNET_CONFIGURATION_Handle *cfg;
-  void *data;
-  enum RunPhase phase;
-  uint64_t offset;
-};
-
-
 static void
 run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
 
@@ -193,10 +194,8 @@
   switch (crc->phase)
   {
   case RP_PUT:
-#if VERBOSE
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing `%s' number %u\n", "PUT",
                 crc->i);
-#endif
     GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key);
     GNUNET_DATASTORE_put (datastore, 0, &crc->key, get_size (crc->i),
                           get_data (crc->i), get_type (crc->i),
@@ -214,20 +213,16 @@
     }
     break;
   case RP_GET:
-#if VERBOSE
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing `%s' number %u\n", "GET",
                 crc->i);
-#endif
     GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key);
     GNUNET_DATASTORE_get_key (datastore, crc->offset++, &crc->key,
                               get_type (crc->i), 1, 1, TIMEOUT, &check_value,
                               crc);
     break;
   case RP_GET_FAIL:
-#if VERBOSE
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing `%s' number %u\n", 
"GET(f)",
                 crc->i);
-#endif
     GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key);
     GNUNET_DATASTORE_get_key (datastore, crc->offset++, &crc->key,
                               get_type (crc->i), 1, 1, TIMEOUT, &check_nothing,
@@ -235,9 +230,7 @@
     break;
   case RP_DONE:
     GNUNET_assert (0 == crc->i);
-#if VERBOSE
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Finished, disconnecting\n");
-#endif
     GNUNET_DATASTORE_disconnect (datastore, GNUNET_YES);
     GNUNET_free (crc);
     ok = 0;
@@ -265,7 +258,7 @@
 
 
 static void
-run (void *cls, char *const *args, const char *cfgfile,
+run (void *cls, 
      const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   struct CpsRunContext *crc;
@@ -290,61 +283,12 @@
 }
 
 
-
-static int
-check ()
-{
-  struct GNUNET_OS_Process *proc;
-  char cfg_name[128];
-
-  char *const argv[] = {
-    "test-datastore-api-management",
-    "-c",
-    cfg_name,
-#if VERBOSE
-    "-L", "DEBUG",
-#endif
-    NULL
-  };
-  struct GNUNET_GETOPT_CommandLineOption options[] = {
-    GNUNET_GETOPT_OPTION_END
-  };
-  GNUNET_snprintf (cfg_name, sizeof (cfg_name),
-                   "test_datastore_api_data_%s.conf", plugin_name);
-  proc =
-    GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
-                               "gnunet-service-arm",
-#if VERBOSE
-                               "-L", "DEBUG",
-#endif
-                               "-c", cfg_name, NULL);
-  GNUNET_assert (NULL != proc);
-  GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv,
-                      "test-datastore-api-management", "nohelp", options, &run,
-                      NULL);
-  sleep (1);                    /* give datastore chance to process 'DROP' 
request */
-  if (0 != GNUNET_OS_process_kill (proc, SIGTERM))
-  {
-    GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
-    ok = 1;
-  }
-  GNUNET_OS_process_wait (proc);
-  GNUNET_OS_process_destroy (proc);
-  proc = NULL;
-  if (ok != 0)
-    FPRINTF (stderr, "Missed some testcases: %u\n", ok);
-  return ok;
-}
-
 int
 main (int argc, char *argv[])
 {
-  int ret;
-
   char *pos;
-  char dir_name[128];
+  char cfg_name[128];
 
-  sleep (1);
   /* determine name of plugin to use */
   plugin_name = argv[0];
   while (NULL != (pos = strstr (plugin_name, "_")))
@@ -353,22 +297,15 @@
     pos[0] = 0;
   else
     pos = (char *) plugin_name;
-
-  GNUNET_snprintf (dir_name, sizeof (dir_name), 
"/tmp/test-gnunet-datastore-%s",
-                   plugin_name);
-  GNUNET_DISK_directory_remove (dir_name);
-  GNUNET_log_setup ("test-datastore-api-management",
-#if VERBOSE
-                    "DEBUG",
-#else
-                    "WARNING",
-#endif
-                    NULL);
-  ret = check ();
-  if (pos != plugin_name)
-    pos[0] = '.';
-  GNUNET_DISK_directory_remove (dir_name);
-  return ret;
+  GNUNET_snprintf (cfg_name, sizeof (cfg_name),
+                   "test_datastore_api_data_%s.conf", plugin_name);
+  if (0 !=
+      GNUNET_TESTING_peer_run ("test-gnunet-datastore-management",
+                              cfg_name,
+                              &run,
+                              NULL))
+    return 1;
+  return ok;
 }
 
 /* end of test_datastore_api_management.c */

Modified: gnunet/src/datastore/test_defaults.conf
===================================================================
--- gnunet/src/datastore/test_defaults.conf     2012-06-10 10:51:12 UTC (rev 
21851)
+++ gnunet/src/datastore/test_defaults.conf     2012-06-10 11:18:59 UTC (rev 
21852)
@@ -31,3 +31,6 @@
 
 [namestore]
 AUTOSTART = NO
+
+[fs]
+AUTOSTART = NO

Modified: gnunet/src/datastore/test_plugin_datastore.c
===================================================================
--- gnunet/src/datastore/test_plugin_datastore.c        2012-06-10 10:51:12 UTC 
(rev 21851)
+++ gnunet/src/datastore/test_plugin_datastore.c        2012-06-10 11:18:59 UTC 
(rev 21852)
@@ -28,8 +28,6 @@
 #include "gnunet_protocols.h"
 #include "gnunet_datastore_plugin.h"
 
-#define VERBOSE GNUNET_NO
-
 /**
  * Number of put operations to perform.
  */
@@ -117,10 +115,9 @@
   value[0] = k;
   msg = NULL;
   prio = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100);
-#if VERBOSE
-  FPRINTF (stderr, "putting type %u, anon %u under key %s\n", i + 1, i,
-           GNUNET_h2s (&key));
-#endif
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "putting type %u, anon %u under key %s\n", i + 1, i,
+             GNUNET_h2s (&key));
   if (GNUNET_OK != api->put (api->cls, &key, size, value, i + 1 /* type */ ,
                              prio, i /* anonymity */ ,
                              0 /* replication */ ,
@@ -159,12 +156,10 @@
   GNUNET_assert (key != NULL);
   guid = uid;
   crc->phase++;
-#if VERBOSE
-  FPRINTF (stderr,
-           "Found result type=%u, priority=%u, size=%u, expire=%llu, key %s\n",
-           type, priority, size, (unsigned long long) expiration.abs_value,
-           GNUNET_h2s (key));
-#endif
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Found result type=%u, priority=%u, size=%u, expire=%llu, key 
%s\n",
+             type, priority, size, (unsigned long long) expiration.abs_value,
+             GNUNET_h2s (key));
   GNUNET_SCHEDULER_add_now (&test, crc);
   return GNUNET_OK;
 }
@@ -229,9 +224,8 @@
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test aborted.\n");
     crc->phase = RP_ERROR;
   }
-#if VERBOSE
-  FPRINTF (stderr, "In phase %d, iteration %u\n", crc->phase, crc->cnt);
-#endif
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
+             "In phase %d, iteration %u\n", crc->phase, crc->cnt);
   switch (crc->phase)
   {
   case RP_ERROR:
@@ -355,42 +349,23 @@
 }
 
 
-static int
-check ()
+
+int
+main (int argc, char *argv[])
 {
+  char *pos;
+  char dir_name[128];
   char cfg_name[128];
-
-  char *const argv[] = {
+  char *const xargv[] = {
     "test-plugin-datastore",
     "-c",
     cfg_name,
-#if VERBOSE
-    "-L", "DEBUG",
-#endif
     NULL
   };
-  struct GNUNET_GETOPT_CommandLineOption options[] = {
+  static struct GNUNET_GETOPT_CommandLineOption options[] = {
     GNUNET_GETOPT_OPTION_END
   };
 
-  GNUNET_snprintf (cfg_name, sizeof (cfg_name),
-                   "test_plugin_datastore_data_%s.conf", plugin_name);
-  GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv,
-                      "test-plugin-datastore", "nohelp", options, &run, NULL);
-  if (ok != 0)
-    FPRINTF (stderr, "Missed some testcases: %u\n", ok);
-  return ok;
-}
-
-
-int
-main (int argc, char *argv[])
-{
-  int ret;
-  char *pos;
-  char dir_name[128];
-
-  sleep (1);
   /* determine name of plugin to use */
   plugin_name = argv[0];
   while (NULL != (pos = strstr (plugin_name, "_")))
@@ -404,18 +379,18 @@
                    "/tmp/test-gnunet-datastore-plugin-%s", plugin_name);
   GNUNET_DISK_directory_remove (dir_name);
   GNUNET_log_setup ("test-plugin-datastore",
-#if VERBOSE
-                    "DEBUG",
-#else
                     "WARNING",
-#endif
                     NULL);
-  ret = check ();
+  GNUNET_snprintf (cfg_name, sizeof (cfg_name),
+                   "test_plugin_datastore_data_%s.conf", plugin_name);
+  GNUNET_PROGRAM_run ((sizeof (xargv) / sizeof (char *)) - 1, xargv,
+                      "test-plugin-datastore", "nohelp", options, &run, NULL);
+  if (ok != 0)
+    FPRINTF (stderr, "Missed some testcases: %u\n", ok);
   if (pos != plugin_name)
     pos[0] = '.';
   GNUNET_DISK_directory_remove (dir_name);
-
-  return ret;
+  return ok;
 }
 
 /* end of test_plugin_datastore.c */




reply via email to

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