aboutsummaryrefslogtreecommitdiff
path: root/src/fs
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-06-15 08:38:53 +0000
committerChristian Grothoff <christian@grothoff.org>2012-06-15 08:38:53 +0000
commit36ca9fcc68935edd109481d30f9e6e15a825c282 (patch)
tree5c976b741a314b5c3486124a9bff74b4ab5f5b78 /src/fs
parente825548ea9a45d1f4b25898f87b5c74f8bc4cc25 (diff)
downloadgnunet-36ca9fcc68935edd109481d30f9e6e15a825c282.tar.gz
gnunet-36ca9fcc68935edd109481d30f9e6e15a825c282.zip
-simplifying tests with new testing lib
Diffstat (limited to 'src/fs')
-rw-r--r--src/fs/Makefile.am6
-rw-r--r--src/fs/test_fs_publish.c111
-rw-r--r--src/fs/test_fs_publish_persistence.c95
-rw-r--r--src/fs/test_fs_search.c95
-rw-r--r--src/fs/test_fs_search_persistence.c110
-rw-r--r--src/fs/test_fs_search_probes.c71
-rw-r--r--src/fs/test_fs_start_stop.c85
-rw-r--r--src/fs/test_fs_uri.c50
8 files changed, 93 insertions, 530 deletions
diff --git a/src/fs/Makefile.am b/src/fs/Makefile.am
index 224c0fd0c..efe126a2c 100644
--- a/src/fs/Makefile.am
+++ b/src/fs/Makefile.am
@@ -327,36 +327,42 @@ test_fs_namespace_list_updateable_LDADD = \
327test_fs_publish_SOURCES = \ 327test_fs_publish_SOURCES = \
328 test_fs_publish.c 328 test_fs_publish.c
329test_fs_publish_LDADD = \ 329test_fs_publish_LDADD = \
330 $(top_builddir)/src/testing/libgnunettesting.la \
330 $(top_builddir)/src/fs/libgnunetfs.la \ 331 $(top_builddir)/src/fs/libgnunetfs.la \
331 $(top_builddir)/src/util/libgnunetutil.la 332 $(top_builddir)/src/util/libgnunetutil.la
332 333
333test_fs_publish_persistence_SOURCES = \ 334test_fs_publish_persistence_SOURCES = \
334 test_fs_publish_persistence.c 335 test_fs_publish_persistence.c
335test_fs_publish_persistence_LDADD = \ 336test_fs_publish_persistence_LDADD = \
337 $(top_builddir)/src/testing/libgnunettesting.la \
336 $(top_builddir)/src/fs/libgnunetfs.la \ 338 $(top_builddir)/src/fs/libgnunetfs.la \
337 $(top_builddir)/src/util/libgnunetutil.la 339 $(top_builddir)/src/util/libgnunetutil.la
338 340
339test_fs_search_SOURCES = \ 341test_fs_search_SOURCES = \
340 test_fs_search.c 342 test_fs_search.c
341test_fs_search_LDADD = \ 343test_fs_search_LDADD = \
344 $(top_builddir)/src/testing/libgnunettesting.la \
342 $(top_builddir)/src/fs/libgnunetfs.la \ 345 $(top_builddir)/src/fs/libgnunetfs.la \
343 $(top_builddir)/src/util/libgnunetutil.la 346 $(top_builddir)/src/util/libgnunetutil.la
344 347
345test_fs_search_probes_SOURCES = \ 348test_fs_search_probes_SOURCES = \
346 test_fs_search_probes.c 349 test_fs_search_probes.c
347test_fs_search_probes_LDADD = \ 350test_fs_search_probes_LDADD = \
351 $(top_builddir)/src/testing/libgnunettesting.la \
348 $(top_builddir)/src/fs/libgnunetfs.la \ 352 $(top_builddir)/src/fs/libgnunetfs.la \
349 $(top_builddir)/src/util/libgnunetutil.la 353 $(top_builddir)/src/util/libgnunetutil.la
350 354
351test_fs_search_persistence_SOURCES = \ 355test_fs_search_persistence_SOURCES = \
352 test_fs_search_persistence.c 356 test_fs_search_persistence.c
353test_fs_search_persistence_LDADD = \ 357test_fs_search_persistence_LDADD = \
358 $(top_builddir)/src/testing/libgnunettesting.la \
354 $(top_builddir)/src/fs/libgnunetfs.la \ 359 $(top_builddir)/src/fs/libgnunetfs.la \
355 $(top_builddir)/src/util/libgnunetutil.la 360 $(top_builddir)/src/util/libgnunetutil.la
356 361
357test_fs_start_stop_SOURCES = \ 362test_fs_start_stop_SOURCES = \
358 test_fs_start_stop.c 363 test_fs_start_stop.c
359test_fs_start_stop_LDADD = \ 364test_fs_start_stop_LDADD = \
365 $(top_builddir)/src/testing/libgnunettesting.la \
360 $(top_builddir)/src/fs/libgnunetfs.la \ 366 $(top_builddir)/src/fs/libgnunetfs.la \
361 $(top_builddir)/src/util/libgnunetutil.la 367 $(top_builddir)/src/util/libgnunetutil.la
362 368
diff --git a/src/fs/test_fs_publish.c b/src/fs/test_fs_publish.c
index 1560f4ea3..47a604c1d 100644
--- a/src/fs/test_fs_publish.c
+++ b/src/fs/test_fs_publish.c
@@ -17,23 +17,17 @@
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20
21/** 20/**
22 * @file fs/test_fs_publish.c 21 * @file fs/test_fs_publish.c
23 * @brief simple testcase for publish operation (indexing, listing 22 * @brief simple testcase for publish operation (indexing, listing
24 * indexed, directory structure) 23 * indexed, directory structure)
25 * @author Christian Grothoff 24 * @author Christian Grothoff
26 */ 25 */
27
28#include "platform.h" 26#include "platform.h"
29#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
30#include "gnunet_arm_service.h" 28#include "gnunet_testing_lib-new.h"
31#include "gnunet_fs_service.h" 29#include "gnunet_fs_service.h"
32 30
33#define VERBOSE GNUNET_NO
34
35#define START_ARM GNUNET_YES
36
37/** 31/**
38 * File-size we use for testing. 32 * File-size we use for testing.
39 */ 33 */
@@ -49,15 +43,6 @@
49 */ 43 */
50#define LIFETIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15) 44#define LIFETIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15)
51 45
52struct PeerContext
53{
54 struct GNUNET_CONFIGURATION_Handle *cfg;
55#if START_ARM
56 struct GNUNET_OS_Process *arm_proc;
57#endif
58};
59
60static struct PeerContext p1;
61 46
62static struct GNUNET_TIME_Absolute start; 47static struct GNUNET_TIME_Absolute start;
63 48
@@ -71,6 +56,7 @@ static char *fn2;
71 56
72static int err; 57static int err;
73 58
59
74static void 60static void
75abort_publish_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 61abort_publish_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
76{ 62{
@@ -107,14 +93,13 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
107 case GNUNET_FS_STATUS_PUBLISH_PROGRESS: 93 case GNUNET_FS_STATUS_PUBLISH_PROGRESS:
108 ret = event->value.publish.cctx; 94 ret = event->value.publish.cctx;
109 GNUNET_assert (publish == event->value.publish.pc); 95 GNUNET_assert (publish == event->value.publish.pc);
110#if VERBOSE 96 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
111 printf ("Publish is progressing (%llu/%llu at level %u off %llu)...\n", 97 "Publish is progressing (%llu/%llu at level %u off %llu)...\n",
112 (unsigned long long) event->value.publish.completed, 98 (unsigned long long) event->value.publish.completed,
113 (unsigned long long) event->value.publish.size, 99 (unsigned long long) event->value.publish.size,
114 event->value.publish.specifics.progress.depth, 100 event->value.publish.specifics.progress.depth,
115 (unsigned long long) event->value.publish.specifics. 101 (unsigned long long) event->value.publish.specifics.
116 progress.offset); 102 progress.offset);
117#endif
118 break; 103 break;
119 case GNUNET_FS_STATUS_PUBLISH_ERROR: 104 case GNUNET_FS_STATUS_PUBLISH_ERROR:
120 ret = event->value.publish.cctx; 105 ret = event->value.publish.cctx;
@@ -168,44 +153,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
168 153
169 154
170static void 155static void
171setup_peer (struct PeerContext *p, const char *cfgname) 156run (void *cls,
172{
173 p->cfg = GNUNET_CONFIGURATION_create ();
174#if START_ARM
175 p->arm_proc =
176 GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
177 "gnunet-service-arm",
178#if VERBOSE
179 "-L", "DEBUG",
180#endif
181 "-c", cfgname, NULL);
182#endif
183 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
184}
185
186
187static void
188stop_arm (struct PeerContext *p)
189{
190#if START_ARM
191 if (NULL != p->arm_proc)
192 {
193 if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
194 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
195 if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK)
196 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
197 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n",
198 GNUNET_OS_process_get_pid (p->arm_proc));
199 GNUNET_OS_process_destroy (p->arm_proc);
200 p->arm_proc = NULL;
201 }
202#endif
203 GNUNET_CONFIGURATION_destroy (p->cfg);
204}
205
206
207static void
208run (void *cls, char *const *args, const char *cfgfile,
209 const struct GNUNET_CONFIGURATION_Handle *cfg) 157 const struct GNUNET_CONFIGURATION_Handle *cfg)
210{ 158{
211 const char *keywords[] = { 159 const char *keywords[] = {
@@ -221,7 +169,6 @@ run (void *cls, char *const *args, const char *cfgfile,
221 size_t i; 169 size_t i;
222 struct GNUNET_FS_BlockOptions bo; 170 struct GNUNET_FS_BlockOptions bo;
223 171
224 setup_peer (&p1, "test_fs_publish_data.conf");
225 fs = GNUNET_FS_start (cfg, "test-fs-publish", &progress_cb, NULL, 172 fs = GNUNET_FS_start (cfg, "test-fs-publish", &progress_cb, NULL,
226 GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); 173 GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END);
227 GNUNET_assert (NULL != fs); 174 GNUNET_assert (NULL != fs);
@@ -283,40 +230,10 @@ run (void *cls, char *const *args, const char *cfgfile,
283int 230int
284main (int argc, char *argv[]) 231main (int argc, char *argv[])
285{ 232{
286 char *const argvx[] = { 233 if (0 != GNUNET_TESTING_peer_run ("test-fs-publish",
287 "test-fs-publish", 234 "test_fs_publish_data.conf",
288 "-c", 235 &run, NULL))
289 "test_fs_publish_data.conf", 236 return 1;
290#if VERBOSE
291 "-L", "DEBUG",
292#endif
293 NULL
294 };
295 struct GNUNET_GETOPT_CommandLineOption options[] = {
296 GNUNET_GETOPT_OPTION_END
297 };
298
299 GNUNET_log_setup ("test_fs_publish",
300#if VERBOSE
301 "DEBUG",
302#else
303 "WARNING",
304#endif
305 NULL);
306 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx,
307 "test-fs-publish", "nohelp", options, &run, NULL);
308 stop_arm (&p1);
309 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-publish/");
310 if (fn1 != NULL)
311 {
312 GNUNET_DISK_directory_remove (fn1);
313 GNUNET_free (fn1);
314 }
315 if (fn2 != NULL)
316 {
317 GNUNET_DISK_directory_remove (fn2);
318 GNUNET_free (fn2);
319 }
320 return err; 237 return err;
321} 238}
322 239
diff --git a/src/fs/test_fs_publish_persistence.c b/src/fs/test_fs_publish_persistence.c
index 7d3bc32ae..cbe859531 100644
--- a/src/fs/test_fs_publish_persistence.c
+++ b/src/fs/test_fs_publish_persistence.c
@@ -17,21 +17,16 @@
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20
21/** 20/**
22 * @file fs/test_fs_publish_persistence.c 21 * @file fs/test_fs_publish_persistence.c
23 * @brief simple testcase for persistence of simple publish operation 22 * @brief simple testcase for persistence of simple publish operation
24 * @author Christian Grothoff 23 * @author Christian Grothoff
25 */ 24 */
26
27#include "platform.h" 25#include "platform.h"
28#include "gnunet_util_lib.h" 26#include "gnunet_util_lib.h"
29#include "gnunet_arm_service.h" 27#include "gnunet_testing_lib-new.h"
30#include "gnunet_fs_service.h" 28#include "gnunet_fs_service.h"
31 29
32#define VERBOSE GNUNET_NO
33
34#define START_ARM GNUNET_YES
35 30
36/** 31/**
37 * File-size we use for testing. 32 * File-size we use for testing.
@@ -48,15 +43,6 @@
48 */ 43 */
49#define LIFETIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15) 44#define LIFETIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15)
50 45
51struct PeerContext
52{
53 struct GNUNET_CONFIGURATION_Handle *cfg;
54#if START_ARM
55 struct GNUNET_OS_Process *arm_proc;
56#endif
57};
58
59static struct PeerContext p1;
60 46
61static struct GNUNET_TIME_Absolute start; 47static struct GNUNET_TIME_Absolute start;
62 48
@@ -76,6 +62,7 @@ static int err;
76 62
77static GNUNET_SCHEDULER_TaskIdentifier rtask; 63static GNUNET_SCHEDULER_TaskIdentifier rtask;
78 64
65
79static void 66static void
80abort_publish_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 67abort_publish_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
81{ 68{
@@ -231,44 +218,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
231 218
232 219
233static void 220static void
234setup_peer (struct PeerContext *p, const char *cfgname) 221run (void *cls,
235{
236 p->cfg = GNUNET_CONFIGURATION_create ();
237#if START_ARM
238 p->arm_proc =
239 GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
240 "gnunet-service-arm",
241#if VERBOSE
242 "-L", "DEBUG",
243#endif
244 "-c", cfgname, NULL);
245#endif
246 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
247}
248
249
250static void
251stop_arm (struct PeerContext *p)
252{
253#if START_ARM
254 if (NULL != p->arm_proc)
255 {
256 if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
257 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
258 if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK)
259 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
260 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n",
261 GNUNET_OS_process_get_pid (p->arm_proc));
262 GNUNET_OS_process_destroy (p->arm_proc);
263 p->arm_proc = NULL;
264 }
265#endif
266 GNUNET_CONFIGURATION_destroy (p->cfg);
267}
268
269
270static void
271run (void *cls, char *const *args, const char *cfgfile,
272 const struct GNUNET_CONFIGURATION_Handle *c) 222 const struct GNUNET_CONFIGURATION_Handle *c)
273{ 223{
274 const char *keywords[] = { 224 const char *keywords[] = {
@@ -285,7 +235,6 @@ run (void *cls, char *const *args, const char *cfgfile,
285 struct GNUNET_FS_BlockOptions bo; 235 struct GNUNET_FS_BlockOptions bo;
286 236
287 cfg = c; 237 cfg = c;
288 setup_peer (&p1, "test_fs_publish_data.conf");
289 fs = GNUNET_FS_start (cfg, "test-fs-publish-persistence", &progress_cb, NULL, 238 fs = GNUNET_FS_start (cfg, "test-fs-publish-persistence", &progress_cb, NULL,
290 GNUNET_FS_FLAGS_PERSISTENCE, GNUNET_FS_OPTIONS_END); 239 GNUNET_FS_FLAGS_PERSISTENCE, GNUNET_FS_OPTIONS_END);
291 GNUNET_assert (NULL != fs); 240 GNUNET_assert (NULL != fs);
@@ -344,40 +293,10 @@ run (void *cls, char *const *args, const char *cfgfile,
344int 293int
345main (int argc, char *argv[]) 294main (int argc, char *argv[])
346{ 295{
347 char *const argvx[] = { 296 if (0 != GNUNET_TESTING_peer_run ("test-fs-publish-persistence",
348 "test-fs-publish-persistence", 297 "test_fs_publish_data.conf",
349 "-c", 298 &run, NULL))
350 "test_fs_publish_data.conf", 299 return 1;
351#if VERBOSE
352 "-L", "DEBUG",
353#endif
354 NULL
355 };
356 struct GNUNET_GETOPT_CommandLineOption options[] = {
357 GNUNET_GETOPT_OPTION_END
358 };
359
360 GNUNET_log_setup ("test_fs_publish_persistence",
361#if VERBOSE
362 "DEBUG",
363#else
364 "WARNING",
365#endif
366 NULL);
367 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx,
368 "test-fs-publish", "nohelp", options, &run, NULL);
369 stop_arm (&p1);
370 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-publish/");
371 if (fn1 != NULL)
372 {
373 GNUNET_DISK_directory_remove (fn1);
374 GNUNET_free (fn1);
375 }
376 if (fn2 != NULL)
377 {
378 GNUNET_DISK_directory_remove (fn2);
379 GNUNET_free (fn2);
380 }
381 return err; 300 return err;
382} 301}
383 302
diff --git a/src/fs/test_fs_search.c b/src/fs/test_fs_search.c
index 04c5897ac..1ae84a8d0 100644
--- a/src/fs/test_fs_search.c
+++ b/src/fs/test_fs_search.c
@@ -17,21 +17,16 @@
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20
21/** 20/**
22 * @file fs/test_fs_search.c 21 * @file fs/test_fs_search.c
23 * @brief simple testcase for simple publish + search operation 22 * @brief simple testcase for simple publish + search operation
24 * @author Christian Grothoff 23 * @author Christian Grothoff
25 */ 24 */
26
27#include "platform.h" 25#include "platform.h"
28#include "gnunet_util_lib.h" 26#include "gnunet_util_lib.h"
29#include "gnunet_arm_service.h" 27#include "gnunet_testing_lib-new.h"
30#include "gnunet_fs_service.h" 28#include "gnunet_fs_service.h"
31 29
32#define VERBOSE GNUNET_NO
33
34#define START_ARM GNUNET_YES
35 30
36/** 31/**
37 * File-size we use for testing. 32 * File-size we use for testing.
@@ -48,16 +43,6 @@
48 */ 43 */
49#define LIFETIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15) 44#define LIFETIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15)
50 45
51struct PeerContext
52{
53 struct GNUNET_CONFIGURATION_Handle *cfg;
54 struct GNUNET_PeerIdentity id;
55#if START_ARM
56 struct GNUNET_OS_Process *arm_proc;
57#endif
58};
59
60static struct PeerContext p1;
61 46
62static struct GNUNET_TIME_Absolute start; 47static struct GNUNET_TIME_Absolute start;
63 48
@@ -96,14 +81,13 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
96 switch (event->status) 81 switch (event->status)
97 { 82 {
98 case GNUNET_FS_STATUS_PUBLISH_PROGRESS: 83 case GNUNET_FS_STATUS_PUBLISH_PROGRESS:
99#if VERBOSE 84 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
100 printf ("Publish is progressing (%llu/%llu at level %u off %llu)...\n", 85 "Publish is progressing (%llu/%llu at level %u off %llu)...\n",
101 (unsigned long long) event->value.publish.completed, 86 (unsigned long long) event->value.publish.completed,
102 (unsigned long long) event->value.publish.size, 87 (unsigned long long) event->value.publish.size,
103 event->value.publish.specifics.progress.depth, 88 event->value.publish.specifics.progress.depth,
104 (unsigned long long) event->value.publish.specifics. 89 (unsigned long long) event->value.publish.specifics.
105 progress.offset); 90 progress.offset);
106#endif
107 break; 91 break;
108 case GNUNET_FS_STATUS_PUBLISH_COMPLETED: 92 case GNUNET_FS_STATUS_PUBLISH_COMPLETED:
109 kuri = GNUNET_FS_uri_ksk_create_from_args (1, keywords); 93 kuri = GNUNET_FS_uri_ksk_create_from_args (1, keywords);
@@ -115,9 +99,8 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
115 GNUNET_assert (search != NULL); 99 GNUNET_assert (search != NULL);
116 break; 100 break;
117 case GNUNET_FS_STATUS_SEARCH_RESULT: 101 case GNUNET_FS_STATUS_SEARCH_RESULT:
118#if VERBOSE 102 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
119 printf ("Search complete.\n"); 103 "Search complete.\n");
120#endif
121 GNUNET_SCHEDULER_add_continuation (&abort_search_task, NULL, 104 GNUNET_SCHEDULER_add_continuation (&abort_search_task, NULL,
122 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 105 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
123 break; 106 break;
@@ -169,41 +152,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
169 152
170 153
171static void 154static void
172setup_peer (struct PeerContext *p, const char *cfgname) 155run (void *cls,
173{
174 p->cfg = GNUNET_CONFIGURATION_create ();
175#if START_ARM
176 p->arm_proc =
177 GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
178 "gnunet-service-arm",
179 "-c", cfgname, NULL);
180#endif
181 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
182}
183
184
185static void
186stop_arm (struct PeerContext *p)
187{
188#if START_ARM
189 if (NULL != p->arm_proc)
190 {
191 if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
192 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
193 if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK)
194 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
195 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n",
196 GNUNET_OS_process_get_pid (p->arm_proc));
197 GNUNET_OS_process_destroy (p->arm_proc);
198 p->arm_proc = NULL;
199 }
200#endif
201 GNUNET_CONFIGURATION_destroy (p->cfg);
202}
203
204
205static void
206run (void *cls, char *const *args, const char *cfgfile,
207 const struct GNUNET_CONFIGURATION_Handle *cfg) 156 const struct GNUNET_CONFIGURATION_Handle *cfg)
208{ 157{
209 const char *keywords[] = { 158 const char *keywords[] = {
@@ -217,7 +166,6 @@ run (void *cls, char *const *args, const char *cfgfile,
217 struct GNUNET_FS_FileInformation *fi; 166 struct GNUNET_FS_FileInformation *fi;
218 size_t i; 167 size_t i;
219 168
220 setup_peer (&p1, "test_fs_search_data.conf");
221 fs = GNUNET_FS_start (cfg, "test-fs-search", &progress_cb, NULL, 169 fs = GNUNET_FS_start (cfg, "test-fs-search", &progress_cb, NULL,
222 GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); 170 GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END);
223 GNUNET_assert (NULL != fs); 171 GNUNET_assert (NULL != fs);
@@ -247,23 +195,10 @@ run (void *cls, char *const *args, const char *cfgfile,
247int 195int
248main (int argc, char *argv[]) 196main (int argc, char *argv[])
249{ 197{
250 char *const argvx[] = { 198 if (0 != GNUNET_TESTING_peer_run ("test-fs-search",
251 "test-fs-search", 199 "test_fs_search_data.conf",
252 "-c", 200 &run, NULL))
253 "test_fs_search_data.conf", 201 return 1;
254 NULL
255 };
256 struct GNUNET_GETOPT_CommandLineOption options[] = {
257 GNUNET_GETOPT_OPTION_END
258 };
259
260 GNUNET_log_setup ("test_fs_search",
261 "WARNING",
262 NULL);
263 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx,
264 "test-fs-search", "nohelp", options, &run, NULL);
265 stop_arm (&p1);
266 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-search/");
267 return 0; 202 return 0;
268} 203}
269 204
diff --git a/src/fs/test_fs_search_persistence.c b/src/fs/test_fs_search_persistence.c
index d18b50eb5..cedf4b8a5 100644
--- a/src/fs/test_fs_search_persistence.c
+++ b/src/fs/test_fs_search_persistence.c
@@ -17,21 +17,16 @@
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20
21/** 20/**
22 * @file fs/test_fs_search_persistence.c 21 * @file fs/test_fs_search_persistence.c
23 * @brief simple testcase for persistence of search operation 22 * @brief simple testcase for persistence of search operation
24 * @author Christian Grothoff 23 * @author Christian Grothoff
25 */ 24 */
26
27#include "platform.h" 25#include "platform.h"
28#include "gnunet_util_lib.h" 26#include "gnunet_util_lib.h"
29#include "gnunet_arm_service.h" 27#include "gnunet_testing_lib-new.h"
30#include "gnunet_fs_service.h" 28#include "gnunet_fs_service.h"
31 29
32#define VERBOSE GNUNET_NO
33
34#define START_ARM GNUNET_YES
35 30
36/** 31/**
37 * File-size we use for testing. 32 * File-size we use for testing.
@@ -48,16 +43,6 @@
48 */ 43 */
49#define LIFETIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15) 44#define LIFETIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15)
50 45
51struct PeerContext
52{
53 struct GNUNET_CONFIGURATION_Handle *cfg;
54 struct GNUNET_PeerIdentity id;
55#if START_ARM
56 struct GNUNET_OS_Process *arm_proc;
57#endif
58};
59
60static struct PeerContext p1;
61 46
62static struct GNUNET_TIME_Absolute start; 47static struct GNUNET_TIME_Absolute start;
63 48
@@ -69,6 +54,7 @@ static struct GNUNET_FS_PublishContext *publish;
69 54
70static const struct GNUNET_CONFIGURATION_Handle *cfg; 55static const struct GNUNET_CONFIGURATION_Handle *cfg;
71 56
57
72static void 58static void
73abort_publish_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 59abort_publish_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
74{ 60{
@@ -99,8 +85,6 @@ restart_fs_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
99} 85}
100 86
101 87
102
103
104/** 88/**
105 * Consider scheduling the restart-task. 89 * Consider scheduling the restart-task.
106 * Only runs the restart task once per event 90 * Only runs the restart task once per event
@@ -135,14 +119,13 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
135 switch (event->status) 119 switch (event->status)
136 { 120 {
137 case GNUNET_FS_STATUS_PUBLISH_PROGRESS: 121 case GNUNET_FS_STATUS_PUBLISH_PROGRESS:
138#if VERBOSE 122 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
139 printf ("Publish is progressing (%llu/%llu at level %u off %llu)...\n", 123 "Publish is progressing (%llu/%llu at level %u off %llu)...\n",
140 (unsigned long long) event->value.publish.completed, 124 (unsigned long long) event->value.publish.completed,
141 (unsigned long long) event->value.publish.size, 125 (unsigned long long) event->value.publish.size,
142 event->value.publish.specifics.progress.depth, 126 event->value.publish.specifics.progress.depth,
143 (unsigned long long) event->value.publish.specifics. 127 (unsigned long long) event->value.publish.specifics.
144 progress.offset); 128 progress.offset);
145#endif
146 break; 129 break;
147 case GNUNET_FS_STATUS_PUBLISH_COMPLETED: 130 case GNUNET_FS_STATUS_PUBLISH_COMPLETED:
148 kuri = GNUNET_FS_uri_ksk_create_from_args (1, keywords); 131 kuri = GNUNET_FS_uri_ksk_create_from_args (1, keywords);
@@ -163,9 +146,8 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
163 case GNUNET_FS_STATUS_SEARCH_RESULT: 146 case GNUNET_FS_STATUS_SEARCH_RESULT:
164 /* FIXME: consider_restart (event->status); cannot be tested with 147 /* FIXME: consider_restart (event->status); cannot be tested with
165 * search result since we exit here after the first one... */ 148 * search result since we exit here after the first one... */
166#if VERBOSE 149 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
167 printf ("Search complete.\n"); 150 "Search complete.\n");
168#endif
169 GNUNET_SCHEDULER_add_continuation (&abort_search_task, NULL, 151 GNUNET_SCHEDULER_add_continuation (&abort_search_task, NULL,
170 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 152 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
171 break; 153 break;
@@ -231,44 +213,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
231 213
232 214
233static void 215static void
234setup_peer (struct PeerContext *p, const char *cfgname) 216run (void *cls,
235{
236 p->cfg = GNUNET_CONFIGURATION_create ();
237#if START_ARM
238 p->arm_proc =
239 GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
240 "gnunet-service-arm",
241#if VERBOSE
242 "-L", "DEBUG",
243#endif
244 "-c", cfgname, NULL);
245#endif
246 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
247}
248
249
250static void
251stop_arm (struct PeerContext *p)
252{
253#if START_ARM
254 if (NULL != p->arm_proc)
255 {
256 if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
257 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
258 if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK)
259 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
260 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n",
261 GNUNET_OS_process_get_pid (p->arm_proc));
262 GNUNET_OS_process_destroy (p->arm_proc);
263 p->arm_proc = NULL;
264 }
265#endif
266 GNUNET_CONFIGURATION_destroy (p->cfg);
267}
268
269
270static void
271run (void *cls, char *const *args, const char *cfgfile,
272 const struct GNUNET_CONFIGURATION_Handle *c) 217 const struct GNUNET_CONFIGURATION_Handle *c)
273{ 218{
274 const char *keywords[] = { 219 const char *keywords[] = {
@@ -283,7 +228,6 @@ run (void *cls, char *const *args, const char *cfgfile,
283 struct GNUNET_FS_BlockOptions bo; 228 struct GNUNET_FS_BlockOptions bo;
284 229
285 cfg = c; 230 cfg = c;
286 setup_peer (&p1, "test_fs_search_data.conf");
287 fs = GNUNET_FS_start (cfg, "test-fs-search-persistence", &progress_cb, NULL, 231 fs = GNUNET_FS_start (cfg, "test-fs-search-persistence", &progress_cb, NULL,
288 GNUNET_FS_FLAGS_PERSISTENCE, GNUNET_FS_OPTIONS_END); 232 GNUNET_FS_FLAGS_PERSISTENCE, GNUNET_FS_OPTIONS_END);
289 GNUNET_assert (NULL != fs); 233 GNUNET_assert (NULL != fs);
@@ -313,32 +257,10 @@ run (void *cls, char *const *args, const char *cfgfile,
313int 257int
314main (int argc, char *argv[]) 258main (int argc, char *argv[])
315{ 259{
316 char *const argvx[] = { 260 if (0 != GNUNET_TESTING_peer_run ("test-fs-search-persistence",
317 "test-fs-search-persistence", 261 "test_fs_search_data.conf",
318 "-c", 262 &run, NULL))
319 "test_fs_search_data.conf", 263 return 1;
320#if VERBOSE
321 "-L", "DEBUG",
322#endif
323 NULL
324 };
325 struct GNUNET_GETOPT_CommandLineOption options[] = {
326 GNUNET_GETOPT_OPTION_END
327 };
328
329 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-search/");
330 GNUNET_log_setup ("test_fs_search_persistence",
331#if VERBOSE
332 "DEBUG",
333#else
334 "WARNING",
335#endif
336 NULL);
337 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx,
338 "test-fs-search-persistence", "nohelp", options, &run,
339 NULL);
340 stop_arm (&p1);
341 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-search/");
342 return 0; 264 return 0;
343} 265}
344 266
diff --git a/src/fs/test_fs_search_probes.c b/src/fs/test_fs_search_probes.c
index b81659899..be710a79c 100644
--- a/src/fs/test_fs_search_probes.c
+++ b/src/fs/test_fs_search_probes.c
@@ -25,10 +25,9 @@
25 */ 25 */
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
28#include "gnunet_arm_service.h" 28#include "gnunet_testing_lib-new.h"
29#include "gnunet_fs_service.h" 29#include "gnunet_fs_service.h"
30 30
31#define START_ARM GNUNET_YES
32 31
33/** 32/**
34 * File-size we use for testing. 33 * File-size we use for testing.
@@ -45,16 +44,6 @@
45 */ 44 */
46#define LIFETIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15) 45#define LIFETIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15)
47 46
48struct PeerContext
49{
50 struct GNUNET_CONFIGURATION_Handle *cfg;
51 struct GNUNET_PeerIdentity id;
52#if START_ARM
53 struct GNUNET_OS_Process *arm_proc;
54#endif
55};
56
57static struct PeerContext p1;
58 47
59static struct GNUNET_TIME_Absolute start; 48static struct GNUNET_TIME_Absolute start;
60 49
@@ -166,41 +155,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
166 155
167 156
168static void 157static void
169setup_peer (struct PeerContext *p, const char *cfgname) 158run (void *cls,
170{
171 p->cfg = GNUNET_CONFIGURATION_create ();
172#if START_ARM
173 p->arm_proc =
174 GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
175 "gnunet-service-arm",
176 "-c", cfgname, NULL);
177#endif
178 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
179}
180
181
182static void
183stop_arm (struct PeerContext *p)
184{
185#if START_ARM
186 if (NULL != p->arm_proc)
187 {
188 if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
189 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
190 if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK)
191 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
192 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n",
193 GNUNET_OS_process_get_pid (p->arm_proc));
194 GNUNET_OS_process_destroy (p->arm_proc);
195 p->arm_proc = NULL;
196 }
197#endif
198 GNUNET_CONFIGURATION_destroy (p->cfg);
199}
200
201
202static void
203run (void *cls, char *const *args, const char *cfgfile,
204 const struct GNUNET_CONFIGURATION_Handle *cfg) 159 const struct GNUNET_CONFIGURATION_Handle *cfg)
205{ 160{
206 const char *keywords[] = { 161 const char *keywords[] = {
@@ -214,7 +169,6 @@ run (void *cls, char *const *args, const char *cfgfile,
214 struct GNUNET_FS_FileInformation *fi; 169 struct GNUNET_FS_FileInformation *fi;
215 size_t i; 170 size_t i;
216 171
217 setup_peer (&p1, "test_fs_search_data.conf");
218 fs = GNUNET_FS_start (cfg, "test-fs-search", &progress_cb, NULL, 172 fs = GNUNET_FS_start (cfg, "test-fs-search", &progress_cb, NULL,
219 GNUNET_FS_FLAGS_DO_PROBES, 173 GNUNET_FS_FLAGS_DO_PROBES,
220 GNUNET_FS_OPTIONS_END); 174 GNUNET_FS_OPTIONS_END);
@@ -245,23 +199,10 @@ run (void *cls, char *const *args, const char *cfgfile,
245int 199int
246main (int argc, char *argv[]) 200main (int argc, char *argv[])
247{ 201{
248 char *const argvx[] = { 202 if (0 != GNUNET_TESTING_peer_run ("test-fs-search-probes",
249 "test-fs-search-probes", 203 "test_fs_search_data.conf",
250 "-c", 204 &run, NULL))
251 "test_fs_search_data.conf", 205 return 1;
252 NULL
253 };
254 struct GNUNET_GETOPT_CommandLineOption options[] = {
255 GNUNET_GETOPT_OPTION_END
256 };
257
258 GNUNET_log_setup ("test_fs_search_probes",
259 "WARNING",
260 NULL);
261 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx,
262 "test-fs-search", "nohelp", options, &run, NULL);
263 stop_arm (&p1);
264 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-search/");
265 return 0; 206 return 0;
266} 207}
267 208
diff --git a/src/fs/test_fs_start_stop.c b/src/fs/test_fs_start_stop.c
index 6bd698a43..f3dff69f6 100644
--- a/src/fs/test_fs_start_stop.c
+++ b/src/fs/test_fs_start_stop.c
@@ -17,7 +17,6 @@
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20
21/** 20/**
22 * @file fs/test_fs_start_stop.c 21 * @file fs/test_fs_start_stop.c
23 * @brief testcase for fs.c (start-stop only) 22 * @brief testcase for fs.c (start-stop only)
@@ -26,23 +25,9 @@
26 25
27#include "platform.h" 26#include "platform.h"
28#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
29#include "gnunet_arm_service.h" 28#include "gnunet_testing_lib-new.h"
30#include "gnunet_fs_service.h" 29#include "gnunet_fs_service.h"
31 30
32#define VERBOSE GNUNET_NO
33
34#define START_ARM GNUNET_YES
35
36static struct PeerContext p1;
37
38struct PeerContext
39{
40 struct GNUNET_CONFIGURATION_Handle *cfg;
41#if START_ARM
42 struct GNUNET_OS_Process *arm_proc;
43#endif
44};
45
46 31
47static void * 32static void *
48progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) 33progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
@@ -52,49 +37,11 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
52 37
53 38
54static void 39static void
55setup_peer (struct PeerContext *p, const char *cfgname) 40run (void *cls,
56{
57 p->cfg = GNUNET_CONFIGURATION_create ();
58#if START_ARM
59 p->arm_proc =
60 GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
61 "gnunet-service-arm",
62#if VERBOSE
63 "-L", "DEBUG",
64#endif
65 "-c", cfgname, NULL);
66#endif
67 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
68}
69
70
71static void
72stop_arm (struct PeerContext *p)
73{
74#if START_ARM
75 if (NULL != p->arm_proc)
76 {
77 if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
78 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
79 if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK)
80 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
81 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n",
82 GNUNET_OS_process_get_pid (p->arm_proc));
83 GNUNET_OS_process_destroy (p->arm_proc);
84 p->arm_proc = NULL;
85 }
86#endif
87 GNUNET_CONFIGURATION_destroy (p->cfg);
88}
89
90
91static void
92run (void *cls, char *const *args, const char *cfgfile,
93 const struct GNUNET_CONFIGURATION_Handle *cfg) 41 const struct GNUNET_CONFIGURATION_Handle *cfg)
94{ 42{
95 struct GNUNET_FS_Handle *fs; 43 struct GNUNET_FS_Handle *fs;
96 44
97 setup_peer (&p1, "test_fs_data.conf");
98 fs = GNUNET_FS_start (cfg, "test-fs-start-stop", &progress_cb, NULL, 45 fs = GNUNET_FS_start (cfg, "test-fs-start-stop", &progress_cb, NULL,
99 GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); 46 GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END);
100 GNUNET_assert (NULL != fs); 47 GNUNET_assert (NULL != fs);
@@ -105,30 +52,10 @@ run (void *cls, char *const *args, const char *cfgfile,
105int 52int
106main (int argc, char *argv[]) 53main (int argc, char *argv[])
107{ 54{
108 char *const argvx[] = { 55 if (0 != GNUNET_TESTING_peer_run ("test-fs-start-stop",
109 "test-fs-start-stop", 56 "test_fs_data.conf",
110 "-c", 57 &run, NULL))
111 "test_fs_data.conf", 58 return 1;
112#if VERBOSE
113 "-L", "DEBUG",
114#endif
115 NULL
116 };
117 struct GNUNET_GETOPT_CommandLineOption options[] = {
118 GNUNET_GETOPT_OPTION_END
119 };
120
121 GNUNET_log_setup ("test_fs_start_stop",
122#if VERBOSE
123 "DEBUG",
124#else
125 "WARNING",
126#endif
127 NULL);
128 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx,
129 "test-fs-start-stop", "nohelp", options, &run, NULL);
130 stop_arm (&p1);
131 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs/");
132 return 0; 59 return 0;
133} 60}
134 61
diff --git a/src/fs/test_fs_uri.c b/src/fs/test_fs_uri.c
index b7a58ec0f..9d6c4abe0 100644
--- a/src/fs/test_fs_uri.c
+++ b/src/fs/test_fs_uri.c
@@ -17,19 +17,16 @@
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20
21/** 20/**
22 * @file fs/test_fs_uri.c 21 * @file fs/test_fs_uri.c
23 * @brief Test for fs_uri.c 22 * @brief Test for fs_uri.c
24 * @author Christian Grothoff 23 * @author Christian Grothoff
25 */ 24 */
26
27#include "platform.h" 25#include "platform.h"
28#include "gnunet_util_lib.h" 26#include "gnunet_util_lib.h"
29#include "gnunet_fs_service.h" 27#include "gnunet_fs_service.h"
30#include "fs_api.h" 28#include "fs_api.h"
31 29
32#define ABORT() { fprintf(stderr, "Error at %s:%d\n", __FILE__, __LINE__); return 1; }
33 30
34static int 31static int
35testKeyword () 32testKeyword ()
@@ -41,26 +38,26 @@ testKeyword ()
41 if (NULL != (ret = GNUNET_FS_uri_parse ("gnunet://fs/ksk/++", &emsg))) 38 if (NULL != (ret = GNUNET_FS_uri_parse ("gnunet://fs/ksk/++", &emsg)))
42 { 39 {
43 GNUNET_FS_uri_destroy (ret); 40 GNUNET_FS_uri_destroy (ret);
44 ABORT (); 41 GNUNET_assert (0);
45 } 42 }
46 GNUNET_free (emsg); 43 GNUNET_free (emsg);
47 ret = GNUNET_FS_uri_parse ("gnunet://fs/ksk/foo+bar", &emsg); 44 ret = GNUNET_FS_uri_parse ("gnunet://fs/ksk/foo+bar", &emsg);
48 if (ret == NULL) 45 if (ret == NULL)
49 { 46 {
50 GNUNET_free (emsg); 47 GNUNET_free (emsg);
51 ABORT (); 48 GNUNET_assert (0);
52 } 49 }
53 if (!GNUNET_FS_uri_test_ksk (ret)) 50 if (!GNUNET_FS_uri_test_ksk (ret))
54 { 51 {
55 GNUNET_FS_uri_destroy (ret); 52 GNUNET_FS_uri_destroy (ret);
56 ABORT (); 53 GNUNET_assert (0);
57 } 54 }
58 if ((2 != ret->data.ksk.keywordCount) || 55 if ((2 != ret->data.ksk.keywordCount) ||
59 (0 != strcmp (" foo", ret->data.ksk.keywords[0])) || 56 (0 != strcmp (" foo", ret->data.ksk.keywords[0])) ||
60 (0 != strcmp (" bar", ret->data.ksk.keywords[1]))) 57 (0 != strcmp (" bar", ret->data.ksk.keywords[1])))
61 { 58 {
62 GNUNET_FS_uri_destroy (ret); 59 GNUNET_FS_uri_destroy (ret);
63 ABORT (); 60 GNUNET_assert (0);
64 } 61 }
65 62
66 uri = GNUNET_FS_uri_to_string (ret); 63 uri = GNUNET_FS_uri_to_string (ret);
@@ -68,13 +65,14 @@ testKeyword ()
68 { 65 {
69 GNUNET_free (uri); 66 GNUNET_free (uri);
70 GNUNET_FS_uri_destroy (ret); 67 GNUNET_FS_uri_destroy (ret);
71 ABORT (); 68 GNUNET_assert (0);
72 } 69 }
73 GNUNET_free (uri); 70 GNUNET_free (uri);
74 GNUNET_FS_uri_destroy (ret); 71 GNUNET_FS_uri_destroy (ret);
75 return 0; 72 return 0;
76} 73}
77 74
75
78static int 76static int
79testLocation () 77testLocation ()
80{ 78{
@@ -157,6 +155,7 @@ testLocation ()
157 return 0; 155 return 0;
158} 156}
159 157
158
160static int 159static int
161testNamespace (int i) 160testNamespace (int i)
162{ 161{
@@ -170,7 +169,7 @@ testNamespace (int i)
170 &emsg))) 169 &emsg)))
171 { 170 {
172 GNUNET_FS_uri_destroy (ret); 171 GNUNET_FS_uri_destroy (ret);
173 ABORT (); 172 GNUNET_assert (0);
174 } 173 }
175 GNUNET_free (emsg); 174 GNUNET_free (emsg);
176 if (NULL != 175 if (NULL !=
@@ -179,13 +178,13 @@ testNamespace (int i)
179 ("gnunet://fs/sks/D1KJS9H2A82Q65VKQ0ML3RFU6U1D3V/test", &emsg))) 178 ("gnunet://fs/sks/D1KJS9H2A82Q65VKQ0ML3RFU6U1D3V/test", &emsg)))
180 { 179 {
181 GNUNET_FS_uri_destroy (ret); 180 GNUNET_FS_uri_destroy (ret);
182 ABORT (); 181 GNUNET_assert (0);
183 } 182 }
184 GNUNET_free (emsg); 183 GNUNET_free (emsg);
185 if (NULL != (ret = GNUNET_FS_uri_parse ("gnunet://fs/sks/test", &emsg))) 184 if (NULL != (ret = GNUNET_FS_uri_parse ("gnunet://fs/sks/test", &emsg)))
186 { 185 {
187 GNUNET_FS_uri_destroy (ret); 186 GNUNET_FS_uri_destroy (ret);
188 ABORT (); 187 GNUNET_assert (0);
189 } 188 }
190 GNUNET_free (emsg); 189 GNUNET_free (emsg);
191 ret = 190 ret =
@@ -195,17 +194,17 @@ testNamespace (int i)
195 if (ret == NULL) 194 if (ret == NULL)
196 { 195 {
197 GNUNET_free (emsg); 196 GNUNET_free (emsg);
198 ABORT (); 197 GNUNET_assert (0);
199 } 198 }
200 if (GNUNET_FS_uri_test_ksk (ret)) 199 if (GNUNET_FS_uri_test_ksk (ret))
201 { 200 {
202 GNUNET_FS_uri_destroy (ret); 201 GNUNET_FS_uri_destroy (ret);
203 ABORT (); 202 GNUNET_assert (0);
204 } 203 }
205 if (!GNUNET_FS_uri_test_sks (ret)) 204 if (!GNUNET_FS_uri_test_sks (ret))
206 { 205 {
207 GNUNET_FS_uri_destroy (ret); 206 GNUNET_FS_uri_destroy (ret);
208 ABORT (); 207 GNUNET_assert (0);
209 } 208 }
210 209
211 uri = GNUNET_FS_uri_to_string (ret); 210 uri = GNUNET_FS_uri_to_string (ret);
@@ -215,7 +214,7 @@ testNamespace (int i)
215 { 214 {
216 GNUNET_FS_uri_destroy (ret); 215 GNUNET_FS_uri_destroy (ret);
217 GNUNET_free (uri); 216 GNUNET_free (uri);
218 ABORT (); 217 GNUNET_assert (0);
219 } 218 }
220 GNUNET_free (uri); 219 GNUNET_free (uri);
221 GNUNET_FS_uri_destroy (ret); 220 GNUNET_FS_uri_destroy (ret);
@@ -236,7 +235,7 @@ testFile (int i)
236 &emsg))) 235 &emsg)))
237 { 236 {
238 GNUNET_FS_uri_destroy (ret); 237 GNUNET_FS_uri_destroy (ret);
239 ABORT (); 238 GNUNET_assert (0);
240 } 239 }
241 GNUNET_free (emsg); 240 GNUNET_free (emsg);
242 if (NULL != 241 if (NULL !=
@@ -246,7 +245,7 @@ testFile (int i)
246 &emsg))) 245 &emsg)))
247 { 246 {
248 GNUNET_FS_uri_destroy (ret); 247 GNUNET_FS_uri_destroy (ret);
249 ABORT (); 248 GNUNET_assert (0);
250 } 249 }
251 GNUNET_free (emsg); 250 GNUNET_free (emsg);
252 if (NULL != 251 if (NULL !=
@@ -256,7 +255,7 @@ testFile (int i)
256 &emsg))) 255 &emsg)))
257 { 256 {
258 GNUNET_FS_uri_destroy (ret); 257 GNUNET_FS_uri_destroy (ret);
259 ABORT (); 258 GNUNET_assert (0);
260 } 259 }
261 GNUNET_free (emsg); 260 GNUNET_free (emsg);
262 ret = 261 ret =
@@ -266,22 +265,22 @@ testFile (int i)
266 if (ret == NULL) 265 if (ret == NULL)
267 { 266 {
268 GNUNET_free (emsg); 267 GNUNET_free (emsg);
269 ABORT (); 268 GNUNET_assert (0);
270 } 269 }
271 if (GNUNET_FS_uri_test_ksk (ret)) 270 if (GNUNET_FS_uri_test_ksk (ret))
272 { 271 {
273 GNUNET_FS_uri_destroy (ret); 272 GNUNET_FS_uri_destroy (ret);
274 ABORT (); 273 GNUNET_assert (0);
275 } 274 }
276 if (GNUNET_FS_uri_test_sks (ret)) 275 if (GNUNET_FS_uri_test_sks (ret))
277 { 276 {
278 GNUNET_FS_uri_destroy (ret); 277 GNUNET_FS_uri_destroy (ret);
279 ABORT (); 278 GNUNET_assert (0);
280 } 279 }
281 if (GNUNET_ntohll (ret->data.chk.file_length) != 42) 280 if (GNUNET_ntohll (ret->data.chk.file_length) != 42)
282 { 281 {
283 GNUNET_FS_uri_destroy (ret); 282 GNUNET_FS_uri_destroy (ret);
284 ABORT (); 283 GNUNET_assert (0);
285 } 284 }
286 285
287 uri = GNUNET_FS_uri_to_string (ret); 286 uri = GNUNET_FS_uri_to_string (ret);
@@ -291,13 +290,14 @@ testFile (int i)
291 { 290 {
292 GNUNET_free (uri); 291 GNUNET_free (uri);
293 GNUNET_FS_uri_destroy (ret); 292 GNUNET_FS_uri_destroy (ret);
294 ABORT (); 293 GNUNET_assert (0);
295 } 294 }
296 GNUNET_free (uri); 295 GNUNET_free (uri);
297 GNUNET_FS_uri_destroy (ret); 296 GNUNET_FS_uri_destroy (ret);
298 return 0; 297 return 0;
299} 298}
300 299
300
301int 301int
302main (int argc, char *argv[]) 302main (int argc, char *argv[])
303{ 303{
@@ -305,11 +305,7 @@ main (int argc, char *argv[])
305 int i; 305 int i;
306 306
307 GNUNET_log_setup ("test_fs_uri", 307 GNUNET_log_setup ("test_fs_uri",
308#if VERBOSE
309 "DEBUG",
310#else
311 "WARNING", 308 "WARNING",
312#endif
313 NULL); 309 NULL);
314 GNUNET_CRYPTO_random_disable_entropy_gathering (); 310 GNUNET_CRYPTO_random_disable_entropy_gathering ();
315 failureCount += testKeyword (); 311 failureCount += testKeyword ();