[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r6316 - GNUnet/src/applications/fs/gap
From: |
gnunet |
Subject: |
[GNUnet-SVN] r6316 - GNUnet/src/applications/fs/gap |
Date: |
Fri, 15 Feb 2008 19:54:40 -0700 (MST) |
Author: grothoff
Date: 2008-02-15 19:54:40 -0700 (Fri, 15 Feb 2008)
New Revision: 6316
Added:
GNUnet/src/applications/fs/gap/test_multi_results.c
Modified:
GNUnet/src/applications/fs/gap/Makefile.am
GNUnet/src/applications/fs/gap/ondemand.c
GNUnet/src/applications/fs/gap/test_linear_topology.c
GNUnet/src/applications/fs/gap/test_loopback.c
GNUnet/src/applications/fs/gap/test_star_topology.c
Log:
fix and more tests
Modified: GNUnet/src/applications/fs/gap/Makefile.am
===================================================================
--- GNUnet/src/applications/fs/gap/Makefile.am 2008-02-16 01:40:47 UTC (rev
6315)
+++ GNUnet/src/applications/fs/gap/Makefile.am 2008-02-16 02:54:40 UTC (rev
6316)
@@ -27,7 +27,10 @@
check_PROGRAMS = \
- test_loopback test_linear_topology test_star_topology
+ test_loopback \
+ test_linear_topology \
+ test_multi_results \
+ test_star_topology
TESTS = $(check_PROGRAMS)
@@ -48,7 +51,15 @@
$(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la \
$(top_builddir)/src/util/libgnunetutil.la
+test_multi_results_SOURCES = \
+ test_multi_results.c
+test_multi_results_LDADD = \
+ $(top_builddir)/src/applications/testing/libgnunettesting_api.la \
+ $(top_builddir)/src/applications/stats/libgnunetstats_api.la \
+ $(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la \
+ $(top_builddir)/src/util/libgnunetutil.la
+
test_star_topology_SOURCES = \
test_star_topology.c
test_star_topology_LDADD = \
Modified: GNUnet/src/applications/fs/gap/ondemand.c
===================================================================
--- GNUnet/src/applications/fs/gap/ondemand.c 2008-02-16 01:40:47 UTC (rev
6315)
+++ GNUnet/src/applications/fs/gap/ondemand.c 2008-02-16 02:54:40 UTC (rev
6316)
@@ -604,8 +604,18 @@
if (state == NULL)
{
GNUNET_GE_BREAK (coreAPI->ectx, 0);
+ GNUNET_free (index_directory);
return GNUNET_SYSERR;
}
+ datastore = capi->request_service ("datastore");
+ if (datastore == NULL)
+ {
+ GNUNET_GE_BREAK (coreAPI->ectx, 0);
+ coreAPI->release_service (state);
+ state = NULL;
+ GNUNET_free (index_directory);
+ return GNUNET_SYSERR;
+ }
return 0;
}
@@ -615,6 +625,8 @@
{
coreAPI->release_service (state);
state = NULL;
+ coreAPI->release_service (datastore);
+ datastore = NULL;
GNUNET_free (index_directory);
index_directory = NULL;
return 0;
Modified: GNUnet/src/applications/fs/gap/test_linear_topology.c
===================================================================
--- GNUnet/src/applications/fs/gap/test_linear_topology.c 2008-02-16
01:40:47 UTC (rev 6315)
+++ GNUnet/src/applications/fs/gap/test_linear_topology.c 2008-02-16
02:54:40 UTC (rev 6316)
@@ -19,7 +19,7 @@
*/
/**
- * @file applications/gap/gaptest2.c
+ * @file applications/gap/test_linear_topology.c
* @brief GAP routing testcase, linear topology
* @author Christian Grothoff
*/
@@ -269,7 +269,7 @@
#if START_PEERS
peers = GNUNET_TESTING_start_daemons ("tcp",
"advertising topology fs stats",
- "/tmp/gnunet-gap-test2",
+ "/tmp/gnunet-gap-linear-test",
2087, 10, PEER_COUNT);
if (peers == NULL)
{
@@ -320,4 +320,4 @@
return ret;
}
-/* end of gaptest2.c */
+/* end of test_linear_topology.c */
Modified: GNUnet/src/applications/fs/gap/test_loopback.c
===================================================================
--- GNUnet/src/applications/fs/gap/test_loopback.c 2008-02-16 01:40:47 UTC
(rev 6315)
+++ GNUnet/src/applications/fs/gap/test_loopback.c 2008-02-16 02:54:40 UTC
(rev 6316)
@@ -19,7 +19,7 @@
*/
/**
- * @file applications/gap/gaptest.c
+ * @file applications/gap/test_loopback.c
* @brief GAP routing testcase
* @author Christian Grothoff
*/
@@ -263,7 +263,7 @@
#if START_PEERS
peers = GNUNET_TESTING_start_daemons ("tcp",
"advertising topology fs stats",
- "/tmp/gnunet-gap-test",
+ "/tmp/gnunet-gap-loopback-test",
2087, 10000, 2);
if (peers == NULL)
{
@@ -304,4 +304,4 @@
return ret;
}
-/* end of gaptest.c */
+/* end of test_loopback.c */
Added: GNUnet/src/applications/fs/gap/test_multi_results.c
===================================================================
--- GNUnet/src/applications/fs/gap/test_multi_results.c
(rev 0)
+++ GNUnet/src/applications/fs/gap/test_multi_results.c 2008-02-16 02:54:40 UTC
(rev 6316)
@@ -0,0 +1,211 @@
+/*
+ This file is part of GNUnet.
+ (C) 2005, 2006, 2007, 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., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+/**
+ * @file applications/gap/test_multi_results.c
+ * @brief GAP routing testcase, linear topology
+ * @author Christian Grothoff
+ */
+
+#include "platform.h"
+#include "gnunet_protocols.h"
+#include "gnunet_ecrs_lib.h"
+#include "gnunet_testing_lib.h"
+#include "gnunet_stats_lib.h"
+#include "gnunet_util.h"
+#include "gnunet_stats_lib.h"
+
+#define START_PEERS 1
+
+#define PEER_COUNT 2
+
+/**
+ * How many search results are there?
+ */
+#define TOTAL 100
+
+static struct GNUNET_GE_Context *ectx;
+
+static struct GNUNET_GC_Configuration *cfg;
+
+static struct GNUNET_ECRS_URI *uris[TOTAL];
+
+static struct GNUNET_ECRS_URI *key;
+
+static unsigned int found;
+
+static int
+testTerminate (void *unused)
+{
+ return found == TOTAL ? GNUNET_SYSERR : GNUNET_OK;
+}
+
+static char *
+makeName (unsigned int i)
+{
+ char *fn;
+
+ fn = GNUNET_malloc (strlen ("/tmp/gnunet-gaptest/GAPTEST") + 14);
+ GNUNET_snprintf (fn,
+ strlen ("/tmp/gnunet-gaptest/GAPTEST") + 14,
+ "/tmp/gnunet-gaptest/GAPTEST%u", i);
+ GNUNET_disk_directory_create_for_file (NULL, fn);
+ return fn;
+}
+
+static struct GNUNET_ECRS_URI *
+uploadFile (int size)
+{
+ int ret;
+ char *name;
+ int fd;
+ char *buf;
+ struct GNUNET_ECRS_URI *uri;
+
+ name = makeName (size);
+ fd =
+ GNUNET_disk_file_open (ectx, name, O_WRONLY | O_CREAT, S_IWUSR | S_IRUSR);
+ buf = GNUNET_malloc (size);
+ memset (buf, size % 255, size);
+ WRITE (fd, buf, size);
+ GNUNET_free (buf);
+ GNUNET_disk_file_close (ectx, name, fd);
+ ret = GNUNET_ECRS_file_upload (ectx, cfg, name, GNUNET_YES, /* index */
+ 1, /* anon */
+ 0, /* prio */
+ GNUNET_get_time () + 100 *
GNUNET_CRON_MINUTES, /* expire */
+ NULL,
+ NULL, &testTerminate, NULL, &uri);
+ if (ret != GNUNET_SYSERR)
+ {
+ struct GNUNET_ECRS_MetaData *meta;
+
+ meta = GNUNET_ECRS_meta_data_create ();
+ ret = GNUNET_ECRS_publish_under_keyword (ectx, cfg, key, 0, 0,
GNUNET_get_time () + 100 * GNUNET_CRON_MINUTES, /* expire */
+ uri, meta);
+ GNUNET_ECRS_meta_data_destroy (meta);
+ GNUNET_ECRS_uri_destroy (uri);
+ GNUNET_free (name);
+ return (ret == GNUNET_OK) ? key : NULL;
+ }
+ else
+ {
+ GNUNET_free (name);
+ return NULL;
+ }
+}
+
+static int
+searchCB (const GNUNET_ECRS_FileInfo * fi,
+ const GNUNET_HashCode * key, int isRoot, void *closure)
+{
+ int i;
+
+ for (i=0;i<TOTAL;i++)
+ {
+ if ( (uris[i] != NULL) &&
+ (GNUNET_ECRS_uri_test_equal(uris[i],
+ fi->uri)) )
+ {
+ uris[i] = NULL;
+ found++;
+ return GNUNET_OK;
+ }
+ }
+ return GNUNET_OK;
+}
+
+#define CHECK(a) if (!(a)) { ret = 1; GNUNET_GE_BREAK(ectx, 0); goto FAILURE; }
+
+/**
+ * Testcase to test gap routing (2 peers only).
+ * @return 0: ok, -1: error
+ */
+int
+main (int argc, char **argv)
+{
+ struct GNUNET_TESTING_DaemonContext *peers;
+ int ret;
+ int i;
+ char buf[128];
+ const char *keywords[] =
+ {
+ "multi-test",
+ NULL,
+ };
+
+ ret = 0;
+ cfg = GNUNET_GC_create ();
+ if (-1 == GNUNET_GC_parse_configuration (cfg, "check.conf"))
+ {
+ GNUNET_GC_free (cfg);
+ return -1;
+ }
+#if START_PEERS
+ peers = GNUNET_TESTING_start_daemons ("tcp",
+ "advertising topology fs stats",
+ "/tmp/gnunet-gap-muti-results-test",
+ 2087, 10, PEER_COUNT);
+ if (peers == NULL)
+ {
+ fprintf (stderr, "Failed to start the gnunetd daemons!\n");
+ GNUNET_GC_free (cfg);
+ return -1;
+ }
+#endif
+ for (i = 1; i < PEER_COUNT; i++)
+ {
+ if (GNUNET_OK != GNUNET_TESTING_connect_daemons (2077 + (10 * i),
+ 2087 + (10 * i)))
+ {
+ GNUNET_TESTING_stop_daemons (peers);
+ fprintf (stderr, "Failed to connect the peers!\n");
+ GNUNET_GC_free (cfg);
+ return -1;
+ }
+ }
+ key = GNUNET_ECRS_keyword_strings_to_uri (keywords);
+ printf ("Uploading...\n");
+ for (i=0;i<TOTAL;i++)
+ {
+ uris[i] = uploadFile (i+1);
+ fprintf(stderr, ".");
+ }
+ fprintf(stderr, "\n");
+
+ GNUNET_snprintf (buf, 128, "localhost:%u", 2077 + PEER_COUNT * 10);
+ GNUNET_GC_set_configuration_value_string (cfg, ectx, "NETWORK", "HOST",
+ buf);
+
+ ret = GNUNET_ECRS_search (ectx,
+ cfg,
+ key, 1, &searchCB, NULL, &testTerminate, NULL);
+ CHECK (ret == GNUNET_OK);
+ CHECK (found == TOTAL);
+FAILURE:
+#if START_PEERS
+ GNUNET_TESTING_stop_daemons (peers);
+#endif
+ GNUNET_ECRS_uri_destroy (key);
+ GNUNET_GC_free (cfg);
+ return ret;
+}
+
+/* end of test_multi_results.c */
Property changes on: GNUnet/src/applications/fs/gap/test_multi_results.c
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: GNUnet/src/applications/fs/gap/test_star_topology.c
===================================================================
--- GNUnet/src/applications/fs/gap/test_star_topology.c 2008-02-16 01:40:47 UTC
(rev 6315)
+++ GNUnet/src/applications/fs/gap/test_star_topology.c 2008-02-16 02:54:40 UTC
(rev 6316)
@@ -19,7 +19,7 @@
*/
/**
- * @file applications/gap/gaptest3.c
+ * @file applications/gap/test_star_topology.c
* @brief GAP economy testcase, download from star topology
* @author Christian Grothoff
*/
@@ -219,7 +219,7 @@
#if START_PEERS
peers = GNUNET_TESTING_start_daemons ("tcp",
"advertising topology fs stats",
- "/tmp/gnunet-gap-test3",
+ "/tmp/gnunet-gap-star-test",
2087, 10, PEER_COUNT);
if (peers == NULL)
{
@@ -290,4 +290,4 @@
return ret;
}
-/* end of gaptest3.c */
+/* end of test_star_topology.c */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r6316 - GNUnet/src/applications/fs/gap,
gnunet <=