diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-08-15 21:54:06 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-08-15 21:54:06 +0000 |
commit | 5746309cb4be2073d550ad7a6885e918631dbc38 (patch) | |
tree | 89455bc4aadf977816b38df13f990372cd81d71a /src/fs/test_fs_list_indexed.c | |
parent | 6fd3e715cae09fa6e657c96f1c6f9711ee51f42f (diff) | |
download | gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.tar.gz gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.zip |
indentation
Diffstat (limited to 'src/fs/test_fs_list_indexed.c')
-rw-r--r-- | src/fs/test_fs_list_indexed.c | 103 |
1 files changed, 46 insertions, 57 deletions
diff --git a/src/fs/test_fs_list_indexed.c b/src/fs/test_fs_list_indexed.c index e3330f3ba..87afa12e1 100644 --- a/src/fs/test_fs_list_indexed.c +++ b/src/fs/test_fs_list_indexed.c | |||
@@ -92,8 +92,8 @@ static void | |||
92 | list_indexed_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 92 | list_indexed_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
93 | { | 93 | { |
94 | 94 | ||
95 | GNUNET_SCHEDULER_add_continuation (&abort_publish_task, | 95 | GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, |
96 | NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); | 96 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); |
97 | } | 97 | } |
98 | 98 | ||
99 | 99 | ||
@@ -110,11 +110,10 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) | |||
110 | printf ("Publish complete, %llu kbps.\n", | 110 | printf ("Publish complete, %llu kbps.\n", |
111 | (unsigned long long) (FILESIZE * 1000 / | 111 | (unsigned long long) (FILESIZE * 1000 / |
112 | (1 + | 112 | (1 + |
113 | GNUNET_TIME_absolute_get_duration | 113 | GNUNET_TIME_absolute_get_duration (start). |
114 | (start).rel_value) / 1024)); | 114 | rel_value) / 1024)); |
115 | if (0 == strcmp ("list_indexed-context-dir", event->value.publish.cctx)) | 115 | if (0 == strcmp ("list_indexed-context-dir", event->value.publish.cctx)) |
116 | GNUNET_SCHEDULER_add_continuation (&list_indexed_task, | 116 | GNUNET_SCHEDULER_add_continuation (&list_indexed_task, NULL, |
117 | NULL, | ||
118 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); | 117 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); |
119 | 118 | ||
120 | break; | 119 | break; |
@@ -126,41 +125,41 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) | |||
126 | (unsigned long long) event->value.publish.completed, | 125 | (unsigned long long) event->value.publish.completed, |
127 | (unsigned long long) event->value.publish.size, | 126 | (unsigned long long) event->value.publish.size, |
128 | event->value.publish.specifics.progress.depth, | 127 | event->value.publish.specifics.progress.depth, |
129 | (unsigned long long) event->value.publish.specifics. | 128 | (unsigned long long) event->value.publish.specifics.progress. |
130 | progress.offset); | 129 | offset); |
131 | #endif | 130 | #endif |
132 | break; | 131 | break; |
133 | case GNUNET_FS_STATUS_PUBLISH_ERROR: | 132 | case GNUNET_FS_STATUS_PUBLISH_ERROR: |
134 | ret = event->value.publish.cctx; | 133 | ret = event->value.publish.cctx; |
135 | fprintf (stderr, | 134 | fprintf (stderr, "Error publishing file: %s\n", |
136 | "Error publishing file: %s\n", | ||
137 | event->value.publish.specifics.error.message); | 135 | event->value.publish.specifics.error.message); |
138 | err = 1; | 136 | err = 1; |
139 | if (0 == strcmp ("list_indexed-context-dir", event->value.publish.cctx)) | 137 | if (0 == strcmp ("list_indexed-context-dir", event->value.publish.cctx)) |
140 | GNUNET_SCHEDULER_add_continuation (&abort_publish_task, | 138 | GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, |
141 | NULL, | ||
142 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); | 139 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); |
143 | break; | 140 | break; |
144 | case GNUNET_FS_STATUS_PUBLISH_START: | 141 | case GNUNET_FS_STATUS_PUBLISH_START: |
145 | ret = event->value.publish.cctx; | 142 | ret = event->value.publish.cctx; |
146 | if (0 == strcmp ("list_indexed-context1", event->value.publish.cctx)) | 143 | if (0 == strcmp ("list_indexed-context1", event->value.publish.cctx)) |
147 | { | 144 | { |
148 | GNUNET_assert (0 == strcmp ("list_indexed-context-dir", | 145 | GNUNET_assert (0 == |
149 | event->value.publish.pctx)); | 146 | strcmp ("list_indexed-context-dir", |
147 | event->value.publish.pctx)); | ||
150 | GNUNET_assert (FILESIZE == event->value.publish.size); | 148 | GNUNET_assert (FILESIZE == event->value.publish.size); |
151 | GNUNET_assert (0 == event->value.publish.completed); | 149 | GNUNET_assert (0 == event->value.publish.completed); |
152 | GNUNET_assert (1 == event->value.publish.anonymity); | 150 | GNUNET_assert (1 == event->value.publish.anonymity); |
153 | } | 151 | } |
154 | else if (0 == strcmp ("list_indexed-context2", event->value.publish.cctx)) | 152 | else if (0 == strcmp ("list_indexed-context2", event->value.publish.cctx)) |
155 | { | 153 | { |
156 | GNUNET_assert (0 == strcmp ("list_indexed-context-dir", | 154 | GNUNET_assert (0 == |
157 | event->value.publish.pctx)); | 155 | strcmp ("list_indexed-context-dir", |
156 | event->value.publish.pctx)); | ||
158 | GNUNET_assert (FILESIZE == event->value.publish.size); | 157 | GNUNET_assert (FILESIZE == event->value.publish.size); |
159 | GNUNET_assert (0 == event->value.publish.completed); | 158 | GNUNET_assert (0 == event->value.publish.completed); |
160 | GNUNET_assert (2 == event->value.publish.anonymity); | 159 | GNUNET_assert (2 == event->value.publish.anonymity); |
161 | } | 160 | } |
162 | else if (0 == strcmp ("list_indexed-context-dir", | 161 | else if (0 == |
163 | event->value.publish.cctx)) | 162 | strcmp ("list_indexed-context-dir", event->value.publish.cctx)) |
164 | { | 163 | { |
165 | GNUNET_assert (0 == event->value.publish.completed); | 164 | GNUNET_assert (0 == event->value.publish.completed); |
166 | GNUNET_assert (3 == event->value.publish.anonymity); | 165 | GNUNET_assert (3 == event->value.publish.anonymity); |
@@ -188,12 +187,13 @@ setup_peer (struct PeerContext *p, const char *cfgname) | |||
188 | { | 187 | { |
189 | p->cfg = GNUNET_CONFIGURATION_create (); | 188 | p->cfg = GNUNET_CONFIGURATION_create (); |
190 | #if START_ARM | 189 | #if START_ARM |
191 | p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", | 190 | p->arm_proc = |
192 | "gnunet-service-arm", | 191 | GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", |
192 | "gnunet-service-arm", | ||
193 | #if VERBOSE | 193 | #if VERBOSE |
194 | "-L", "DEBUG", | 194 | "-L", "DEBUG", |
195 | #endif | 195 | #endif |
196 | "-c", cfgname, NULL); | 196 | "-c", cfgname, NULL); |
197 | #endif | 197 | #endif |
198 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); | 198 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); |
199 | } | 199 | } |
@@ -209,8 +209,7 @@ stop_arm (struct PeerContext *p) | |||
209 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); | 209 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); |
210 | if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) | 210 | if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) |
211 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); | 211 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); |
212 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 212 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n", |
213 | "ARM process %u stopped\n", | ||
214 | GNUNET_OS_process_get_pid (p->arm_proc)); | 213 | GNUNET_OS_process_get_pid (p->arm_proc)); |
215 | GNUNET_OS_process_close (p->arm_proc); | 214 | GNUNET_OS_process_close (p->arm_proc); |
216 | p->arm_proc = NULL; | 215 | p->arm_proc = NULL; |
@@ -221,9 +220,8 @@ stop_arm (struct PeerContext *p) | |||
221 | 220 | ||
222 | 221 | ||
223 | static void | 222 | static void |
224 | run (void *cls, | 223 | run (void *cls, char *const *args, const char *cfgfile, |
225 | char *const *args, | 224 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
226 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
227 | { | 225 | { |
228 | const char *keywords[] = { | 226 | const char *keywords[] = { |
229 | "down_foo", | 227 | "down_foo", |
@@ -239,19 +237,15 @@ run (void *cls, | |||
239 | struct GNUNET_FS_BlockOptions bo; | 237 | struct GNUNET_FS_BlockOptions bo; |
240 | 238 | ||
241 | setup_peer (&p1, "test_fs_list_indexed_data.conf"); | 239 | setup_peer (&p1, "test_fs_list_indexed_data.conf"); |
242 | fs = GNUNET_FS_start (cfg, | 240 | fs = GNUNET_FS_start (cfg, "test-fs-list_indexed", &progress_cb, NULL, |
243 | "test-fs-list_indexed", | 241 | GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); |
244 | &progress_cb, | ||
245 | NULL, GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); | ||
246 | GNUNET_assert (NULL != fs); | 242 | GNUNET_assert (NULL != fs); |
247 | fn1 = GNUNET_DISK_mktemp ("gnunet-list_indexed-test-dst"); | 243 | fn1 = GNUNET_DISK_mktemp ("gnunet-list_indexed-test-dst"); |
248 | buf = GNUNET_malloc (FILESIZE); | 244 | buf = GNUNET_malloc (FILESIZE); |
249 | for (i = 0; i < FILESIZE; i++) | 245 | for (i = 0; i < FILESIZE; i++) |
250 | buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); | 246 | buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); |
251 | GNUNET_assert (FILESIZE == | 247 | GNUNET_assert (FILESIZE == |
252 | GNUNET_DISK_fn_write (fn1, | 248 | GNUNET_DISK_fn_write (fn1, buf, FILESIZE, |
253 | buf, | ||
254 | FILESIZE, | ||
255 | GNUNET_DISK_PERM_USER_READ | | 249 | GNUNET_DISK_PERM_USER_READ | |
256 | GNUNET_DISK_PERM_USER_WRITE)); | 250 | GNUNET_DISK_PERM_USER_WRITE)); |
257 | GNUNET_free (buf); | 251 | GNUNET_free (buf); |
@@ -261,9 +255,7 @@ run (void *cls, | |||
261 | for (i = 0; i < FILESIZE; i++) | 255 | for (i = 0; i < FILESIZE; i++) |
262 | buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); | 256 | buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); |
263 | GNUNET_assert (FILESIZE == | 257 | GNUNET_assert (FILESIZE == |
264 | GNUNET_DISK_fn_write (fn2, | 258 | GNUNET_DISK_fn_write (fn2, buf, FILESIZE, |
265 | buf, | ||
266 | FILESIZE, | ||
267 | GNUNET_DISK_PERM_USER_READ | | 259 | GNUNET_DISK_PERM_USER_READ | |
268 | GNUNET_DISK_PERM_USER_WRITE)); | 260 | GNUNET_DISK_PERM_USER_WRITE)); |
269 | GNUNET_free (buf); | 261 | GNUNET_free (buf); |
@@ -274,33 +266,31 @@ run (void *cls, | |||
274 | bo.anonymity_level = 1; | 266 | bo.anonymity_level = 1; |
275 | bo.replication_level = 0; | 267 | bo.replication_level = 0; |
276 | bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME); | 268 | bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME); |
277 | fi1 = GNUNET_FS_file_information_create_from_file (fs, | 269 | fi1 = |
278 | "list_indexed-context1", | 270 | GNUNET_FS_file_information_create_from_file (fs, "list_indexed-context1", |
279 | fn1, | 271 | fn1, kuri, meta, GNUNET_YES, |
280 | kuri, | 272 | &bo); |
281 | meta, GNUNET_YES, &bo); | ||
282 | GNUNET_assert (NULL != fi1); | 273 | GNUNET_assert (NULL != fi1); |
283 | bo.anonymity_level = 2; | 274 | bo.anonymity_level = 2; |
284 | fi2 = GNUNET_FS_file_information_create_from_file (fs, | 275 | fi2 = |
285 | "list_indexed-context2", | 276 | GNUNET_FS_file_information_create_from_file (fs, "list_indexed-context2", |
286 | fn2, | 277 | fn2, kuri, meta, GNUNET_YES, |
287 | kuri, | 278 | &bo); |
288 | meta, GNUNET_YES, &bo); | ||
289 | GNUNET_assert (NULL != fi2); | 279 | GNUNET_assert (NULL != fi2); |
290 | bo.anonymity_level = 3; | 280 | bo.anonymity_level = 3; |
291 | fidir = GNUNET_FS_file_information_create_empty_directory (fs, | 281 | fidir = |
292 | "list_indexed-context-dir", | 282 | GNUNET_FS_file_information_create_empty_directory (fs, |
293 | kuri, meta, &bo); | 283 | "list_indexed-context-dir", |
284 | kuri, meta, &bo); | ||
294 | GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi1)); | 285 | GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi1)); |
295 | GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi2)); | 286 | GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi2)); |
296 | GNUNET_FS_uri_destroy (kuri); | 287 | GNUNET_FS_uri_destroy (kuri); |
297 | GNUNET_CONTAINER_meta_data_destroy (meta); | 288 | GNUNET_CONTAINER_meta_data_destroy (meta); |
298 | GNUNET_assert (NULL != fidir); | 289 | GNUNET_assert (NULL != fidir); |
299 | start = GNUNET_TIME_absolute_get (); | 290 | start = GNUNET_TIME_absolute_get (); |
300 | publish = GNUNET_FS_publish_start (fs, | 291 | publish = |
301 | fidir, | 292 | GNUNET_FS_publish_start (fs, fidir, NULL, NULL, NULL, |
302 | NULL, NULL, NULL, | 293 | GNUNET_FS_PUBLISH_OPTION_NONE); |
303 | GNUNET_FS_PUBLISH_OPTION_NONE); | ||
304 | GNUNET_assert (publish != NULL); | 294 | GNUNET_assert (publish != NULL); |
305 | } | 295 | } |
306 | 296 | ||
@@ -328,9 +318,8 @@ main (int argc, char *argv[]) | |||
328 | "WARNING", | 318 | "WARNING", |
329 | #endif | 319 | #endif |
330 | NULL); | 320 | NULL); |
331 | GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, | 321 | GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx, |
332 | argvx, "test-fs-list_indexed", | 322 | "test-fs-list_indexed", "nohelp", options, &run, NULL); |
333 | "nohelp", options, &run, NULL); | ||
334 | stop_arm (&p1); | 323 | stop_arm (&p1); |
335 | GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-list-indexed/"); | 324 | GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-list-indexed/"); |
336 | if (fn1 != NULL) | 325 | if (fn1 != NULL) |