new solver test
[oweals/gnunet.git] / src / ats / test_ats_solver_add_address.c
1 /*
2   if (NULL == (perf_ats = GNUNET_ATS_performance_init (cfg, &ats_perf_cb, NULL)))
3   {
4     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
5         "Failed to connect to performance API\n");
6     GNUNET_SCHEDULER_add_now (end_badly, NULL);
7   }
8  This file is part of GNUnet.
9  (C) 2010-2013 Christian Grothoff (and other contributing authors)
10
11  GNUnet is free software; you can redistribute it and/or modify
12  it under the terms of the GNU General Public License as published
13  by the Free Software Foundation; either version 3, or (at your
14  option) any later version.
15
16  GNUnet is distributed in the hope that it will be useful, but
17  WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  General Public License for more details.
20
21  You should have received a copy of the GNU General Public License
22  along with GNUnet; see the file COPYING.  If not, write to the
23  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24  Boston, MA 02111-1307, USA.
25  */
26 /**
27  * @file ats/test_ats_solver_add_address.c
28  * @brief solver test: add address
29  * @author Christian Grothoff
30  * @author Matthias Wachs
31  */
32 #include "platform.h"
33 #include "gnunet_util_lib.h"
34 #include "gnunet_testbed_service.h"
35 #include "gnunet_ats_service.h"
36
37 static int ret;
38
39
40 static void
41 run (void *cls, const struct GNUNET_CONFIGURATION_Handle *mycfg,
42     struct GNUNET_TESTING_Peer *peer)
43 {
44   ret = 0;
45 }
46
47 int
48 main (int argc, char *argv[])
49 {
50   char *sep;
51   char *src_filename = GNUNET_strdup (__FILE__);
52   char *test_filename = GNUNET_strdup (argv[0]);
53   char *config_file;
54   char *solver;
55
56   ret = 0;
57
58   if (NULL == (sep  = (strstr (src_filename,".c"))))
59   {
60     GNUNET_break (0);
61     return -1;
62   }
63   sep[0] = '\0';
64
65   if (NULL != (sep = strstr (test_filename, ".exe")))
66     sep[0] = '\0';
67
68   if (NULL == (solver = strstr (test_filename, src_filename)))
69   {
70     GNUNET_break (0);
71     return -1;
72   }
73   solver += strlen (src_filename) +1;
74
75   if (0 == strcmp(solver, "proportional"))
76   {
77     config_file = "test_ats_solver_proportional.conf";
78   }
79   else if (0 == strcmp(solver, "mlp"))
80   {
81     config_file = "test_ats_solver_mlp.conf";
82   }
83   else if ((0 == strcmp(solver, "ril")))
84   {
85     config_file = "test_ats_solver_ril.conf";
86   }
87   else
88   {
89     GNUNET_break (0);
90     GNUNET_free (src_filename);
91     GNUNET_free (test_filename);
92     return 1;
93   }
94
95   GNUNET_free (src_filename);
96   GNUNET_free (test_filename);
97
98   if (0 != GNUNET_TESTING_peer_run ("test_ats_api_performance",
99       config_file, &run, NULL ))
100     return GNUNET_SYSERR;
101
102   return ret;
103 }
104
105 /* end of file test_ats_solver_add_address.c */