gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r3340 - in GNUnet: . src/applications/fs/ecrs


From: grothoff
Subject: [GNUnet-SVN] r3340 - in GNUnet: . src/applications/fs/ecrs
Date: Sun, 27 Aug 2006 16:38:13 -0700 (PDT)

Author: grothoff
Date: 2006-08-27 16:38:07 -0700 (Sun, 27 Aug 2006)
New Revision: 3340

Added:
   GNUnet/src/applications/fs/ecrs/peer.conf
Modified:
   GNUnet/src/applications/fs/ecrs/Makefile.am
   GNUnet/src/applications/fs/ecrs/check.conf
   GNUnet/src/applications/fs/ecrs/directorytest.c
   GNUnet/src/applications/fs/ecrs/ecrstest.c
   GNUnet/src/applications/fs/ecrs/metatest.c
   GNUnet/src/applications/fs/ecrs/metatest2.c
   GNUnet/src/applications/fs/ecrs/namespacetest.c
   GNUnet/src/applications/fs/ecrs/searchtest.c
   GNUnet/src/applications/fs/ecrs/uritest.c
   GNUnet/todo
Log:
making ecrs test compile

Modified: GNUnet/src/applications/fs/ecrs/Makefile.am
===================================================================
--- GNUnet/src/applications/fs/ecrs/Makefile.am 2006-08-27 22:51:18 UTC (rev 
3339)
+++ GNUnet/src/applications/fs/ecrs/Makefile.am 2006-08-27 23:38:07 UTC (rev 
3340)
@@ -48,6 +48,8 @@
 namespacetest_SOURCES = \
   namespacetest.c 
 namespacetest_LDADD = \
+  $(top_builddir)/src/util/config_impl/libgnunetutil_config.la  \
+  $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la  \
   $(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la 
 
 metatest_SOURCES = \
@@ -64,17 +66,23 @@
 ecrstest_SOURCES = \
   ecrstest.c
 ecrstest_LDADD = \
+  $(top_builddir)/src/util/config_impl/libgnunetutil_config.la  \
+  $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la  \
   $(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la 
 
 searchtest_SOURCES = \
   searchtest.c
 searchtest_LDADD = \
+  $(top_builddir)/src/util/config_impl/libgnunetutil_config.la  \
+  $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la  \
   $(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la 
 
 directorytest_SOURCES = \
   directorytest.c
 directorytest_LDADD = \
+  $(top_builddir)/src/util/config_impl/libgnunetutil_config.la  \
+  $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la  \
   $(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la 
 
 EXTRA_DIST = \
-  check.conf
+  check.conf peer.conf

Modified: GNUnet/src/applications/fs/ecrs/check.conf
===================================================================
--- GNUnet/src/applications/fs/ecrs/check.conf  2006-08-27 22:51:18 UTC (rev 
3339)
+++ GNUnet/src/applications/fs/ecrs/check.conf  2006-08-27 23:38:07 UTC (rev 
3340)
@@ -1,52 +1,12 @@
-# This is the configuration for the GNUnet daemon when running
-# the test in this directory (make check).
+# General settings
+[GNUNET]
+GNUNET_HOME = "/tmp/gnunet-session-test-driver"
+LOGLEVEL = "WARNING"
+LOGFILE = ""
+PROCESS-PRIORITY = "NORMAL"
 
-[GNUNETD]
-GNUNETD_HOME     = /tmp/gnunet-check-ecrs
-# VALGRIND        = 300
-HELLOEXPIRES     = 60
-LOGLEVEL        = NOTHING
-LOGFILE         = $GNUNETD_HOME/logs
-KEEPLOG         = 0
-PIDFILE         = $GNUNETD_HOME/gnunetd.pid
-HOSTS          = $GNUNETD_HOME/data/hosts/
-APPLICATIONS = "fs getoption stats"
-# TRANSPORTS = -- no transports!
-
-[MODULES]
-sqstore = "sqstore_sqlite"
-# you can also use sqstore_mysql here if 
-# that DB is available...
-topology = "topology_default"
-
+# Network options for the clients
 [NETWORK]
-PORT = 2087
-INTERFACE = eth0
-HELOEXCHANGE = NO
-TRUSTED = 127.0.0.0/8;
+CLIENT-PORT = 2087
+HOST = "localhost"
 
-[LOAD]
-INTERFACES      = eth0
-BASICLIMITING = YES
-MAXNETUPBPSTOTAL       = 50000
-MAXNETDOWNBPSTOTAL     = 50000
-MAXCPULOAD             = 100
-
-[FS]
-QUOTA  = 1024
-ACTIVEMIGRATION = NO
-DIR          = /tmp/gnunet-ecrs-test/
-INDEX-DIRECTORY = $GNUNETD_HOME/data/shared/
-INDEX-QUOTA = 8192
-
-[MYSQL]
-DELAYED = NO
-DATABASE = gnunetcheck
-
-[GAP]
-TABLESIZE = 65536
-
-[DHT]
-BUCKETCOUNT = 160
-MASTER-TABLE-SIZE = 65536
-

Modified: GNUnet/src/applications/fs/ecrs/directorytest.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/directorytest.c     2006-08-27 22:51:18 UTC 
(rev 3339)
+++ GNUnet/src/applications/fs/ecrs/directorytest.c     2006-08-27 23:38:07 UTC 
(rev 3340)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2005 Christian Grothoff (and other contributing authors)
+     (C) 2005, 2006 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
@@ -83,7 +83,7 @@
             512,
             
"gnunet://ecrs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.%u",
             p);
-    fis[p].uri = ECRS_stringToUri(uri);
+    fis[p].uri = ECRS_stringToUri(NULL, uri);
     if (fis[p].uri == NULL)
       ABORT(); /* error in testcase */
   }
@@ -94,7 +94,8 @@
   ECRS_addToMetaData(meta,
                     EXTRACTOR_AUTHOR,
                     "An author");
-  if (OK != ECRS_createDirectory(&data,
+  if (OK != ECRS_createDirectory(NULL,
+                                &data,
                                 &dlen,
                                 i,
                                 fis,
@@ -102,7 +103,8 @@
     ABORT();
   cls.pos = 0;
   cls.fi = fis;
-  if (i != ECRS_listDirectory(data,
+  if (i != ECRS_listDirectory(NULL,
+                             data,
                              dlen,
                              &meta2,
                              &processor,

Modified: GNUnet/src/applications/fs/ecrs/ecrstest.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/ecrstest.c  2006-08-27 22:51:18 UTC (rev 
3339)
+++ GNUnet/src/applications/fs/ecrs/ecrstest.c  2006-08-27 23:38:07 UTC (rev 
3340)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2004, 2005 Christian Grothoff (and other contributing authors)
+     (C) 2004, 2005, 2006 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
@@ -27,39 +27,24 @@
 #include "platform.h"
 #include "gnunet_util.h"
 #include "gnunet_ecrs_lib.h"
+#include "gnunet_util_config_impl.h"
+#include "gnunet_util_network_client.h"
 #include "tree.h"
 
-#define CHECK(a) if (!(a)) { ok = NO; GE_BREAK(ectx, 0); goto FAILURE; }
+#define CHECK(a) if (!(a)) { ok = NO; GE_BREAK(NULL, 0); goto FAILURE; }
 
-static int parseCommandLine(int argc,
-                           char * argv[]) {
-  FREENONNULL(setConfigurationString("GNUNETD",
-                                    "_MAGIC_",
-                                    "NO"));
-  FREENONNULL(setConfigurationString("GNUNETD",
-                                    "LOGFILE",
-                                    NULL));
-  FREENONNULL(setConfigurationString("GNUNET",
-                                    "LOGLEVEL",
-                                    "NOTHING"));
-  FREENONNULL(setConfigurationString("GNUNET",
-                                    "GNUNETD-CONFIG",
-                                    "check.conf"));
-  return OK;
-}
-
 static int testTerminate(void * unused) {
   return OK;
 }
 
+static struct GC_Configuration * cfg;
+
 static char * makeName(unsigned int i) {
   char * name;
   char * fn;
 
-  fn = STRDUP("/tmp/gnunet-ecrstest");
-  name = expandFileName(fn);
-  disk_directory_create(ectx, name);
-  FREE(fn);
+  name = STRDUP("/tmp/gnunet-ecrstest");
+  disk_directory_create(NULL, name);
   fn = MALLOC(strlen(name) + 40);
   SNPRINTF(fn,
           strlen(name) + 40,
@@ -80,7 +65,9 @@
   int i;
 
   name = makeName(size);
-  fd = fileopen(name, O_WRONLY|O_CREAT, S_IWUSR|S_IRUSR);
+  fd = disk_file_open(NULL,
+                     name,
+                     O_WRONLY|O_CREAT, S_IWUSR|S_IRUSR);
   buf = MALLOC(size);
   memset(buf, size + size / 253, size);
   for (i=0;i<(int) (size - 42 - sizeof(HashCode512));i+=sizeof(HashCode512))
@@ -89,8 +76,10 @@
         (HashCode512*) &buf[i+sizeof(HashCode512)]);
   WRITE(fd, buf, size);
   FREE(buf);
-  closefile(fd);
-  ret = ECRS_uploadFile(name,
+  CLOSE(fd);
+  ret = ECRS_uploadFile(NULL,
+                       cfg,
+                       name,
                        YES, /* index */
                        0, /* anon */
                        0, /* prio */
@@ -110,7 +99,9 @@
 
     meta = ECRS_createMetaData();
     key = ECRS_keywordsToUri(keywords);
-    ret = ECRS_addToKeyspace(key,
+    ret = ECRS_addToKeyspace(NULL,
+                            cfg,
+                            key,
                             0,
                             0,
                             get_time() + 10 * cronMINUTES, /* expire */
@@ -139,11 +130,12 @@
   char * tmp;
 
   tmp = ECRS_uriToString(fi->uri);
-  GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
-      "Search found URI `%s'\n",
-      tmp);
+  GE_LOG(NULL,
+        GE_DEBUG | GE_REQUEST | GE_USER,
+        "Search found URI `%s'\n",
+        tmp);
   FREE(tmp);
-  GE_ASSERT(ectx, NULL == *my);
+  GE_ASSERT(NULL, NULL == *my);
   *my = ECRS_dupUri(fi->uri);
   return SYSERR; /* abort search */
 }
@@ -157,7 +149,9 @@
   struct ECRS_URI * myURI;
 
   myURI = NULL;
-  ret = ECRS_search(*uri,
+  ret = ECRS_search(NULL,
+                   cfg,
+                   *uri,
                    0,
                    15 * cronSECONDS,
                    &searchCB,
@@ -184,13 +178,16 @@
   char * tmp;
 
   tmp = ECRS_uriToString(uri);
-  GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
-      "Starting download of `%s'\n",
-      tmp);
+  GE_LOG(NULL,
+        GE_DEBUG | GE_REQUEST | GE_USER,
+        "Starting download of `%s'\n",
+        tmp);
   FREE(tmp);
   tmpName = makeName(0);
   ret = SYSERR;
-  if (OK == ECRS_downloadFile(uri,
+  if (OK == ECRS_downloadFile(NULL,
+                             cfg,
+                             uri,
                              tmpName,
                              0,
                              NULL,
@@ -198,7 +195,9 @@
                              &testTerminate,
                              NULL)) {
 
-    fd = fileopen(tmpName, O_RDONLY);
+    fd = disk_file_open(NULL,
+                       tmpName, 
+                       O_RDONLY);
     buf = MALLOC(size);
     in = MALLOC(size);
     memset(buf, size + size / 253, size);
@@ -214,7 +213,7 @@
       ret = OK;
     FREE(buf);
     FREE(in);
-    closefile(fd);
+    CLOSE(fd);
   }
   UNLINK(tmpName);
   FREE(tmpName);
@@ -227,7 +226,9 @@
   char * name;
 
   name = makeName(size);
-  ret = ECRS_unindexFile(name,
+  ret = ECRS_unindexFile(NULL,
+                        cfg,
+                        name,
                         NULL,
                         NULL,
                         &testTerminate,
@@ -260,17 +261,23 @@
   struct ECRS_URI * uri;
   int i;
 
-  if (OK != initUtil(argc,
-                    argv,
-                    &parseCommandLine))
-    return -1;
-  daemon = startGNUnetDaemon(NO);
-  GE_ASSERT(ectx, daemon > 0);
+  cfg = GC_create_C_impl();
+  if (-1 == GC_parse_configuration(cfg,
+                                  "check.conf")) {
+    GC_free(cfg);
+    return -1;  
+  }
+  daemon  = os_daemon_start(NULL,
+                           cfg,
+                           "peer.conf",
+                           NO);
+  GE_ASSERT(NULL, daemon > 0);
+  GE_ASSERT(NULL, OK == connection_wait_for_running(NULL,
+                                                   cfg,
+                                                   30 * cronSECONDS));
   ok = YES;
-  startCron();
-  GE_ASSERT(ectx, OK == waitForGNUnetDaemonRunning(30 * cronSECONDS));
   PTHREAD_SLEEP(5 * cronSECONDS); /* give apps time to start */
-  sock = getClientSocket();
+  sock = client_connection_create(NULL, cfg);
   CHECK(sock != NULL);
 
   /* ACTUAL TEST CODE */
@@ -294,10 +301,7 @@
  FAILURE:
   if (sock != NULL)
     connection_destroy(sock);
-  stopCron();
-  GE_ASSERT(ectx, OK == stopGNUnetDaemon());
-  GE_ASSERT(ectx, OK == waitForGNUnetDaemonTermination(daemon));
-  doneUtil();
+  GE_ASSERT(NULL, OK == os_daemon_stop(NULL, daemon));
   return (ok == YES) ? 0 : 1;
 }
 

Modified: GNUnet/src/applications/fs/ecrs/metatest.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/metatest.c  2006-08-27 22:51:18 UTC (rev 
3339)
+++ GNUnet/src/applications/fs/ecrs/metatest.c  2006-08-27 23:38:07 UTC (rev 
3340)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2003, 2004 Christian Grothoff (and other contributing authors)
+     (C) 2003, 2004, 2006 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
@@ -94,13 +94,15 @@
   size = ECRS_sizeofMetaData(m,
                             ECRS_SERIALIZE_FULL);
   val = MALLOC(size);
-  if (size != ECRS_serializeMetaData(m,
+  if (size != ECRS_serializeMetaData(NULL,
+                                    m,
                                     val,
                                     size,
                                     ECRS_SERIALIZE_FULL))
     ABORT();
   ECRS_freeMetaData(m);
-  m = ECRS_deserializeMetaData(val,
+  m = ECRS_deserializeMetaData(NULL,
+                              val,
                               size);
   if (m == NULL)
     ABORT();
@@ -143,7 +145,8 @@
   size = ECRS_sizeofMetaData(meta,
                             ECRS_SERIALIZE_FULL);
   data = MALLOC(size * 4);
-  if (size != ECRS_serializeMetaData(meta,
+  if (size != ECRS_serializeMetaData(NULL,
+                                    meta,
                                     data,
                                     size * 4,
                                     ECRS_SERIALIZE_FULL))
@@ -161,10 +164,9 @@
   for (i=1;i<255;i++)
     failureCount += testMetaMore(i);
 
-  if (failureCount == 0)
-    return 0;
-  else
+  if (failureCount != 0)
     return 1;
+  return 0;
 }
 
 /* end of metatest.c */

Modified: GNUnet/src/applications/fs/ecrs/metatest2.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/metatest2.c 2006-08-27 22:51:18 UTC (rev 
3339)
+++ GNUnet/src/applications/fs/ecrs/metatest2.c 2006-08-27 23:38:07 UTC (rev 
3340)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2003, 2004 Christian Grothoff (and other contributing authors)
+     (C) 2003, 2004, 2006 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
@@ -49,13 +49,15 @@
   size = ECRS_sizeofMetaData(m,
                             ECRS_SERIALIZE_FULL);
   val = MALLOC(size);
-  if (size != ECRS_serializeMetaData(m,
+  if (size != ECRS_serializeMetaData(NULL,
+                                    m,
                                     val,
                                     size,
                                     ECRS_SERIALIZE_FULL))
     ABORT();
   ECRS_freeMetaData(m);
-  m = ECRS_deserializeMetaData(val,
+  m = ECRS_deserializeMetaData(NULL,
+                              val,
                               size);
   if (m == NULL)
     ABORT();
@@ -69,10 +71,9 @@
 
   failureCount += testMeta();
 
-  if (failureCount == 0)
-    return 0;
-  else
+  if (failureCount != 0)
     return 1;
+  return 0;
 }
 
 /* end of metatest2.c */

Modified: GNUnet/src/applications/fs/ecrs/namespacetest.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/namespacetest.c     2006-08-27 22:51:18 UTC 
(rev 3339)
+++ GNUnet/src/applications/fs/ecrs/namespacetest.c     2006-08-27 23:38:07 UTC 
(rev 3340)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2005 Christian Grothoff (and other contributing authors)
+     (C) 2005, 2006 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
@@ -26,6 +26,8 @@
 
 #include "platform.h"
 #include "gnunet_util.h"
+#include "gnunet_util_config_impl.h"
+#include "gnunet_util_network_client.h"
 #include "gnunet_ecrs_lib.h"
 #include "ecrs.h"
 
@@ -34,6 +36,8 @@
 
 #define CHECKNAME "gnunet-namespace-test"
 
+static struct GC_Configuration * cfg;
+
 static int testNamespace() {
   HashCode512 root;
   HashCode512 thisId;
@@ -49,12 +53,16 @@
   };
 
 
-  ECRS_deleteNamespace(CHECKNAME); /* make sure old one is deleted */
+  ECRS_deleteNamespace(NULL,
+                      cfg,
+                      CHECKNAME); /* make sure old one is deleted */
   meta = ECRS_createMetaData();
   adv = ECRS_keywordsToUri(keys);
   hash("root", 4, &root);
   rootURI =
-    ECRS_createNamespace(CHECKNAME,
+    ECRS_createNamespace(NULL,
+                        cfg,
+                        CHECKNAME,
                         meta,
                         0,
                         0,
@@ -65,7 +73,9 @@
   hash("this", 4, &thisId);
   hash("next", 4, &nextId);
   uri = rootURI; /* just for fun: NS::this advertises NS::root */
-  advURI = ECRS_addToNamespace(CHECKNAME,
+  advURI = ECRS_addToNamespace(NULL,
+                              cfg,
+                              CHECKNAME,
                               0,
                               0,
                               TIME(NULL) + 300,
@@ -76,49 +86,42 @@
                               uri,
                               meta);
   CHECK(NULL != advURI);
-  CHECK(OK == ECRS_deleteNamespace(CHECKNAME));
-  CHECK(SYSERR == ECRS_deleteNamespace(CHECKNAME));
+  CHECK(OK == ECRS_deleteNamespace(NULL,
+                                  cfg,
+                                  CHECKNAME));
+  CHECK(SYSERR == ECRS_deleteNamespace(NULL,
+                                      cfg,
+                                      CHECKNAME));
   ECRS_freeMetaData(meta);
   ECRS_freeUri(rootURI);
   ECRS_freeUri(advURI);
   return 0;
 }
 
-static int parseCommandLine(int argc,
-                           char * argv[]) {
-  FREENONNULL(setConfigurationString("GNUNETD",
-                                    "_MAGIC_",
-                                    "NO"));
-  FREENONNULL(setConfigurationString("GNUNETD",
-                                    "LOGFILE",
-                                    NULL));
-  FREENONNULL(setConfigurationString("GNUNET",
-                                    "LOGLEVEL",
-                                    "ERROR"));
-  FREENONNULL(setConfigurationString("GNUNET",
-                                    "GNUNETD-CONFIG",
-                                    "check.conf"));
-  return OK;
-}
-
 int main(int argc, char * argv[]) {
   pid_t daemon;
   int failureCount = 0;
 
-  if (OK != initUtil(argc,
-                    argv,
-                    &parseCommandLine))
-    return -1;
-  daemon = startGNUnetDaemon(NO);
-  GE_ASSERT(ectx, daemon > 0);
-  GE_ASSERT(ectx, OK == waitForGNUnetDaemonRunning(30 * cronSECONDS));
-  PTHREAD_SLEEP(30 * cronSECONDS);
+  cfg = GC_create_C_impl();
+  if (-1 == GC_parse_configuration(cfg,
+                                  "check.conf")) {
+    GC_free(cfg);
+    return -1;  
+  }
+  daemon  = os_daemon_start(NULL,
+                           cfg,
+                           "peer.conf",
+                           NO);
+  GE_ASSERT(NULL, daemon > 0);
+  GE_ASSERT(NULL, OK == connection_wait_for_running(NULL,
+                                                   cfg,
+                                                   30 * cronSECONDS));
+  PTHREAD_SLEEP(5 * cronSECONDS);
 
   failureCount += testNamespace();
 
-  GE_ASSERT(ectx, OK == stopGNUnetDaemon());
-  GE_ASSERT(ectx, OK == waitForGNUnetDaemonTermination(daemon));
-  doneUtil();
+  GE_ASSERT(NULL, OK == os_daemon_stop(NULL, daemon));
+
   return (failureCount == 0) ? 0 : 1;
 }
 

Copied: GNUnet/src/applications/fs/ecrs/peer.conf (from rev 3322, 
GNUnet/src/applications/fs/ecrs/check.conf)

Modified: GNUnet/src/applications/fs/ecrs/searchtest.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/searchtest.c        2006-08-27 22:51:18 UTC 
(rev 3339)
+++ GNUnet/src/applications/fs/ecrs/searchtest.c        2006-08-27 23:38:07 UTC 
(rev 3340)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2004, 2005 Christian Grothoff (and other contributing authors)
+     (C) 2004, 2005, 2006 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
@@ -27,31 +27,18 @@
 #include "platform.h"
 #include "gnunet_util.h"
 #include "gnunet_ecrs_lib.h"
+#include "gnunet_util_config_impl.h"
+#include "gnunet_util_network_client.h"
 #include "tree.h"
 
-#define CHECK(a) if (!(a)) { ok = NO; GE_BREAK(ectx, 0); goto FAILURE; }
+#define CHECK(a) if (!(a)) { ok = NO; GE_BREAK(NULL, 0); goto FAILURE; }
 
-static int parseCommandLine(int argc,
-                           char * argv[]) {
-  FREENONNULL(setConfigurationString("GNUNETD",
-                                    "_MAGIC_",
-                                    "NO"));
-  FREENONNULL(setConfigurationString("GNUNETD",
-                                    "LOGFILE",
-                                    NULL));
-  FREENONNULL(setConfigurationString("GNUNET",
-                                    "LOGLEVEL",
-                                    "NOTHING"));
-  FREENONNULL(setConfigurationString("GNUNET",
-                                    "GNUNETD-CONFIG",
-                                    "check.conf"));
-  return OK;
-}
-
 static int testTerminate(void * unused) {
   return OK;
 }
 
+static struct GC_Configuration * cfg;
+
 static int searchCB(const ECRS_FileInfo * fi,
                    const HashCode512 * key,
                    int isRoot,
@@ -68,8 +55,7 @@
   (*cnt)--;
   if (0 == *cnt)
     return SYSERR; /* abort search */
-  else
-    return OK;
+  return OK;
 }
 
 /**
@@ -78,17 +64,18 @@
  */
 static int searchFile(const struct ECRS_URI * uri,
                      int resultCount) {
-  ECRS_search(uri,
+  ECRS_search(NULL,
+             cfg,
+             uri,
              0,
              60 * 15 * cronSECONDS,
              &searchCB,
              &resultCount,
              &testTerminate,
              NULL);
-  if (resultCount <= 0)
-    return OK;
-  else
+  if (resultCount > 0)
     return SYSERR;
+  return OK;
 }
 
 int main(int argc, char * argv[]){
@@ -100,31 +87,40 @@
   struct ECRS_URI * key;
   const char * keywords[6];
 
-  if (OK != initUtil(argc,
-                    argv,
-                    &parseCommandLine))
-    return -1;
-  daemon = startGNUnetDaemon(NO);
-  GE_ASSERT(ectx, daemon > 0);
+
+  cfg = GC_create_C_impl();
+  if (-1 == GC_parse_configuration(cfg,
+                                  "check.conf")) {
+    GC_free(cfg);
+    return -1;  
+  }
+  daemon  = os_daemon_start(NULL,
+                           cfg,
+                           "peer.conf",
+                           NO);
+  GE_ASSERT(NULL, daemon > 0);
+  GE_ASSERT(NULL, OK == connection_wait_for_running(NULL,
+                                                   cfg,
+                                                   30 * cronSECONDS));
   ok = YES;
-  startCron();
-  GE_ASSERT(ectx, OK == waitForGNUnetDaemonRunning(30 * cronSECONDS));
   PTHREAD_SLEEP(5 * cronSECONDS); /* give apps time to start */
-  sock = getClientSocket();
+  sock = client_connection_create(NULL, cfg);
   CHECK(sock != NULL);
-
   /* ACTUAL TEST CODE */
   /* first, simple insertion => one result */
 #if 0
   printf("Testing search for 'XXtest' with one result.\n");
 #endif
-  uri = 
ECRS_stringToUri("gnunet://ecrs/sks/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820/test");
+  uri = ECRS_stringToUri(NULL,
+                        
"gnunet://ecrs/sks/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820/test");
   meta = ECRS_createMetaData();
   keywords[0] = "XXtest";
   keywords[1] = NULL;
 
   key = ECRS_keywordsToUri(keywords);
-  CHECK(OK == ECRS_addToKeyspace(key,
+  CHECK(OK == ECRS_addToKeyspace(NULL,
+                                cfg,
+                                key,
                                 0,
                                 0,
                                 get_time() + 10 * cronMINUTES, /* expire */
@@ -140,11 +136,14 @@
 #if 0
   printf("Testing search for 'XXtest AND binary' with two results.\n");
 #endif
-  uri = 
ECRS_stringToUri("gnunet://ecrs/sks/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820/test-different");
+  uri = ECRS_stringToUri(NULL,
+                        
"gnunet://ecrs/sks/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820/test-different");
   keywords[1] = "binary";
   keywords[2] = NULL;
   key = ECRS_keywordsToUri(keywords);
-  CHECK(OK == ECRS_addToKeyspace(key,
+  CHECK(OK == ECRS_addToKeyspace(NULL,
+                                cfg,
+                                key,
                                 0,
                                 0,
                                 get_time() + 10 * cronMINUTES, /* expire */
@@ -170,10 +169,7 @@
  FAILURE:
   if (sock != NULL)
     connection_destroy(sock);
-  stopCron();
-  GE_ASSERT(ectx, OK == stopGNUnetDaemon());
-  GE_ASSERT(ectx, OK == waitForGNUnetDaemonTermination(daemon));
-  doneUtil();
+  GE_ASSERT(NULL, OK == os_daemon_stop(NULL, daemon));
   return (ok == YES) ? 0 : 1;
 }
 

Modified: GNUnet/src/applications/fs/ecrs/uritest.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/uritest.c   2006-08-27 22:51:18 UTC (rev 
3339)
+++ GNUnet/src/applications/fs/ecrs/uritest.c   2006-08-27 23:38:07 UTC (rev 
3340)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2003, 2004 Christian Grothoff (and other contributing authors)
+     (C) 2003, 2004, 2006 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
@@ -35,9 +35,9 @@
   char * uri;
   struct ECRS_URI * ret;
 
-  if (NULL != ECRS_stringToUri("gnunet://ecrs/ksk/++"))
+  if (NULL != ECRS_stringToUri(NULL, "gnunet://ecrs/ksk/++"))
     ABORT();
-  ret = ECRS_stringToUri("gnunet://ecrs/ksk/foo+bar");
+  ret = ECRS_stringToUri(NULL, "gnunet://ecrs/ksk/foo+bar");
   if (ret == NULL)
     ABORT();
   if (! ECRS_isKeywordUri(ret))
@@ -60,13 +60,13 @@
   char * uri;
   struct ECRS_URI * ret;
 
-  if (NULL != 
ECRS_stringToUri("gnunet://ecrs/sks/D1KJS9H2A82Q65VKQ0ML3RFU6U1D3VUK"))
+  if (NULL != ECRS_stringToUri(NULL, 
"gnunet://ecrs/sks/D1KJS9H2A82Q65VKQ0ML3RFU6U1D3VUK"))
     ABORT();
-  if (NULL != 
ECRS_stringToUri("gnunet://ecrs/sks/D1KJS9H2A82Q65VKQ0ML3RFU6U1D3V/test"))
+  if (NULL != ECRS_stringToUri(NULL, 
"gnunet://ecrs/sks/D1KJS9H2A82Q65VKQ0ML3RFU6U1D3V/test"))
     ABORT();
-  if (NULL != ECRS_stringToUri("gnunet://ecrs/sks/test"))
+  if (NULL != ECRS_stringToUri(NULL, "gnunet://ecrs/sks/test"))
      ABORT();
-  ret = 
ECRS_stringToUri("gnunet://ecrs/sks/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820/test");
+  ret = ECRS_stringToUri(NULL, 
"gnunet://ecrs/sks/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820/test");
   if (ret == NULL)
     ABORT();
   if (ECRS_isKeywordUri(ret))
@@ -87,13 +87,13 @@
   char * uri;
   struct ECRS_URI * ret;
 
-  if (NULL != 
ECRS_stringToUri("gnunet://ecrs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H00000440000.42"))
+  if (NULL != ECRS_stringToUri(NULL, 
"gnunet://ecrs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H00000440000.42"))
     ABORT();
-  if (NULL != 
ECRS_stringToUri("gnunet://ecrs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000"))
+  if (NULL != ECRS_stringToUri(NULL, 
"gnunet://ecrs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000"))
     ABORT();
-  if (NULL != 
ECRS_stringToUri("gnunet://ecrs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.FGH"))
+  if (NULL != ECRS_stringToUri(NULL, 
"gnunet://ecrs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.FGH"))
     ABORT();
-  ret = 
ECRS_stringToUri("gnunet://ecrs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.42");
+  ret = ECRS_stringToUri(NULL, 
"gnunet://ecrs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.42");
   if (ret == NULL)
     ABORT();
   if (ECRS_isKeywordUri(ret))
@@ -113,35 +113,18 @@
   return 0;
 }
 
-static int parseCommandLine(int argc,
-                           char * argv[]) {
-  FREENONNULL(setConfigurationString("GNUNETD",
-                                    "_MAGIC_",
-                                    "NO"));
-  FREENONNULL(setConfigurationString("GNUNETD",
-                                    "LOGFILE",
-                                    NULL));
-  FREENONNULL(setConfigurationString("GNUNET",
-                                    "LOGLEVEL",
-                                    "NOTHING"));
-  return OK;
-}
-
 int main(int argc, char * argv[]) {
   int failureCount = 0;
   int i;
 
-  initUtil(argc, argv, &parseCommandLine);
   failureCount += testKeyword();
   for (i=0;i<255;i++) {
     failureCount += testNamespace(i);
     failureCount += testFile(i);
   }
-  doneUtil();
-  if (failureCount == 0)
-    return 0;
-  else
+  if (failureCount != 0)
     return 1;
+  return 0;
 }
 
 /* end of uritest.c */

Modified: GNUnet/todo
===================================================================
--- GNUnet/todo 2006-08-27 22:51:18 UTC (rev 3339)
+++ GNUnet/todo 2006-08-27 23:38:07 UTC (rev 3340)
@@ -14,6 +14,7 @@
 
 0.7.1 ['06] (aka "stabilization")
 - finish util refactoring: [RC]
+  * $GNUNET_HOME directory creation (where?)
   * util: 
     + statuscalls: load always extremely high (2^31 ++)
     + network/io: load monitor support
@@ -21,8 +22,8 @@
     + use new loggers in for CS error reporting
   * make testcases compile & pass again:
     + session -- compiles, but fails (peers do not connect!)
+    + fs/ecrs -- compiles, but searchtest hangs
     + gap
-    + fs/ecrs
     + fs/namespace
     + fs/fsui
     + tbench





reply via email to

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