[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r487 - GNUnet/src/applications/gap
From: |
grothoff |
Subject: |
[GNUnet-SVN] r487 - GNUnet/src/applications/gap |
Date: |
Fri, 25 Mar 2005 14:29:52 -0800 (PST) |
Author: grothoff
Date: 2005-03-25 14:29:51 -0800 (Fri, 25 Mar 2005)
New Revision: 487
Modified:
GNUnet/src/applications/gap/Makefile.am
GNUnet/src/applications/gap/gaptest.c
GNUnet/src/applications/gap/peer1.conf
GNUnet/src/applications/gap/peer2.conf
Log:
drafted gap test (failing)
Modified: GNUnet/src/applications/gap/Makefile.am
===================================================================
--- GNUnet/src/applications/gap/Makefile.am 2005-03-25 22:16:17 UTC (rev
486)
+++ GNUnet/src/applications/gap/Makefile.am 2005-03-25 22:29:51 UTC (rev
487)
@@ -25,7 +25,8 @@
gaptest_SOURCES = \
gaptest.c
gaptest_LDADD = \
- $(top_builddir)/src/applications/fs/lib/libgnunetfs.la \
+ $(top_builddir)/src/applications/stats/libgnunetstats_api.la \
+ $(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la \
$(top_builddir)/src/util/libgnunetutil.la
EXTRA_DIST = \
Modified: GNUnet/src/applications/gap/gaptest.c
===================================================================
--- GNUnet/src/applications/gap/gaptest.c 2005-03-25 22:16:17 UTC (rev
486)
+++ GNUnet/src/applications/gap/gaptest.c 2005-03-25 22:29:51 UTC (rev
487)
@@ -19,13 +19,14 @@
*/
/**
- * @file applications/session/sessiontest.c
- * @brief Session establishment testcase
+ * @file applications/gap/gaptest.c
+ * @brief GAP routing testcase
* @author Christian Grothoff
*/
#include "platform.h"
#include "gnunet_protocols.h"
+#include "gnunet_ecrs_lib.h"
#include "gnunet_stats_lib.h"
#include <sys/wait.h>
@@ -52,7 +53,198 @@
return OK;
}
+
+static int testTerminate(void * unused) {
+ return OK;
+}
+
+static char * makeName(unsigned int i) {
+ char * name;
+ char * fn;
+
+ fn = STRDUP("/tmp/gnunet-ecrstest");
+ name = expandFileName(fn);
+ mkdirp(name);
+ FREE(fn);
+ fn = MALLOC(strlen(name) + 40);
+ SNPRINTF(fn,
+ strlen(name) + 40,
+ "%s%sECRSTEST%u",
+ DIR_SEPARATOR_STR,
+ name,
+ i);
+ FREE(name);
+ return fn;
+}
+
+static struct ECRS_URI * uploadFile(unsigned int size) {
+ int ret;
+ char * name;
+ int fd;
+ char * buf;
+ struct ECRS_URI * uri;
+ int i;
+
+ name = makeName(size);
+ fd = OPEN(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))
+ hash(&buf[i+sizeof(HashCode512)],
+ 42,
+ (HashCode512*) &buf[i]);
+ write(fd, buf, size);
+ FREE(buf);
+ CLOSE(fd);
+ ret = ECRS_uploadFile(name,
+ YES, /* index */
+ 0, /* anon */
+ 0, /* prio */
+ cronTime(NULL) + 10 * cronMINUTES, /* expire */
+ NULL, /* progress */
+ NULL,
+ &testTerminate,
+ NULL,
+ &uri);
+ if (ret != SYSERR) {
+ struct ECRS_MetaData * meta;
+ struct ECRS_URI * key;
+ const char * keywords[2];
+
+ keywords[0] = name;
+ keywords[1] = NULL;
+
+ meta = ECRS_createMetaData();
+ key = ECRS_keywordsToUri(keywords);
+ ret = ECRS_addToKeyspace(key,
+ 0,
+ 0,
+ cronTime(NULL) + 10 * cronMINUTES, /* expire */
+ uri,
+ meta);
+ ECRS_freeMetaData(meta);
+ ECRS_freeUri(uri);
+ FREE(name);
+ if (ret == OK) {
+ return key;
+ } else {
+ ECRS_freeUri(key);
+ return NULL;
+ }
+ } else {
+ FREE(name);
+ return NULL;
+ }
+}
+
+static int searchCB(const ECRS_FileInfo * fi,
+ const HashCode512 * key,
+ void * closure) {
+ struct ECRS_URI ** my = closure;
+ char * tmp;
+
+ tmp = ECRS_uriToString(fi->uri);
+ LOG(LOG_DEBUG,
+ "Search found URI '%s'\n",
+ tmp);
+ FREE(tmp);
+ GNUNET_ASSERT(NULL == *my);
+ *my = ECRS_dupUri(fi->uri);
+ return SYSERR; /* abort search */
+}
+
/**
+ * @param *uri In: keyword URI, out: file URI
+ * @return OK on success
+ */
+static int searchFile(struct ECRS_URI ** uri) {
+ int ret;
+ struct ECRS_URI * myURI;
+
+ myURI = NULL;
+ ret = ECRS_search(*uri,
+ 0,
+ 15 * cronSECONDS,
+ &searchCB,
+ &myURI,
+ &testTerminate,
+ NULL);
+ ECRS_freeUri(*uri);
+ *uri = myURI;
+ if ( (ret != SYSERR) &&
+ (myURI != NULL) )
+ return OK;
+ else
+ return SYSERR;
+}
+
+static int downloadFile(unsigned int size,
+ const struct ECRS_URI * uri) {
+ int ret;
+ char * tmpName;
+ int fd;
+ char * buf;
+ char * in;
+ int i;
+ char * tmp;
+
+ tmp = ECRS_uriToString(uri);
+ LOG(LOG_DEBUG,
+ "Starting download of '%s'\n",
+ tmp);
+ FREE(tmp);
+ tmpName = makeName(0);
+ ret = SYSERR;
+ if (OK == ECRS_downloadFile(uri,
+ tmpName,
+ 0,
+ NULL,
+ NULL,
+ &testTerminate,
+ NULL)) {
+
+ fd = OPEN(tmpName, O_RDONLY);
+ buf = MALLOC(size);
+ in = MALLOC(size);
+ memset(buf, size + size / 253, size);
+ for (i=0;i<(int) (size - 42 - sizeof(HashCode512));i+=sizeof(HashCode512))
+ hash(&buf[i+sizeof(HashCode512)],
+ 42,
+ (HashCode512*) &buf[i]);
+ if (size != read(fd, in, size))
+ ret = SYSERR;
+ else if (0 == memcmp(buf,
+ in,
+ size))
+ ret = OK;
+ FREE(buf);
+ FREE(in);
+ CLOSE(fd);
+ }
+ UNLINK(tmpName);
+ FREE(tmpName);
+ return ret;
+}
+
+static int unindexFile(unsigned int size) {
+ int ret;
+ char * name;
+
+ name = makeName(size);
+ ret = ECRS_unindexFile(name,
+ NULL,
+ NULL,
+ &testTerminate,
+ NULL);
+ if (0 != UNLINK(name))
+ ret = SYSERR;
+ FREE(name);
+ return ret;
+}
+
+#define CHECK(a) if (!(a)) { ret = 1; BREAK(); goto FAILURE; }
+
+/**
* Testcase to test p2p session key exchange.
*
* @param argc number of arguments from the command line
@@ -66,6 +258,7 @@
int status;
GNUNET_TCP_SOCKET * sock;
int left;
+ struct ECRS_URI * uri;
GNUNET_ASSERT(OK ==
enc2hash("BV3AS3KMIIBVIFCGEG907N6NTDTH26B7T6FODUSLSGK"
@@ -164,10 +357,7 @@
left);
sleep(1);
left--;
- if (left == 0) {
- ret = 1;
- break;
- }
+ CHECK(left > 0);
}
} while (sock == NULL);
@@ -179,12 +369,25 @@
left);
sleep(5);
left--;
- if (left == 0) {
- ret = 1;
- break;
- }
+ CHECK(left > 0);
}
releaseClientSocket(sock);
+
+
+ uri = uploadFile(12345);
+ CHECK(NULL != uri);
+ CHECK(OK == searchFile(&uri));
+ setConfigurationInt("NETWORK",
+ "PORT",
+ 12087);
+ CHECK(OK == downloadFile(12345, uri));
+ ECRS_freeUri(uri);
+ setConfigurationInt("NETWORK",
+ "PORT",
+ 2087);
+ CHECK(OK == unindexFile(12345));
+
+ FAILURE:
doneUtil();
/* also shutdown daemons again */
Modified: GNUnet/src/applications/gap/peer1.conf
===================================================================
--- GNUnet/src/applications/gap/peer1.conf 2005-03-25 22:16:17 UTC (rev
486)
+++ GNUnet/src/applications/gap/peer1.conf 2005-03-25 22:29:51 UTC (rev
487)
@@ -16,6 +16,8 @@
[MODULES]
topology = "topology_default"
+sqstore = "sqstore_sqlite"
+dht = "none"
[NETWORK]
PORT = 2087
@@ -58,3 +60,18 @@
# BLACKLIST =
+
+[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
+
Modified: GNUnet/src/applications/gap/peer2.conf
===================================================================
--- GNUnet/src/applications/gap/peer2.conf 2005-03-25 22:16:17 UTC (rev
486)
+++ GNUnet/src/applications/gap/peer2.conf 2005-03-25 22:29:51 UTC (rev
487)
@@ -16,6 +16,8 @@
[MODULES]
topology = "topology_default"
+sqstore = "sqstore_sqlite"
+dht = "none"
[NETWORK]
PORT = 12087
@@ -58,3 +60,17 @@
# BLACKLIST =
+
+[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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r487 - GNUnet/src/applications/gap,
grothoff <=