gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r22013 - gnunet/src/fs


From: gnunet
Subject: [GNUnet-SVN] r22013 - gnunet/src/fs
Date: Fri, 15 Jun 2012 10:38:53 +0200

Author: grothoff
Date: 2012-06-15 10:38:53 +0200 (Fri, 15 Jun 2012)
New Revision: 22013

Modified:
   gnunet/src/fs/Makefile.am
   gnunet/src/fs/test_fs_publish.c
   gnunet/src/fs/test_fs_publish_persistence.c
   gnunet/src/fs/test_fs_search.c
   gnunet/src/fs/test_fs_search_persistence.c
   gnunet/src/fs/test_fs_search_probes.c
   gnunet/src/fs/test_fs_start_stop.c
   gnunet/src/fs/test_fs_uri.c
Log:
-simplifying tests with new testing lib

Modified: gnunet/src/fs/Makefile.am
===================================================================
--- gnunet/src/fs/Makefile.am   2012-06-15 08:10:52 UTC (rev 22012)
+++ gnunet/src/fs/Makefile.am   2012-06-15 08:38:53 UTC (rev 22013)
@@ -327,36 +327,42 @@
 test_fs_publish_SOURCES = \
  test_fs_publish.c
 test_fs_publish_LDADD = \
+  $(top_builddir)/src/testing/libgnunettesting.la \
   $(top_builddir)/src/fs/libgnunetfs.la  \
   $(top_builddir)/src/util/libgnunetutil.la  
 
 test_fs_publish_persistence_SOURCES = \
  test_fs_publish_persistence.c
 test_fs_publish_persistence_LDADD = \
+  $(top_builddir)/src/testing/libgnunettesting.la \
   $(top_builddir)/src/fs/libgnunetfs.la  \
   $(top_builddir)/src/util/libgnunetutil.la  
 
 test_fs_search_SOURCES = \
  test_fs_search.c
 test_fs_search_LDADD = \
+  $(top_builddir)/src/testing/libgnunettesting.la \
   $(top_builddir)/src/fs/libgnunetfs.la        \
   $(top_builddir)/src/util/libgnunetutil.la
 
 test_fs_search_probes_SOURCES = \
  test_fs_search_probes.c
 test_fs_search_probes_LDADD = \
+  $(top_builddir)/src/testing/libgnunettesting.la \
   $(top_builddir)/src/fs/libgnunetfs.la        \
   $(top_builddir)/src/util/libgnunetutil.la
 
 test_fs_search_persistence_SOURCES = \
  test_fs_search_persistence.c
 test_fs_search_persistence_LDADD = \
+  $(top_builddir)/src/testing/libgnunettesting.la \
   $(top_builddir)/src/fs/libgnunetfs.la        \
   $(top_builddir)/src/util/libgnunetutil.la
 
 test_fs_start_stop_SOURCES = \
  test_fs_start_stop.c
 test_fs_start_stop_LDADD = \
+  $(top_builddir)/src/testing/libgnunettesting.la \
   $(top_builddir)/src/fs/libgnunetfs.la  \
   $(top_builddir)/src/util/libgnunetutil.la  
 

Modified: gnunet/src/fs/test_fs_publish.c
===================================================================
--- gnunet/src/fs/test_fs_publish.c     2012-06-15 08:10:52 UTC (rev 22012)
+++ gnunet/src/fs/test_fs_publish.c     2012-06-15 08:38:53 UTC (rev 22013)
@@ -17,23 +17,17 @@
      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
      Boston, MA 02111-1307, USA.
 */
-
 /**
  * @file fs/test_fs_publish.c
  * @brief simple testcase for publish operation (indexing, listing
  *        indexed, directory structure)
  * @author Christian Grothoff
  */
-
 #include "platform.h"
 #include "gnunet_util_lib.h"
-#include "gnunet_arm_service.h"
+#include "gnunet_testing_lib-new.h"
 #include "gnunet_fs_service.h"
 
-#define VERBOSE GNUNET_NO
-
-#define START_ARM GNUNET_YES
-
 /**
  * File-size we use for testing.
  */
@@ -49,16 +43,7 @@
  */
 #define LIFETIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15)
 
-struct PeerContext
-{
-  struct GNUNET_CONFIGURATION_Handle *cfg;
-#if START_ARM
-  struct GNUNET_OS_Process *arm_proc;
-#endif
-};
 
-static struct PeerContext p1;
-
 static struct GNUNET_TIME_Absolute start;
 
 static struct GNUNET_FS_Handle *fs;
@@ -71,6 +56,7 @@
 
 static int err;
 
+
 static void
 abort_publish_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
@@ -107,14 +93,13 @@
   case GNUNET_FS_STATUS_PUBLISH_PROGRESS:
     ret = event->value.publish.cctx;
     GNUNET_assert (publish == event->value.publish.pc);
-#if VERBOSE
-    printf ("Publish is progressing (%llu/%llu at level %u off %llu)...\n",
-            (unsigned long long) event->value.publish.completed,
-            (unsigned long long) event->value.publish.size,
-            event->value.publish.specifics.progress.depth,
-            (unsigned long long) event->value.publish.specifics.
-            progress.offset);
-#endif
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+               "Publish is progressing (%llu/%llu at level %u off %llu)...\n",
+               (unsigned long long) event->value.publish.completed,
+               (unsigned long long) event->value.publish.size,
+               event->value.publish.specifics.progress.depth,
+               (unsigned long long) event->value.publish.specifics.
+               progress.offset);
     break;
   case GNUNET_FS_STATUS_PUBLISH_ERROR:
     ret = event->value.publish.cctx;
@@ -168,44 +153,7 @@
 
 
 static void
-setup_peer (struct PeerContext *p, const char *cfgname)
-{
-  p->cfg = GNUNET_CONFIGURATION_create ();
-#if START_ARM
-  p->arm_proc =
-    GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
-                               "gnunet-service-arm",
-#if VERBOSE
-                               "-L", "DEBUG",
-#endif
-                               "-c", cfgname, NULL);
-#endif
-  GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
-}
-
-
-static void
-stop_arm (struct PeerContext *p)
-{
-#if START_ARM
-  if (NULL != p->arm_proc)
-  {
-    if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
-      GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
-    if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK)
-      GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n",
-                GNUNET_OS_process_get_pid (p->arm_proc));
-    GNUNET_OS_process_destroy (p->arm_proc);
-    p->arm_proc = NULL;
-  }
-#endif
-  GNUNET_CONFIGURATION_destroy (p->cfg);
-}
-
-
-static void
-run (void *cls, char *const *args, const char *cfgfile,
+run (void *cls, 
      const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   const char *keywords[] = {
@@ -221,7 +169,6 @@
   size_t i;
   struct GNUNET_FS_BlockOptions bo;
 
-  setup_peer (&p1, "test_fs_publish_data.conf");
   fs = GNUNET_FS_start (cfg, "test-fs-publish", &progress_cb, NULL,
                         GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END);
   GNUNET_assert (NULL != fs);
@@ -283,40 +230,10 @@
 int
 main (int argc, char *argv[])
 {
-  char *const argvx[] = {
-    "test-fs-publish",
-    "-c",
-    "test_fs_publish_data.conf",
-#if VERBOSE
-    "-L", "DEBUG",
-#endif
-    NULL
-  };
-  struct GNUNET_GETOPT_CommandLineOption options[] = {
-    GNUNET_GETOPT_OPTION_END
-  };
-
-  GNUNET_log_setup ("test_fs_publish",
-#if VERBOSE
-                    "DEBUG",
-#else
-                    "WARNING",
-#endif
-                    NULL);
-  GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx,
-                      "test-fs-publish", "nohelp", options, &run, NULL);
-  stop_arm (&p1);
-  GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-publish/");
-  if (fn1 != NULL)
-  {
-    GNUNET_DISK_directory_remove (fn1);
-    GNUNET_free (fn1);
-  }
-  if (fn2 != NULL)
-  {
-    GNUNET_DISK_directory_remove (fn2);
-    GNUNET_free (fn2);
-  }
+  if (0 != GNUNET_TESTING_peer_run ("test-fs-publish",
+                                   "test_fs_publish_data.conf",
+                                   &run, NULL))
+    return 1;
   return err;
 }
 

Modified: gnunet/src/fs/test_fs_publish_persistence.c
===================================================================
--- gnunet/src/fs/test_fs_publish_persistence.c 2012-06-15 08:10:52 UTC (rev 
22012)
+++ gnunet/src/fs/test_fs_publish_persistence.c 2012-06-15 08:38:53 UTC (rev 
22013)
@@ -17,22 +17,17 @@
      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
      Boston, MA 02111-1307, USA.
 */
-
 /**
  * @file fs/test_fs_publish_persistence.c
  * @brief simple testcase for persistence of simple publish operation
  * @author Christian Grothoff
  */
-
 #include "platform.h"
 #include "gnunet_util_lib.h"
-#include "gnunet_arm_service.h"
+#include "gnunet_testing_lib-new.h"
 #include "gnunet_fs_service.h"
 
-#define VERBOSE GNUNET_NO
 
-#define START_ARM GNUNET_YES
-
 /**
  * File-size we use for testing.
  */
@@ -48,16 +43,7 @@
  */
 #define LIFETIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15)
 
-struct PeerContext
-{
-  struct GNUNET_CONFIGURATION_Handle *cfg;
-#if START_ARM
-  struct GNUNET_OS_Process *arm_proc;
-#endif
-};
 
-static struct PeerContext p1;
-
 static struct GNUNET_TIME_Absolute start;
 
 static struct GNUNET_FS_Handle *fs;
@@ -76,6 +62,7 @@
 
 static GNUNET_SCHEDULER_TaskIdentifier rtask;
 
+
 static void
 abort_publish_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
@@ -231,44 +218,7 @@
 
 
 static void
-setup_peer (struct PeerContext *p, const char *cfgname)
-{
-  p->cfg = GNUNET_CONFIGURATION_create ();
-#if START_ARM
-  p->arm_proc =
-      GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
-                               "gnunet-service-arm",
-#if VERBOSE
-                               "-L", "DEBUG",
-#endif
-                               "-c", cfgname, NULL);
-#endif
-  GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
-}
-
-
-static void
-stop_arm (struct PeerContext *p)
-{
-#if START_ARM
-  if (NULL != p->arm_proc)
-  {
-    if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
-      GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
-    if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK)
-      GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n",
-                GNUNET_OS_process_get_pid (p->arm_proc));
-    GNUNET_OS_process_destroy (p->arm_proc);
-    p->arm_proc = NULL;
-  }
-#endif
-  GNUNET_CONFIGURATION_destroy (p->cfg);
-}
-
-
-static void
-run (void *cls, char *const *args, const char *cfgfile,
+run (void *cls, 
      const struct GNUNET_CONFIGURATION_Handle *c)
 {
   const char *keywords[] = {
@@ -285,7 +235,6 @@
   struct GNUNET_FS_BlockOptions bo;
 
   cfg = c;
-  setup_peer (&p1, "test_fs_publish_data.conf");
   fs = GNUNET_FS_start (cfg, "test-fs-publish-persistence", &progress_cb, NULL,
                         GNUNET_FS_FLAGS_PERSISTENCE, GNUNET_FS_OPTIONS_END);
   GNUNET_assert (NULL != fs);
@@ -344,40 +293,10 @@
 int
 main (int argc, char *argv[])
 {
-  char *const argvx[] = {
-    "test-fs-publish-persistence",
-    "-c",
-    "test_fs_publish_data.conf",
-#if VERBOSE
-    "-L", "DEBUG",
-#endif
-    NULL
-  };
-  struct GNUNET_GETOPT_CommandLineOption options[] = {
-    GNUNET_GETOPT_OPTION_END
-  };
-
-  GNUNET_log_setup ("test_fs_publish_persistence",
-#if VERBOSE
-                    "DEBUG",
-#else
-                    "WARNING",
-#endif
-                    NULL);
-  GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx,
-                      "test-fs-publish", "nohelp", options, &run, NULL);
-  stop_arm (&p1);
-  GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-publish/");
-  if (fn1 != NULL)
-  {
-    GNUNET_DISK_directory_remove (fn1);
-    GNUNET_free (fn1);
-  }
-  if (fn2 != NULL)
-  {
-    GNUNET_DISK_directory_remove (fn2);
-    GNUNET_free (fn2);
-  }
+  if (0 != GNUNET_TESTING_peer_run ("test-fs-publish-persistence",
+                                   "test_fs_publish_data.conf",
+                                   &run, NULL))
+    return 1;
   return err;
 }
 

Modified: gnunet/src/fs/test_fs_search.c
===================================================================
--- gnunet/src/fs/test_fs_search.c      2012-06-15 08:10:52 UTC (rev 22012)
+++ gnunet/src/fs/test_fs_search.c      2012-06-15 08:38:53 UTC (rev 22013)
@@ -17,22 +17,17 @@
      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
      Boston, MA 02111-1307, USA.
 */
-
 /**
  * @file fs/test_fs_search.c
  * @brief simple testcase for simple publish + search operation
  * @author Christian Grothoff
  */
-
 #include "platform.h"
 #include "gnunet_util_lib.h"
-#include "gnunet_arm_service.h"
+#include "gnunet_testing_lib-new.h"
 #include "gnunet_fs_service.h"
 
-#define VERBOSE GNUNET_NO
 
-#define START_ARM GNUNET_YES
-
 /**
  * File-size we use for testing.
  */
@@ -48,17 +43,7 @@
  */
 #define LIFETIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15)
 
-struct PeerContext
-{
-  struct GNUNET_CONFIGURATION_Handle *cfg;
-  struct GNUNET_PeerIdentity id;
-#if START_ARM
-  struct GNUNET_OS_Process *arm_proc;
-#endif
-};
 
-static struct PeerContext p1;
-
 static struct GNUNET_TIME_Absolute start;
 
 static struct GNUNET_FS_Handle *fs;
@@ -96,14 +81,13 @@
   switch (event->status)
   {
   case GNUNET_FS_STATUS_PUBLISH_PROGRESS:
-#if VERBOSE
-    printf ("Publish is progressing (%llu/%llu at level %u off %llu)...\n",
-            (unsigned long long) event->value.publish.completed,
-            (unsigned long long) event->value.publish.size,
-            event->value.publish.specifics.progress.depth,
-            (unsigned long long) event->value.publish.specifics.
-            progress.offset);
-#endif
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+               "Publish is progressing (%llu/%llu at level %u off %llu)...\n",
+               (unsigned long long) event->value.publish.completed,
+               (unsigned long long) event->value.publish.size,
+               event->value.publish.specifics.progress.depth,
+               (unsigned long long) event->value.publish.specifics.
+               progress.offset);
     break;
   case GNUNET_FS_STATUS_PUBLISH_COMPLETED:
     kuri = GNUNET_FS_uri_ksk_create_from_args (1, keywords);
@@ -115,9 +99,8 @@
     GNUNET_assert (search != NULL);
     break;
   case GNUNET_FS_STATUS_SEARCH_RESULT:
-#if VERBOSE
-    printf ("Search complete.\n");
-#endif
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+               "Search complete.\n");
     GNUNET_SCHEDULER_add_continuation (&abort_search_task, NULL,
                                        GNUNET_SCHEDULER_REASON_PREREQ_DONE);
     break;
@@ -169,41 +152,7 @@
 
 
 static void
-setup_peer (struct PeerContext *p, const char *cfgname)
-{
-  p->cfg = GNUNET_CONFIGURATION_create ();
-#if START_ARM
-  p->arm_proc =
-      GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
-                               "gnunet-service-arm",
-                               "-c", cfgname, NULL);
-#endif
-  GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
-}
-
-
-static void
-stop_arm (struct PeerContext *p)
-{
-#if START_ARM
-  if (NULL != p->arm_proc)
-  {
-    if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
-      GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
-    if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK)
-      GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n",
-                GNUNET_OS_process_get_pid (p->arm_proc));
-    GNUNET_OS_process_destroy (p->arm_proc);
-    p->arm_proc = NULL;
-  }
-#endif
-  GNUNET_CONFIGURATION_destroy (p->cfg);
-}
-
-
-static void
-run (void *cls, char *const *args, const char *cfgfile,
+run (void *cls,
      const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   const char *keywords[] = {
@@ -217,7 +166,6 @@
   struct GNUNET_FS_FileInformation *fi;
   size_t i;
 
-  setup_peer (&p1, "test_fs_search_data.conf");
   fs = GNUNET_FS_start (cfg, "test-fs-search", &progress_cb, NULL,
                         GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END);
   GNUNET_assert (NULL != fs);
@@ -247,23 +195,10 @@
 int
 main (int argc, char *argv[])
 {
-  char *const argvx[] = {
-    "test-fs-search",
-    "-c",
-    "test_fs_search_data.conf",
-    NULL
-  };
-  struct GNUNET_GETOPT_CommandLineOption options[] = {
-    GNUNET_GETOPT_OPTION_END
-  };
-
-  GNUNET_log_setup ("test_fs_search",
-                    "WARNING",
-                    NULL);
-  GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx,
-                      "test-fs-search", "nohelp", options, &run, NULL);
-  stop_arm (&p1);
-  GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-search/");
+  if (0 != GNUNET_TESTING_peer_run ("test-fs-search",
+                                   "test_fs_search_data.conf",
+                                   &run, NULL))
+    return 1;
   return 0;
 }
 

Modified: gnunet/src/fs/test_fs_search_persistence.c
===================================================================
--- gnunet/src/fs/test_fs_search_persistence.c  2012-06-15 08:10:52 UTC (rev 
22012)
+++ gnunet/src/fs/test_fs_search_persistence.c  2012-06-15 08:38:53 UTC (rev 
22013)
@@ -17,22 +17,17 @@
      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
      Boston, MA 02111-1307, USA.
 */
-
 /**
  * @file fs/test_fs_search_persistence.c
  * @brief simple testcase for persistence of search operation
  * @author Christian Grothoff
  */
-
 #include "platform.h"
 #include "gnunet_util_lib.h"
-#include "gnunet_arm_service.h"
+#include "gnunet_testing_lib-new.h"
 #include "gnunet_fs_service.h"
 
-#define VERBOSE GNUNET_NO
 
-#define START_ARM GNUNET_YES
-
 /**
  * File-size we use for testing.
  */
@@ -48,17 +43,7 @@
  */
 #define LIFETIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15)
 
-struct PeerContext
-{
-  struct GNUNET_CONFIGURATION_Handle *cfg;
-  struct GNUNET_PeerIdentity id;
-#if START_ARM
-  struct GNUNET_OS_Process *arm_proc;
-#endif
-};
 
-static struct PeerContext p1;
-
 static struct GNUNET_TIME_Absolute start;
 
 static struct GNUNET_FS_Handle *fs;
@@ -69,6 +54,7 @@
 
 static const struct GNUNET_CONFIGURATION_Handle *cfg;
 
+
 static void
 abort_publish_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
@@ -99,8 +85,6 @@
 }
 
 
-
-
 /**
  * Consider scheduling the restart-task.
  * Only runs the restart task once per event
@@ -135,14 +119,13 @@
   switch (event->status)
   {
   case GNUNET_FS_STATUS_PUBLISH_PROGRESS:
-#if VERBOSE
-    printf ("Publish is progressing (%llu/%llu at level %u off %llu)...\n",
-            (unsigned long long) event->value.publish.completed,
-            (unsigned long long) event->value.publish.size,
-            event->value.publish.specifics.progress.depth,
-            (unsigned long long) event->value.publish.specifics.
-            progress.offset);
-#endif
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+               "Publish is progressing (%llu/%llu at level %u off %llu)...\n",
+               (unsigned long long) event->value.publish.completed,
+               (unsigned long long) event->value.publish.size,
+               event->value.publish.specifics.progress.depth,
+               (unsigned long long) event->value.publish.specifics.
+               progress.offset);
     break;
   case GNUNET_FS_STATUS_PUBLISH_COMPLETED:
     kuri = GNUNET_FS_uri_ksk_create_from_args (1, keywords);
@@ -163,9 +146,8 @@
   case GNUNET_FS_STATUS_SEARCH_RESULT:
     /* FIXME: consider_restart (event->status); cannot be tested with
      * search result since we exit here after the first one... */
-#if VERBOSE
-    printf ("Search complete.\n");
-#endif
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+               "Search complete.\n");
     GNUNET_SCHEDULER_add_continuation (&abort_search_task, NULL,
                                        GNUNET_SCHEDULER_REASON_PREREQ_DONE);
     break;
@@ -231,44 +213,7 @@
 
 
 static void
-setup_peer (struct PeerContext *p, const char *cfgname)
-{
-  p->cfg = GNUNET_CONFIGURATION_create ();
-#if START_ARM
-  p->arm_proc =
-      GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
-                               "gnunet-service-arm",
-#if VERBOSE
-                               "-L", "DEBUG",
-#endif
-                               "-c", cfgname, NULL);
-#endif
-  GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
-}
-
-
-static void
-stop_arm (struct PeerContext *p)
-{
-#if START_ARM
-  if (NULL != p->arm_proc)
-  {
-    if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
-      GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
-    if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK)
-      GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n",
-                GNUNET_OS_process_get_pid (p->arm_proc));
-    GNUNET_OS_process_destroy (p->arm_proc);
-    p->arm_proc = NULL;
-  }
-#endif
-  GNUNET_CONFIGURATION_destroy (p->cfg);
-}
-
-
-static void
-run (void *cls, char *const *args, const char *cfgfile,
+run (void *cls,
      const struct GNUNET_CONFIGURATION_Handle *c)
 {
   const char *keywords[] = {
@@ -283,7 +228,6 @@
   struct GNUNET_FS_BlockOptions bo;
 
   cfg = c;
-  setup_peer (&p1, "test_fs_search_data.conf");
   fs = GNUNET_FS_start (cfg, "test-fs-search-persistence", &progress_cb, NULL,
                         GNUNET_FS_FLAGS_PERSISTENCE, GNUNET_FS_OPTIONS_END);
   GNUNET_assert (NULL != fs);
@@ -313,32 +257,10 @@
 int
 main (int argc, char *argv[])
 {
-  char *const argvx[] = {
-    "test-fs-search-persistence",
-    "-c",
-    "test_fs_search_data.conf",
-#if VERBOSE
-    "-L", "DEBUG",
-#endif
-    NULL
-  };
-  struct GNUNET_GETOPT_CommandLineOption options[] = {
-    GNUNET_GETOPT_OPTION_END
-  };
-
-  GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-search/");
-  GNUNET_log_setup ("test_fs_search_persistence",
-#if VERBOSE
-                    "DEBUG",
-#else
-                    "WARNING",
-#endif
-                    NULL);
-  GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx,
-                      "test-fs-search-persistence", "nohelp", options, &run,
-                      NULL);
-  stop_arm (&p1);
-  GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-search/");
+  if (0 != GNUNET_TESTING_peer_run ("test-fs-search-persistence",
+                                   "test_fs_search_data.conf",
+                                   &run, NULL))
+    return 1;
   return 0;
 }
 

Modified: gnunet/src/fs/test_fs_search_probes.c
===================================================================
--- gnunet/src/fs/test_fs_search_probes.c       2012-06-15 08:10:52 UTC (rev 
22012)
+++ gnunet/src/fs/test_fs_search_probes.c       2012-06-15 08:38:53 UTC (rev 
22013)
@@ -25,10 +25,9 @@
  */
 #include "platform.h"
 #include "gnunet_util_lib.h"
-#include "gnunet_arm_service.h"
+#include "gnunet_testing_lib-new.h"
 #include "gnunet_fs_service.h"
 
-#define START_ARM GNUNET_YES
 
 /**
  * File-size we use for testing.
@@ -45,17 +44,7 @@
  */
 #define LIFETIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15)
 
-struct PeerContext
-{
-  struct GNUNET_CONFIGURATION_Handle *cfg;
-  struct GNUNET_PeerIdentity id;
-#if START_ARM
-  struct GNUNET_OS_Process *arm_proc;
-#endif
-};
 
-static struct PeerContext p1;
-
 static struct GNUNET_TIME_Absolute start;
 
 static struct GNUNET_FS_Handle *fs;
@@ -166,41 +155,7 @@
 
 
 static void
-setup_peer (struct PeerContext *p, const char *cfgname)
-{
-  p->cfg = GNUNET_CONFIGURATION_create ();
-#if START_ARM
-  p->arm_proc =
-      GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
-                               "gnunet-service-arm",
-                               "-c", cfgname, NULL);
-#endif
-  GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
-}
-
-
-static void
-stop_arm (struct PeerContext *p)
-{
-#if START_ARM
-  if (NULL != p->arm_proc)
-  {
-    if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
-      GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
-    if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK)
-      GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n",
-                GNUNET_OS_process_get_pid (p->arm_proc));
-    GNUNET_OS_process_destroy (p->arm_proc);
-    p->arm_proc = NULL;
-  }
-#endif
-  GNUNET_CONFIGURATION_destroy (p->cfg);
-}
-
-
-static void
-run (void *cls, char *const *args, const char *cfgfile,
+run (void *cls,
      const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   const char *keywords[] = {
@@ -214,7 +169,6 @@
   struct GNUNET_FS_FileInformation *fi;
   size_t i;
 
-  setup_peer (&p1, "test_fs_search_data.conf");
   fs = GNUNET_FS_start (cfg, "test-fs-search", &progress_cb, NULL,
                         GNUNET_FS_FLAGS_DO_PROBES, 
                        GNUNET_FS_OPTIONS_END);
@@ -245,23 +199,10 @@
 int
 main (int argc, char *argv[])
 {
-  char *const argvx[] = {
-    "test-fs-search-probes",
-    "-c",
-    "test_fs_search_data.conf",
-    NULL
-  };
-  struct GNUNET_GETOPT_CommandLineOption options[] = {
-    GNUNET_GETOPT_OPTION_END
-  };
-
-  GNUNET_log_setup ("test_fs_search_probes",
-                    "WARNING",
-                    NULL);
-  GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx,
-                      "test-fs-search", "nohelp", options, &run, NULL);
-  stop_arm (&p1);
-  GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-search/");
+  if (0 != GNUNET_TESTING_peer_run ("test-fs-search-probes",
+                                   "test_fs_search_data.conf",
+                                   &run, NULL))
+    return 1;
   return 0;
 }
 

Modified: gnunet/src/fs/test_fs_start_stop.c
===================================================================
--- gnunet/src/fs/test_fs_start_stop.c  2012-06-15 08:10:52 UTC (rev 22012)
+++ gnunet/src/fs/test_fs_start_stop.c  2012-06-15 08:38:53 UTC (rev 22013)
@@ -17,7 +17,6 @@
      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
      Boston, MA 02111-1307, USA.
 */
-
 /**
  * @file fs/test_fs_start_stop.c
  * @brief testcase for fs.c (start-stop only)
@@ -26,24 +25,10 @@
 
 #include "platform.h"
 #include "gnunet_util_lib.h"
-#include "gnunet_arm_service.h"
+#include "gnunet_testing_lib-new.h"
 #include "gnunet_fs_service.h"
 
-#define VERBOSE GNUNET_NO
 
-#define START_ARM GNUNET_YES
-
-static struct PeerContext p1;
-
-struct PeerContext
-{
-  struct GNUNET_CONFIGURATION_Handle *cfg;
-#if START_ARM
-  struct GNUNET_OS_Process *arm_proc;
-#endif
-};
-
-
 static void *
 progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
 {
@@ -52,49 +37,11 @@
 
 
 static void
-setup_peer (struct PeerContext *p, const char *cfgname)
-{
-  p->cfg = GNUNET_CONFIGURATION_create ();
-#if START_ARM
-  p->arm_proc =
-      GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
-                               "gnunet-service-arm",
-#if VERBOSE
-                               "-L", "DEBUG",
-#endif
-                               "-c", cfgname, NULL);
-#endif
-  GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
-}
-
-
-static void
-stop_arm (struct PeerContext *p)
-{
-#if START_ARM
-  if (NULL != p->arm_proc)
-  {
-    if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
-      GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
-    if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK)
-      GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n",
-                GNUNET_OS_process_get_pid (p->arm_proc));
-    GNUNET_OS_process_destroy (p->arm_proc);
-    p->arm_proc = NULL;
-  }
-#endif
-  GNUNET_CONFIGURATION_destroy (p->cfg);
-}
-
-
-static void
-run (void *cls, char *const *args, const char *cfgfile,
+run (void *cls, 
      const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   struct GNUNET_FS_Handle *fs;
 
-  setup_peer (&p1, "test_fs_data.conf");
   fs = GNUNET_FS_start (cfg, "test-fs-start-stop", &progress_cb, NULL,
                         GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END);
   GNUNET_assert (NULL != fs);
@@ -105,30 +52,10 @@
 int
 main (int argc, char *argv[])
 {
-  char *const argvx[] = {
-    "test-fs-start-stop",
-    "-c",
-    "test_fs_data.conf",
-#if VERBOSE
-    "-L", "DEBUG",
-#endif
-    NULL
-  };
-  struct GNUNET_GETOPT_CommandLineOption options[] = {
-    GNUNET_GETOPT_OPTION_END
-  };
-
-  GNUNET_log_setup ("test_fs_start_stop",
-#if VERBOSE
-                    "DEBUG",
-#else
-                    "WARNING",
-#endif
-                    NULL);
-  GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx,
-                      "test-fs-start-stop", "nohelp", options, &run, NULL);
-  stop_arm (&p1);
-  GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs/");
+  if (0 != GNUNET_TESTING_peer_run ("test-fs-start-stop",
+                                   "test_fs_data.conf",
+                                   &run, NULL))
+    return 1;
   return 0;
 }
 

Modified: gnunet/src/fs/test_fs_uri.c
===================================================================
--- gnunet/src/fs/test_fs_uri.c 2012-06-15 08:10:52 UTC (rev 22012)
+++ gnunet/src/fs/test_fs_uri.c 2012-06-15 08:38:53 UTC (rev 22013)
@@ -17,19 +17,16 @@
      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
      Boston, MA 02111-1307, USA.
 */
-
 /**
  * @file fs/test_fs_uri.c
  * @brief Test for fs_uri.c
  * @author Christian Grothoff
  */
-
 #include "platform.h"
 #include "gnunet_util_lib.h"
 #include "gnunet_fs_service.h"
 #include "fs_api.h"
 
-#define ABORT() { fprintf(stderr, "Error at %s:%d\n", __FILE__, __LINE__); 
return 1; }
 
 static int
 testKeyword ()
@@ -41,26 +38,26 @@
   if (NULL != (ret = GNUNET_FS_uri_parse ("gnunet://fs/ksk/++", &emsg)))
   {
     GNUNET_FS_uri_destroy (ret);
-    ABORT ();
+    GNUNET_assert (0);
   }
   GNUNET_free (emsg);
   ret = GNUNET_FS_uri_parse ("gnunet://fs/ksk/foo+bar", &emsg);
   if (ret == NULL)
   {
     GNUNET_free (emsg);
-    ABORT ();
+    GNUNET_assert (0);
   }
   if (!GNUNET_FS_uri_test_ksk (ret))
   {
     GNUNET_FS_uri_destroy (ret);
-    ABORT ();
+    GNUNET_assert (0);
   }
   if ((2 != ret->data.ksk.keywordCount) ||
       (0 != strcmp (" foo", ret->data.ksk.keywords[0])) ||
       (0 != strcmp (" bar", ret->data.ksk.keywords[1])))
   {
     GNUNET_FS_uri_destroy (ret);
-    ABORT ();
+    GNUNET_assert (0);
   }
 
   uri = GNUNET_FS_uri_to_string (ret);
@@ -68,13 +65,14 @@
   {
     GNUNET_free (uri);
     GNUNET_FS_uri_destroy (ret);
-    ABORT ();
+    GNUNET_assert (0);
   }
   GNUNET_free (uri);
   GNUNET_FS_uri_destroy (ret);
   return 0;
 }
 
+
 static int
 testLocation ()
 {
@@ -157,6 +155,7 @@
   return 0;
 }
 
+
 static int
 testNamespace (int i)
 {
@@ -170,7 +169,7 @@
                             &emsg)))
   {
     GNUNET_FS_uri_destroy (ret);
-    ABORT ();
+    GNUNET_assert (0);
   }
   GNUNET_free (emsg);
   if (NULL !=
@@ -179,13 +178,13 @@
        ("gnunet://fs/sks/D1KJS9H2A82Q65VKQ0ML3RFU6U1D3V/test", &emsg)))
   {
     GNUNET_FS_uri_destroy (ret);
-    ABORT ();
+    GNUNET_assert (0);
   }
   GNUNET_free (emsg);
   if (NULL != (ret = GNUNET_FS_uri_parse ("gnunet://fs/sks/test", &emsg)))
   {
     GNUNET_FS_uri_destroy (ret);
-    ABORT ();
+    GNUNET_assert (0);
   }
   GNUNET_free (emsg);
   ret =
@@ -195,17 +194,17 @@
   if (ret == NULL)
   {
     GNUNET_free (emsg);
-    ABORT ();
+    GNUNET_assert (0);
   }
   if (GNUNET_FS_uri_test_ksk (ret))
   {
     GNUNET_FS_uri_destroy (ret);
-    ABORT ();
+    GNUNET_assert (0);
   }
   if (!GNUNET_FS_uri_test_sks (ret))
   {
     GNUNET_FS_uri_destroy (ret);
-    ABORT ();
+    GNUNET_assert (0);
   }
 
   uri = GNUNET_FS_uri_to_string (ret);
@@ -215,7 +214,7 @@
   {
     GNUNET_FS_uri_destroy (ret);
     GNUNET_free (uri);
-    ABORT ();
+    GNUNET_assert (0);
   }
   GNUNET_free (uri);
   GNUNET_FS_uri_destroy (ret);
@@ -236,7 +235,7 @@
         &emsg)))
   {
     GNUNET_FS_uri_destroy (ret);
-    ABORT ();
+    GNUNET_assert (0);
   }
   GNUNET_free (emsg);
   if (NULL !=
@@ -246,7 +245,7 @@
         &emsg)))
   {
     GNUNET_FS_uri_destroy (ret);
-    ABORT ();
+    GNUNET_assert (0);
   }
   GNUNET_free (emsg);
   if (NULL !=
@@ -256,7 +255,7 @@
         &emsg)))
   {
     GNUNET_FS_uri_destroy (ret);
-    ABORT ();
+    GNUNET_assert (0);
   }
   GNUNET_free (emsg);
   ret =
@@ -266,22 +265,22 @@
   if (ret == NULL)
   {
     GNUNET_free (emsg);
-    ABORT ();
+    GNUNET_assert (0);
   }
   if (GNUNET_FS_uri_test_ksk (ret))
   {
     GNUNET_FS_uri_destroy (ret);
-    ABORT ();
+    GNUNET_assert (0);
   }
   if (GNUNET_FS_uri_test_sks (ret))
   {
     GNUNET_FS_uri_destroy (ret);
-    ABORT ();
+    GNUNET_assert (0);
   }
   if (GNUNET_ntohll (ret->data.chk.file_length) != 42)
   {
     GNUNET_FS_uri_destroy (ret);
-    ABORT ();
+    GNUNET_assert (0);
   }
 
   uri = GNUNET_FS_uri_to_string (ret);
@@ -291,13 +290,14 @@
   {
     GNUNET_free (uri);
     GNUNET_FS_uri_destroy (ret);
-    ABORT ();
+    GNUNET_assert (0);
   }
   GNUNET_free (uri);
   GNUNET_FS_uri_destroy (ret);
   return 0;
 }
 
+
 int
 main (int argc, char *argv[])
 {
@@ -305,11 +305,7 @@
   int i;
 
   GNUNET_log_setup ("test_fs_uri",
-#if VERBOSE
-                    "DEBUG",
-#else
                     "WARNING",
-#endif
                     NULL);
   GNUNET_CRYPTO_random_disable_entropy_gathering ();
   failureCount += testKeyword ();




reply via email to

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