diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/fs/Makefile.am | 17 | ||||
-rw-r--r-- | src/fs/test_fs_lib_data.conf | 49 | ||||
-rw-r--r-- | src/fs/test_gnunet_service_fs_p2p.c | 149 |
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 | ||
130 | TESTS = \ | 131 | TESTS = \ |
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 | |||
142 | test_fs_collection_SOURCES = \ | 145 | test_fs_collection_SOURCES = \ |
143 | test_fs_collection.c | 146 | test_fs_collection.c |
144 | test_fs_collection_LDADD = \ | 147 | test_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 | ||
223 | test_gnunet_service_fs_p2p_SOURCES = \ | ||
224 | test_gnunet_service_fs_p2p.c | ||
225 | test_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 | |||
220 | EXTRA_DIST = \ | 232 | EXTRA_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] | ||
2 | SERVICEHOME = /tmp/gnunet-test-fs-lib/ | ||
3 | DEFAULTCONFIG = test_fs_lib_data.conf | ||
4 | |||
5 | [gnunetd] | ||
6 | HOSTKEY = $SERVICEHOME/.hostkey | ||
7 | |||
8 | [resolver] | ||
9 | PORT = 43464 | ||
10 | HOSTNAME = localhost | ||
11 | |||
12 | [transport] | ||
13 | PORT = 43465 | ||
14 | PLUGINS = tcp | ||
15 | |||
16 | [arm] | ||
17 | PORT = 43466 | ||
18 | HOSTNAME = localhost | ||
19 | DEFAULTSERVICES = resolver datastore transport core fs | ||
20 | |||
21 | [datastore] | ||
22 | #DEBUG = YES | ||
23 | |||
24 | [statistics] | ||
25 | PORT = 43467 | ||
26 | HOSTNAME = localhost | ||
27 | |||
28 | [transport-tcp] | ||
29 | ALLOW_SHUTDOWN = NO | ||
30 | TIMEOUT = 300000 | ||
31 | PORT = 43468 | ||
32 | |||
33 | [peerinfo] | ||
34 | PORT = 43469 | ||
35 | HOSTNAME = localhost | ||
36 | |||
37 | [core] | ||
38 | PORT = 43470 | ||
39 | HOSTNAME = localhost | ||
40 | |||
41 | [fs] | ||
42 | PORT = 43471 | ||
43 | HOSTNAME = localhost | ||
44 | #DEBUG = YES | ||
45 | #PREFIX = valgrind --tool=memcheck --leak-check=yes | ||
46 | #BINARY = /home/grothoff/bin/gnunet-service-fs | ||
47 | |||
48 | [testing] | ||
49 | WEAKRANDOM = 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 | |||
45 | static struct GNUNET_FS_TestDaemon *daemons[NUM_DAEMONS]; | ||
46 | |||
47 | static struct GNUNET_SCHEDULER_Handle *sched; | ||
48 | |||
49 | |||
50 | static void | ||
51 | do_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 | |||
61 | static void | ||
62 | do_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 | |||
75 | static void | ||
76 | do_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 | |||
89 | static void | ||
90 | do_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 | |||
103 | static void | ||
104 | run (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 | |||
120 | int | ||
121 | main (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 */ | ||