From 07ba70f731218eb74993553ff4923fd2ece3635b Mon Sep 17 00:00:00 2001 From: "Nathan S. Evans" Date: Wed, 27 Jul 2011 15:49:02 +0000 Subject: [PATCH] use arm timeouts, bad GNUNET_TIME function that will probably get removed --- src/include/gnunet_time_lib.h | 11 +++++++++++ src/testing/testing.c | 12 +++++++++++- src/util/time.c | 19 +++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/include/gnunet_time_lib.h b/src/include/gnunet_time_lib.h index b1ffc4d40..386f6d609 100644 --- a/src/include/gnunet_time_lib.h +++ b/src/include/gnunet_time_lib.h @@ -421,6 +421,17 @@ struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh (struct GNUNET_TIME_AbsoluteNBO a); +/** + * Convert a relative time to a string. + * NOT reentrant! + * + * @param time the time to print + * + * @return string form of the time (as milliseconds) + */ +const char * +GNUNET_TIME_relative_to_string (struct GNUNET_TIME_Relative time); + /** * Set the timestamp offset for this instance. * diff --git a/src/testing/testing.c b/src/testing/testing.c index a079390ad..a9734aea6 100644 --- a/src/testing/testing.c +++ b/src/testing/testing.c @@ -576,7 +576,7 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) #if DEBUG_TESTING "-L", "DEBUG", #endif - "-s", "-q", NULL); + "-s", "-q", "-T", GNUNET_TIME_relative_to_string(GNUNET_TIME_absolute_get_remaining(d->max_timeout)), NULL); } else { @@ -602,6 +602,7 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) "-L", "DEBUG", #endif "-c", d->cfgfile, "-s", "-q", + "-T", GNUNET_TIME_relative_to_string(GNUNET_TIME_absolute_get_remaining(d->max_timeout)), NULL); } else @@ -617,6 +618,7 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) "-L", "DEBUG", #endif "-c", d->cfgfile, "-s", "-q", + "-T", GNUNET_TIME_relative_to_string(GNUNET_TIME_absolute_get_remaining(d->max_timeout)), NULL); } GNUNET_free (dst); @@ -1101,6 +1103,7 @@ GNUNET_TESTING_daemon_start_stopped_service (struct GNUNET_TESTING_Daemon *d, "-L", "DEBUG", #endif "-c", d->cfgfile, "-i", service, "-q", + "-T", GNUNET_TIME_relative_to_string(timeout), NULL); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting gnunet-arm with command ssh %s gnunet-arm -c %s -i %s -q\n", @@ -1120,6 +1123,7 @@ GNUNET_TESTING_daemon_start_stopped_service (struct GNUNET_TESTING_Daemon *d, "-L", "DEBUG", #endif "-c", d->cfgfile, "-i", service, "-q", + "-T", GNUNET_TIME_relative_to_string(timeout), NULL); } @@ -1180,6 +1184,7 @@ GNUNET_TESTING_daemon_start_service (struct GNUNET_TESTING_Daemon *d, "-L", "DEBUG", #endif "-c", d->cfgfile, "-i", service, "-q", + "-T", GNUNET_TIME_relative_to_string(timeout), NULL); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting gnunet-arm with command ssh %s gnunet-arm -c %s -i %s -q\n", @@ -1199,6 +1204,7 @@ GNUNET_TESTING_daemon_start_service (struct GNUNET_TESTING_Daemon *d, "-L", "DEBUG", #endif "-c", d->cfgfile, "-i", service, "-q", + "-T", GNUNET_TIME_relative_to_string(timeout), NULL); } @@ -1644,6 +1650,7 @@ GNUNET_TESTING_daemon_stop_service (struct GNUNET_TESTING_Daemon *d, "-L", "DEBUG", #endif "-c", d->cfgfile, "-k", service, "-q", + "-T", GNUNET_TIME_relative_to_string(timeout), NULL); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping gnunet-arm with command ssh %s gnunet-arm -c %s -k %s -q\n", @@ -1663,6 +1670,7 @@ GNUNET_TESTING_daemon_stop_service (struct GNUNET_TESTING_Daemon *d, "-L", "DEBUG", #endif "-c", d->cfgfile, "-k", service, "-q", + "-T", GNUNET_TIME_relative_to_string(timeout), NULL); } @@ -1781,6 +1789,7 @@ GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d, "-L", "DEBUG", #endif "-c", d->cfgfile, "-e", "-q", + "-T", GNUNET_TIME_relative_to_string(timeout), del_arg, NULL); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping gnunet-arm with command ssh %s gnunet-arm -c %s -e -q %s\n", @@ -1801,6 +1810,7 @@ GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d, "-L", "DEBUG", #endif "-c", d->cfgfile, "-e", "-q", + "-T", GNUNET_TIME_relative_to_string(timeout), del_arg, NULL); } diff --git a/src/util/time.c b/src/util/time.c index 5ae05b0d7..3631c0a78 100644 --- a/src/util/time.c +++ b/src/util/time.c @@ -486,6 +486,25 @@ GNUNET_TIME_absolute_ntoh (struct GNUNET_TIME_AbsoluteNBO a) } +/** + * Convert a relative time to a string. + * This is one of the very few calls in the entire API that is + * NOT reentrant! + * + * @param time the time to print + * + * @return string form of the time (as milliseconds) + */ +const char * +GNUNET_TIME_relative_to_string (struct GNUNET_TIME_Relative time) +{ + static char time_string[21]; + memset(time_string, 0, sizeof(time_string)); + + sprintf(time_string, "%lu", time.rel_value); + return (const char *) time_string; +} + /* end of time.c */ -- 2.25.1