aboutsummaryrefslogtreecommitdiff
path: root/src/fs/test_fs_download_persistence.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-05-06 13:02:14 +0000
committerChristian Grothoff <christian@grothoff.org>2010-05-06 13:02:14 +0000
commit0b41a005a697d23fedef619df03597e6c308a6c1 (patch)
tree4496ec441facf994a3d025098e6f45d5504cdd89 /src/fs/test_fs_download_persistence.c
parentbd8e94679cb54749ae9574e37a86dfb445c1c9af (diff)
downloadgnunet-0b41a005a697d23fedef619df03597e6c308a6c1.tar.gz
gnunet-0b41a005a697d23fedef619df03597e6c308a6c1.zip
bugfixes
Diffstat (limited to 'src/fs/test_fs_download_persistence.c')
-rw-r--r--src/fs/test_fs_download_persistence.c44
1 files changed, 30 insertions, 14 deletions
diff --git a/src/fs/test_fs_download_persistence.c b/src/fs/test_fs_download_persistence.c
index dda7369ef..82e19a797 100644
--- a/src/fs/test_fs_download_persistence.c
+++ b/src/fs/test_fs_download_persistence.c
@@ -175,7 +175,6 @@ static void *
175progress_cb (void *cls, 175progress_cb (void *cls,
176 const struct GNUNET_FS_ProgressInfo *event) 176 const struct GNUNET_FS_ProgressInfo *event)
177{ 177{
178
179 switch (event->status) 178 switch (event->status)
180 { 179 {
181 case GNUNET_FS_STATUS_PUBLISH_PROGRESS: 180 case GNUNET_FS_STATUS_PUBLISH_PROGRESS:
@@ -192,17 +191,17 @@ progress_cb (void *cls,
192 (unsigned long long) (FILESIZE * 1000LL / (1+GNUNET_TIME_absolute_get_duration (start).value) / 1024LL)); 191 (unsigned long long) (FILESIZE * 1000LL / (1+GNUNET_TIME_absolute_get_duration (start).value) / 1024LL));
193 fn = GNUNET_DISK_mktemp ("gnunet-download-test-dst"); 192 fn = GNUNET_DISK_mktemp ("gnunet-download-test-dst");
194 start = GNUNET_TIME_absolute_get (); 193 start = GNUNET_TIME_absolute_get ();
195 download = GNUNET_FS_download_start (fs, 194 GNUNET_assert (download == NULL);
196 event->value.publish.specifics.completed.chk_uri, 195 GNUNET_FS_download_start (fs,
197 NULL, 196 event->value.publish.specifics.completed.chk_uri,
198 fn, NULL, 197 NULL,
199 0, 198 fn, NULL,
200 FILESIZE, 199 0,
201 1, 200 FILESIZE,
202 GNUNET_FS_DOWNLOAD_OPTION_NONE, 201 1,
203 "download", 202 GNUNET_FS_DOWNLOAD_OPTION_NONE,
204 NULL); 203 "download",
205 GNUNET_assert (download != NULL); 204 NULL);
206 break; 205 break;
207 case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED: 206 case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED:
208 consider_restart (event->status); 207 consider_restart (event->status);
@@ -241,6 +240,22 @@ progress_cb (void *cls,
241 &abort_download_task, 240 &abort_download_task,
242 NULL); 241 NULL);
243 break; 242 break;
243 case GNUNET_FS_STATUS_PUBLISH_SUSPEND:
244 GNUNET_assert (event->value.publish.sc == publish);
245 publish = NULL;
246 break;
247 case GNUNET_FS_STATUS_PUBLISH_RESUME:
248 GNUNET_assert (NULL == publish);
249 publish = event->value.publish.sc;
250 break;
251 case GNUNET_FS_STATUS_DOWNLOAD_SUSPEND:
252 GNUNET_assert (event->value.download.dc == download);
253 download = NULL;
254 break;
255 case GNUNET_FS_STATUS_DOWNLOAD_RESUME:
256 GNUNET_assert (NULL == download);
257 download = event->value.download.dc;
258 break;
244 case GNUNET_FS_STATUS_DOWNLOAD_ACTIVE: 259 case GNUNET_FS_STATUS_DOWNLOAD_ACTIVE:
245 consider_restart (event->status); 260 consider_restart (event->status);
246 break; 261 break;
@@ -264,6 +279,7 @@ progress_cb (void *cls,
264 case GNUNET_FS_STATUS_DOWNLOAD_START: 279 case GNUNET_FS_STATUS_DOWNLOAD_START:
265 consider_restart (event->status); 280 consider_restart (event->status);
266 GNUNET_assert (download == NULL); 281 GNUNET_assert (download == NULL);
282 download = event->value.download.dc;
267 GNUNET_assert (0 == strcmp ("download", event->value.download.cctx)); 283 GNUNET_assert (0 == strcmp ("download", event->value.download.cctx));
268 GNUNET_assert (NULL == event->value.download.pctx); 284 GNUNET_assert (NULL == event->value.download.pctx);
269 GNUNET_assert (NULL != event->value.download.uri); 285 GNUNET_assert (NULL != event->value.download.uri);
@@ -273,12 +289,12 @@ progress_cb (void *cls,
273 GNUNET_assert (1 == event->value.download.anonymity); 289 GNUNET_assert (1 == event->value.download.anonymity);
274 break; 290 break;
275 case GNUNET_FS_STATUS_DOWNLOAD_STOPPED: 291 case GNUNET_FS_STATUS_DOWNLOAD_STOPPED:
276 consider_restart (event->status);
277 GNUNET_assert (download == event->value.download.dc); 292 GNUNET_assert (download == event->value.download.dc);
278 GNUNET_SCHEDULER_add_continuation (sched, 293 GNUNET_SCHEDULER_add_continuation (sched,
279 &abort_publish_task, 294 &abort_publish_task,
280 NULL, 295 NULL,
281 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 296 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
297 download = NULL;
282 break; 298 break;
283 default: 299 default:
284 printf ("Unexpected event: %d\n", 300 printf ("Unexpected event: %d\n",
@@ -394,7 +410,6 @@ main (int argc, char *argv[])
394 struct GNUNET_GETOPT_CommandLineOption options[] = { 410 struct GNUNET_GETOPT_CommandLineOption options[] = {
395 GNUNET_GETOPT_OPTION_END 411 GNUNET_GETOPT_OPTION_END
396 }; 412 };
397
398 GNUNET_log_setup ("test_fs_download_persistence", 413 GNUNET_log_setup ("test_fs_download_persistence",
399#if VERBOSE 414#if VERBOSE
400 "DEBUG", 415 "DEBUG",
@@ -402,6 +417,7 @@ main (int argc, char *argv[])
402 "WARNING", 417 "WARNING",
403#endif 418#endif
404 NULL); 419 NULL);
420 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-download/");
405 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, 421 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1,
406 argvx, "test-fs-download-persistence", 422 argvx, "test-fs-download-persistence",
407 "nohelp", options, &run, NULL); 423 "nohelp", options, &run, NULL);