aboutsummaryrefslogtreecommitdiff
path: root/src/statistics
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-06-22 16:28:22 +0000
committerChristian Grothoff <christian@grothoff.org>2010-06-22 16:28:22 +0000
commit17e508354c448c82c35d9149f4aee77e9d5a3ce8 (patch)
treece0ed3fa0dc2e05c9dbcbda0e9676110afe49423 /src/statistics
parent407dd6df75e93a6708d3b92dfa004df10275c82c (diff)
downloadgnunet-17e508354c448c82c35d9149f4aee77e9d5a3ce8.tar.gz
gnunet-17e508354c448c82c35d9149f4aee77e9d5a3ce8.zip
make it easy to start service by hand
Diffstat (limited to 'src/statistics')
-rw-r--r--src/statistics/statistics.h2
-rw-r--r--src/statistics/test_statistics_api.c13
2 files changed, 12 insertions, 3 deletions
diff --git a/src/statistics/statistics.h b/src/statistics/statistics.h
index 6eedd4d34..c4a79765a 100644
--- a/src/statistics/statistics.h
+++ b/src/statistics/statistics.h
@@ -27,7 +27,7 @@
27 27
28#include "gnunet_common.h" 28#include "gnunet_common.h"
29 29
30#define DEBUG_STATISTICS 0 30#define DEBUG_STATISTICS GNUNET_NO
31 31
32/** 32/**
33 * Statistics message. Contains how long the system is up 33 * Statistics message. Contains how long the system is up
diff --git a/src/statistics/test_statistics_api.c b/src/statistics/test_statistics_api.c
index d7eb90b4d..42704c801 100644
--- a/src/statistics/test_statistics_api.c
+++ b/src/statistics/test_statistics_api.c
@@ -31,6 +31,8 @@
31 31
32#define VERBOSE GNUNET_NO 32#define VERBOSE GNUNET_NO
33 33
34#define START_SERVICE GNUNET_YES
35
34static int 36static int
35check_1 (void *cls, 37check_1 (void *cls,
36 const char *subsystem, 38 const char *subsystem,
@@ -95,7 +97,6 @@ run (void *cls,
95 const char *cfgfile, 97 const char *cfgfile,
96 const struct GNUNET_CONFIGURATION_Handle *cfg) 98 const struct GNUNET_CONFIGURATION_Handle *cfg)
97{ 99{
98
99 h = GNUNET_STATISTICS_create (sched, "test-statistics-api", cfg); 100 h = GNUNET_STATISTICS_create (sched, "test-statistics-api", cfg);
100 GNUNET_STATISTICS_set (h, "test-1", 1, GNUNET_NO); 101 GNUNET_STATISTICS_set (h, "test-1", 1, GNUNET_NO);
101 GNUNET_STATISTICS_set (h, "test-2", 2, GNUNET_NO); 102 GNUNET_STATISTICS_set (h, "test-2", 2, GNUNET_NO);
@@ -123,7 +124,6 @@ static int
123check () 124check ()
124{ 125{
125 int ok = 1; 126 int ok = 1;
126 pid_t pid;
127 char *const argv[] = { "test-statistics-api", 127 char *const argv[] = { "test-statistics-api",
128 "-c", 128 "-c",
129 "test_statistics_api_data.conf", 129 "test_statistics_api_data.conf",
@@ -132,23 +132,29 @@ check ()
132 struct GNUNET_GETOPT_CommandLineOption options[] = { 132 struct GNUNET_GETOPT_CommandLineOption options[] = {
133 GNUNET_GETOPT_OPTION_END 133 GNUNET_GETOPT_OPTION_END
134 }; 134 };
135#if START_SERVICE
136 pid_t pid;
135 pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-statistics", 137 pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-statistics",
136 "gnunet-service-statistics", 138 "gnunet-service-statistics",
137#if DEBUG_STATISTICS 139#if DEBUG_STATISTICS
138 "-L", "DEBUG", 140 "-L", "DEBUG",
139#endif 141#endif
140 "-c", "test_statistics_api_data.conf", NULL); 142 "-c", "test_statistics_api_data.conf", NULL);
143#endif
141 GNUNET_PROGRAM_run (3, argv, "test-statistics-api", "nohelp", 144 GNUNET_PROGRAM_run (3, argv, "test-statistics-api", "nohelp",
142 options, &run, &ok); 145 options, &run, &ok);
146#if START_SERVICE
143 if (0 != PLIBC_KILL (pid, SIGTERM)) 147 if (0 != PLIBC_KILL (pid, SIGTERM))
144 { 148 {
145 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 149 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
146 ok = 1; 150 ok = 1;
147 } 151 }
148 GNUNET_OS_process_wait(pid); 152 GNUNET_OS_process_wait(pid);
153#endif
149 if (ok != 0) 154 if (ok != 0)
150 return ok; 155 return ok;
151 ok = 1; 156 ok = 1;
157#if START_SERVICE
152 /* restart to check persistence! */ 158 /* restart to check persistence! */
153 pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-statistics", 159 pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-statistics",
154 "gnunet-service-statistics", 160 "gnunet-service-statistics",
@@ -156,14 +162,17 @@ check ()
156 "-L", "DEBUG", 162 "-L", "DEBUG",
157#endif 163#endif
158 "-c", "test_statistics_api_data.conf", NULL); 164 "-c", "test_statistics_api_data.conf", NULL);
165#endif
159 GNUNET_PROGRAM_run (3, argv, "test-statistics-api", "nohelp", 166 GNUNET_PROGRAM_run (3, argv, "test-statistics-api", "nohelp",
160 options, &run_more, &ok); 167 options, &run_more, &ok);
168#if START_SERVICE
161 if (0 != PLIBC_KILL (pid, SIGTERM)) 169 if (0 != PLIBC_KILL (pid, SIGTERM))
162 { 170 {
163 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 171 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
164 ok = 1; 172 ok = 1;
165 } 173 }
166 GNUNET_OS_process_wait(pid); 174 GNUNET_OS_process_wait(pid);
175#endif
167 return ok; 176 return ok;
168} 177}
169 178