summaryrefslogtreecommitdiff
path: root/src/ats-tests/gnunet-ats-sim.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2014-01-30 09:32:01 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2014-01-30 09:32:01 +0000
commit247ecc51c01c54313844cb495c1fa829806bc170 (patch)
tree72d9f516765361cfae33825e2a2e7057d59b5c0a /src/ats-tests/gnunet-ats-sim.c
parent4ed987ed9bd12e201d9146972274933b4479bb0e (diff)
downloadgnunet-247ecc51c01c54313844cb495c1fa829806bc170.tar.gz
gnunet-247ecc51c01c54313844cb495c1fa829806bc170.zip
fix and improved logging
Diffstat (limited to 'src/ats-tests/gnunet-ats-sim.c')
-rw-r--r--src/ats-tests/gnunet-ats-sim.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/ats-tests/gnunet-ats-sim.c b/src/ats-tests/gnunet-ats-sim.c
index c7febecc9..6a9797179 100644
--- a/src/ats-tests/gnunet-ats-sim.c
+++ b/src/ats-tests/gnunet-ats-sim.c
@@ -37,6 +37,16 @@
37static struct BenchmarkPeer *masters_p; 37static struct BenchmarkPeer *masters_p;
38static struct BenchmarkPeer *slaves_p; 38static struct BenchmarkPeer *slaves_p;
39 39
40/**
41 * cmd option -e: experiment file
42 */
43static char *opt_exp_file;
44
45/**
46 * cmd option -l: enable logging
47 */
48static int opt_log;
49
40GNUNET_SCHEDULER_TaskIdentifier timeout_task; 50GNUNET_SCHEDULER_TaskIdentifier timeout_task;
41 51
42struct Experiment *e; 52struct Experiment *e;
@@ -151,11 +161,14 @@ experiment_done_cb (struct Experiment *e, struct GNUNET_TIME_Relative duration,i
151 /* Stop logging */ 161 /* Stop logging */
152 GNUNET_ATS_TEST_logging_stop (l); 162 GNUNET_ATS_TEST_logging_stop (l);
153 evaluate (duration); 163 evaluate (duration);
164 if (opt_log)
165 GNUNET_ATS_TEST_logging_write_to_file(l, opt_exp_file);
154 166
155 /* Stop traffic generation */ 167 /* Stop traffic generation */
156 GNUNET_ATS_TEST_generate_traffic_stop_all(); 168 GNUNET_ATS_TEST_generate_traffic_stop_all();
157 /* Clean up experiment */ 169 /* Clean up experiment */
158 GNUNET_ATS_TEST_experimentation_stop (e); 170 GNUNET_ATS_TEST_experimentation_stop (e);
171 GNUNET_ATS_TEST_logging_clean_up (l);
159 e = NULL; 172 e = NULL;
160 173
161 /* Shutdown topology */ 174 /* Shutdown topology */
@@ -179,8 +192,10 @@ static void topology_setup_done (void *cls,
179 masters_p = masters; 192 masters_p = masters;
180 slaves_p = slaves; 193 slaves_p = slaves;
181 194
182 l = GNUNET_ATS_TEST_logging_start (GNUNET_TIME_UNIT_SECONDS, e->name, 195 l = GNUNET_ATS_TEST_logging_start (GNUNET_TIME_UNIT_SECONDS,
183 masters_p, e->num_masters); 196 e->name,
197 masters_p,
198 e->num_masters);
184 GNUNET_ATS_TEST_experimentation_run (e, &episode_done_cb, &experiment_done_cb); 199 GNUNET_ATS_TEST_experimentation_run (e, &episode_done_cb, &experiment_done_cb);
185 200
186 for (c_m = 0; c_m < e->num_masters; c_m++) 201 for (c_m = 0; c_m < e->num_masters; c_m++)
@@ -199,9 +214,6 @@ static void topology_setup_done (void *cls,
199 e->max_duration), &do_shutdown, NULL); 214 e->max_duration), &do_shutdown, NULL);
200} 215}
201 216
202static char *opt_exp_file;
203static int opt_log;
204
205static void 217static void
206parse_args (int argc, char *argv[]) 218parse_args (int argc, char *argv[])
207{ 219{
@@ -236,7 +248,6 @@ main (int argc, char *argv[])
236 248
237 fprintf (stderr, "Loading experiment `%s' \n", opt_exp_file ); 249 fprintf (stderr, "Loading experiment `%s' \n", opt_exp_file );
238 e = GNUNET_ATS_TEST_experimentation_load (opt_exp_file); 250 e = GNUNET_ATS_TEST_experimentation_load (opt_exp_file);
239 GNUNET_free (opt_exp_file);
240 if (NULL == e) 251 if (NULL == e)
241 { 252 {
242 fprintf (stderr, "Invalid experiment\n"); 253 fprintf (stderr, "Invalid experiment\n");
@@ -257,6 +268,7 @@ main (int argc, char *argv[])
257 NULL, 268 NULL,
258 &transport_recv_cb, 269 &transport_recv_cb,
259 &log_request__cb); 270 &log_request__cb);
271 GNUNET_free (opt_exp_file);
260 return 0; 272 return 0;
261} 273}
262/* end of file gnunet-ats-sim.c */ 274/* end of file gnunet-ats-sim.c */