diff options
author | Bart Polot <bart@net.in.tum.de> | 2011-10-21 13:00:09 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2011-10-21 13:00:09 +0000 |
commit | a30718300ec364b57daf8ef68559f947c9efa672 (patch) | |
tree | c4447554d661b12a42f1f0558fc282283847b50d /src/dht | |
parent | 59d63f89e82ccf724ac7c95f2e589d75a4eb0cc8 (diff) | |
download | gnunet-a30718300ec364b57daf8ef68559f947c9efa672.tar.gz gnunet-a30718300ec364b57daf8ef68559f947c9efa672.zip |
Integrated all 2dtorus test in one and added some more targets
Diffstat (limited to 'src/dht')
-rw-r--r-- | src/dht/Makefile.am | 16 | ||||
-rw-r--r-- | src/dht/test_dht_2dtorus.c | 113 |
2 files changed, 86 insertions, 43 deletions
diff --git a/src/dht/Makefile.am b/src/dht/Makefile.am index 6a8ce280a..952e828d3 100644 --- a/src/dht/Makefile.am +++ b/src/dht/Makefile.am | |||
@@ -78,8 +78,7 @@ check_PROGRAMS = \ | |||
78 | test_dht_twopeer_get_put \ | 78 | test_dht_twopeer_get_put \ |
79 | test_dht_twopeer_path_tracking \ | 79 | test_dht_twopeer_path_tracking \ |
80 | test_dht_multipeer \ | 80 | test_dht_multipeer \ |
81 | test_dht_2dtorus \ | 81 | test_dht_2dtorus |
82 | test_dht_2dtorus_far | ||
83 | 82 | ||
84 | if ENABLE_TEST_RUN | 83 | if ENABLE_TEST_RUN |
85 | TESTS = test_dht_api $(check_SCRIPTS) \ | 84 | TESTS = test_dht_api $(check_SCRIPTS) \ |
@@ -88,8 +87,7 @@ TESTS = test_dht_api $(check_SCRIPTS) \ | |||
88 | test_dht_twopeer_get_put \ | 87 | test_dht_twopeer_get_put \ |
89 | test_dht_twopeer_path_tracking \ | 88 | test_dht_twopeer_path_tracking \ |
90 | test_dht_multipeer \ | 89 | test_dht_multipeer \ |
91 | test_dht_2dtorus \ | 90 | test_dht_2dtorus |
92 | test_dht_2dtorus_far | ||
93 | endif | 91 | endif |
94 | 92 | ||
95 | test_dht_api_SOURCES = \ | 93 | test_dht_api_SOURCES = \ |
@@ -150,16 +148,6 @@ test_dht_2dtorus_LDADD = \ | |||
150 | test_dht_2dtorus_DEPENDENCIES = \ | 148 | test_dht_2dtorus_DEPENDENCIES = \ |
151 | libgnunetdht.la | 149 | libgnunetdht.la |
152 | 150 | ||
153 | test_dht_2dtorus_far_SOURCES = \ | ||
154 | test_dht_2dtorus.c | ||
155 | test_dht_2dtorus_far_LDADD = \ | ||
156 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
157 | $(top_builddir)/src/testing/libgnunettesting.la \ | ||
158 | $(top_builddir)/src/dht/libgnunetdht.la | ||
159 | test_dht_2dtorus_far_DEPENDENCIES = \ | ||
160 | libgnunetdht.la | ||
161 | |||
162 | |||
163 | EXTRA_DIST = \ | 151 | EXTRA_DIST = \ |
164 | $(check_SCRIPTS) \ | 152 | $(check_SCRIPTS) \ |
165 | test_dht_api_data.conf \ | 153 | test_dht_api_data.conf \ |
diff --git a/src/dht/test_dht_2dtorus.c b/src/dht/test_dht_2dtorus.c index 7c6c61a81..cc2520580 100644 --- a/src/dht/test_dht_2dtorus.c +++ b/src/dht/test_dht_2dtorus.c | |||
@@ -41,8 +41,6 @@ | |||
41 | 41 | ||
42 | static int ok; | 42 | static int ok; |
43 | 43 | ||
44 | static int far; | ||
45 | |||
46 | /** | 44 | /** |
47 | * Be verbose | 45 | * Be verbose |
48 | */ | 46 | */ |
@@ -115,6 +113,12 @@ struct GNUNET_DHT_Handle **hs; | |||
115 | 113 | ||
116 | struct GNUNET_DHT_GetHandle *get_h; | 114 | struct GNUNET_DHT_GetHandle *get_h; |
117 | 115 | ||
116 | struct GNUNET_DHT_GetHandle *get_h_2; | ||
117 | |||
118 | struct GNUNET_DHT_GetHandle *get_h_far; | ||
119 | |||
120 | unsigned int found; | ||
121 | |||
118 | /** | 122 | /** |
119 | * Check whether peers successfully shut down. | 123 | * Check whether peers successfully shut down. |
120 | */ | 124 | */ |
@@ -168,6 +172,10 @@ disconnect_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
168 | GNUNET_SCHEDULER_cancel (put_task); | 172 | GNUNET_SCHEDULER_cancel (put_task); |
169 | if (NULL != get_h) | 173 | if (NULL != get_h) |
170 | GNUNET_DHT_get_stop(get_h); | 174 | GNUNET_DHT_get_stop(get_h); |
175 | if (NULL != get_h_2) | ||
176 | GNUNET_DHT_get_stop(get_h_2); | ||
177 | if (NULL != get_h_far) | ||
178 | GNUNET_DHT_get_stop(get_h_far); | ||
171 | for (i = 0; i < num_peers; i++) | 179 | for (i = 0; i < num_peers; i++) |
172 | { | 180 | { |
173 | GNUNET_DHT_disconnect(hs[i]); | 181 | GNUNET_DHT_disconnect(hs[i]); |
@@ -185,47 +193,74 @@ dht_get_id_handler (void *cls, struct GNUNET_TIME_Absolute exp, | |||
185 | unsigned int put_path_length, | 193 | unsigned int put_path_length, |
186 | enum GNUNET_BLOCK_Type type, size_t size, const void *data) | 194 | enum GNUNET_BLOCK_Type type, size_t size, const void *data) |
187 | { | 195 | { |
188 | ok = 0; | 196 | int i; |
189 | 197 | ||
198 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
199 | "test: ************* FOUND!!! ***********\n"); | ||
200 | if (sizeof(GNUNET_HashCode) == size) | ||
201 | { | ||
202 | const GNUNET_HashCode *h = data; | ||
190 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 203 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
191 | "test: ************* FOUND!!! ***********\n"); | 204 | "test: Contents: %s\n", |
192 | if (sizeof(GNUNET_HashCode) == size) | 205 | GNUNET_h2s_full (h)); |
193 | { | 206 | |
194 | const GNUNET_HashCode *h = data; | 207 | } |
195 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 208 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
196 | "test: Contents: %s\n", | 209 | "test: PATH: (get %u, put %u)\n", |
197 | GNUNET_h2s_full (h)); | 210 | get_path_length, |
198 | 211 | put_path_length); | |
199 | } | 212 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
200 | GNUNET_SCHEDULER_cancel(disconnect_task); | 213 | "test: LOCAL\n"); |
201 | disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_peers, NULL); | 214 | for (i = get_path_length - 1; i >= 0; i--) |
215 | { | ||
216 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
217 | "test: %s\n", | ||
218 | GNUNET_i2s (&get_path[i])); | ||
219 | } | ||
220 | for (i = put_path_length - 1; i >= 0; i--) | ||
221 | { | ||
222 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
223 | "test: %s\n", | ||
224 | GNUNET_i2s (&put_path[i])); | ||
225 | } | ||
226 | found++; | ||
227 | if (found < 3) | ||
228 | return; | ||
229 | ok = 0; | ||
230 | GNUNET_SCHEDULER_cancel(disconnect_task); | ||
231 | disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_peers, NULL); | ||
202 | } | 232 | } |
203 | 233 | ||
204 | static void | 234 | static void |
205 | do_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 235 | do_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
206 | { | 236 | { |
207 | struct GNUNET_TESTING_Daemon *d; | 237 | struct GNUNET_TESTING_Daemon *d; |
238 | struct GNUNET_TESTING_Daemon *d2; | ||
239 | struct GNUNET_TESTING_Daemon *d_far; | ||
208 | struct GNUNET_TESTING_Daemon *o; | 240 | struct GNUNET_TESTING_Daemon *o; |
209 | struct GNUNET_TESTING_Daemon *aux; | 241 | struct GNUNET_TESTING_Daemon *aux; |
210 | const char *id_aux; | 242 | const char *id_aux; |
211 | const char *id_origin = "FC74"; | 243 | const char *id_origin = "FC74"; |
212 | const char *id_near = "9P6V"; | 244 | const char *id_near = "9P6V"; |
245 | const char *id_near2 = "2GDS"; | ||
213 | const char *id_far = "KPST"; | 246 | const char *id_far = "KPST"; |
214 | unsigned int i; | 247 | unsigned int i; |
215 | 248 | ||
216 | d = o = NULL; | 249 | d = d2 = d_far = o = NULL; |
217 | for (i = 0; i < num_peers; i++) | 250 | for (i = 0; i < num_peers; i++) |
218 | { | 251 | { |
219 | aux = GNUNET_TESTING_daemon_get (pg, i); | 252 | aux = GNUNET_TESTING_daemon_get (pg, i); |
220 | id_aux = GNUNET_i2s (&aux->id); | 253 | id_aux = GNUNET_i2s (&aux->id); |
221 | if (strcmp (id_aux, id_origin) == 0) | 254 | if (strcmp (id_aux, id_origin) == 0) |
222 | o = aux; | 255 | o = aux; |
223 | if (far == GNUNET_YES && strcmp (id_aux, id_far) == 0) | 256 | if (strcmp (id_aux, id_far) == 0) |
224 | d = aux; | 257 | d_far = aux; |
225 | if (far == GNUNET_NO && strcmp (id_aux, id_near) == 0) | 258 | if (strcmp (id_aux, id_near) == 0) |
226 | d = aux; | 259 | d = aux; |
260 | if (strcmp (id_aux, id_near2) == 0) | ||
261 | d2 = aux; | ||
227 | } | 262 | } |
228 | if (NULL == o || NULL == d) | 263 | if (NULL == o || NULL == d || NULL == d2 || NULL == d_far) |
229 | { | 264 | { |
230 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 265 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
231 | "test: Peers not found (hostkey file changed?)\n"); | 266 | "test: Peers not found (hostkey file changed?)\n"); |
@@ -237,8 +272,15 @@ do_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
237 | "test: looking for %s\n", | 272 | "test: looking for %s\n", |
238 | GNUNET_h2s_full (&d->id.hashPubKey)); | 273 | GNUNET_h2s_full (&d->id.hashPubKey)); |
239 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 274 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
275 | "test: looking for %s\n", | ||
276 | GNUNET_h2s_full (&d2->id.hashPubKey)); | ||
277 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
278 | "test: looking for %s\n", | ||
279 | GNUNET_h2s_full (&d_far->id.hashPubKey)); | ||
280 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
240 | "test: from %s\n", | 281 | "test: from %s\n", |
241 | GNUNET_h2s_full (&o->id.hashPubKey)); | 282 | GNUNET_h2s_full (&o->id.hashPubKey)); |
283 | found = 0; | ||
242 | get_h = GNUNET_DHT_get_start (hs[0], | 284 | get_h = GNUNET_DHT_get_start (hs[0], |
243 | GNUNET_TIME_UNIT_FOREVER_REL, /* timeout */ | 285 | GNUNET_TIME_UNIT_FOREVER_REL, /* timeout */ |
244 | GNUNET_BLOCK_TYPE_TEST, /* type */ | 286 | GNUNET_BLOCK_TYPE_TEST, /* type */ |
@@ -250,6 +292,28 @@ do_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
250 | 0, /* xquery bits */ | 292 | 0, /* xquery bits */ |
251 | &dht_get_id_handler, | 293 | &dht_get_id_handler, |
252 | NULL); | 294 | NULL); |
295 | get_h_2 = GNUNET_DHT_get_start (hs[0], | ||
296 | GNUNET_TIME_UNIT_FOREVER_REL, /* timeout */ | ||
297 | GNUNET_BLOCK_TYPE_TEST, /* type */ | ||
298 | &d2->id.hashPubKey, /*key to search */ | ||
299 | 4U, /* replication level */ | ||
300 | GNUNET_DHT_RO_RECORD_ROUTE | | ||
301 | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, | ||
302 | NULL, /* xquery */ | ||
303 | 0, /* xquery bits */ | ||
304 | &dht_get_id_handler, | ||
305 | NULL); | ||
306 | get_h_far = GNUNET_DHT_get_start (hs[0], | ||
307 | GNUNET_TIME_UNIT_FOREVER_REL, /* timeout */ | ||
308 | GNUNET_BLOCK_TYPE_TEST, /* type */ | ||
309 | &d_far->id.hashPubKey, /*key to search */ | ||
310 | 4U, /* replication level */ | ||
311 | GNUNET_DHT_RO_RECORD_ROUTE | | ||
312 | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, | ||
313 | NULL, /* xquery */ | ||
314 | 0, /* xquery bits */ | ||
315 | &dht_get_id_handler, | ||
316 | NULL); | ||
253 | GNUNET_SCHEDULER_cancel (disconnect_task); | 317 | GNUNET_SCHEDULER_cancel (disconnect_task); |
254 | disconnect_task = GNUNET_SCHEDULER_add_delayed( | 318 | disconnect_task = GNUNET_SCHEDULER_add_delayed( |
255 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30), | 319 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30), |
@@ -522,15 +586,6 @@ main (int xargc, char *xargv[]) | |||
522 | #endif | 586 | #endif |
523 | NULL | 587 | NULL |
524 | }; | 588 | }; |
525 | |||
526 | if (strstr (xargv[0], "2dtorus_far") != NULL) | ||
527 | { | ||
528 | far = GNUNET_YES; | ||
529 | } | ||
530 | else | ||
531 | { | ||
532 | far = GNUNET_NO; | ||
533 | } | ||
534 | 589 | ||
535 | GNUNET_PROGRAM_run (sizeof(argv)/sizeof(char*) - 1, argv, "test_dht_2dtorus", | 590 | GNUNET_PROGRAM_run (sizeof(argv)/sizeof(char*) - 1, argv, "test_dht_2dtorus", |
536 | gettext_noop ("Test dht in a small 2D torus."), options, | 591 | gettext_noop ("Test dht in a small 2D torus."), options, |