if HAVE_LIBGLPK
TRANSPORT_ATS_SRC = gnunet-service-transport_ats.c
+ TEST_TRANSPORT_ATS = \
+ test_transport_ats \
+ test_transport_ats_multiple_peers
+ GN_GLPK = -lglpk
+if HAVE_BENCHMARKS
+ ATS_TRANSPORT_BENCHMARKS = \
+ perf_transport_ats
+endif
endif
if USE_COVERAGE
gnunet_transport_DEPENDENCIES = \
libgnunettransportnew.la
-if HAVE_LIBGLPK
- GN_GLPK = -lglpk
-endif
-
gnunet_service_transport_SOURCES = \
gnunet-service-transport.c $(TRANSPORT_ATS_SRC)
gnunet_service_transport_LDADD = \
libgnunet_plugin_transport_https_la_CPPFLAGS = \
@LIBCURL_CPPFLAGS@
-if HAVE_BENCHMARKS
- TRANSPORT_BENCHMARKS = \
- perf_transport_ats
-endif
check_PROGRAMS = \
- test_transport_ats \
- test_transport_ats_multiple_peers \
- $(TRANSPORT_BENCHMARKS) \
+ $(TEST_TRANSPORT_ATS) \
+ $(ATS_TRANSPORT_BENCHMARKS) \
test_transport_api_tcp \
test_transport_api_tcp_nat \
test_transport_api_udp \
if ENABLE_TEST_RUN
TESTS = \
- test_transport_ats \
- test_transport_ats_multiple_peers \
+ $(TEST_TRANSPORT_ATS) \
perf_transport_ats \
test_transport_api_tcp \
test_transport_api_tcp_nat \
$(GN_GLPK)
test_transport_ats_multiple_peers_SOURCES = \
- test_transport_ats_multiple_peers.c
+ test_transport_ats_multiple_peers.c $(TRANSPORT_ATS_SRC)
test_transport_ats_multiple_peers_LDADD = -lm \
$(top_builddir)/src/transport/libgnunettransportnew.la \
$(top_builddir)/src/statistics/libgnunetstatistics.la \
perf_transport_ats_SOURCES = \
perf_transport_ats.c
perf_transport_ats_LDADD = \
- $(GN_GLPK) \
+ -lglpk \
$(top_builddir)/src/util/libgnunetutil.la
test_transport_api_tcp_SOURCES = \
*/
/**
- * @file transport/transport_ats.h
+ * @file transport/gnunet-service-transport_ats.h
* @brief common internal definitions for transport service's ats code
* @author Matthias Wachs
*/
int log_problem);
#endif
-/* end of file transport_ats.h */
+/* end of file gnunet-service-transport_ats.h */
Boston, MA 02111-1307, USA.
*/
/**
- * @file testing/per_transport_ats.c
+ * @file transport/perf_transport_ats.c
* @brief testcase for ats functionality
*/
#include "platform.h"
#include "gnunet_time_lib.h"
#include "gauger.h"
-#if HAVE_LIBGLPK
#include <glpk.h>
-#endif
#define VERBOSE GNUNET_NO
static int ret = 0;
-#if HAVE_LIBGLPK
static int executions = EXECS;
static uint64_t exec_time[EXECS];
static struct GNUNET_TIME_Absolute start;
static struct GNUNET_TIME_Absolute end;
-void solve_mlp(int presolve)
+static void
+solve_mlp(int presolve)
{
int result, solution;
glp_iocp opt_mlp;
GNUNET_assert ((solution == 5) && (result==0));
}
-void solve_lp(int presolve)
+static void
+solve_lp(int presolve)
{
int result;
int solution;
GNUNET_assert ((solution == 5) && (result==0));
}
+#if 0
/* Modify quality constraint */
-void modify_qm(int start, int length, int values_to_change)
+static void
+modify_qm(int start, int length, int values_to_change)
{
//int * ind = GNUNET_malloc (length * sizeof (int));
//double *val = GNUNET_malloc (length * sizeof (double));
}
//glp_set_mat_row(prob, start, length, ind, val);
}
+#endif
-void bench_simplex_optimization(char * file, int executions)
+static void
+bench_simplex_optimization(char * file, int executions)
{
int c;
int res;
}
-void bench_simplex_no_optimization(char * file, int executions)
+static void
+bench_simplex_no_optimization(char * file, int executions)
{
int c;
int res;
glp_delete_prob(prob);
}
-void bench_mlp_no_optimization(char * file, int executions)
+static void
+bench_mlp_no_optimization(char * file, int executions)
{
int c;
int res;
}
-void bench_mlp_with_optimization(char * file, int executions, int changes)
+static void
+bench_mlp_with_optimization(char * file, int executions, int changes)
{
int c;
int res;
//glp_set_mat_row(prob, start, length, ind, val);
}
#endif
-#endif
+
int main (int argc, char *argv[])
{
"INFO",
#endif
NULL);
-
-#if !HAVE_LIBGLPK
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "GLPK not installed, exiting testcase\n");
- return 0;
-#else
-
int nullfd = OPEN ("/dev/null", O_RDWR | O_APPEND);
if (nullfd < 0)
return GNUNET_SYSERR;
"GLPK MLP 100 peers 400 addresses with optimization",
((double) mlp_with_opt_avg / EXECS) / 400, "ms/address");
(void) CLOSE (nullfd);
-
-#endif
return ret;
}
-/* end of per_transport_ats.c*/
+/* end of perf_transport_ats.c*/
#define VERBOSE GNUNET_YES
static struct ATS_Handle * ats;
+
static struct GNUNET_CONFIGURATION_Handle * cfg;
-void ats_result_cb ()
+static struct TransportConfiguration *tc;
+
+
+static void
+ats_result_cb ()
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"ATS Result callback\n");
struct ATS_mechanism * m_tail;
};
-struct TransportConfiguration *tc;
-
-/*
-void create_topology (int c_peers, int c_mechanisms)
-{
- int c;
- peers = GNUNET_malloc ( c_peers * sizeof (struct ATS_peer));
- for (c=0 ; c<c_peers; c++)
- {
- peers[c].f = 1.0 / c_peers;
- GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, &peers[c].peer.hashPubKey);
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Peer %s \n", GNUNET_i2s (&peers[c].peer));
- peers[c].m_head = NULL;
- peers[c].m_tail = NULL;
- }
- mechanisms = GNUNET_malloc ( c_mechanisms * sizeof (struct ATS_mechanism));
- for (c=0 ; c<c_mechanisms; c++)
- {
- mechanisms[c].peer = &peers[c];
- }
-}
-
-
-void delete_topology (void)
-{
- GNUNET_free (peers);
- GNUNET_free (mechanisms);
-}*/
-
-
-void create_ats_information (struct ATS_peer **p, int * c_p,
- struct ATS_mechanism ** m, int * c_m)
-{
+static void
+create_ats_information (struct ATS_peer **p, int * c_p,
+ struct ATS_mechanism ** m, int * c_m)
+{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"ATS needs addresses\n");
(*c_p) = tc->mechanisms;
(*m) = tc->m_head;
(*c_m) = tc->mechanisms;
-
}
-int run_ats (void)
+
+static
+int run_ats ()
{
int ret = 0;
-#if HAVE_LIBGLPK
ats_calculate_bandwidth_distribution (ats);
-#endif
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Running ATS: %s \n", (ret==0)? "SUCCESSFUL": "FAILED");
return ret;
}
-int init_ats (void)
+
+static int
+init_ats ()
{
int ret = 0;
-#if HAVE_LIBGLPK
ats = ats_init(1.0, 1.0, 1.0, 50000, 5, 10, ATS_MAX_EXEC_DURATION,
create_ats_information,
ats_result_cb);
-#endif
//GNUNET_assert (ats != NULL);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
}
-int shutdown_ats (void)
+static int
+shutdown_ats ()
{
int ret = 0;
-#if HAVE_LIBGLPK
ats_delete_problem (ats);
ats_shutdown (ats);
-#endif
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Shutdown ATS: %s \n", (ret==0)? "SUCCESSFUL": "FAILED");
return ret;
}
+
/* To make compiler happy */
-void dummy(void)
+void
+dummy()
{
struct ATS_quality_metric * q = qm;
q = NULL;
struct ATS_ressource * r = ressources;
r = NULL;
+ q++;
+ r++;
}
-void iterate_peer_values (void *cls,
- const char *section,
- const char *option,
- const char *value)
+
+static void
+iterate_peer_values (void *cls,
+ const char *section,
+ const char *option,
+ const char *value)
{
if (strcmp (option, "f") == 0)
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"\t %s %s\n", option, value);
}
-void iterate_mech_values (void *cls,
- const char *section,
- const char *option,
- const char *value)
+static void
+iterate_mech_values (void *cls,
+ const char *section,
+ const char *option,
+ const char *value)
{
if (strcmp (option, "f") == 0)
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"\t %s %s\n", option, value);
}
-void iterate_sections (void *cls,
- const char *section)
+static void
+iterate_sections (void *cls,
+ const char *section)
{
struct TransportConfiguration * tc = cls;
/* Peer definition */
}
}
-void destroy_transport_configuration (char * filename)
-{
- GNUNET_CONFIGURATION_destroy (cfg);
-}
-
-struct TransportConfiguration * load_transport_configuration (char * filename)
+static struct TransportConfiguration *
+load_transport_configuration (char * filename)
{
struct TransportConfiguration * ret = GNUNET_malloc(sizeof (struct TransportConfiguration));
- cfg = GNUNET_CONFIGURATION_create();
- GNUNET_CONFIGURATION_load(cfg, filename);
- GNUNET_CONFIGURATION_iterate_sections(cfg, iterate_sections, ret);
+ cfg = GNUNET_CONFIGURATION_create();
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_CONFIGURATION_load(cfg, filename));
+ GNUNET_CONFIGURATION_iterate_sections (cfg, iterate_sections, ret);
+ GNUNET_CONFIGURATION_destroy (cfg);
+ cfg = NULL;
return ret;
}
+
int
main (int argc, char *argv[])
{
"INFO",
#endif
NULL);
-#if !HAVE_LIBGLPK
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "HAVE_LIBGLPK not set, exiting testcase\n");
-#endif
-
-#if !HAVE_LIBGLPK
- return ret;
-#endif
-
- return 0;
-
tc = load_transport_configuration ("test.ats");
-
- return ret;
-
- /* Testing */
ats = NULL;
-
ret += init_ats ();
ret += run_ats ();
ret += shutdown_ats ();
-
- /* Shutdown */
return ret;
}
#include "platform.h"
#include "gnunet_util_lib.h"
-#if HAVE_LIBGLPK
-
#include "gnunet_testing_lib.h"
#include "gnunet_transport_service.h"
#include "gauger.h"
{
struct ATS_quality_metric * q = qm;
q = NULL;
+ q++;
struct ATS_ressource * r = ressources;
r = NULL;
+ r++;
}
static size_t
return ok;
}
-#endif
-
int
main (int argc, char *argv[])
{
#endif
NULL);
-#if !HAVE_LIBGLPK
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "GLPK not installed, exiting testcase\n");
- return ret;
-#else
GNUNET_DISK_directory_remove ("/tmp/test-gnunet-testing");
machine_parsable = GNUNET_NO;
peers = NUM_PEERS;
*/
GNUNET_DISK_directory_remove ("/tmp/test-gnunet-testing");
return ret;
-#endif
}
/* end of test_transport_ats_multiple_peers.c*/