aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-05-27 10:54:00 +0000
committerChristian Grothoff <christian@grothoff.org>2010-05-27 10:54:00 +0000
commit512de1fc705634737fbe776d8cd33249b61a897a (patch)
tree6f4e20dcfc33be89dbe2c36201ac001c6d53ec70
parent315a5cc108293e1ac8f8aaa8fda5c9a7bbd71531 (diff)
downloadgnunet-512de1fc705634737fbe776d8cd33249b61a897a.tar.gz
gnunet-512de1fc705634737fbe776d8cd33249b61a897a.zip
fixing mig test
-rw-r--r--src/fs/fs_test_lib.c17
-rw-r--r--src/fs/fs_test_lib.h11
-rw-r--r--src/fs/test_gnunet_service_fs_migration.c39
3 files changed, 61 insertions, 6 deletions
diff --git a/src/fs/fs_test_lib.c b/src/fs/fs_test_lib.c
index 766bb121b..9c6e6e05c 100644
--- a/src/fs/fs_test_lib.c
+++ b/src/fs/fs_test_lib.c
@@ -446,6 +446,19 @@ GNUNET_FS_TEST_daemons_connect (struct GNUNET_SCHEDULER_Handle *sched,
446 446
447 447
448/** 448/**
449 * Obtain peer group used for testing.
450 *
451 * @param daemons array with the daemons (must contain at least one)
452 * @return peer group
453 */
454struct GNUNET_TESTING_PeerGroup *
455GNUNET_FS_TEST_get_group (struct GNUNET_FS_TestDaemon **daemons)
456{
457 return daemons[0]->group;
458}
459
460
461/**
449 * Stop daemons used for testing. 462 * Stop daemons used for testing.
450 * 463 *
451 * @param sched scheduler to use 464 * @param sched scheduler to use
@@ -458,9 +471,10 @@ GNUNET_FS_TEST_daemons_stop (struct GNUNET_SCHEDULER_Handle *sched,
458 struct GNUNET_FS_TestDaemon **daemons) 471 struct GNUNET_FS_TestDaemon **daemons)
459{ 472{
460 unsigned int i; 473 unsigned int i;
474 struct GNUNET_TESTING_PeerGroup *pg;
461 475
462 GNUNET_assert (total > 0); 476 GNUNET_assert (total > 0);
463 GNUNET_TESTING_daemons_stop (daemons[0]->group, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30)); 477 pg = daemons[0]->group;
464 for (i=0;i<total;i++) 478 for (i=0;i<total;i++)
465 { 479 {
466 GNUNET_FS_stop (daemons[i]->fs); 480 GNUNET_FS_stop (daemons[i]->fs);
@@ -468,6 +482,7 @@ GNUNET_FS_TEST_daemons_stop (struct GNUNET_SCHEDULER_Handle *sched,
468 GNUNET_free (daemons[i]); 482 GNUNET_free (daemons[i]);
469 daemons[i] = NULL; 483 daemons[i] = NULL;
470 } 484 }
485 GNUNET_TESTING_daemons_stop (pg, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30));
471} 486}
472 487
473 488
diff --git a/src/fs/fs_test_lib.h b/src/fs/fs_test_lib.h
index a13de9874..62d78f8a2 100644
--- a/src/fs/fs_test_lib.h
+++ b/src/fs/fs_test_lib.h
@@ -82,6 +82,17 @@ GNUNET_FS_TEST_daemons_connect (struct GNUNET_SCHEDULER_Handle *sched,
82 82
83 83
84/** 84/**
85 * Obtain peer group used for testing.
86 *
87 * @param daemons array with the daemons (must contain at least one)
88 * @return peer group
89 */
90struct GNUNET_TESTING_PeerGroup *
91GNUNET_FS_TEST_get_group (struct GNUNET_FS_TestDaemon **daemons);
92
93
94
95/**
85 * Stop daemons used for testing. 96 * Stop daemons used for testing.
86 * 97 *
87 * @param sched scheduler to use 98 * @param sched scheduler to use
diff --git a/src/fs/test_gnunet_service_fs_migration.c b/src/fs/test_gnunet_service_fs_migration.c
index 78cd3813a..94e959f14 100644
--- a/src/fs/test_gnunet_service_fs_migration.c
+++ b/src/fs/test_gnunet_service_fs_migration.c
@@ -25,8 +25,9 @@
25 */ 25 */
26#include "platform.h" 26#include "platform.h"
27#include "fs_test_lib.h" 27#include "fs_test_lib.h"
28#include "gnunet_testing_lib.h"
28 29
29#define VERBOSE GNUNET_NO 30#define VERBOSE GNUNET_YES
30 31
31/** 32/**
32 * File-size we use for testing. 33 * File-size we use for testing.
@@ -61,7 +62,7 @@ do_stop (void *cls,
61 char *fancy; 62 char *fancy;
62 63
63 GNUNET_FS_TEST_daemons_stop (sched, 64 GNUNET_FS_TEST_daemons_stop (sched,
64 1, 65 2,
65 daemons); 66 daemons);
66 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)) 67 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE))
67 { 68 {
@@ -88,11 +89,21 @@ do_stop (void *cls,
88 89
89static void 90static void
90do_download (void *cls, 91do_download (void *cls,
91 const struct GNUNET_SCHEDULER_TaskContext *tc) 92 const char *emsg)
92{ 93{
93 struct GNUNET_FS_Uri *uri = cls; 94 struct GNUNET_FS_Uri *uri = cls;
94 95
95 GNUNET_FS_TEST_daemons_stop (sched, 1, &daemons[1]); 96 if (emsg != NULL)
97 {
98 GNUNET_FS_TEST_daemons_stop (sched,
99 2,
100 daemons);
101 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
102 "Failed to stop source daemon: %s\n",
103 emsg);
104 ok = 1;
105 return;
106 }
96 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 107 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
97 "Downloading %llu bytes\n", 108 "Downloading %llu bytes\n",
98 (unsigned long long) FILESIZE); 109 (unsigned long long) FILESIZE);
@@ -107,6 +118,22 @@ do_download (void *cls,
107 118
108 119
109static void 120static void
121stop_source_peer (void *cls,
122 const struct GNUNET_SCHEDULER_TaskContext *tc)
123{
124 struct GNUNET_FS_Uri *uri = cls;
125 struct GNUNET_TESTING_PeerGroup *pg;
126
127 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
128 "Stopping source peer\n");
129 pg = GNUNET_FS_TEST_get_group (daemons);
130 GNUNET_TESTING_daemons_vary (pg, 1, GNUNET_NO, TIMEOUT,
131 &do_download,
132 uri);
133}
134
135
136static void
110do_wait (void *cls, 137do_wait (void *cls,
111 const struct GNUNET_FS_Uri *uri) 138 const struct GNUNET_FS_Uri *uri)
112{ 139{
@@ -122,10 +149,12 @@ do_wait (void *cls,
122 ok = 1; 149 ok = 1;
123 return; 150 return;
124 } 151 }
152 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
153 "Waiting to allow content to migrate\n");
125 d = GNUNET_FS_uri_dup (uri); 154 d = GNUNET_FS_uri_dup (uri);
126 GNUNET_SCHEDULER_add_delayed (sched, 155 GNUNET_SCHEDULER_add_delayed (sched,
127 MIGRATION_DELAY, 156 MIGRATION_DELAY,
128 &do_download, 157 &stop_source_peer,
129 d); 158 d);
130} 159}
131 160