aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-02-19 10:42:33 +0000
committerChristian Grothoff <christian@grothoff.org>2010-02-19 10:42:33 +0000
commit90ddf5bbf052b14d37a218e901ab4d69754f71d9 (patch)
treec9f492bc5958a8f4c70f0147e9f418974488a74b /src
parentc96194dcadd70af690465f874dfefd2c60c357f9 (diff)
downloadgnunet-90ddf5bbf052b14d37a218e901ab4d69754f71d9.tar.gz
gnunet-90ddf5bbf052b14d37a218e901ab4d69754f71d9.zip
test
Diffstat (limited to 'src')
-rw-r--r--src/fs/Makefile.am17
-rw-r--r--src/fs/test_fs_lib_data.conf49
-rw-r--r--src/fs/test_gnunet_service_fs_p2p.c149
3 files changed, 213 insertions, 2 deletions
diff --git a/src/fs/Makefile.am b/src/fs/Makefile.am
index 2e994b95a..743d93e14 100644
--- a/src/fs/Makefile.am
+++ b/src/fs/Makefile.am
@@ -125,7 +125,8 @@ check_PROGRAMS = \
125 test_fs_search \ 125 test_fs_search \
126 test_fs_start_stop \ 126 test_fs_start_stop \
127 test_fs_unindex \ 127 test_fs_unindex \
128 test_fs_uri 128 test_fs_uri \
129 test_gnunet_service_fs_p2p
129 130
130TESTS = \ 131TESTS = \
131 test_fs_directory \ 132 test_fs_directory \
@@ -136,9 +137,11 @@ TESTS = \
136 test_fs_search \ 137 test_fs_search \
137 test_fs_start_stop \ 138 test_fs_start_stop \
138 test_fs_unindex \ 139 test_fs_unindex \
139 test_fs_uri 140 test_fs_uri \
141 test_gnunet_service_fs_p2p
140# $(check_PROGRAMS) 142# $(check_PROGRAMS)
141 143
144
142test_fs_collection_SOURCES = \ 145test_fs_collection_SOURCES = \
143 test_fs_collection.c 146 test_fs_collection.c
144test_fs_collection_LDADD = \ 147test_fs_collection_LDADD = \
@@ -217,11 +220,21 @@ test_fs_uri_LDADD = \
217 $(top_builddir)/src/fs/libgnunetfs.la \ 220 $(top_builddir)/src/fs/libgnunetfs.la \
218 $(top_builddir)/src/util/libgnunetutil.la 221 $(top_builddir)/src/util/libgnunetutil.la
219 222
223test_gnunet_service_fs_p2p_SOURCES = \
224 test_gnunet_service_fs_p2p.c
225test_gnunet_service_fs_p2p_LDADD = \
226 $(top_builddir)/src/fs/libgnunetfstest.a \
227 $(top_builddir)/src/testing/libgnunettesting.la \
228 $(top_builddir)/src/fs/libgnunetfs.la \
229 $(top_builddir)/src/util/libgnunetutil.la
230
231
220EXTRA_DIST = \ 232EXTRA_DIST = \
221 test_fs_data.conf \ 233 test_fs_data.conf \
222 test_fs_collection_data.conf \ 234 test_fs_collection_data.conf \
223 test_fs_download_data.conf \ 235 test_fs_download_data.conf \
224 test_fs_file_information_data.conf \ 236 test_fs_file_information_data.conf \
237 test_fs_lib_data.conf \
225 test_fs_list_indexed_data.conf \ 238 test_fs_list_indexed_data.conf \
226 test_fs_namespace_data.conf \ 239 test_fs_namespace_data.conf \
227 test_fs_publish_data.conf \ 240 test_fs_publish_data.conf \
diff --git a/src/fs/test_fs_lib_data.conf b/src/fs/test_fs_lib_data.conf
new file mode 100644
index 000000000..b9d11c371
--- /dev/null
+++ b/src/fs/test_fs_lib_data.conf
@@ -0,0 +1,49 @@
1[PATHS]
2SERVICEHOME = /tmp/gnunet-test-fs-lib/
3DEFAULTCONFIG = test_fs_lib_data.conf
4
5[gnunetd]
6HOSTKEY = $SERVICEHOME/.hostkey
7
8[resolver]
9PORT = 43464
10HOSTNAME = localhost
11
12[transport]
13PORT = 43465
14PLUGINS = tcp
15
16[arm]
17PORT = 43466
18HOSTNAME = localhost
19DEFAULTSERVICES = resolver datastore transport core fs
20
21[datastore]
22#DEBUG = YES
23
24[statistics]
25PORT = 43467
26HOSTNAME = localhost
27
28[transport-tcp]
29ALLOW_SHUTDOWN = NO
30TIMEOUT = 300000
31PORT = 43468
32
33[peerinfo]
34PORT = 43469
35HOSTNAME = localhost
36
37[core]
38PORT = 43470
39HOSTNAME = localhost
40
41[fs]
42PORT = 43471
43HOSTNAME = localhost
44#DEBUG = YES
45#PREFIX = valgrind --tool=memcheck --leak-check=yes
46#BINARY = /home/grothoff/bin/gnunet-service-fs
47
48[testing]
49WEAKRANDOM = YES
diff --git a/src/fs/test_gnunet_service_fs_p2p.c b/src/fs/test_gnunet_service_fs_p2p.c
new file mode 100644
index 000000000..d36088d2b
--- /dev/null
+++ b/src/fs/test_gnunet_service_fs_p2p.c
@@ -0,0 +1,149 @@
1/*
2 This file is part of GNUnet.
3 (C) 2010 Christian Grothoff (and other contributing authors)
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21/**
22 * @file fs/test_gnunet_service_fs_p2p.c
23 * @brief test P2P routing using simple publish + download operation
24 * @author Christian Grothoff
25 */
26#include "platform.h"
27#include "test_fs_lib.h"
28
29#define VERBOSE GNUNET_NO
30
31/**
32 * File-size we use for testing.
33 */
34#define FILESIZE (1024 * 1024 * 2)
35
36/**
37 * How long until we give up on transmitting the message?
38 */
39#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
40
41#define NUM_DAEMONS 2
42
43#define SEED 42
44
45static struct GNUNET_FS_TestDaemon *daemons[NUM_DAEMONS];
46
47static struct GNUNET_SCHEDULER_Handle *sched;
48
49
50static void
51do_stop (void *cls,
52 const struct GNUNET_SCHEDULER_TaskContext *tc)
53{
54 GNUNET_assert (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE));
55 GNUNET_FS_TEST_daemons_stop (sched,
56 NUM_DAEMONS,
57 daemons);
58}
59
60
61static void
62do_download (void *cls,
63 const struct GNUNET_FS_Uri *uri)
64{
65 GNUNET_assert (NULL != uri);
66 GNUNET_FS_TEST_download (sched,
67 daemons[1],
68 TIMEOUT,
69 1, SEED, uri,
70 VERBOSE,
71 &do_stop, NULL);
72}
73
74
75static void
76do_publish (void *cls,
77 const struct GNUNET_SCHEDULER_TaskContext *tc)
78{
79 GNUNET_assert (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE));
80 GNUNET_FS_TEST_publish (sched,
81 daemons[1],
82 TIMEOUT,
83 1, GNUNET_NO, FILESIZE, SEED,
84 VERBOSE,
85 &do_download, NULL);
86}
87
88
89static void
90do_connect (void *cls,
91 const struct GNUNET_SCHEDULER_TaskContext *tc)
92{
93 GNUNET_assert (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE));
94 GNUNET_FS_TEST_daemons_connect (sched,
95 daemons[1],
96 daemons[2],
97 TIMEOUT,
98 &do_publish,
99 NULL);
100}
101
102
103static void
104run (void *cls,
105 struct GNUNET_SCHEDULER_Handle *s,
106 char *const *args,
107 const char *cfgfile,
108 const struct GNUNET_CONFIGURATION_Handle *cfg)
109{
110 sched = s;
111 GNUNET_FS_TEST_daemons_start (sched,
112 TIMEOUT,
113 NUM_DAEMONS,
114 daemons,
115 &do_connect,
116 NULL);
117}
118
119
120int
121main (int argc, char *argv[])
122{
123 char *const argvx[] = {
124 "test-gnunet-service-fs-p2p",
125 "-c",
126 "test_fs_lib_data.conf",
127#if VERBOSE
128 "-L", "DEBUG",
129#endif
130 NULL
131 };
132 struct GNUNET_GETOPT_CommandLineOption options[] = {
133 GNUNET_GETOPT_OPTION_END
134 };
135
136 GNUNET_log_setup ("test_gnunet_service_fs_p2p",
137#if VERBOSE
138 "DEBUG",
139#else
140 "WARNING",
141#endif
142 NULL);
143 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1,
144 argvx, "test-gnunet-service-fs-p2p",
145 "nohelp", options, &run, NULL);
146 return 0;
147}
148
149/* end of test_gnunet_service_fs_p2p.c */