diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2011-04-01 11:40:08 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2011-04-01 11:40:08 +0000 |
commit | 3695f55c493a485a838b3defff6b15a63fddd987 (patch) | |
tree | 4f02c4c685fad95491bf70b5e98a869645147852 /src/transport/test_transport_ats.c | |
parent | 2c803aa73957a91e8d523b072134dff7b6c5ca73 (diff) | |
download | gnunet-3695f55c493a485a838b3defff6b15a63fddd987.tar.gz gnunet-3695f55c493a485a838b3defff6b15a63fddd987.zip |
changes
Diffstat (limited to 'src/transport/test_transport_ats.c')
-rw-r--r-- | src/transport/test_transport_ats.c | 74 |
1 files changed, 68 insertions, 6 deletions
diff --git a/src/transport/test_transport_ats.c b/src/transport/test_transport_ats.c index d4189d063..fca54ed52 100644 --- a/src/transport/test_transport_ats.c +++ b/src/transport/test_transport_ats.c | |||
@@ -46,7 +46,6 @@ static struct GNUNET_TESTING_PeerGroup *pg; | |||
46 | 46 | ||
47 | static GNUNET_SCHEDULER_TaskIdentifier shutdown_task; | 47 | static GNUNET_SCHEDULER_TaskIdentifier shutdown_task; |
48 | static GNUNET_SCHEDULER_TaskIdentifier stats_task; | 48 | static GNUNET_SCHEDULER_TaskIdentifier stats_task; |
49 | |||
50 | struct GNUNET_TESTING_Daemon * master_deamon; | 49 | struct GNUNET_TESTING_Daemon * master_deamon; |
51 | 50 | ||
52 | struct GNUNET_STATISTICS_Handle * stats; | 51 | struct GNUNET_STATISTICS_Handle * stats; |
@@ -65,6 +64,11 @@ static int r_index; | |||
65 | static int peers; | 64 | static int peers; |
66 | static struct TEST_result results[MEASUREMENTS]; | 65 | static struct TEST_result results[MEASUREMENTS]; |
67 | 66 | ||
67 | struct GNUNET_STATISTICS_GetHandle * s_solution; | ||
68 | struct GNUNET_STATISTICS_GetHandle * s_time; | ||
69 | struct GNUNET_STATISTICS_GetHandle * s_peers; | ||
70 | struct GNUNET_STATISTICS_GetHandle * s_mechs; | ||
71 | struct GNUNET_STATISTICS_GetHandle * s_duration; | ||
68 | 72 | ||
69 | /** | 73 | /** |
70 | * Check whether peers successfully shut down. | 74 | * Check whether peers successfully shut down. |
@@ -105,6 +109,33 @@ static void shutdown_peers() | |||
105 | stats_task = GNUNET_SCHEDULER_NO_TASK; | 109 | stats_task = GNUNET_SCHEDULER_NO_TASK; |
106 | } | 110 | } |
107 | 111 | ||
112 | if (s_time != NULL) | ||
113 | { | ||
114 | GNUNET_STATISTICS_get_cancel(s_time); | ||
115 | s_time = NULL; | ||
116 | } | ||
117 | if (s_peers != NULL) | ||
118 | { | ||
119 | GNUNET_STATISTICS_get_cancel(s_peers); | ||
120 | s_peers = NULL; | ||
121 | } | ||
122 | if (s_mechs != NULL) | ||
123 | { | ||
124 | GNUNET_STATISTICS_get_cancel(s_mechs); | ||
125 | s_mechs = NULL; | ||
126 | } | ||
127 | if (s_solution != NULL) | ||
128 | { | ||
129 | GNUNET_STATISTICS_get_cancel(s_solution); | ||
130 | s_solution = NULL; | ||
131 | } | ||
132 | if (s_duration != NULL) | ||
133 | { | ||
134 | GNUNET_STATISTICS_get_cancel(s_duration); | ||
135 | s_duration = NULL; | ||
136 | } | ||
137 | |||
138 | |||
108 | GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); | 139 | GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); |
109 | } | 140 | } |
110 | 141 | ||
@@ -120,6 +151,8 @@ static void evaluate_measurements() | |||
120 | output = temp; | 151 | output = temp; |
121 | } | 152 | } |
122 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR,"%s\n",output); | 153 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR,"%s\n",output); |
154 | |||
155 | |||
123 | shutdown_peers(); | 156 | shutdown_peers(); |
124 | } | 157 | } |
125 | 158 | ||
@@ -129,6 +162,30 @@ int stats_cb (void *cls, | |||
129 | uint64_t value, | 162 | uint64_t value, |
130 | int is_persistent) | 163 | int is_persistent) |
131 | { | 164 | { |
165 | if (0 == strcmp (name,"ATS solution")) | ||
166 | { | ||
167 | s_solution = NULL; | ||
168 | } | ||
169 | |||
170 | if (0 == strcmp (name,"ATS peers")) | ||
171 | { | ||
172 | s_peers = NULL; | ||
173 | } | ||
174 | |||
175 | if (0 == strcmp (name,"ATS mechanisms")) | ||
176 | { | ||
177 | s_mechs = NULL; | ||
178 | } | ||
179 | |||
180 | if (0 == strcmp (name,"ATS duration")) | ||
181 | { | ||
182 | s_duration = NULL; | ||
183 | } | ||
184 | if (0 == strcmp (name,"ATS timestamp")) | ||
185 | { | ||
186 | s_time = NULL; | ||
187 | } | ||
188 | |||
132 | if ((measurement_started == GNUNET_NO) && (0 == strcmp (name, "ATS peers")) && (value == peers-1)) | 189 | if ((measurement_started == GNUNET_NO) && (0 == strcmp (name, "ATS peers")) && (value == peers-1)) |
133 | { | 190 | { |
134 | measurement_started = GNUNET_YES; | 191 | measurement_started = GNUNET_YES; |
@@ -147,6 +204,11 @@ int stats_cb (void *cls, | |||
147 | r_index++; | 204 | r_index++; |
148 | if (r_index >= MEASUREMENTS) | 205 | if (r_index >= MEASUREMENTS) |
149 | { | 206 | { |
207 | if (stats_task != GNUNET_SCHEDULER_NO_TASK) | ||
208 | { | ||
209 | GNUNET_SCHEDULER_cancel(stats_task); | ||
210 | stats_task = GNUNET_SCHEDULER_NO_TASK; | ||
211 | } | ||
150 | evaluate_measurements(); | 212 | evaluate_measurements(); |
151 | return GNUNET_NO; | 213 | return GNUNET_NO; |
152 | } | 214 | } |
@@ -195,11 +257,11 @@ stats_get_task (void *cls, | |||
195 | if ( (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | 257 | if ( (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) |
196 | return; | 258 | return; |
197 | 259 | ||
198 | GNUNET_STATISTICS_get (stats, "transport", "ATS timestamp", TIMEOUT, NULL, &stats_cb, NULL); | 260 | s_time = GNUNET_STATISTICS_get (stats, "transport", "ATS timestamp", TIMEOUT, NULL, &stats_cb, NULL); |
199 | GNUNET_STATISTICS_get (stats, "transport", "ATS solution", TIMEOUT, NULL, &stats_cb, NULL); | 261 | s_solution = GNUNET_STATISTICS_get (stats, "transport", "ATS solution", TIMEOUT, NULL, &stats_cb, NULL); |
200 | GNUNET_assert (NULL != GNUNET_STATISTICS_get (stats, "transport","ATS duration", TIMEOUT, NULL, &stats_cb, NULL)); | 262 | s_duration = GNUNET_STATISTICS_get (stats, "transport","ATS duration", TIMEOUT, NULL, &stats_cb, NULL); |
201 | GNUNET_STATISTICS_get (stats, "transport", "ATS peers", TIMEOUT, NULL, &stats_cb, NULL); | 263 | s_peers = GNUNET_STATISTICS_get (stats, "transport", "ATS peers", TIMEOUT, NULL, &stats_cb, NULL); |
202 | GNUNET_STATISTICS_get (stats, "transport", "ATS mechanisms", TIMEOUT, NULL, &stats_cb, NULL); | 264 | s_mechs = GNUNET_STATISTICS_get (stats, "transport", "ATS mechanisms", TIMEOUT, NULL, &stats_cb, NULL); |
203 | 265 | ||
204 | stats_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 250), &stats_get_task, NULL); | 266 | stats_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 250), &stats_get_task, NULL); |
205 | } | 267 | } |