aboutsummaryrefslogtreecommitdiff
path: root/src/fs/test_fs_publish.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2009-10-26 08:56:45 +0000
committerChristian Grothoff <christian@grothoff.org>2009-10-26 08:56:45 +0000
commit81759960dce0da1f263a5de92658a1913af27ccd (patch)
tree662a6169a80646ff680026a25062c5f9edccf1cf /src/fs/test_fs_publish.c
parentf3ae4ca96ccf47a56cbf3fc152747779c7d142ca (diff)
downloadgnunet-81759960dce0da1f263a5de92658a1913af27ccd.tar.gz
gnunet-81759960dce0da1f263a5de92658a1913af27ccd.zip
fix
Diffstat (limited to 'src/fs/test_fs_publish.c')
-rw-r--r--src/fs/test_fs_publish.c87
1 files changed, 62 insertions, 25 deletions
diff --git a/src/fs/test_fs_publish.c b/src/fs/test_fs_publish.c
index 0a312085d..9473cddb5 100644
--- a/src/fs/test_fs_publish.c
+++ b/src/fs/test_fs_publish.c
@@ -74,6 +74,7 @@ static char *fn1;
74 74
75static char *fn2; 75static char *fn2;
76 76
77static int err;
77 78
78static void 79static void
79abort_publish_task (void *cls, 80abort_publish_task (void *cls,
@@ -94,19 +95,25 @@ static void *
94progress_cb (void *cls, 95progress_cb (void *cls,
95 const struct GNUNET_FS_ProgressInfo *event) 96 const struct GNUNET_FS_ProgressInfo *event)
96{ 97{
98 void *ret;
97 99
100 ret = NULL;
98 switch (event->status) 101 switch (event->status)
99 { 102 {
100 case GNUNET_FS_STATUS_PUBLISH_COMPLETED: 103 case GNUNET_FS_STATUS_PUBLISH_COMPLETED:
104 ret = event->value.publish.cctx;
101 printf ("Publish complete, %llu kbps.\n", 105 printf ("Publish complete, %llu kbps.\n",
102 (unsigned long long) (FILESIZE * 1000 / (1+GNUNET_TIME_absolute_get_duration (start).value) / 1024)); 106 (unsigned long long) (FILESIZE * 1000 / (1+GNUNET_TIME_absolute_get_duration (start).value) / 1024));
103 GNUNET_SCHEDULER_add_continuation (sched, 107 if (0 == strcmp ("list_indexed-context-dir",
104 GNUNET_NO, 108 event->value.publish.cctx))
105 &abort_publish_task, 109 GNUNET_SCHEDULER_add_continuation (sched,
106 NULL, 110 GNUNET_NO,
107 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 111 &abort_publish_task,
112 NULL,
113 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
108 break; 114 break;
109 case GNUNET_FS_STATUS_PUBLISH_PROGRESS: 115 case GNUNET_FS_STATUS_PUBLISH_PROGRESS:
116 ret = event->value.publish.cctx;
110 GNUNET_assert (publish == event->value.publish.sc); 117 GNUNET_assert (publish == event->value.publish.sc);
111#if VERBOSE 118#if VERBOSE
112 printf ("Publish is progressing (%llu/%llu at level %u off %llu)...\n", 119 printf ("Publish is progressing (%llu/%llu at level %u off %llu)...\n",
@@ -117,36 +124,66 @@ progress_cb (void *cls,
117#endif 124#endif
118 break; 125 break;
119 case GNUNET_FS_STATUS_PUBLISH_ERROR: 126 case GNUNET_FS_STATUS_PUBLISH_ERROR:
127 ret = event->value.publish.cctx;
120 fprintf (stderr, 128 fprintf (stderr,
121 "Error publishing file: %s\n", 129 "Error publishing file: %s\n",
122 event->value.publish.specifics.error.message); 130 event->value.publish.specifics.error.message);
123 GNUNET_SCHEDULER_add_continuation (sched, 131 err = 1;
124 GNUNET_NO, 132 if (0 == strcmp ("list_indexed-context-dir",
125 &abort_publish_task, 133 event->value.publish.cctx))
126 NULL, 134 GNUNET_SCHEDULER_add_continuation (sched,
127 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 135 GNUNET_NO,
136 &abort_publish_task,
137 NULL,
138 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
128 break; 139 break;
129 case GNUNET_FS_STATUS_PUBLISH_START: 140 case GNUNET_FS_STATUS_PUBLISH_START:
130 GNUNET_assert (0 == strcmp ("publish-context", event->value.publish.cctx)); 141 ret = event->value.publish.cctx;
131 GNUNET_assert (NULL == event->value.publish.pctx); 142 if (0 == strcmp ("publish-context1",
132 GNUNET_assert (FILESIZE == event->value.publish.size); 143 event->value.publish.cctx))
133 GNUNET_assert (0 == event->value.publish.completed); 144 {
134 GNUNET_assert (1 == event->value.publish.anonymity); 145 GNUNET_assert (0 == strcmp ("publish-context-dir",
146 event->value.publish.pctx));
147 GNUNET_assert (FILESIZE == event->value.publish.size);
148 GNUNET_assert (0 == event->value.publish.completed);
149 GNUNET_assert (1 == event->value.publish.anonymity);
150 }
151 else if (0 == strcmp ("publish-context2",
152 event->value.publish.cctx))
153 {
154 GNUNET_assert (0 == strcmp ("publish-context-dir",
155 event->value.publish.pctx));
156 GNUNET_assert (FILESIZE == event->value.publish.size);
157 GNUNET_assert (0 == event->value.publish.completed);
158 GNUNET_assert (2 == event->value.publish.anonymity);
159 }
160 else if (0 == strcmp ("publish-context-dir",
161 event->value.publish.cctx))
162 {
163 GNUNET_assert (0 == event->value.publish.completed);
164 GNUNET_assert (3 == event->value.publish.anonymity);
165 }
166 else
167 GNUNET_assert (0);
135 break; 168 break;
136 case GNUNET_FS_STATUS_PUBLISH_STOPPED: 169 case GNUNET_FS_STATUS_PUBLISH_STOPPED:
137 GNUNET_assert (publish == event->value.publish.sc); 170 if (0 == strcmp ("list_indexed-context-dir",
138 GNUNET_SCHEDULER_add_continuation (sched, 171 event->value.publish.cctx))
139 GNUNET_NO, 172 {
140 &abort_publish_task, 173 GNUNET_assert (publish == event->value.publish.sc);
141 NULL, 174 GNUNET_SCHEDULER_add_continuation (sched,
142 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 175 GNUNET_NO,
176 &abort_publish_task,
177 NULL,
178 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
179 }
143 break; 180 break;
144 default: 181 default:
145 printf ("Unexpected event: %d\n", 182 printf ("Unexpected event: %d\n",
146 event->status); 183 event->status);
147 break; 184 break;
148 } 185 }
149 return NULL; 186 return ret;
150} 187}
151 188
152 189
@@ -249,13 +286,13 @@ run (void *cls,
249 kuri, 286 kuri,
250 meta, 287 meta,
251 GNUNET_YES, 288 GNUNET_YES,
252 1, 289 2,
253 42, 290 42,
254 GNUNET_TIME_relative_to_absolute (LIFETIME)); 291 GNUNET_TIME_relative_to_absolute (LIFETIME));
255 fidir = GNUNET_FS_file_information_create_empty_directory ("publish-context-dir", 292 fidir = GNUNET_FS_file_information_create_empty_directory ("publish-context-dir",
256 kuri, 293 kuri,
257 meta, 294 meta,
258 1, 295 3,
259 42, 296 42,
260 GNUNET_TIME_relative_to_absolute (LIFETIME)); 297 GNUNET_TIME_relative_to_absolute (LIFETIME));
261 GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi1)); 298 GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi1));
@@ -304,7 +341,7 @@ main (int argc, char *argv[])
304 GNUNET_free_non_null (fn1); 341 GNUNET_free_non_null (fn1);
305 GNUNET_DISK_directory_remove (fn2); 342 GNUNET_DISK_directory_remove (fn2);
306 GNUNET_free_non_null (fn2); 343 GNUNET_free_non_null (fn2);
307 return 0; 344 return err;
308} 345}
309 346
310/* end of test_fs_publish.c */ 347/* end of test_fs_publish.c */