aboutsummaryrefslogtreecommitdiff
path: root/src/ats-tests
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-07-06 15:24:26 +0000
committerChristian Grothoff <christian@grothoff.org>2016-07-06 15:24:26 +0000
commit3d7bae58c4b9b128e6000a2fe1fe65595235bb14 (patch)
treed50cfa569c5d447da5663333e61964c47ac09f73 /src/ats-tests
parent6cef8fea0c3b6756870786ebc4db0588373c8f65 (diff)
downloadgnunet-3d7bae58c4b9b128e6000a2fe1fe65595235bb14.tar.gz
gnunet-3d7bae58c4b9b128e6000a2fe1fe65595235bb14.zip
misc fixes
Diffstat (limited to 'src/ats-tests')
-rw-r--r--src/ats-tests/ats-testing-log.c2
-rw-r--r--src/ats-tests/gnunet-ats-sim.c77
-rw-r--r--src/ats-tests/perf_ats.c8
3 files changed, 47 insertions, 40 deletions
diff --git a/src/ats-tests/ats-testing-log.c b/src/ats-tests/ats-testing-log.c
index 61aca6b18..6e8e3bd13 100644
--- a/src/ats-tests/ats-testing-log.c
+++ b/src/ats-tests/ats-testing-log.c
@@ -693,7 +693,7 @@ GNUNET_ATS_TEST_logging_now (struct LoggingHandle *l)
693 else 693 else
694 { 694 {
695 mlt->total_throughput_send = mult * mlt->total_bytes_sent; 695 mlt->total_throughput_send = mult * mlt->total_bytes_sent;
696 mlt->total_throughput_send = mult * mlt->total_bytes_received; 696 mlt->total_throughput_recv = mult * mlt->total_bytes_received;
697 } 697 }
698 698
699 if (GNUNET_YES == l->verbose) 699 if (GNUNET_YES == l->verbose)
diff --git a/src/ats-tests/gnunet-ats-sim.c b/src/ats-tests/gnunet-ats-sim.c
index 27850e3e7..f624c2b21 100644
--- a/src/ats-tests/gnunet-ats-sim.c
+++ b/src/ats-tests/gnunet-ats-sim.c
@@ -57,10 +57,12 @@ static int opt_plot;
57 */ 57 */
58static int opt_verbose; 58static int opt_verbose;
59 59
60struct GNUNET_SCHEDULER_Task * timeout_task; 60static struct GNUNET_SCHEDULER_Task *timeout_task;
61
62static struct Experiment *e;
63
64static struct LoggingHandle *l;
61 65
62struct Experiment *e;
63struct LoggingHandle *l;
64 66
65static void 67static void
66evaluate (struct GNUNET_TIME_Relative duration_total) 68evaluate (struct GNUNET_TIME_Relative duration_total)
@@ -125,11 +127,16 @@ evaluate (struct GNUNET_TIME_Relative duration_total)
125 } 127 }
126} 128}
127 129
130
128static void 131static void
129do_shutdown () 132do_shutdown (void *cls)
130{ 133{
131 fprintf (stderr, "Shutdown\n"); 134 fprintf (stderr, "Shutdown\n");
132 /* timeout */ 135 if (NULL != timeout_task)
136 {
137 GNUNET_SCHEDULER_cancel (timeout_task);
138 timeout_task = NULL;
139 }
133 if (NULL != l) 140 if (NULL != l)
134 { 141 {
135 GNUNET_ATS_TEST_logging_stop (l); 142 GNUNET_ATS_TEST_logging_stop (l);
@@ -153,9 +160,17 @@ do_shutdown ()
153 160
154 161
155static void 162static void
163do_timeout (void *cls)
164{
165 timeout_task = NULL;
166 GNUNET_SCHEDULER_shutdown ();
167}
168
169
170static void
156transport_recv_cb (void *cls, 171transport_recv_cb (void *cls,
157 const struct GNUNET_PeerIdentity * peer, 172 const struct GNUNET_PeerIdentity *peer,
158 const struct GNUNET_MessageHeader * message) 173 const struct GNUNET_MessageHeader *message)
159{ 174{
160 175
161} 176}
@@ -175,19 +190,19 @@ log_request__cb (void *cls, const struct GNUNET_HELLO_Address *address,
175 190
176} 191}
177 192
193
178static void 194static void
179experiment_done_cb (struct Experiment *e, struct GNUNET_TIME_Relative duration,int success) 195experiment_done_cb (struct Experiment *e,
196 struct GNUNET_TIME_Relative duration,int success)
180{ 197{
181 if (GNUNET_OK == success) 198 if (GNUNET_OK == success)
182 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment done successful in %s\n", 199 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
183 GNUNET_STRINGS_relative_time_to_string (duration, GNUNET_YES)); 200 "Experiment done successful in %s\n",
201 GNUNET_STRINGS_relative_time_to_string (duration,
202 GNUNET_YES));
184 else 203 else
185 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment failed \n"); 204 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment failed \n");
186 if (NULL != timeout_task) 205
187 {
188 GNUNET_SCHEDULER_cancel (timeout_task);
189 timeout_task = NULL;
190 }
191 /* Stop logging */ 206 /* Stop logging */
192 GNUNET_ATS_TEST_logging_stop (l); 207 GNUNET_ATS_TEST_logging_stop (l);
193 208
@@ -200,31 +215,20 @@ experiment_done_cb (struct Experiment *e, struct GNUNET_TIME_Relative duration,i
200 evaluate (duration); 215 evaluate (duration);
201 if (opt_log) 216 if (opt_log)
202 GNUNET_ATS_TEST_logging_write_to_file(l, opt_exp_file, opt_plot); 217 GNUNET_ATS_TEST_logging_write_to_file(l, opt_exp_file, opt_plot);
203 218 GNUNET_SCHEDULER_shutdown ();
204 if (NULL != l)
205 {
206 GNUNET_ATS_TEST_logging_stop (l);
207 GNUNET_ATS_TEST_logging_clean_up (l);
208 l = NULL;
209 }
210
211 /* Clean up experiment */
212 GNUNET_ATS_TEST_experimentation_stop (e);
213 e = NULL;
214
215 /* Shutdown topology */
216 GNUNET_ATS_TEST_shutdown_topology ();
217} 219}
218 220
221
219static void 222static void
220episode_done_cb (struct Episode *ep) 223episode_done_cb (struct Episode *ep)
221{ 224{
222 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Episode %u done\n", ep->id); 225 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Episode %u done\n", ep->id);
223} 226}
224 227
228
225static void topology_setup_done (void *cls, 229static void topology_setup_done (void *cls,
226 struct BenchmarkPeer *masters, 230 struct BenchmarkPeer *masters,
227 struct BenchmarkPeer *slaves) 231 struct BenchmarkPeer *slaves)
228{ 232{
229 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Topology setup complete!\n"); 233 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Topology setup complete!\n");
230 234
@@ -309,10 +313,15 @@ static void topology_setup_done (void *cls,
309 } 313 }
310#endif 314#endif
311 315
312 timeout_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_add (GNUNET_TIME_UNIT_MINUTES, 316 timeout_task
313 e->max_duration), &do_shutdown, NULL); 317 = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_add (GNUNET_TIME_UNIT_MINUTES,
318 e->max_duration),
319 &do_timeout,
320 NULL);
321 GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL);
314} 322}
315 323
324
316static void 325static void
317parse_args (int argc, char *argv[]) 326parse_args (int argc, char *argv[])
318{ 327{
@@ -325,6 +334,7 @@ parse_args (int argc, char *argv[])
325 { 334 {
326 if ((c < (argc - 1)) && (0 == strcmp (argv[c], "-e"))) 335 if ((c < (argc - 1)) && (0 == strcmp (argv[c], "-e")))
327 { 336 {
337 GNUNET_free_non_null (opt_exp_file);
328 opt_exp_file = GNUNET_strdup ( argv[c + 1]); 338 opt_exp_file = GNUNET_strdup ( argv[c + 1]);
329 } 339 }
330 if (0 == strcmp (argv[c], "-l")) 340 if (0 == strcmp (argv[c], "-l"))
@@ -342,6 +352,7 @@ parse_args (int argc, char *argv[])
342 } 352 }
343} 353}
344 354
355
345int 356int
346main (int argc, char *argv[]) 357main (int argc, char *argv[])
347{ 358{
diff --git a/src/ats-tests/perf_ats.c b/src/ats-tests/perf_ats.c
index 0e4056a6c..a7c1dc3bf 100644
--- a/src/ats-tests/perf_ats.c
+++ b/src/ats-tests/perf_ats.c
@@ -137,14 +137,12 @@ evaluate ()
137 double kb_recv_percent; 137 double kb_recv_percent;
138 unsigned int rtt; 138 unsigned int rtt;
139 139
140 duration = (perf_duration.rel_value_us / (1000 * 1000)); 140 duration = 1 + (perf_duration.rel_value_us / (1000 * 1000));
141 for (c_m = 0; c_m < num_masters; c_m++) 141 for (c_m = 0; c_m < num_masters; c_m++)
142 { 142 {
143 mp = &mps[c_m]; 143 mp = &mps[c_m];
144 if (NULL == mp)
145 continue;
146 fprintf (stderr, 144 fprintf (stderr,
147 _("Master [%u]: sent: %u KiB in %u sec. = %u KiB/s, received: %u KiB in %u sec. = %u KiB/s\n"), 145 "Master [%u]: sent: %u KiB in %u sec. = %u KiB/s, received: %u KiB in %u sec. = %u KiB/s\n",
148 mp->no, mp->total_bytes_sent / 1024, duration, 146 mp->no, mp->total_bytes_sent / 1024, duration,
149 (mp->total_bytes_sent / 1024) / duration, 147 (mp->total_bytes_sent / 1024) / duration,
150 mp->total_bytes_received / 1024, duration, 148 mp->total_bytes_received / 1024, duration,
@@ -153,8 +151,6 @@ evaluate ()
153 for (c_s = 0; c_s < num_slaves; c_s++) 151 for (c_s = 0; c_s < num_slaves; c_s++)
154 { 152 {
155 p = &mp->partners[c_s]; 153 p = &mp->partners[c_s];
156 if (NULL == p)
157 continue;
158 kb_sent_sec = 0; 154 kb_sent_sec = 0;
159 kb_recv_sec = 0; 155 kb_recv_sec = 0;
160 kb_sent_percent = 0.0; 156 kb_sent_percent = 0.0;