2 This file is part of GNUnet.
3 (C) 2010,2011 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/test_ats.c
22 * @brief ats benchmark: start peers and modify preferences, monitor change over time
23 * @author Christian Grothoff
24 * @author Matthias Wachs
27 #include "gnunet_util_lib.h"
28 #include "gnunet_testbed_service.h"
30 #define TEST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
31 #define TESTNAME_PREFIX "perf_ats_"
37 static GNUNET_SCHEDULER_TaskIdentifier shutdown_task;
41 static char *preference;
47 * @param tc the task context
50 do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
52 shutdown_task = GNUNET_SCHEDULER_NO_TASK;
54 GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Benchmarking done\n"));
57 GNUNET_SCHEDULER_shutdown();
61 * Controller event callback
64 * @param event the controller event
67 controller_event_cb (void *cls,
68 const struct GNUNET_TESTBED_EventInformation *event)
74 * Signature of a main function for a testcase.
77 * @param num_peers number of peers in 'peers'
78 * @param peers_ handle to peers run in the testbed
79 * @param links_succeeded the number of overlay link connection attempts that
81 * @param links_failed the number of overlay link connection attempts that
85 test_master (void *cls, unsigned int num_peers,
86 struct GNUNET_TESTBED_Peer **peers_,
87 unsigned int links_succeeded,
88 unsigned int links_failed)
90 GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Benchmarking solver `%s' on preference `%s'\n"), solver, preference);
92 shutdown_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, &do_shutdown, NULL);
97 main (int argc, char *argv[])
106 /* figure out testname */
107 tmp = strstr (argv[0], TESTNAME_PREFIX);
110 fprintf (stderr, "Unable to parse test name `%s'\n", argv[0]);
111 return GNUNET_SYSERR;
113 tmp += strlen(TESTNAME_PREFIX);
114 solver = GNUNET_strdup (tmp);
115 tmp_sep = strchr (solver, '_');
118 fprintf (stderr, "Unable to parse test name `%s'\n", argv[0]);
119 GNUNET_free (solver);
120 return GNUNET_SYSERR;
123 preference = GNUNET_strdup(tmp_sep + 1);
125 GNUNET_asprintf(&conf_name, "%s%s_%s.conf", TESTNAME_PREFIX, solver, preference);
126 GNUNET_asprintf(&test_name, "%s%s_%s", TESTNAME_PREFIX, solver, preference);
130 result = GNUNET_SYSERR;
132 event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT);
133 event_mask |= (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED);
134 (void) GNUNET_TESTBED_test_run (test_name,
136 event_mask, &controller_event_cb, NULL,
139 GNUNET_free (solver);
140 GNUNET_free (preference);
141 GNUNET_free (conf_name);
142 GNUNET_free (test_name);
147 /* end of file perf_ats.c */