2 This file is part of GNUnet.
3 (C) 2010-2013 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
21 * @file ats-tests/ats-testing-experiment.c
22 * @brief ats benchmark: controlled experiment execution
23 * @author Christian Grothoff
24 * @author Matthias Wachs
27 #include "gnunet_util_lib.h"
28 #include "ats-testing.h"
30 static struct Experiment *
34 e = GNUNET_new (struct Experiment);
43 free_experiment (struct Experiment *e)
45 GNUNET_free_non_null (e->name);
46 GNUNET_free_non_null (e->cfg_file);
51 GNUNET_ATS_TEST_experimentation_start (char *filename)
54 struct GNUNET_CONFIGURATION_Handle *cfg;
57 cfg = GNUNET_CONFIGURATION_create();
58 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg, filename))
60 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to load `%s'\n", filename);
61 GNUNET_CONFIGURATION_destroy (cfg);
65 e = create_experiment ();
67 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, "experiment",
70 fprintf (stderr, "Invalid %s", "name");
75 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment name: `%s'\n", e->name);
77 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_filename (cfg, "experiment",
78 "cfg_file", &e->cfg_file))
80 fprintf (stderr, "Invalid %s", "cfg_file");
85 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment name: `%s'\n", e->cfg_file);
87 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg, "experiment",
88 "masters", &e->num_masters))
90 fprintf (stderr, "Invalid %s", "masters");
95 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment masters: `%llu'\n",
98 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg, "experiment",
99 "slaves", &e->num_slaves))
101 fprintf (stderr, "Invalid %s", "slaves");
106 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment slaves: `%llu'\n",
109 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg, "experiment",
110 "max_duration", &e->max_duration))
112 fprintf (stderr, "Invalid %s", "max_duration");
117 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment duration: `%s'\n",
118 GNUNET_STRINGS_relative_time_to_string (e->max_duration, GNUNET_YES));
124 GNUNET_ATS_TEST_experimentation_stop (struct Experiment *e)
129 /* end of file ats-testing-experiment.c*/