X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Ffs%2Ftest_fs_unindex_persistence.c;h=0529aacfa71c2e77ad8a2b94cbb885d9c6c89be6;hb=20e86c5bb520dadff4354ab8a0728b914ed82e3f;hp=191dec57dbea1ec45e10449304037ab1b5ba5ea2;hpb=502af2167f7c218366666ca4944bd7cc54b5b19a;p=oweals%2Fgnunet.git diff --git a/src/fs/test_fs_unindex_persistence.c b/src/fs/test_fs_unindex_persistence.c index 191dec57d..0529aacfa 100644 --- a/src/fs/test_fs_unindex_persistence.c +++ b/src/fs/test_fs_unindex_persistence.c @@ -28,7 +28,7 @@ #include "gnunet_arm_service.h" #include "gnunet_fs_service.h" -#define VERBOSE GNUNET_NO +#define VERBOSE GNUNET_EXTRA_LOGGING #define START_ARM GNUNET_YES @@ -94,25 +94,22 @@ abort_unindex_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } -static void *progress_cb (void *cls, - const struct GNUNET_FS_ProgressInfo *event); +static void * +progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event); static void restart_fs_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { GNUNET_FS_stop (fs); - fs = GNUNET_FS_start (cfg, - "test-fs-unindex-persistence", - &progress_cb, - NULL, + fs = GNUNET_FS_start (cfg, "test-fs-unindex-persistence", &progress_cb, NULL, GNUNET_FS_FLAGS_PERSISTENCE, GNUNET_FS_OPTIONS_END); } /** - * Consider scheduling the restart-task. - * Only runs the restart task once per event + * Consider scheduling the restart-task. + * Only runs the restart task once per event * category. * * @param ev type of the event to consider @@ -199,20 +196,16 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) unindex = event->value.unindex.uc; return "unindex"; case GNUNET_FS_STATUS_PUBLISH_ERROR: - fprintf (stderr, - "Error publishing file: %s\n", + fprintf (stderr, "Error publishing file: %s\n", event->value.publish.specifics.error.message); GNUNET_break (0); - GNUNET_SCHEDULER_add_continuation (&abort_publish_task, - NULL, + GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; case GNUNET_FS_STATUS_UNINDEX_ERROR: - fprintf (stderr, - "Error unindexing file: %s\n", + fprintf (stderr, "Error unindexing file: %s\n", event->value.unindex.specifics.error.message); - GNUNET_SCHEDULER_add_continuation (&abort_unindex_task, - NULL, + GNUNET_SCHEDULER_add_continuation (&abort_unindex_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; case GNUNET_FS_STATUS_PUBLISH_START: @@ -239,8 +232,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) break; case GNUNET_FS_STATUS_UNINDEX_STOPPED: GNUNET_assert (unindex == event->value.unindex.uc); - GNUNET_SCHEDULER_add_continuation (&abort_publish_task, - NULL, + GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; default: @@ -256,12 +248,13 @@ setup_peer (struct PeerContext *p, const char *cfgname) { p->cfg = GNUNET_CONFIGURATION_create (); #if START_ARM - p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", - "gnunet-service-arm", + p->arm_proc = + GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", + "gnunet-service-arm", #if VERBOSE - "-L", "DEBUG", + "-L", "DEBUG", #endif - "-c", cfgname, NULL); + "-c", cfgname, NULL); #endif GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); } @@ -277,8 +270,7 @@ stop_arm (struct PeerContext *p) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "ARM process %u stopped\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc)); GNUNET_OS_process_close (p->arm_proc); p->arm_proc = NULL; @@ -289,9 +281,8 @@ stop_arm (struct PeerContext *p) static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *c) { const char *keywords[] = { "down_foo", @@ -307,19 +298,14 @@ run (void *cls, cfg = c; setup_peer (&p1, "test_fs_unindex_data.conf"); fn = GNUNET_DISK_mktemp ("gnunet-unindex-test-dst"); - fs = GNUNET_FS_start (cfg, - "test-fs-unindex-persistence", - &progress_cb, - NULL, + fs = GNUNET_FS_start (cfg, "test-fs-unindex-persistence", &progress_cb, NULL, GNUNET_FS_FLAGS_PERSISTENCE, GNUNET_FS_OPTIONS_END); GNUNET_assert (NULL != fs); buf = GNUNET_malloc (FILESIZE); for (i = 0; i < FILESIZE; i++) buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); GNUNET_assert (FILESIZE == - GNUNET_DISK_fn_write (fn, - buf, - FILESIZE, + GNUNET_DISK_fn_write (fn, buf, FILESIZE, GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE)); GNUNET_free (buf); @@ -329,19 +315,16 @@ run (void *cls, bo.anonymity_level = 1; bo.replication_level = 0; bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME); - fi = GNUNET_FS_file_information_create_from_file (fs, - "publish-context", - fn, - kuri, - meta, GNUNET_YES, &bo); + fi = GNUNET_FS_file_information_create_from_file (fs, "publish-context", fn, + kuri, meta, GNUNET_YES, + &bo); GNUNET_FS_uri_destroy (kuri); GNUNET_CONTAINER_meta_data_destroy (meta); GNUNET_assert (NULL != fi); start = GNUNET_TIME_absolute_get (); - publish = GNUNET_FS_publish_start (fs, - fi, - NULL, NULL, NULL, - GNUNET_FS_PUBLISH_OPTION_NONE); + publish = + GNUNET_FS_publish_start (fs, fi, NULL, NULL, NULL, + GNUNET_FS_PUBLISH_OPTION_NONE); GNUNET_assert (publish != NULL); } @@ -369,8 +352,8 @@ main (int argc, char *argv[]) "WARNING", #endif NULL); - GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, - argvx, "test-fs-unindex", "nohelp", options, &run, NULL); + GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx, + "test-fs-unindex", "nohelp", options, &run, NULL); stop_arm (&p1); GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-unindex/"); if (NULL != fn)