aboutsummaryrefslogtreecommitdiff
path: root/src/fs/test_fs_unindex.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-08-15 21:54:06 +0000
committerChristian Grothoff <christian@grothoff.org>2011-08-15 21:54:06 +0000
commit5746309cb4be2073d550ad7a6885e918631dbc38 (patch)
tree89455bc4aadf977816b38df13f990372cd81d71a /src/fs/test_fs_unindex.c
parent6fd3e715cae09fa6e657c96f1c6f9711ee51f42f (diff)
downloadgnunet-5746309cb4be2073d550ad7a6885e918631dbc38.tar.gz
gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.zip
indentation
Diffstat (limited to 'src/fs/test_fs_unindex.c')
-rw-r--r--src/fs/test_fs_unindex.c77
1 files changed, 32 insertions, 45 deletions
diff --git a/src/fs/test_fs_unindex.c b/src/fs/test_fs_unindex.c
index 70a9e0bcf..177b687ca 100644
--- a/src/fs/test_fs_unindex.c
+++ b/src/fs/test_fs_unindex.c
@@ -100,16 +100,16 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
100 (unsigned long long) event->value.publish.completed, 100 (unsigned long long) event->value.publish.completed,
101 (unsigned long long) event->value.publish.size, 101 (unsigned long long) event->value.publish.size,
102 event->value.publish.specifics.progress.depth, 102 event->value.publish.specifics.progress.depth,
103 (unsigned long long) event->value.publish.specifics. 103 (unsigned long long) event->value.publish.specifics.progress.
104 progress.offset); 104 offset);
105#endif 105#endif
106 break; 106 break;
107 case GNUNET_FS_STATUS_PUBLISH_COMPLETED: 107 case GNUNET_FS_STATUS_PUBLISH_COMPLETED:
108 printf ("Publishing complete, %llu kbps.\n", 108 printf ("Publishing complete, %llu kbps.\n",
109 (unsigned long long) (FILESIZE * 1000 / 109 (unsigned long long) (FILESIZE * 1000 /
110 (1 + 110 (1 +
111 GNUNET_TIME_absolute_get_duration 111 GNUNET_TIME_absolute_get_duration (start).
112 (start).rel_value) / 1024)); 112 rel_value) / 1024));
113 start = GNUNET_TIME_absolute_get (); 113 start = GNUNET_TIME_absolute_get ();
114 unindex = GNUNET_FS_unindex_start (fs, fn, "unindex"); 114 unindex = GNUNET_FS_unindex_start (fs, fn, "unindex");
115 GNUNET_assert (unindex != NULL); 115 GNUNET_assert (unindex != NULL);
@@ -118,8 +118,8 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
118 printf ("Unindex complete, %llu kbps.\n", 118 printf ("Unindex complete, %llu kbps.\n",
119 (unsigned long long) (FILESIZE * 1000 / 119 (unsigned long long) (FILESIZE * 1000 /
120 (1 + 120 (1 +
121 GNUNET_TIME_absolute_get_duration 121 GNUNET_TIME_absolute_get_duration (start).
122 (start).rel_value) / 1024)); 122 rel_value) / 1024));
123 GNUNET_SCHEDULER_add_continuation (&abort_unindex_task, NULL, 123 GNUNET_SCHEDULER_add_continuation (&abort_unindex_task, NULL,
124 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 124 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
125 break; 125 break;
@@ -130,25 +130,21 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
130 (unsigned long long) event->value.unindex.completed, 130 (unsigned long long) event->value.unindex.completed,
131 (unsigned long long) event->value.unindex.size, 131 (unsigned long long) event->value.unindex.size,
132 event->value.unindex.specifics.progress.depth, 132 event->value.unindex.specifics.progress.depth,
133 (unsigned long long) event->value.unindex.specifics. 133 (unsigned long long) event->value.unindex.specifics.progress.
134 progress.offset); 134 offset);
135#endif 135#endif
136 break; 136 break;
137 case GNUNET_FS_STATUS_PUBLISH_ERROR: 137 case GNUNET_FS_STATUS_PUBLISH_ERROR:
138 fprintf (stderr, 138 fprintf (stderr, "Error publishing file: %s\n",
139 "Error publishing file: %s\n",
140 event->value.publish.specifics.error.message); 139 event->value.publish.specifics.error.message);
141 GNUNET_break (0); 140 GNUNET_break (0);
142 GNUNET_SCHEDULER_add_continuation (&abort_publish_task, 141 GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL,
143 NULL,
144 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 142 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
145 break; 143 break;
146 case GNUNET_FS_STATUS_UNINDEX_ERROR: 144 case GNUNET_FS_STATUS_UNINDEX_ERROR:
147 fprintf (stderr, 145 fprintf (stderr, "Error unindexing file: %s\n",
148 "Error unindexing file: %s\n",
149 event->value.unindex.specifics.error.message); 146 event->value.unindex.specifics.error.message);
150 GNUNET_SCHEDULER_add_continuation (&abort_unindex_task, 147 GNUNET_SCHEDULER_add_continuation (&abort_unindex_task, NULL,
151 NULL,
152 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 148 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
153 break; 149 break;
154 case GNUNET_FS_STATUS_PUBLISH_START: 150 case GNUNET_FS_STATUS_PUBLISH_START:
@@ -174,8 +170,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
174 break; 170 break;
175 case GNUNET_FS_STATUS_UNINDEX_STOPPED: 171 case GNUNET_FS_STATUS_UNINDEX_STOPPED:
176 GNUNET_assert (unindex == event->value.unindex.uc); 172 GNUNET_assert (unindex == event->value.unindex.uc);
177 GNUNET_SCHEDULER_add_continuation (&abort_publish_task, 173 GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL,
178 NULL,
179 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 174 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
180 break; 175 break;
181 default: 176 default:
@@ -191,12 +186,13 @@ setup_peer (struct PeerContext *p, const char *cfgname)
191{ 186{
192 p->cfg = GNUNET_CONFIGURATION_create (); 187 p->cfg = GNUNET_CONFIGURATION_create ();
193#if START_ARM 188#if START_ARM
194 p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", 189 p->arm_proc =
195 "gnunet-service-arm", 190 GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
191 "gnunet-service-arm",
196#if VERBOSE 192#if VERBOSE
197 "-L", "DEBUG", 193 "-L", "DEBUG",
198#endif 194#endif
199 "-c", cfgname, NULL); 195 "-c", cfgname, NULL);
200#endif 196#endif
201 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); 197 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
202} 198}
@@ -212,8 +208,7 @@ stop_arm (struct PeerContext *p)
212 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 208 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
213 if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) 209 if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK)
214 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); 210 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
215 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 211 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n",
216 "ARM process %u stopped\n",
217 GNUNET_OS_process_get_pid (p->arm_proc)); 212 GNUNET_OS_process_get_pid (p->arm_proc));
218 GNUNET_OS_process_close (p->arm_proc); 213 GNUNET_OS_process_close (p->arm_proc);
219 p->arm_proc = NULL; 214 p->arm_proc = NULL;
@@ -224,9 +219,8 @@ stop_arm (struct PeerContext *p)
224 219
225 220
226static void 221static void
227run (void *cls, 222run (void *cls, char *const *args, const char *cfgfile,
228 char *const *args, 223 const struct GNUNET_CONFIGURATION_Handle *cfg)
229 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
230{ 224{
231 const char *keywords[] = { 225 const char *keywords[] = {
232 "down_foo", 226 "down_foo",
@@ -241,18 +235,14 @@ run (void *cls,
241 235
242 setup_peer (&p1, "test_fs_unindex_data.conf"); 236 setup_peer (&p1, "test_fs_unindex_data.conf");
243 fn = GNUNET_DISK_mktemp ("gnunet-unindex-test-dst"); 237 fn = GNUNET_DISK_mktemp ("gnunet-unindex-test-dst");
244 fs = GNUNET_FS_start (cfg, 238 fs = GNUNET_FS_start (cfg, "test-fs-unindex", &progress_cb, NULL,
245 "test-fs-unindex", 239 GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END);
246 &progress_cb,
247 NULL, GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END);
248 GNUNET_assert (NULL != fs); 240 GNUNET_assert (NULL != fs);
249 buf = GNUNET_malloc (FILESIZE); 241 buf = GNUNET_malloc (FILESIZE);
250 for (i = 0; i < FILESIZE; i++) 242 for (i = 0; i < FILESIZE; i++)
251 buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); 243 buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256);
252 GNUNET_assert (FILESIZE == 244 GNUNET_assert (FILESIZE ==
253 GNUNET_DISK_fn_write (fn, 245 GNUNET_DISK_fn_write (fn, buf, FILESIZE,
254 buf,
255 FILESIZE,
256 GNUNET_DISK_PERM_USER_READ | 246 GNUNET_DISK_PERM_USER_READ |
257 GNUNET_DISK_PERM_USER_WRITE)); 247 GNUNET_DISK_PERM_USER_WRITE));
258 GNUNET_free (buf); 248 GNUNET_free (buf);
@@ -262,19 +252,16 @@ run (void *cls,
262 bo.anonymity_level = 1; 252 bo.anonymity_level = 1;
263 bo.replication_level = 0; 253 bo.replication_level = 0;
264 bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME); 254 bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME);
265 fi = GNUNET_FS_file_information_create_from_file (fs, 255 fi = GNUNET_FS_file_information_create_from_file (fs, "publish-context", fn,
266 "publish-context", 256 kuri, meta, GNUNET_YES,
267 fn, 257 &bo);
268 kuri,
269 meta, GNUNET_YES, &bo);
270 GNUNET_FS_uri_destroy (kuri); 258 GNUNET_FS_uri_destroy (kuri);
271 GNUNET_CONTAINER_meta_data_destroy (meta); 259 GNUNET_CONTAINER_meta_data_destroy (meta);
272 GNUNET_assert (NULL != fi); 260 GNUNET_assert (NULL != fi);
273 start = GNUNET_TIME_absolute_get (); 261 start = GNUNET_TIME_absolute_get ();
274 publish = GNUNET_FS_publish_start (fs, 262 publish =
275 fi, 263 GNUNET_FS_publish_start (fs, fi, NULL, NULL, NULL,
276 NULL, NULL, NULL, 264 GNUNET_FS_PUBLISH_OPTION_NONE);
277 GNUNET_FS_PUBLISH_OPTION_NONE);
278 GNUNET_assert (publish != NULL); 265 GNUNET_assert (publish != NULL);
279} 266}
280 267
@@ -302,8 +289,8 @@ main (int argc, char *argv[])
302 "WARNING", 289 "WARNING",
303#endif 290#endif
304 NULL); 291 NULL);
305 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, 292 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx,
306 argvx, "test-fs-unindex", "nohelp", options, &run, NULL); 293 "test-fs-unindex", "nohelp", options, &run, NULL);
307 stop_arm (&p1); 294 stop_arm (&p1);
308 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-unindex/"); 295 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-unindex/");
309 if (NULL != fn) 296 if (NULL != fn)