diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-09-05 21:18:45 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-09-05 21:18:45 +0000 |
commit | 563b71afee70ac213a8bb28ce0697fcbae06aac3 (patch) | |
tree | 122d6a25630f68a9845651ba2295ef68f7d2af09 /src/fs | |
parent | cf6e2bdb1b9a5aedc4f090df853814b9df817e03 (diff) | |
download | gnunet-563b71afee70ac213a8bb28ce0697fcbae06aac3.tar.gz gnunet-563b71afee70ac213a8bb28ce0697fcbae06aac3.zip |
fixing API and clean up issues in testing
Diffstat (limited to 'src/fs')
-rw-r--r-- | src/fs/fs_test_lib.c | 32 | ||||
-rw-r--r-- | src/fs/fs_test_lib.h | 14 | ||||
-rw-r--r-- | src/fs/test_fs_test_lib.c | 12 | ||||
-rw-r--r-- | src/fs/test_gnunet_service_fs_migration.c | 14 | ||||
-rw-r--r-- | src/fs/test_gnunet_service_fs_p2p.c | 12 |
5 files changed, 68 insertions, 16 deletions
diff --git a/src/fs/fs_test_lib.c b/src/fs/fs_test_lib.c index 17291d1bd..40a9f6276 100644 --- a/src/fs/fs_test_lib.c +++ b/src/fs/fs_test_lib.c | |||
@@ -379,10 +379,11 @@ GNUNET_FS_TEST_daemons_start (const char *template_cfg_file, | |||
379 | } | 379 | } |
380 | 380 | ||
381 | 381 | ||
382 | struct ConnectContext | 382 | struct GNUNET_FS_TEST_ConnectContext |
383 | { | 383 | { |
384 | GNUNET_SCHEDULER_Task cont; | 384 | GNUNET_SCHEDULER_Task cont; |
385 | void *cont_cls; | 385 | void *cont_cls; |
386 | struct GNUNET_TESTING_ConnectContext *cc; | ||
386 | }; | 387 | }; |
387 | 388 | ||
388 | 389 | ||
@@ -409,8 +410,9 @@ notify_connection (void *cls, const struct GNUNET_PeerIdentity *first, | |||
409 | struct GNUNET_TESTING_Daemon *second_daemon, | 410 | struct GNUNET_TESTING_Daemon *second_daemon, |
410 | const char *emsg) | 411 | const char *emsg) |
411 | { | 412 | { |
412 | struct ConnectContext *cc = cls; | 413 | struct GNUNET_FS_TEST_ConnectContext *cc = cls; |
413 | 414 | ||
415 | cc->cc = NULL; | ||
414 | if (emsg != NULL) | 416 | if (emsg != NULL) |
415 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failed to connect peers: %s\n", | 417 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failed to connect peers: %s\n", |
416 | emsg); | 418 | emsg); |
@@ -432,20 +434,34 @@ notify_connection (void *cls, const struct GNUNET_PeerIdentity *first, | |||
432 | * @param cont function to call when done | 434 | * @param cont function to call when done |
433 | * @param cont_cls closure for cont | 435 | * @param cont_cls closure for cont |
434 | */ | 436 | */ |
435 | void | 437 | struct GNUNET_FS_TEST_ConnectContext * |
436 | GNUNET_FS_TEST_daemons_connect (struct GNUNET_FS_TestDaemon *daemon1, | 438 | GNUNET_FS_TEST_daemons_connect (struct GNUNET_FS_TestDaemon *daemon1, |
437 | struct GNUNET_FS_TestDaemon *daemon2, | 439 | struct GNUNET_FS_TestDaemon *daemon2, |
438 | struct GNUNET_TIME_Relative timeout, | 440 | struct GNUNET_TIME_Relative timeout, |
439 | GNUNET_SCHEDULER_Task cont, void *cont_cls) | 441 | GNUNET_SCHEDULER_Task cont, void *cont_cls) |
440 | { | 442 | { |
441 | struct ConnectContext *ncc; | 443 | struct GNUNET_FS_TEST_ConnectContext *ncc; |
442 | 444 | ||
443 | ncc = GNUNET_malloc (sizeof (struct ConnectContext)); | 445 | ncc = GNUNET_malloc (sizeof (struct GNUNET_FS_TEST_ConnectContext)); |
444 | ncc->cont = cont; | 446 | ncc->cont = cont; |
445 | ncc->cont_cls = cont_cls; | 447 | ncc->cont_cls = cont_cls; |
446 | GNUNET_TESTING_daemons_connect (daemon1->daemon, daemon2->daemon, timeout, | 448 | ncc->cc = GNUNET_TESTING_daemons_connect (daemon1->daemon, daemon2->daemon, timeout, |
447 | CONNECT_ATTEMPTS, GNUNET_YES, | 449 | CONNECT_ATTEMPTS, GNUNET_YES, |
448 | ¬ify_connection, ncc); | 450 | ¬ify_connection, ncc); |
451 | return ncc; | ||
452 | } | ||
453 | |||
454 | |||
455 | /** | ||
456 | * Cancel connect operation. | ||
457 | * | ||
458 | * @param cc operation to cancel | ||
459 | */ | ||
460 | void | ||
461 | GNUNET_FS_TEST_daemons_connect_cancel (struct GNUNET_FS_TEST_ConnectContext *cc) | ||
462 | { | ||
463 | GNUNET_TESTING_daemons_connect_cancel (cc->cc); | ||
464 | GNUNET_free (cc); | ||
449 | } | 465 | } |
450 | 466 | ||
451 | 467 | ||
diff --git a/src/fs/fs_test_lib.h b/src/fs/fs_test_lib.h index ad1d96bf0..204d5b2ab 100644 --- a/src/fs/fs_test_lib.h +++ b/src/fs/fs_test_lib.h | |||
@@ -61,6 +61,9 @@ GNUNET_FS_TEST_daemons_start (const char *template_cfg_file, | |||
61 | GNUNET_SCHEDULER_Task cont, void *cont_cls); | 61 | GNUNET_SCHEDULER_Task cont, void *cont_cls); |
62 | 62 | ||
63 | 63 | ||
64 | struct GNUNET_FS_TEST_ConnectContext; | ||
65 | |||
66 | |||
64 | /** | 67 | /** |
65 | * Connect two daemons for testing. | 68 | * Connect two daemons for testing. |
66 | * | 69 | * |
@@ -71,7 +74,7 @@ GNUNET_FS_TEST_daemons_start (const char *template_cfg_file, | |||
71 | * @param cont function to call when done | 74 | * @param cont function to call when done |
72 | * @param cont_cls closure for cont | 75 | * @param cont_cls closure for cont |
73 | */ | 76 | */ |
74 | void | 77 | struct GNUNET_FS_TEST_ConnectContext * |
75 | GNUNET_FS_TEST_daemons_connect (struct GNUNET_FS_TestDaemon *daemon1, | 78 | GNUNET_FS_TEST_daemons_connect (struct GNUNET_FS_TestDaemon *daemon1, |
76 | struct GNUNET_FS_TestDaemon *daemon2, | 79 | struct GNUNET_FS_TestDaemon *daemon2, |
77 | struct GNUNET_TIME_Relative timeout, | 80 | struct GNUNET_TIME_Relative timeout, |
@@ -79,6 +82,15 @@ GNUNET_FS_TEST_daemons_connect (struct GNUNET_FS_TestDaemon *daemon1, | |||
79 | 82 | ||
80 | 83 | ||
81 | /** | 84 | /** |
85 | * Cancel connect operation. | ||
86 | * | ||
87 | * @param cc operation to cancel | ||
88 | */ | ||
89 | void | ||
90 | GNUNET_FS_TEST_daemons_connect_cancel (struct GNUNET_FS_TEST_ConnectContext *cc); | ||
91 | |||
92 | |||
93 | /** | ||
82 | * Obtain peer group used for testing. | 94 | * Obtain peer group used for testing. |
83 | * | 95 | * |
84 | * @param daemons array with the daemons (must contain at least one) | 96 | * @param daemons array with the daemons (must contain at least one) |
diff --git a/src/fs/test_fs_test_lib.c b/src/fs/test_fs_test_lib.c index 458d4606b..1f2119259 100644 --- a/src/fs/test_fs_test_lib.c +++ b/src/fs/test_fs_test_lib.c | |||
@@ -44,11 +44,18 @@ | |||
44 | 44 | ||
45 | static struct GNUNET_FS_TestDaemon *daemons[NUM_DAEMONS]; | 45 | static struct GNUNET_FS_TestDaemon *daemons[NUM_DAEMONS]; |
46 | 46 | ||
47 | static struct GNUNET_FS_TEST_ConnectContext *cc; | ||
48 | |||
47 | static int ret; | 49 | static int ret; |
48 | 50 | ||
49 | static void | 51 | static void |
50 | do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 52 | do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
51 | { | 53 | { |
54 | if (NULL != cc) | ||
55 | { | ||
56 | GNUNET_FS_TEST_daemons_connect_cancel (cc); | ||
57 | cc = NULL; | ||
58 | } | ||
52 | if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)) | 59 | if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)) |
53 | { | 60 | { |
54 | GNUNET_break (0); | 61 | GNUNET_break (0); |
@@ -83,6 +90,7 @@ do_download (void *cls, const struct GNUNET_FS_Uri *uri) | |||
83 | static void | 90 | static void |
84 | do_publish (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 91 | do_publish (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
85 | { | 92 | { |
93 | cc = NULL; | ||
86 | if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)) | 94 | if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)) |
87 | { | 95 | { |
88 | GNUNET_break (0); | 96 | GNUNET_break (0); |
@@ -109,8 +117,8 @@ do_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
109 | } | 117 | } |
110 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 118 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
111 | "Daemons started, will now try to connect them\n"); | 119 | "Daemons started, will now try to connect them\n"); |
112 | GNUNET_FS_TEST_daemons_connect (daemons[0], daemons[1], TIMEOUT, &do_publish, | 120 | cc = GNUNET_FS_TEST_daemons_connect (daemons[0], daemons[1], TIMEOUT, &do_publish, |
113 | NULL); | 121 | NULL); |
114 | } | 122 | } |
115 | 123 | ||
116 | 124 | ||
diff --git a/src/fs/test_gnunet_service_fs_migration.c b/src/fs/test_gnunet_service_fs_migration.c index a5570e1d4..bbf2534d2 100644 --- a/src/fs/test_gnunet_service_fs_migration.c +++ b/src/fs/test_gnunet_service_fs_migration.c | |||
@@ -52,12 +52,19 @@ static int ok; | |||
52 | 52 | ||
53 | static struct GNUNET_TIME_Absolute start_time; | 53 | static struct GNUNET_TIME_Absolute start_time; |
54 | 54 | ||
55 | static struct GNUNET_FS_TEST_ConnectContext *cc; | ||
56 | |||
55 | static void | 57 | static void |
56 | do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 58 | do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
57 | { | 59 | { |
58 | struct GNUNET_TIME_Relative del; | 60 | struct GNUNET_TIME_Relative del; |
59 | char *fancy; | 61 | char *fancy; |
60 | 62 | ||
63 | if (NULL != cc) | ||
64 | { | ||
65 | GNUNET_FS_TEST_daemons_connect_cancel (cc); | ||
66 | cc = NULL; | ||
67 | } | ||
61 | GNUNET_FS_TEST_daemons_stop (2, daemons); | 68 | GNUNET_FS_TEST_daemons_stop (2, daemons); |
62 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)) | 69 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)) |
63 | { | 70 | { |
@@ -138,6 +145,7 @@ do_wait (void *cls, const struct GNUNET_FS_Uri *uri) | |||
138 | static void | 145 | static void |
139 | do_publish (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 146 | do_publish (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
140 | { | 147 | { |
148 | cc = NULL; | ||
141 | if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)) | 149 | if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)) |
142 | { | 150 | { |
143 | GNUNET_FS_TEST_daemons_stop (2, daemons); | 151 | GNUNET_FS_TEST_daemons_stop (2, daemons); |
@@ -165,8 +173,8 @@ do_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
165 | } | 173 | } |
166 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 174 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
167 | "Daemons started, will now try to connect them\n"); | 175 | "Daemons started, will now try to connect them\n"); |
168 | GNUNET_FS_TEST_daemons_connect (daemons[0], daemons[1], TIMEOUT, &do_publish, | 176 | cc = GNUNET_FS_TEST_daemons_connect (daemons[0], daemons[1], TIMEOUT, &do_publish, |
169 | NULL); | 177 | NULL); |
170 | } | 178 | } |
171 | 179 | ||
172 | 180 | ||
diff --git a/src/fs/test_gnunet_service_fs_p2p.c b/src/fs/test_gnunet_service_fs_p2p.c index aece0e80a..26372cfa8 100644 --- a/src/fs/test_gnunet_service_fs_p2p.c +++ b/src/fs/test_gnunet_service_fs_p2p.c | |||
@@ -48,12 +48,19 @@ static int ok; | |||
48 | 48 | ||
49 | static struct GNUNET_TIME_Absolute start_time; | 49 | static struct GNUNET_TIME_Absolute start_time; |
50 | 50 | ||
51 | static struct GNUNET_FS_TEST_ConnectContext *cc; | ||
52 | |||
51 | static void | 53 | static void |
52 | do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 54 | do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
53 | { | 55 | { |
54 | struct GNUNET_TIME_Relative del; | 56 | struct GNUNET_TIME_Relative del; |
55 | char *fancy; | 57 | char *fancy; |
56 | 58 | ||
59 | if (NULL != cc) | ||
60 | { | ||
61 | GNUNET_FS_TEST_daemons_connect_cancel (cc); | ||
62 | cc = NULL; | ||
63 | } | ||
57 | GNUNET_FS_TEST_daemons_stop (NUM_DAEMONS, daemons); | 64 | GNUNET_FS_TEST_daemons_stop (NUM_DAEMONS, daemons); |
58 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)) | 65 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)) |
59 | { | 66 | { |
@@ -99,6 +106,7 @@ do_download (void *cls, const struct GNUNET_FS_Uri *uri) | |||
99 | static void | 106 | static void |
100 | do_publish (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 107 | do_publish (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
101 | { | 108 | { |
109 | cc = NULL; | ||
102 | if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)) | 110 | if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)) |
103 | { | 111 | { |
104 | GNUNET_FS_TEST_daemons_stop (NUM_DAEMONS, daemons); | 112 | GNUNET_FS_TEST_daemons_stop (NUM_DAEMONS, daemons); |
@@ -120,8 +128,8 @@ do_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
120 | GNUNET_assert (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)); | 128 | GNUNET_assert (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)); |
121 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 129 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
122 | "Daemons started, will now try to connect them\n"); | 130 | "Daemons started, will now try to connect them\n"); |
123 | GNUNET_FS_TEST_daemons_connect (daemons[0], daemons[1], TIMEOUT, &do_publish, | 131 | cc = GNUNET_FS_TEST_daemons_connect (daemons[0], daemons[1], TIMEOUT, &do_publish, |
124 | NULL); | 132 | NULL); |
125 | } | 133 | } |
126 | 134 | ||
127 | 135 | ||