X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Ftesting%2Fgnunet-testing-run-service.c;h=988b67e4fc9d4dfdee550f2e55e76f3fb75a63a9;hb=bcbd694ad35e182e5a1486b545ea0706082ee94a;hp=fa98e1a6c47b691987cf35773efccb60fb0fc616;hpb=265a7c5f1b656d4e27647ac05fa91f7dd2ae8542;p=oweals%2Fgnunet.git diff --git a/src/testing/gnunet-testing-run-service.c b/src/testing/gnunet-testing-run-service.c index fa98e1a6c..988b67e4f 100644 --- a/src/testing/gnunet-testing-run-service.c +++ b/src/testing/gnunet-testing-run-service.c @@ -28,28 +28,22 @@ * Outputs the path to the temporary configuration file to stdout. * * The peer will run until this program is killed, - * or stdin is closed. When reading the character 'r' from stdin, the running service is - * restarted with the same configuration. + * or stdin is closed. When reading the character 'r' from stdin, + * the running service is restarted with the same configuration. * * This executable is intended to be used by gnunet-java, in order to reliably * start and stop services for test cases. */ - #include "platform.h" -#include "gnunet_getopt_lib.h" -#include "gnunet_program_lib.h" #include "gnunet_util_lib.h" -#include "gnunet_signal_lib.h" #include "gnunet_testing_lib-new.h" -#include "gnunet_os_lib.h" - #define LOG(kind,...) \ GNUNET_log_from (kind, "gnunet-testing", __VA_ARGS__) /** - * FIXME + * File handle to STDIN, for reading restart/quit commands. */ static struct GNUNET_DISK_FileHandle *fh; @@ -135,7 +129,8 @@ stdin_cb (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) fprintf (stderr, _("Unknown command, use 'q' to quit or 'r' to restart peer\n")); break; } - tid = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, &fh, &stdin_cb, NULL); + tid = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, fh, + &stdin_cb, NULL); } @@ -149,26 +144,28 @@ stdin_cb (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) */ static void testing_main (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, - const struct GNUNET_TESTING_Peer *peer) + struct GNUNET_TESTING_Peer *peer) { - my_peer = (struct GNUNET_TESTING_Peer *) peer; + my_peer = peer; if (NULL == (tmpfilename = GNUNET_DISK_mktemp ("gnunet-testing"))) { GNUNET_break (0); - cleanup (); + GNUNET_SCHEDULER_shutdown (); return; } if (GNUNET_SYSERR == - GNUNET_CONFIGURATION_write ((struct GNUNET_CONFIGURATION_Handle *) cfg, tmpfilename)) + GNUNET_CONFIGURATION_write ((struct GNUNET_CONFIGURATION_Handle *) cfg, + tmpfilename)) { GNUNET_break (0); return; } - printf("%s\n", tmpfilename); + printf("ok\n%s\n", tmpfilename); fflush(stdout); - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREFER_REL, &cleanup); + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleanup, NULL); fh = GNUNET_DISK_get_handle_from_native (stdin); - tid = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, &fh, &stdin_cb, NULL); + tid = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, fh, + &stdin_cb, NULL); } @@ -186,7 +183,7 @@ main (int argc, char *const *argv) static char *srv_name; static const struct GNUNET_GETOPT_CommandLineOption options[] = { {'c', "config", "FILENAME", - gettext_noop ("name of the configuration file to use"), 1, + gettext_noop ("name of the template configuration file to use (optional)"), 1, &GNUNET_GETOPT_set_string, &cfg_name}, {'s', "service", "SERVICE", gettext_noop ("name of the service to run"), 1, @@ -199,8 +196,8 @@ main (int argc, char *const *argv) if (GNUNET_SYSERR == GNUNET_GETOPT_run("gnunet-testing-run-service", options, argc, argv)) return 1; - ret = GNUNET_TESTING_service_run_restartable ("gnunet_service_test", srv_name, - cfg_name, &testing_main, NULL); + ret = GNUNET_TESTING_service_run ("gnunet_service_test", srv_name, + cfg_name, &testing_main, NULL); if (0 != ret) { printf ("error\n");