gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r9251 - gnunet/src/fs
Date: Fri, 23 Oct 2009 04:54:27 -0600

Author: grothoff
Date: 2009-10-23 04:54:26 -0600 (Fri, 23 Oct 2009)
New Revision: 9251

Added:
   gnunet/src/fs/test_fs_data.conf
   gnunet/src/fs/test_fs_namespace.c
Removed:
   gnunet/src/fs/test_namespace.c
Modified:
   gnunet/src/fs/
   gnunet/src/fs/Makefile.am
   gnunet/src/fs/fs_download.c
   gnunet/src/fs/fs_search.c
   gnunet/src/fs/gnunet-service-fs.c
   gnunet/src/fs/test_fs_download.c
   gnunet/src/fs/test_fs_download_data.conf
   gnunet/src/fs/test_fs_search.c
   gnunet/src/fs/test_fs_search_data.conf
   gnunet/src/fs/test_fs_start_stop.c
Log:
hacking on fs


Property changes on: gnunet/src/fs
___________________________________________________________________
Modified: svn:ignore
   - test_fs_download
test_fs_uri.gcno
test_fs_uri.gcda
test_fs_getopt.gcno
test_fs_directory.gcno
test_fs_directory.gcda
test_fs_collection.gcno
gnunet-unindex.gcno
gnunet-service-fs.gcno
gnunet-search.gcno
gnunet-publish.gcno
gnunet-pseudonym.gcno
gnunet-download.gcno
gnunet-directory.gcno
fs_uri.gcno
fs_uri.gcda
fs_unindex.gcno
fs_unindex.gcda
fs_tree.gcno
fs_tree.gcda
fs_search.gcno
fs_search.gcda
fs_publish.gcno
fs_publish.gcda
fs_namespace.gcno
fs_namespace.gcda
fs_list_indexed.gcno
fs_list_indexed.gcda
fs_getopt.gcno
fs_getopt.gcda
fs_file_information.gcno
fs_file_information.gcda
fs_download.gcno
fs_download.gcda
fs_directory.gcno
fs_directory.gcda
fs_collection.gcno
fs_collection.gcda
fs.gcno
fs.gcda
test_fs_uri
test_fs_getopt
test_fs_directory
test_fs_collection
gnunet-service-fs
gnunet-pseudonym
gnunet-directory
gnunet-unindex
gnunet-search
gnunet-download
gnunet-publish
Makefile.in
Makefile
.deps

   + test_fs_start_stop
test_fs_search
test_fs_download
test_fs_uri.gcno
test_fs_uri.gcda
test_fs_getopt.gcno
test_fs_directory.gcno
test_fs_directory.gcda
test_fs_collection.gcno
gnunet-unindex.gcno
gnunet-service-fs.gcno
gnunet-search.gcno
gnunet-publish.gcno
gnunet-pseudonym.gcno
gnunet-download.gcno
gnunet-directory.gcno
fs_uri.gcno
fs_uri.gcda
fs_unindex.gcno
fs_unindex.gcda
fs_tree.gcno
fs_tree.gcda
fs_search.gcno
fs_search.gcda
fs_publish.gcno
fs_publish.gcda
fs_namespace.gcno
fs_namespace.gcda
fs_list_indexed.gcno
fs_list_indexed.gcda
fs_getopt.gcno
fs_getopt.gcda
fs_file_information.gcno
fs_file_information.gcda
fs_download.gcno
fs_download.gcda
fs_directory.gcno
fs_directory.gcda
fs_collection.gcno
fs_collection.gcda
fs.gcno
fs.gcda
test_fs_uri
test_fs_getopt
test_fs_directory
test_fs_collection
gnunet-service-fs
gnunet-pseudonym
gnunet-directory
gnunet-unindex
gnunet-search
gnunet-download
gnunet-publish
Makefile.in
Makefile
.deps


Modified: gnunet/src/fs/Makefile.am
===================================================================
--- gnunet/src/fs/Makefile.am   2009-10-23 01:17:43 UTC (rev 9250)
+++ gnunet/src/fs/Makefile.am   2009-10-23 10:54:26 UTC (rev 9251)
@@ -1,3 +1,4 @@
+
 INCLUDES = -I$(top_srcdir)/src/include
 
 if MINGW
@@ -106,11 +107,17 @@
  test_fs_directory \
  test_fs_download \
  test_fs_getopt \
+ test_fs_namespace \
  test_fs_search \
+ test_fs_start_stop \
  test_fs_uri
 
-TESTS = test_fs_directory test_fs_download test_fs_uri
-
+TESTS = \
+ test_fs_directory \
+ test_fs_download \
+ test_fs_search \
+ test_fs_start_stop \
+ test_fs_uri
 # $(check_PROGRAMS)
 
 test_fs_collection_SOURCES = \
@@ -132,9 +139,22 @@
   $(top_builddir)/src/arm/libgnunetarm.la  \
   $(top_builddir)/src/util/libgnunetutil.la  
 
+test_fs_namespace_SOURCES = \
+ test_fs_namespace.c
+test_fs_namespace_LDADD = \
+  $(top_builddir)/src/fs/libgnunetfs.la  \
+  $(top_builddir)/src/arm/libgnunetarm.la  \
+  $(top_builddir)/src/util/libgnunetutil.la  
+
 test_fs_search_SOURCES = \
  test_fs_search.c
-test_fs_search_LDADD = \
+test_fs_search_LDADD = $(top_builddir)/src/fs/libgnunetfs.la   \
+  $(top_builddir)/src/arm/libgnunetarm.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/fs/libgnunetfs.la  \
   $(top_builddir)/src/arm/libgnunetarm.la  \
   $(top_builddir)/src/util/libgnunetutil.la  
@@ -152,6 +172,9 @@
   $(top_builddir)/src/util/libgnunetutil.la  
 
 EXTRA_DIST = \
+  test_fs_data.conf \
   test_fs_collection_data.conf \
   test_fs_download_data.conf \
+  test_fs_namespace_data.conf \
+  test_fs_search_data.conf \
   test_fs_uri_data.conf

Modified: gnunet/src/fs/fs_download.c
===================================================================
--- gnunet/src/fs/fs_download.c 2009-10-23 01:17:43 UTC (rev 9250)
+++ gnunet/src/fs/fs_download.c 2009-10-23 10:54:26 UTC (rev 9251)
@@ -36,7 +36,7 @@
 #include "fs.h"
 #include "fs_tree.h"
 
-#define DEBUG_DOWNLOAD GNUNET_YES
+#define DEBUG_DOWNLOAD GNUNET_NO
 
 /**
  * We're storing the IBLOCKS after the

Modified: gnunet/src/fs/fs_search.c
===================================================================
--- gnunet/src/fs/fs_search.c   2009-10-23 01:17:43 UTC (rev 9250)
+++ gnunet/src/fs/fs_search.c   2009-10-23 10:54:26 UTC (rev 9251)
@@ -208,7 +208,7 @@
   int is_new;
 
   /* check if new */
-  if (! GNUNET_FS_uri_test_ksk (uri))
+  if (! GNUNET_FS_uri_test_chk (uri))
     {
       GNUNET_break_op (0);
       return;
@@ -380,7 +380,7 @@
     }
   /* decrypt */
   GNUNET_CRYPTO_hash_to_aes_key (&sc->requests[i].key, &skey, &iv);
-  GNUNET_CRYPTO_aes_encrypt (&kb[1],
+  GNUNET_CRYPTO_aes_decrypt (&kb[1],
                             size - sizeof (struct KBlock),
                             &skey,
                             &iv,

Modified: gnunet/src/fs/gnunet-service-fs.c
===================================================================
--- gnunet/src/fs/gnunet-service-fs.c   2009-10-23 01:17:43 UTC (rev 9250)
+++ gnunet/src/fs/gnunet-service-fs.c   2009-10-23 10:54:26 UTC (rev 9251)
@@ -47,7 +47,7 @@
 #include "gnunet_util_lib.h"
 #include "fs.h"
 
-#define DEBUG_FS GNUNET_YES
+#define DEBUG_FS GNUNET_NO
 
 
 /**

Added: gnunet/src/fs/test_fs_data.conf
===================================================================
--- gnunet/src/fs/test_fs_data.conf                             (rev 0)
+++ gnunet/src/fs/test_fs_data.conf     2009-10-23 10:54:26 UTC (rev 9251)
@@ -0,0 +1,42 @@
+[PATHS]
+SERVICEHOME = /tmp/gnunet-test-fs/
+DEFAULTCONFIG = test_fs_data.conf
+
+[gnunetd]
+HOSTKEY = $SERVICEHOME/.hostkey
+
+[resolver]
+PORT = 42464
+HOSTNAME = localhost
+
+[transport]
+PORT = 42465
+PLUGINS = 
+
+[arm]
+PORT = 42466
+HOSTNAME = localhost
+DEFAULTSERVICES = resolver datastore transport core fs
+
+[datastore]
+#DEBUG = YES
+
+[statistics]
+PORT = 42467
+HOSTNAME = localhost
+
+[peerinfo]
+PORT = 42469
+HOSTNAME = localhost
+
+[core]
+PORT = 42470
+HOSTNAME = localhost
+
+[fs]
+PORT = 42471
+HOSTNAME = localhost
+#DEBUG = YES
+
+[testing]
+WEAKRANDOM = YES

Modified: gnunet/src/fs/test_fs_download.c
===================================================================
--- gnunet/src/fs/test_fs_download.c    2009-10-23 01:17:43 UTC (rev 9250)
+++ gnunet/src/fs/test_fs_download.c    2009-10-23 10:54:26 UTC (rev 9251)
@@ -29,7 +29,7 @@
 #include "gnunet_arm_service.h"
 #include "gnunet_fs_service.h"
 
-#define VERBOSE GNUNET_YES
+#define VERBOSE GNUNET_NO
 
 #define START_ARM GNUNET_YES
 
@@ -324,6 +324,7 @@
                       argvx, "test-fs-download",
                      "nohelp", options, &run, NULL);
   stop_arm (&p1);
+  GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-download/");
   return 0;
 }
 

Modified: gnunet/src/fs/test_fs_download_data.conf
===================================================================
--- gnunet/src/fs/test_fs_download_data.conf    2009-10-23 01:17:43 UTC (rev 
9250)
+++ gnunet/src/fs/test_fs_download_data.conf    2009-10-23 10:54:26 UTC (rev 
9251)
@@ -19,7 +19,7 @@
 DEFAULTSERVICES = resolver datastore transport core fs
 
 [datastore]
-DEBUG = YES
+#DEBUG = YES
 
 [statistics]
 PORT = 42467
@@ -36,7 +36,7 @@
 [fs]
 PORT = 42471
 HOSTNAME = localhost
-DEBUG = YES
+#DEBUG = YES
 
 [testing]
 WEAKRANDOM = YES

Copied: gnunet/src/fs/test_fs_namespace.c (from rev 9250, 
gnunet/src/fs/test_namespace.c)
===================================================================
--- gnunet/src/fs/test_fs_namespace.c                           (rev 0)
+++ gnunet/src/fs/test_fs_namespace.c   2009-10-23 10:54:26 UTC (rev 9251)
@@ -0,0 +1,214 @@
+/*
+     This file is part of GNUnet.
+     (C) 2005, 2006, 2008, 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 fs/test_fs_namespace.c
+ * @brief Test for fs_namespace.c
+ * @author Christian Grothoff
+ */
+
+#include "platform.h"
+#include "gnunet_util_lib.h"
+#include "gnunet_arm_service.h"
+#include "gnunet_fs_service.h"
+
+#define START_ARM GNUNET_YES
+
+static struct GNUNET_SCHEDULER_Handle *sched;
+
+static struct PeerContext p1;
+
+static struct GNUNET_FS_Handle *fs;
+
+
+struct PeerContext
+{
+  struct GNUNET_CONFIGURATION_Handle *cfg;
+  struct GNUNET_PeerIdentity id;   
+#if START_ARM
+  pid_t arm_pid;
+#endif
+};
+
+
+static void *
+progress_cb (void *cls, 
+            const struct GNUNET_FS_ProgressInfo *event)
+{
+  return NULL;
+}
+
+
+static void
+setup_peer (struct PeerContext *p, const char *cfgname)
+{
+  p->cfg = GNUNET_CONFIGURATION_create ();
+#if START_ARM
+  p->arm_pid = GNUNET_OS_start_process ("gnunet-service-arm",
+                                        "gnunet-service-arm",
+#if VERBOSE
+                                        "-L", "DEBUG",
+#endif
+                                        "-c", cfgname, NULL);
+  sleep (1);                    /* allow ARM to start */
+#endif
+  GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
+  GNUNET_ARM_start_services (p->cfg, sched, "core", NULL);
+}
+
+
+static void
+stop_arm (struct PeerContext *p)
+{
+#if START_ARM
+  if (0 != PLIBC_KILL (p->arm_pid, SIGTERM))
+    GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
+  if (GNUNET_OS_process_wait(p->arm_pid) != GNUNET_OK)
+    GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "ARM process %u stopped\n", p->arm_pid);
+#endif
+  GNUNET_CONFIGURATION_destroy (p->cfg);
+}
+
+
+static void
+spcb (void *cls,
+      const char *name,
+      const GNUNET_HashCode * key)
+{
+}
+
+
+static void
+publish_cont (void *cls,
+             const struct GNUNET_FS_Uri *uri,
+             const char *emsg)
+{
+  struct GNUNET_FS_SearchContext *search;
+
+  GNUNET_assert (NULL == emsg);
+  fprintf (stderr, "Starting namespace search...\n");
+  search = GNUNET_FS_search_start (fs, uri, 1);
+}
+
+
+static void
+testNamespace ()
+{
+  struct GNUNET_FS_Namespace *ns;
+  struct GNUNET_FS_Uri *adv;
+  struct GNUNET_FS_Uri *rootUri;
+  struct GNUNET_CONTAINER_MetaData *meta;
+  struct GNUNET_TIME_Absolute expiration;
+
+  expiration = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES);
+  meta = GNUNET_CONTAINER_meta_data_create ();
+  adv = GNUNET_FS_uri_ksk_create ("testNamespace", NULL);
+  ns = GNUNET_FS_namespace_create (fs,
+                                  "testNamespace");
+  rootUri = GNUNET_FS_namespace_advertise (fs,
+                                          ns,
+                                          meta,
+                                          1, 1,
+                                          expiration,
+                                          adv,
+                                          "root");
+  GNUNET_assert (NULL != rootUri);
+  GNUNET_FS_publish_sks (fs,
+                        ns,
+                        "this",
+                        "next",
+                        meta,
+                        rootUri,
+                        expiration,
+                        1, 1,
+                        GNUNET_FS_PUBLISH_OPTION_NONE,
+                        &publish_cont,
+                        NULL);
+  GNUNET_CONTAINER_meta_data_destroy (meta);
+}
+
+#if 0
+  fprintf (stderr, "Completed namespace search...\n");
+  GNUNET_assert (GNUNET_OK == GNUNET_FS_namespace_delete (NULL, cfg, &pid));
+  GNUNET_assert (GNUNET_SYSERR == GNUNET_FS_namespace_delete (NULL, cfg, 
&pid));
+  GNUNET_FS_uri_destroy (rootURI);
+  GNUNET_FS_uri_destroy (advURI);
+  GNUNET_assert (match == 1);
+  return 0;
+}
+#endif
+
+
+static void
+run (void *cls,
+     struct GNUNET_SCHEDULER_Handle *s,
+     char *const *args,
+     const char *cfgfile,
+     const struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+  sched = s;
+  setup_peer (&p1, "test_fs_download_data.conf");
+  fs = GNUNET_FS_start (sched,
+                       cfg,
+                       "test-fs-namespace",
+                       &progress_cb,
+                       NULL,
+                       GNUNET_FS_FLAGS_NONE,
+                       GNUNET_FS_OPTIONS_END);
+  testNamespace ();
+}
+
+
+int
+main (int argc, char *argv[])
+{
+  char *const argvx[] = { 
+    "test-fs-namespace",
+    "-c",
+    "test_fs_namespace_data.conf",
+#if VERBOSE
+    "-L", "DEBUG",
+#endif
+    NULL
+  };
+  struct GNUNET_GETOPT_CommandLineOption options[] = {
+    GNUNET_GETOPT_OPTION_END
+  };
+
+  GNUNET_log_setup ("test_fs_namespace", 
+#if VERBOSE
+                   "DEBUG",
+#else
+                   "WARNING",
+#endif
+                   NULL);
+  GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1,
+                      argvx, "test-fs-namespace",
+                     "nohelp", options, &run, NULL);
+  stop_arm (&p1);
+  GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-namespace/");
+  return 0;
+}
+
+
+
+/* end of test_fs_namespace.c */

Modified: gnunet/src/fs/test_fs_search.c
===================================================================
--- gnunet/src/fs/test_fs_search.c      2009-10-23 01:17:43 UTC (rev 9250)
+++ gnunet/src/fs/test_fs_search.c      2009-10-23 10:54:26 UTC (rev 9251)
@@ -29,7 +29,7 @@
 #include "gnunet_arm_service.h"
 #include "gnunet_fs_service.h"
 
-#define VERBOSE GNUNET_YES
+#define VERBOSE GNUNET_NO
 
 #define START_ARM GNUNET_YES
 
@@ -83,7 +83,8 @@
 abort_search_task (void *cls,
                     const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
-  GNUNET_FS_search_stop (search);
+  if (search != NULL)
+    GNUNET_FS_search_stop (search);
   search = NULL;
 }
 
@@ -118,7 +119,9 @@
       GNUNET_assert (search != NULL);
       break;
     case GNUNET_FS_STATUS_SEARCH_RESULT:
+#if VERBOSE
       printf ("Search complete.\n");
+#endif
       GNUNET_SCHEDULER_add_continuation (sched,
                                         GNUNET_NO,
                                         &abort_search_task,
@@ -165,6 +168,8 @@
       //  GNUNET_assert (0 == strcmp ("search", event->value.search.cctx));
       GNUNET_assert (1 == event->value.search.anonymity);
       break;
+    case GNUNET_FS_STATUS_SEARCH_RESULT_STOPPED:
+      break;
     case GNUNET_FS_STATUS_SEARCH_STOPPED:
       GNUNET_assert (search == event->value.search.sc);
       GNUNET_SCHEDULER_add_continuation (sched,
@@ -174,8 +179,9 @@
                                         GNUNET_SCHEDULER_REASON_PREREQ_DONE);
       break;
     default:
-      printf ("Unexpected event: %d\n", 
-             event->status);
+      fprintf (stderr,
+              "Unexpected event: %d\n", 
+              event->status);
       break;
     }
   return NULL;
@@ -295,6 +301,7 @@
                       argvx, "test-fs-search",
                      "nohelp", options, &run, NULL);
   stop_arm (&p1);
+  GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-search/");
   return 0;
 }
 

Modified: gnunet/src/fs/test_fs_search_data.conf
===================================================================
--- gnunet/src/fs/test_fs_search_data.conf      2009-10-23 01:17:43 UTC (rev 
9250)
+++ gnunet/src/fs/test_fs_search_data.conf      2009-10-23 10:54:26 UTC (rev 
9251)
@@ -1,5 +1,5 @@
 [PATHS]
-SERVICEHOME = /tmp/gnunet-test-fs-download/
+SERVICEHOME = /tmp/gnunet-test-fs-search/
 DEFAULTCONFIG = test_fs_download_data.conf
 
 [gnunetd]

Modified: gnunet/src/fs/test_fs_start_stop.c
===================================================================
--- gnunet/src/fs/test_fs_start_stop.c  2009-10-23 01:17:43 UTC (rev 9250)
+++ gnunet/src/fs/test_fs_start_stop.c  2009-10-23 10:54:26 UTC (rev 9251)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2004, 2005, 2006 Christian Grothoff (and other contributing authors)
+     (C) 2004, 2005, 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
@@ -19,71 +19,125 @@
 */
 
 /**
- * @file applications/fs/fsui/fsui_start_stop_test.c
- * @brief testcase for fsui (start-stop only)
+ * @file fs/test_fs_start_stop.c
+ * @brief testcase for fs.c (start-stop only)
  * @author Christian Grothoff
  */
 
 #include "platform.h"
-#include "gnunet_util.h"
-#include "gnunet_fsui_lib.h"
+#include "gnunet_util_lib.h"
+#include "gnunet_arm_service.h"
+#include "gnunet_fs_service.h"
 
-#define CHECK(a) if (!(a)) { ok = GNUNET_NO; GNUNET_GE_BREAK(NULL, 0); goto 
FAILURE; }
+#define START_ARM GNUNET_YES
 
+static struct GNUNET_SCHEDULER_Handle *sched;
 
-static struct GNUNET_FSUI_Context *ctx;
+static struct PeerContext p1;
 
+struct PeerContext
+{
+  struct GNUNET_CONFIGURATION_Handle *cfg;
+  struct GNUNET_PeerIdentity id;   
+#if START_ARM
+  pid_t arm_pid;
+#endif
+};
+
+
 static void *
-eventCallback (void *cls, const GNUNET_FSUI_Event * event)
+progress_cb (void *cls, 
+            const struct GNUNET_FS_ProgressInfo *event)
 {
   return NULL;
 }
 
-#define START_DAEMON 1
 
-int
-main (int argc, char *argv[])
+static void
+setup_peer (struct PeerContext *p, const char *cfgname)
 {
-#if START_DAEMON
-  pid_t daemon;
+  p->cfg = GNUNET_CONFIGURATION_create ();
+#if START_ARM
+  p->arm_pid = GNUNET_OS_start_process ("gnunet-service-arm",
+                                        "gnunet-service-arm",
+#if VERBOSE
+                                        "-L", "DEBUG",
 #endif
-  int ok;
-  struct GNUNET_GC_Configuration *cfg;
+                                        "-c", cfgname, NULL);
+  sleep (1);                    /* allow ARM to start */
+#endif
+  GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
+  GNUNET_ARM_start_services (p->cfg, sched, "core", NULL);
+}
 
-  cfg = GNUNET_GC_create ();
-  if (-1 == GNUNET_GC_parse_configuration (cfg, "check.conf"))
-    {
-      GNUNET_GC_free (cfg);
-      return -1;
-    }
-#if START_DAEMON
-  daemon = GNUNET_daemon_start (NULL, cfg, "peer.conf", GNUNET_NO);
-  GNUNET_GE_ASSERT (NULL, daemon > 0);
-  CHECK (GNUNET_OK ==
-         GNUNET_wait_for_daemon_running (NULL, cfg,
-                                         60 * GNUNET_CRON_SECONDS));
+
+static void
+stop_arm (struct PeerContext *p)
+{
+#if START_ARM
+  if (0 != PLIBC_KILL (p->arm_pid, SIGTERM))
+    GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
+  if (GNUNET_OS_process_wait(p->arm_pid) != GNUNET_OK)
+    GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "ARM process %u stopped\n", p->arm_pid);
 #endif
-  ok = GNUNET_YES;
-  GNUNET_thread_sleep (5 * GNUNET_CRON_SECONDS);        /* give apps time to 
start */
+  GNUNET_CONFIGURATION_destroy (p->cfg);
+}
 
-  /* ACTUAL TEST CODE */
-  ctx = GNUNET_FSUI_start (NULL, cfg, "fsui_start_stop_test", 32, GNUNET_YES,  
 /* do resume! */
-                           &eventCallback, NULL);
-  CHECK (ctx != NULL);
-  GNUNET_FSUI_stop (ctx);
-  ctx =
-    GNUNET_FSUI_start (NULL, cfg, "fsui_start_stop_test", 32, GNUNET_YES,
-                       &eventCallback, NULL);
-  CHECK (ctx != NULL);
-FAILURE:
-  if (ctx != NULL)
-    GNUNET_FSUI_stop (ctx);
-#if START_DAEMON
-  GNUNET_GE_ASSERT (NULL, GNUNET_OK == GNUNET_daemon_stop (NULL, daemon));
+
+static void
+run (void *cls,
+     struct GNUNET_SCHEDULER_Handle *s,
+     char *const *args,
+     const char *cfgfile,
+     const struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+  struct GNUNET_FS_Handle *fs;
+
+  sched = s;
+  setup_peer (&p1, "test_fs_data.conf");
+  fs = GNUNET_FS_start (sched,
+                       cfg,
+                       "test-fs-start-stop",
+                       &progress_cb,
+                       NULL,
+                       GNUNET_FS_FLAGS_NONE,
+                       GNUNET_FS_OPTIONS_END);
+  GNUNET_assert (NULL != fs); 
+  GNUNET_FS_stop (fs);
+}
+
+
+int
+main (int argc, char *argv[])
+{
+  char *const argvx[] = { 
+    "test-fs-start-stop",
+    "-c",
+    "test_fs_data.conf",
+#if VERBOSE
+    "-L", "DEBUG",
 #endif
-  GNUNET_GC_free (cfg);
+    NULL
+  };
+  struct GNUNET_GETOPT_CommandLineOption options[] = {
+    GNUNET_GETOPT_OPTION_END
+  };
 
-  return (ok == GNUNET_YES) ? 0 : 1;
+  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/");
+  return 0;
 }
 
-/* end of fsui_start_stop_test.c */
+/* end of test_fs_start_stop.c */

Deleted: gnunet/src/fs/test_namespace.c
===================================================================
--- gnunet/src/fs/test_namespace.c      2009-10-23 01:17:43 UTC (rev 9250)
+++ gnunet/src/fs/test_namespace.c      2009-10-23 10:54:26 UTC (rev 9251)
@@ -1,136 +0,0 @@
-/*
-     This file is part of GNUnet.
-     (C) 2005, 2006, 2008 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 applications/fs/ecrs/namespacetest.c
- * @brief Test for namespace.c
- * @author Christian Grothoff
- */
-
-#include "platform.h"
-#include "gnunet_util.h"
-#include "gnunet_ecrs_lib.h"
-#include "ecrs.h"
-
-#define ABORT() { fprintf(stderr, "Error at %s:%d\n", __FILE__, __LINE__); 
return 1; }
-#define CHECK(c) { do { if (!(c)) ABORT(); } while(0); }
-
-#define CHECKNAME "gnunet-namespace-test"
-
-static struct GNUNET_GC_Configuration *cfg;
-
-static int match;
-
-static int
-spcb (const GNUNET_ECRS_FileInfo * fi,
-      const GNUNET_HashCode * key, int isRoot, void *closure)
-{
-  struct GNUNET_ECRS_URI *want = closure;
-
-  if (GNUNET_ECRS_uri_test_equal (want, fi->uri))
-    match = 1;
-  else
-    fprintf (stderr,
-             "Namespace search returned unexpected result: \nHAVE: %s\nWANT: 
%s...\n",
-             GNUNET_ECRS_uri_to_string (fi->uri),
-             GNUNET_ECRS_uri_to_string (want));
-  return GNUNET_OK;
-}
-
-static int
-tt (void *unused)
-{
-  if (match == 1)
-    return GNUNET_SYSERR;
-  return GNUNET_OK;
-}
-
-static int
-testNamespace ()
-{
-  GNUNET_HashCode pid;
-  struct GNUNET_ECRS_URI *adv;
-  struct GNUNET_ECRS_URI *advURI;
-  struct GNUNET_ECRS_URI *rootURI;
-  struct GNUNET_MetaData *meta;
-
-  meta = GNUNET_meta_data_create ();
-  adv = GNUNET_ECRS_keyword_string_to_uri (NULL, "testNamespace");
-  rootURI =
-    GNUNET_ECRS_namespace_create (NULL,
-                                  cfg,
-                                  meta,
-                                  0, 0,
-                                  GNUNET_get_time () +
-                                  15 * GNUNET_CRON_MINUTES, adv, "root");
-  CHECK (NULL != rootURI);
-  GNUNET_ECRS_uri_get_namespace_from_sks (rootURI, &pid);
-  advURI = GNUNET_ECRS_namespace_add_content (NULL, cfg, &pid, 1,       /* 
anonymity */
-                                              1000,     /* priority */
-                                              5 * GNUNET_CRON_MINUTES +
-                                              GNUNET_get_time (),
-                                              "this", "next", rootURI, meta);
-  CHECK (NULL != advURI);
-  fprintf (stderr, "Starting namespace search...\n");
-  CHECK (GNUNET_OK == GNUNET_ECRS_search (NULL,
-                                          cfg,
-                                          advURI, 1, &spcb, rootURI, &tt,
-                                          NULL));
-  fprintf (stderr, "Completed namespace search...\n");
-  CHECK (GNUNET_OK == GNUNET_ECRS_namespace_delete (NULL, cfg, &pid));
-  CHECK (GNUNET_SYSERR == GNUNET_ECRS_namespace_delete (NULL, cfg, &pid));
-  GNUNET_meta_data_destroy (meta);
-  GNUNET_ECRS_uri_destroy (rootURI);
-  GNUNET_ECRS_uri_destroy (advURI);
-  CHECK (match == 1);
-  return 0;
-}
-
-int
-main (int argc, char *argv[])
-{
-  pid_t daemon;
-  int failureCount = 0;
-
-  GNUNET_disable_entropy_gathering ();
-  cfg = GNUNET_GC_create ();
-  if (-1 == GNUNET_GC_parse_configuration (cfg, "check.conf"))
-    {
-      GNUNET_GC_free (cfg);
-      return -1;
-    }
-  daemon = GNUNET_daemon_start (NULL, cfg, "peer.conf", GNUNET_NO);
-  GNUNET_GE_ASSERT (NULL, daemon > 0);
-  if (GNUNET_OK !=
-      GNUNET_wait_for_daemon_running (NULL, cfg, 60 * GNUNET_CRON_SECONDS))
-    {
-      failureCount++;
-    }
-  else
-    {
-      GNUNET_thread_sleep (5 * GNUNET_CRON_SECONDS);
-      failureCount += testNamespace ();
-    }
-  GNUNET_GE_ASSERT (NULL, GNUNET_OK == GNUNET_daemon_stop (NULL, daemon));
-
-  return (failureCount == 0) ? 0 : 1;
-}
-
-/* end of namespacetest.c */





reply via email to

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