[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r30443 - gnunet/src/ats
From: |
gnunet |
Subject: |
[GNUnet-SVN] r30443 - gnunet/src/ats |
Date: |
Mon, 28 Oct 2013 17:23:43 +0100 |
Author: wachs
Date: 2013-10-28 17:23:43 +0100 (Mon, 28 Oct 2013)
New Revision: 30443
Removed:
gnunet/src/ats/test_ats_api_performance_feedback.c
gnunet/src/ats/test_ats_api_scheduling_block_and_reset.c
gnunet/src/ats/test_ats_api_scheduling_check_min_bw_alt.c
gnunet/src/ats/test_ats_api_scheduling_destroy_inbound_connection.c
gnunet/src/ats/test_ats_api_scheduling_min_bw.c
gnunet/src/ats/test_ats_api_scheduling_update_address.c
gnunet/src/ats/test_ats_change_preference.c
gnunet/src/ats/test_ats_mlp.c
gnunet/src/ats/test_ats_mlp_update.c
gnunet/src/ats/test_ats_normalization_update_quality.c
gnunet/src/ats/test_ats_simplistic.c
gnunet/src/ats/test_ats_simplistic_change_preference.c
gnunet/src/ats/test_ats_simplistic_switch_networks.c
Modified:
gnunet/src/ats/Makefile.am
Log:
removing unused tests and clean up makefile
Modified: gnunet/src/ats/Makefile.am
===================================================================
--- gnunet/src/ats/Makefile.am 2013-10-28 15:55:43 UTC (rev 30442)
+++ gnunet/src/ats/Makefile.am 2013-10-28 16:23:43 UTC (rev 30443)
@@ -20,9 +20,6 @@
if HAVE_LIBGLPK
GN_LIBGLPK = -lglpk
GN_MLP_LIB = libgnunet_plugin_ats_mlp.la
- GN_MLP_TEST = test_ats_mlp
- GN_MLP_TEST_UPDATE = test_ats_mlp_update
- GN_MLP_TEST_AVG = test_ats_mlp_averaging
GN_MLP_PERF = perf_ats_mlp
GN_MLP_ADD_ADDRESS = test_ats_solver_add_address_mlp
GN_MLP_ADD_REQUEST_ADDRESS = test_ats_solver_add_address_and_request_mlp
@@ -125,8 +122,8 @@
test_ats_solver_request_and_add_address_proportional \
test_ats_solver_request_and_delete_address_proportional \
test_ats_solver_alternative_after_delete_address_proportional \
+ $(GN_MLP_ADD_ADDRESS) \
$(GN_MLP_ADD_REQUEST_ADDRESS) \
- $(GN_MLP_ADD_REQUEST_ADDRESS) \
$(GN_MLP_REQUEST_ADD_ADDRESS) \
$(GN_MLP_REQUEST_DELETE_ADDRESS) \
$(GN_MLP_ALTERNATIVE_DELETE_ADDRESS) \
@@ -135,25 +132,10 @@
test_ats_solver_request_and_add_address_ril \
test_ats_solver_request_and_delete_address_ril \
test_ats_solver_alternative_after_delete_address_ril
-
-# test_ats_api_scheduling_min_bw
-# test_ats_api_scheduling_check_min_bw_alt
-# test_ats_api_scheduling_update_address
-# test_ats_api_scheduling_destroy_inbound_connection
-# test_ats_api_scheduling_block_and_reset
-# test_ats_normalization_update_quality
-# test_ats_change_preference
-# test_ats_simplistic
-# test_ats_simplistic_switch_networks
-# test_ats_simplistic_change_preference
-# test_ats_api_performance_address_info
-# test_ats_api_performance_feedback
endif
check_PROGRAMS = \
$(TESTING_TESTS)
-# $(GN_MLP_TEST) $(GN_MLP_PERF) $(GN_MLP_TEST_UPDATE)
-# $(GN_MLP_TEST_AVG)
if ENABLE_TEST_RUN
TESTS = $(check_PROGRAMS)
@@ -442,108 +424,6 @@
$(top_builddir)/src/ats/libgnunetats.la \
$(top_builddir)/src/statistics/libgnunetstatistics.la
-
-#test_ats_api_scheduling_min_bw_SOURCES = \
-# test_ats_api_scheduling_min_bw.c test_ats_api_common.c
-#test_ats_api_scheduling_min_bw_LDADD = \
-# $(top_builddir)/src/util/libgnunetutil.la \
-# $(top_builddir)/src/testing/libgnunettesting.la \
-# $(top_builddir)/src/ats/libgnunetats.la
-#
-#test_ats_api_scheduling_check_min_bw_alt_SOURCES = \
-# test_ats_api_scheduling_check_min_bw_alt.c test_ats_api_common.c
-#test_ats_api_scheduling_check_min_bw_alt_LDADD = \
-# $(top_builddir)/src/util/libgnunetutil.la \
-# $(top_builddir)/src/testing/libgnunettesting.la \
-# $(top_builddir)/src/ats/libgnunetats.la
-
-
-#test_ats_api_scheduling_update_address_SOURCES = \
-# test_ats_api_scheduling_update_address.c test_ats_api_common.c
-#test_ats_api_scheduling_update_address_LDADD = \
-# $(top_builddir)/src/util/libgnunetutil.la \
-# $(top_builddir)/src/testing/libgnunettesting.la \
-# $(top_builddir)/src/ats/libgnunetats.la
-
-#test_ats_api_scheduling_destroy_inbound_connection_SOURCES = \
-# test_ats_api_scheduling_destroy_inbound_connection.c test_ats_api_common.c
-#test_ats_api_scheduling_destroy_inbound_connection_LDADD = \
-# $(top_builddir)/src/util/libgnunetutil.la \
-# $(top_builddir)/src/testing/libgnunettesting.la \
-# $(top_builddir)/src/ats/libgnunetats.la
-
-#test_ats_api_scheduling_block_and_reset_SOURCES = \
-# test_ats_api_scheduling_block_and_reset.c test_ats_api_common.c
-#test_ats_api_scheduling_block_and_reset_LDADD = \
-# $(top_builddir)/src/util/libgnunetutil.la \
-# $(top_builddir)/src/testing/libgnunettesting.la \
-# $(top_builddir)/src/ats/libgnunetats.la
-
-#test_ats_api_performance_feedback_SOURCES = \
-# test_ats_api_performance_feedback.c
-#test_ats_api_performance_feedback_LDADD = \
-# $(top_builddir)/src/util/libgnunetutil.la \
-# $(top_builddir)/src/testing/libgnunettesting.la \
-# $(top_builddir)/src/hello/libgnunethello.la \
-# $(top_builddir)/src/ats/libgnunetats.la
-
-
-
-#test_ats_api_performance_address_info_SOURCES = \
-# test_ats_api_performance_address_info.c
-#test_ats_api_performance_address_info_LDADD = \
-# $(top_builddir)/src/util/libgnunetutil.la \
-# $(top_builddir)/src/testing/libgnunettesting.la \
-# $(top_builddir)/src/hello/libgnunethello.la \
-# $(top_builddir)/src/ats/libgnunetats.la
-
-
-#test_ats_simplistic_SOURCES = \
-# test_ats_simplistic.c test_ats_api_common.c
-#test_ats_simplistic_LDADD = \
-# $(top_builddir)/src/util/libgnunetutil.la \
-# $(top_builddir)/src/testing/libgnunettesting.la \
-# $(top_builddir)/src/hello/libgnunethello.la \
-# $(top_builddir)/src/ats/libgnunetats.la
-
-#test_ats_simplistic_switch_networks_SOURCES = \
-# test_ats_simplistic_switch_networks.c test_ats_api_common.c
-#test_ats_simplistic_switch_networks_LDADD = \
-# $(top_builddir)/src/util/libgnunetutil.la \
-# $(top_builddir)/src/testing/libgnunettesting.la \
-# $(top_builddir)/src/ats/libgnunetats.la
-
-#test_ats_simplistic_change_preference_SOURCES = \
-# test_ats_simplistic_change_preference.c test_ats_api_common.c
-#test_ats_simplistic_change_preference_LDADD = \
-# $(top_builddir)/src/util/libgnunetutil.la \
-# $(top_builddir)/src/testing/libgnunettesting.la \
-# $(top_builddir)/src/ats/libgnunetats.la
-
-#test_ats_change_preference_SOURCES = \
-# test_ats_change_preference.c test_ats_api_common.c
-#test_ats_change_preference_LDADD = \
-# $(top_builddir)/src/util/libgnunetutil.la \
-# $(top_builddir)/src/testing/libgnunettesting.la \
-# $(top_builddir)/src/ats/libgnunetats.la
-
-
-#test_ats_mlp_SOURCES = \
-# $(GN_MLP_SRC) test_ats_mlp.c test_ats_api_common.c
gnunet-service-ats_normalization.c
-#test_ats_mlp_LDADD = \
-# $(GN_LIBGLPK) \
-# $(top_builddir)/src/util/libgnunetutil.la \
-# $(top_builddir)/src/statistics/libgnunetstatistics.la \
-# $(top_builddir)/src/ats/libgnunetats.la
-
-#test_ats_mlp_update_SOURCES = \
-# $(GN_MLP_SRC) test_ats_mlp_update.c test_ats_api_common.c
gnunet-service-ats_normalization.c
-#test_ats_mlp_update_LDADD = \
-# $(GN_LIBGLPK) \
-# $(top_builddir)/src/util/libgnunetutil.la \
-# $(top_builddir)/src/statistics/libgnunetstatistics.la \
-# $(top_builddir)/src/ats/libgnunetats.la
-
#perf_ats_mlp_SOURCES = \
# $(GN_MLP_SRC) perf_ats_mlp.c test_ats_api_common.c
gnunet-service-ats_normalization.c
#perf_ats_mlp_LDADD = \
@@ -552,15 +432,7 @@
# $(top_builddir)/src/statistics/libgnunetstatistics.la \
# $(top_builddir)/src/ats/libgnunetats.la
-#test_ats_normalization_update_quality_SOURCES = \
-# test_ats_normalization_update_quality.c test_ats_api_common.c
-#test_ats_normalization_update_quality_LDADD = \
-# $(GN_LIBGLPK) \
-# $(top_builddir)/src/util/libgnunetutil.la \
-# $(top_builddir)/src/statistics/libgnunetstatistics.la \
-# $(top_builddir)/src/testing/libgnunettesting.la \
-# $(top_builddir)/src/ats/libgnunetats.la
-#endif
+
EXTRA_DIST = \
ats.h \
test_ats_api.conf \
Deleted: gnunet/src/ats/test_ats_api_performance_feedback.c
===================================================================
--- gnunet/src/ats/test_ats_api_performance_feedback.c 2013-10-28 15:55:43 UTC
(rev 30442)
+++ gnunet/src/ats/test_ats_api_performance_feedback.c 2013-10-28 16:23:43 UTC
(rev 30443)
@@ -1,240 +0,0 @@
-/*
- This file is part of GNUnet.
- (C) 2010,2011 Christian Grothoff (and other contributing authors)
-
- GNUnet is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-*/
-/**
- * @file ats/test_ats_api_performance_feedback
- * @brief Test performance API:
- * Test for address feedback API
- * @author Christian Grothoff
- * @author Matthias Wachs
- */
-#include "platform.h"
-#include "gnunet_ats_service.h"
-#include "gnunet_testing_lib.h"
-#include "ats.h"
-
-#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 20)
-#define SHUTDOWN_CORRECT GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_SECONDS, 5)
-
-#define ATS_COUNT 2
-
-static GNUNET_SCHEDULER_TaskIdentifier die_task;
-static GNUNET_SCHEDULER_TaskIdentifier stage_task;
-
-struct GNUNET_CONFIGURATION_Handle *cfg;
-
-static struct GNUNET_ATS_SchedulingHandle *sh;
-
-static struct GNUNET_ATS_PerformanceHandle *ph;
-
-static struct GNUNET_HELLO_Address addr[2];
-
-static struct GNUNET_ATS_Information atsi[ATS_COUNT];
-
-static int ret;
-
-static int res_suggest_cb_p0;
-static int res_suggest_cb_p1;
-
-static int res_addrinfo_cb_p0;
-static int res_addrinfo_cb_p1;
-
-/**
- * Stage 0: Init, request address and wait for peer0 suggest cb
- * Stage 1: Got peer0 suggest cb, expect monitoring cb
- * Stage 2: Got peer0 monitoring cb, update address and expect monitor cb
- * Stage 3: Got 2nd peer0 monitoring cb, shutdown
- */
-
-static int stage;
-
-
-static void cleanup_addresses ()
-{
- GNUNET_ATS_address_destroyed (sh, &addr[0], NULL);
- GNUNET_ATS_address_destroyed (sh, &addr[1], NULL);
-}
-
-static void
-end_now (int res)
-{
- if (GNUNET_SCHEDULER_NO_TASK != stage_task)
- {
- GNUNET_SCHEDULER_cancel (stage_task);
- stage_task = GNUNET_SCHEDULER_NO_TASK;
- }
- if (GNUNET_SCHEDULER_NO_TASK != die_task)
- {
- GNUNET_SCHEDULER_cancel (die_task);
- die_task = GNUNET_SCHEDULER_NO_TASK;
- }
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown\n");
-
- cleanup_addresses ();
-
- if (NULL != ph)
- {
- GNUNET_ATS_performance_done (ph);
- ph = NULL;
- }
-
- if (NULL != sh)
- {
- GNUNET_ATS_scheduling_done (sh);
- sh = NULL;
- }
- ret = res;
-}
-
-#if 0
-static void
-end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
- die_task = GNUNET_SCHEDULER_NO_TASK;
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error!\n");
- if (GNUNET_NO == res_addrinfo_cb_p0)
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Did not get address information
for requested peer0!\n");
- if (GNUNET_NO == res_addrinfo_cb_p1)
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Did not get address information
for requested peer1!\n");
- if (GNUNET_NO == res_suggest_cb_p0)
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Did not get suggestion for not
peer!\n");
- if (GNUNET_YES == res_suggest_cb_p1)
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Got suggestion for not requested
peer!\n");
- end_now (1);
-}
-#endif
-
-static void end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Success\n");
- end_now (0);
-}
-
-static void
-addrinfo_cb (void *cls,
- const struct
GNUNET_HELLO_Address *address,
- int address_active,
- struct
GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
- struct
GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
- const struct
GNUNET_ATS_Information *ats,
- uint32_t ats_count)
-{
- //static int shutdown = GNUNET_NO;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "ATS has information about address for peer `%s'\n",
GNUNET_i2s (&address->peer));
-
- if (0 == memcmp (&addr[0].peer, &address->peer, sizeof (address->peer)))
- res_addrinfo_cb_p0 = GNUNET_YES;
- if (0 == memcmp (&addr[1].peer, &address->peer, sizeof (address->peer)))
- res_addrinfo_cb_p1 = GNUNET_YES;
-}
-
-void ats_suggest_cb (void *cls,
-
const struct GNUNET_HELLO_Address * address,
-
struct Session * session,
-
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
-
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
-
const struct GNUNET_ATS_Information *ats,
-
uint32_t ats_count)
-{
- static int feedbacks = 0;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "ATS is suggesting address for peer `%s'\n", GNUNET_i2s
(&address->peer));
-
- if (feedbacks >= 2)
- return;
- feedbacks++;
-
- if (0 == memcmp (&addr[0].peer, &address->peer, sizeof (address->peer)))
- {
- res_suggest_cb_p0 = GNUNET_YES;
- stage = 1;
- GNUNET_ATS_address_update (sh, &addr[1], NULL, atsi, ATS_COUNT);
- GNUNET_ATS_performance_give_feedback (ph, &addr[0].peer,
- GNUNET_TIME_UNIT_SECONDS,
GNUNET_ATS_PREFERENCE_BANDWIDTH,
- (double) 1000, GNUNET_ATS_PREFERENCE_END);
- }
- if (0 == memcmp (&addr[1].peer, &address->peer, sizeof (address->peer)))
- {
- GNUNET_ATS_performance_give_feedback (ph, &addr[1].peer,
- GNUNET_TIME_UNIT_SECONDS,
GNUNET_ATS_PREFERENCE_BANDWIDTH,
- GNUNET_ATS_PREFERENCE_END);
- res_suggest_cb_p1 = GNUNET_YES;
- }
-}
-
-
-static void next (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
- memset (&addr[0].peer,'\0', sizeof (addr[0].peer));
- addr[0].transport_name = "test0";
- addr[0].address = "test_addr0";
- addr[0].address_length = strlen ("test_addr0") + 1;
-
- atsi[0].type = htonl(GNUNET_ATS_QUALITY_NET_DELAY);
- atsi[0].value = htonl(100);
-
- atsi[1].type = htonl(GNUNET_ATS_QUALITY_NET_DISTANCE);
- atsi[1].value = htonl(5);
-
- GNUNET_ATS_address_add (sh, &addr[0], NULL, atsi, ATS_COUNT);
- GNUNET_ATS_suggest_address (sh, &addr[0].peer);
-
- memset (&addr[1].peer,'\1', sizeof (addr[1].peer));
- addr[1].transport_name = "test1";
- addr[1].address = "test_addr1";
- addr[1].address_length = strlen ("test_addr1") + 1;
-
- GNUNET_ATS_address_add (sh, &addr[1], NULL, atsi, ATS_COUNT);
- GNUNET_ATS_suggest_address (sh, &addr[1].peer);
- GNUNET_SCHEDULER_add_delayed (SHUTDOWN_CORRECT, &end, NULL);
-}
-
-static void
-run (void *cls,
- const struct GNUNET_CONFIGURATION_Handle *mycfg,
- struct GNUNET_TESTING_Peer *peer)
-{
- ret = 1;
- stage = 0;
- cfg = (struct GNUNET_CONFIGURATION_Handle *) mycfg;
-// die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
-
- ph = GNUNET_ATS_performance_init (cfg, &addrinfo_cb, NULL);
- GNUNET_assert (NULL != ph);
-
- sh = GNUNET_ATS_scheduling_init (cfg, &ats_suggest_cb, NULL);
- GNUNET_assert (NULL != sh);
-
- GNUNET_SCHEDULER_add_delayed (SHUTDOWN_CORRECT, &next, NULL);
-}
-
-
-int
-main (int argc, char *argv[])
-{
- if (0 != GNUNET_TESTING_peer_run ("test_ats_api_performance_monitor",
- "test_ats_api.conf",
- &run, NULL))
- return 1;
- return ret;
-}
-
-/* end of file test_ats_api_performance_feedback.c */
Deleted: gnunet/src/ats/test_ats_api_scheduling_block_and_reset.c
===================================================================
--- gnunet/src/ats/test_ats_api_scheduling_block_and_reset.c 2013-10-28
15:55:43 UTC (rev 30442)
+++ gnunet/src/ats/test_ats_api_scheduling_block_and_reset.c 2013-10-28
16:23:43 UTC (rev 30443)
@@ -1,391 +0,0 @@
-/*
- This file is part of GNUnet.
- (C) 2010,2011 Christian Grothoff (and other contributing authors)
-
- GNUnet is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-*/
-/**
- * @file ats/test_ats_api_scheduling_reset_backoff.c
- * @brief test case for blocking suggests and blocking reset API
- * measure duration of initial suggest, measure blocking duration,
- * reset block, measure suggest, compare time
- * @author Christian Grothoff
- * @author Matthias Wachs
- */
-#include "platform.h"
-#include "gnunet_ats_service.h"
-#include "gnunet_testing_lib.h"
-#include "ats.h"
-#include "test_ats_api_common.h"
-
-#define WAIT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 10)
-
-static GNUNET_SCHEDULER_TaskIdentifier die_task;
-
-static GNUNET_SCHEDULER_TaskIdentifier wait_task;
-
-/**
- * Scheduling handle
- */
-static struct GNUNET_ATS_SchedulingHandle *sched_ats;
-
-/**
- * Return value
- */
-static int ret;
-
-/**
- * Test address
- */
-static struct Test_Address test_addr;
-
-/**
- * Test peer
- */
-static struct PeerContext p;
-
-/**
- * HELLO address
- */
-struct GNUNET_HELLO_Address test_hello_address;
-
-/**
- * Session
- */
-static void *test_session;
-
-/**
- * Test ats info
- */
-struct GNUNET_ATS_Information test_ats_info[2];
-
-/**
- * Test ats count
- */
-uint32_t test_ats_count;
-
-
-struct GNUNET_TIME_Absolute initial_start;
-
-struct GNUNET_TIME_Relative initial_duration;
-
-/**
- * Blocking start
- */
-struct GNUNET_TIME_Absolute block_start;
-
-struct GNUNET_TIME_Relative block_duration;
-
-struct GNUNET_TIME_Absolute reset_block_start;
-
-struct GNUNET_TIME_Relative reset_block_duration;
-
-static void
-end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
- die_task = GNUNET_SCHEDULER_NO_TASK;
- if (wait_task != GNUNET_SCHEDULER_NO_TASK)
- {
- GNUNET_SCHEDULER_cancel (wait_task);
- wait_task = GNUNET_SCHEDULER_NO_TASK;
- }
- if (sched_ats != NULL)
- GNUNET_ATS_scheduling_done (sched_ats);
- free_test_address (&test_addr);
- ret = GNUNET_SYSERR;
-}
-
-
-static void
-end ()
-{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down\n");
- if (die_task != GNUNET_SCHEDULER_NO_TASK)
- {
- GNUNET_SCHEDULER_cancel (die_task);
- die_task = GNUNET_SCHEDULER_NO_TASK;
- }
- if (wait_task != GNUNET_SCHEDULER_NO_TASK)
- {
- GNUNET_SCHEDULER_cancel (wait_task);
- wait_task = GNUNET_SCHEDULER_NO_TASK;
- }
- GNUNET_ATS_scheduling_done (sched_ats);
- sched_ats = NULL;
- free_test_address (&test_addr);
-}
-
-static void
-request_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
- wait_task = GNUNET_SCHEDULER_NO_TASK;
- GNUNET_ATS_suggest_address (sched_ats, &p.id);
- wait_task = GNUNET_SCHEDULER_add_delayed (WAIT, &request_task, NULL);
-}
-
-static void
-address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address,
- struct Session *session,
- struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
- struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
- const struct GNUNET_ATS_Information *atsi,
- uint32_t ats_count)
-{
- static int stage = 0;
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Stage %u\n", stage);
- if (3 == stage)
- {
- /* Suggestion after resetting block interval */
- reset_block_duration = GNUNET_TIME_absolute_get_difference
(reset_block_start,
-
GNUNET_TIME_absolute_get());
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Address suggestion after resetting blocking took about
%s!\n",
- GNUNET_STRINGS_relative_time_to_string (reset_block_duration,
- GNUNET_YES));
- if ((block_duration.rel_value_us <= (initial_duration.rel_value_us * 3))
||
- (initial_duration.rel_value_us <= (block_duration.rel_value_us * 3)))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Address suggestion after resetting blocking took about
the same as initial suggestion (%s)\n",
- GNUNET_STRINGS_relative_time_to_string (initial_duration,
- GNUNET_YES));
- ret = 0;
- }
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Address suggestion after resetting blocking has too big
difference to initial suggestion (%s)\n",
- GNUNET_STRINGS_relative_time_to_string (initial_duration,
- GNUNET_YES));
- ret = 1;
- GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id);
- GNUNET_SCHEDULER_add_now (&end, NULL);
- return;
- }
-
- if (((initial_duration.rel_value_us * 3) <= block_duration.rel_value_us)
&&
- ((reset_block_duration.rel_value_us * 3) <=
block_duration.rel_value_us))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Address suggestion after resetting blocking and initial
suggestion (%llu us) much faster than with blocking (%llu us)\n",
- (unsigned long long) initial_duration.rel_value_us,
- (unsigned long long) block_duration.rel_value_us);
- ret = 0;
- }
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Address suggestion after resetting blocking and initial
suggestion (%llu us) not faster than with blocking (%llu us)\n",
- (unsigned long long) initial_duration.rel_value_us,
- (unsigned long long) block_duration.rel_value_us);
- ret = 1;
- }
-
-
- GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id);
- GNUNET_SCHEDULER_add_now (&end, NULL);
-
- }
- if (2 == stage)
- {
- /* Suggestion after block*/
- block_duration = GNUNET_TIME_absolute_get_difference(block_start,
GNUNET_TIME_absolute_get());
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Address suggestion was blocked for about %s!\n",
- GNUNET_STRINGS_relative_time_to_string (block_duration,
- GNUNET_YES));
-
- if (GNUNET_OK == compare_addresses (address, session,
&test_hello_address, test_session))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Stage %u: Callback with correct address `%s'\n", stage,
- GNUNET_i2s (&address->peer));
- ret = 0;
- }
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Stage %u: Callback with invalid address `%s'\n", stage,
- GNUNET_i2s (&address->peer));
- GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id);
- GNUNET_SCHEDULER_add_now (&end, NULL);
- ret = 1;
- }
-
- if (GNUNET_OK != compare_ats(atsi, ats_count, test_ats_info,
test_ats_count))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Stage %u: Callback with incorrect ats info \n");
- GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id);
- GNUNET_SCHEDULER_add_now (&end, NULL);
- ret = 1;
- }
- stage ++;
-
- /* Reset block interval */
- GNUNET_ATS_reset_backoff (sched_ats, &address->peer);
- reset_block_start = GNUNET_TIME_absolute_get();
- GNUNET_ATS_suggest_address (sched_ats, &p.id);
- }
- if (1 == stage)
- {
- /* Initial suggestion */
- if (GNUNET_OK == compare_addresses (address, session, &test_hello_address,
test_session))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Stage %u: Callback with correct address `%s'\n",
- stage,
- GNUNET_i2s (&address->peer));
- ret = 0;
- }
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Stage %u: Callback with invalid address `%s'\n",
- stage,
- GNUNET_i2s (&address->peer));
- GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id);
- GNUNET_SCHEDULER_add_now (&end, NULL);
- ret = 1;
- }
-
- if (GNUNET_OK != compare_ats(atsi, ats_count, test_ats_info,
test_ats_count))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Stage %u: Callback with incorrect ats info\n",
- stage);
- GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id);
- GNUNET_SCHEDULER_add_now (&end, NULL);
- ret = 1;
- }
- stage++;
- initial_duration = GNUNET_TIME_absolute_get_difference(initial_start,
GNUNET_TIME_absolute_get());
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Stage %u: Initial suggestion took about %s\n",
- stage,
- GNUNET_STRINGS_relative_time_to_string (block_duration,
- GNUNET_YES));
-
- block_start = GNUNET_TIME_absolute_get();
- wait_task = GNUNET_SCHEDULER_add_delayed (WAIT, &request_task, NULL);
- }
- if (0 == stage)
- {
- /* Startup suggestion */
- if (GNUNET_OK == compare_addresses (address, session, &test_hello_address,
test_session))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Stage %u: Callback with correct address `%s'\n",
- stage,
- GNUNET_i2s (&address->peer));
- ret = 0;
- }
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Stage %u: Callback with invalid address `%s'\n",
- stage,
- GNUNET_i2s (&address->peer));
- GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id);
- GNUNET_SCHEDULER_add_now (&end, NULL);
- ret = 1;
- }
-
- if (GNUNET_OK != compare_ats (atsi, ats_count, test_ats_info,
test_ats_count))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Stage %u: Callback with incorrect ats info\n",
- stage);
- GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id);
- GNUNET_SCHEDULER_add_now (&end, NULL);
- ret = 1;
- }
- stage ++;
-
- GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id);
-
- initial_start = GNUNET_TIME_absolute_get();
- GNUNET_ATS_suggest_address (sched_ats, &p.id);
- }
-}
-
-
-static void
-run (void *cls,
- const struct GNUNET_CONFIGURATION_Handle *cfg,
- struct GNUNET_TESTING_Peer *peer)
-{
-
- die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
-
- /* Connect to ATS scheduling */
- sched_ats = GNUNET_ATS_scheduling_init (cfg, &address_suggest_cb, NULL);
- if (sched_ats == NULL)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Could not connect to ATS scheduling!\n");
- ret = 1;
- end ();
- return;
- }
-
- /* Set up peer */
- if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID0,
&p.id.hashPubKey))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Could not setup peer!\n");
- ret = GNUNET_SYSERR;
- end ();
- return;
- }
- GNUNET_assert (0 == strcmp (PEERID0, GNUNET_i2s_full (&p.id)));
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Created peer `%s'\n",
- GNUNET_i2s_full(&p.id));
-
- /* Prepare ATS Information */
- test_ats_info[0].type = htonl (GNUNET_ATS_NETWORK_TYPE);
- test_ats_info[0].value = htonl(GNUNET_ATS_NET_WAN);
- test_ats_info[1].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
- test_ats_info[1].value = htonl(1);
- test_ats_count = 2;
-
- /* Adding address without session */
- test_session = &test_addr;
- create_test_address (&test_addr, "test", test_session, "test", strlen
("test") + 1);
- test_hello_address.peer = p.id;
- test_hello_address.transport_name = test_addr.plugin;
- test_hello_address.address = test_addr.addr;
- test_hello_address.address_length = test_addr.addr_len;
- GNUNET_ATS_address_add (sched_ats, &test_hello_address, test_session,
test_ats_info, test_ats_count);
-
- initial_start = GNUNET_TIME_absolute_get();
- GNUNET_ATS_suggest_address (sched_ats, &p.id);
-}
-
-
-int
-main (int argc, char *argv[])
-{
- if (0 != GNUNET_TESTING_peer_run ("test_ats_api_scheduling_add_address",
- "test_ats_api.conf",
- &run, NULL))
- return 1;
- return ret;
-}
-/* end of file test_ats_api_scheduling_reset_backoff.c */
Deleted: gnunet/src/ats/test_ats_api_scheduling_check_min_bw_alt.c
===================================================================
--- gnunet/src/ats/test_ats_api_scheduling_check_min_bw_alt.c 2013-10-28
15:55:43 UTC (rev 30442)
+++ gnunet/src/ats/test_ats_api_scheduling_check_min_bw_alt.c 2013-10-28
16:23:43 UTC (rev 30443)
@@ -1,423 +0,0 @@
-/*
- This file is part of GNUnet.
- (C) 2010,2011 Christian Grothoff (and other contributing authors)
-
- GNUnet is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-*/
-/**
- * @file ats/test_ats_mlp.c
- * @brief test for the MLP solver
- * @author Christian Grothoff
- * @author Matthias Wachs
-
- */
-/**
- * @file ats/test_ats_api_scheduling_check_min_bw_alt.c
- * @brief alternative suggestion on network change if no bw is available
- * @author Christian Grothoff
- * @author Matthias Wachs
- */
-#include "platform.h"
-#include "gnunet_ats_service.h"
-#include "gnunet_testing_lib.h"
-#include "ats.h"
-#include "test_ats_api_common.h"
-
-#define DEBUG_ATS_INFO GNUNET_NO
-
-static GNUNET_SCHEDULER_TaskIdentifier die_task;
-
-/**
- * Scheduling handle
- */
-static struct GNUNET_ATS_SchedulingHandle *sched_ats;
-
-/**
- * Return value
- */
-static int ret;
-
-/**
- * Test address
- */
-static struct Test_Address test_addr[2];
-
-/**
- * Test peer
- */
-static struct PeerContext p[2];
-
-
-/**
- * HELLO address
- */
-struct GNUNET_HELLO_Address test_hello_address[2];
-
-/**
- * Session
- */
-static void *test_session[2];
-
-/**
- * Test ats info
- */
-struct GNUNET_ATS_Information test_ats_info[2][2];
-
-/**
- * Test ats count
- */
-uint32_t test_ats_count;
-
-/**
- * Configured WAN out quota
- */
-unsigned long long wan_quota_out;
-
-/**
- * Configured WAN in quota
- */
-unsigned long long wan_quota_in;
-
-
-static void
-end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
- die_task = GNUNET_SCHEDULER_NO_TASK;
-
- if (NULL != sched_ats)
- {
- GNUNET_ATS_scheduling_done (sched_ats);
- sched_ats = NULL;
- }
- free_test_address (&test_addr[0]);
- free_test_address (&test_addr[1]);
- ret = GNUNET_SYSERR;
-}
-
-
-static void
-end ()
-{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down\n");
- if (die_task != GNUNET_SCHEDULER_NO_TASK)
- {
- GNUNET_SCHEDULER_cancel (die_task);
- die_task = GNUNET_SCHEDULER_NO_TASK;
- }
- if (NULL != sched_ats)
- {
- GNUNET_ATS_scheduling_done (sched_ats);
- sched_ats = NULL;
- }
- free_test_address (&test_addr[0]);
- free_test_address (&test_addr[1]);
-}
-
-
-static void
-address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address,
- struct Session *session,
- struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
- struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
- const struct GNUNET_ATS_Information *atsi,
- uint32_t ats_count)
-{
- static int stage = 0;
- unsigned int bw_in = ntohl(bandwidth_in.value__);
- unsigned int bw_out = ntohl(bandwidth_out.value__);
-
- if (0 == stage)
- {
- /* Initial suggestion for 1st address */
- if (GNUNET_OK == compare_addresses (address, session,
&test_hello_address[0], test_session[0]))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Callback with correct
address `%s'\n",
- stage, GNUNET_i2s (&address->peer));
- ret = 0;
- }
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Callback with invalid
address `%s'\n",
- stage, GNUNET_i2s (&address->peer));
- ret = 1;
- }
-
- if (GNUNET_OK != compare_ats(atsi, ats_count, test_ats_info[0],
test_ats_count))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback with incorrect
ats info \n");
- ret = 1;
- }
-
- if (bw_in > wan_quota_in)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Suggested WAN inbound
quota %u bigger than allowed quota %llu \n",
- stage, bw_in, wan_quota_in);
- ret = 1;
- }
- else
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Suggested WAN inbound
quota %u, allowed quota %llu \n",
- stage, bw_in, wan_quota_in);
-
- if (bw_out > wan_quota_out)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Suggested WAN outbound
quota %u bigger than allowed quota %llu \n",
- stage, bw_out, wan_quota_out);
- ret = 1;
- }
- else
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Suggested WAN outbound
quota %u, allowed quota %llu \n",
- stage, bw_out, wan_quota_out);
-
- if (1 == ret)
- {
- GNUNET_ATS_suggest_address_cancel (sched_ats, &p[0].id);
- GNUNET_SCHEDULER_add_now (&end, NULL);
- return;
- }
-
- p[0].bw_out_assigned = bw_out;
- p[0].bw_in_assigned = bw_in;
- stage ++;
-
- /* Add a 2nd address to give ATS an suggestion alternative */
- /* Prepare ATS Information */
- test_ats_info[1][0].type = htonl (GNUNET_ATS_NETWORK_TYPE);
- test_ats_info[1][0].value = htonl(GNUNET_ATS_NET_LAN);
- test_ats_info[1][1].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
- test_ats_info[1][1].value = htonl(1);
- test_ats_count = 2;
-
- /* Adding address with session */
- test_session[1] = &test_addr[1];
- create_test_address (&test_addr[1], "test1", test_session[1], "test1",
strlen ("test1") + 1);
- test_hello_address[1].peer = p[0].id;
- test_hello_address[1].transport_name = test_addr[1].plugin;
- test_hello_address[1].address = test_addr[1].addr;
- test_hello_address[1].address_length = test_addr[1].addr_len;
- GNUNET_ATS_address_add (sched_ats, &test_hello_address[1], test_session[1],
- test_ats_info[1], test_ats_count);
-
-
- /* Changing 1st address to network with now bw available (WLAN) */
- test_ats_info[0][0].type = htonl (GNUNET_ATS_NETWORK_TYPE);
- test_ats_info[0][0].value = htonl(GNUNET_ATS_NET_WLAN);
- test_ats_info[0][1].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
- test_ats_info[0][1].value = htonl(1);
- test_ats_count = 2;
-
- GNUNET_ATS_address_update (sched_ats, &test_hello_address[0],
test_session[0],
- test_ats_info[0], test_ats_count);
- return;
- }
- if (1 == stage)
- {
- /* Bandwidth update to (in/out) 0/0 for 1st address */
- if (GNUNET_OK == compare_addresses (address, session,
&test_hello_address[0], test_session[0]))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Callback with correct
address `%s'\n",
- stage, GNUNET_i2s (&address->peer));
- ret = 0;
- }
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Callback with invalid
address `%s'\n",
- stage, GNUNET_i2s (&address->peer));
- ret = 1;
- }
-
- if (GNUNET_OK != compare_ats(atsi, ats_count, test_ats_info[0],
test_ats_count))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback with incorrect
ats info \n");
- ret = 1;
- }
-
- if ((bw_in != 0) || (bw_out != 0))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: ATS did not set
bandwidth to 0 but instead to %u/%u \n",
- stage, bw_in, wan_quota_in);
- ret = 1;
- }
-
- if (1 == ret)
- {
- GNUNET_ATS_suggest_address_cancel (sched_ats, &p[0].id);
- GNUNET_SCHEDULER_add_now (&end, NULL);
- return;
- }
- p[0].bw_out_assigned = bw_out;
- p[0].bw_in_assigned = bw_in;
- stage ++;
- return;
- }
- if (2 == stage)
- {
- /* Expecting suggestion of alternative 2nd address*/
- if (GNUNET_OK == compare_addresses (address, session,
&test_hello_address[1], test_session[1]))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Callback with correct
address `%s'\n",
- stage, GNUNET_i2s (&address->peer));
- ret = 0;
- }
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Callback with invalid
address `%s'\n",
- stage, GNUNET_i2s (&address->peer));
- ret = 1;
- }
-
- if (GNUNET_OK != compare_ats(atsi, ats_count, test_ats_info[1],
test_ats_count))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback with incorrect
ats info \n",
- stage);
- ret = 1;
- }
-
- if ((bw_in == 0) || (bw_out == 0))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: ATS did not set
bandwidth correctly \n",
- stage);
- ret = 1;
- }
-
- if (1 == ret)
- {
- GNUNET_ATS_suggest_address_cancel (sched_ats, &p[0].id);
- GNUNET_SCHEDULER_add_now (&end, NULL);
- return;
- }
-
- GNUNET_ATS_suggest_address_cancel (sched_ats, &p[0].id);
- GNUNET_SCHEDULER_add_now (&end, NULL);
- ret = 0;
- return;
- }
-}
-
-static void
-run (void *cls,
- const struct GNUNET_CONFIGURATION_Handle *cfg,
- struct GNUNET_TESTING_Peer *peer)
-{
- char *quota_str;
-
- if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string(cfg, "ats",
"WAN_QUOTA_OUT", "a_str))
- {
- fprintf (stderr, "Cannot load WAN outbound quota from configuration,
exit!\n");
- ret = 1;
- return;
- }
- if (GNUNET_SYSERR == GNUNET_STRINGS_fancy_size_to_bytes (quota_str,
&wan_quota_out))
- {
- fprintf (stderr, "Cannot load WAN outbound quota from configuration,
exit!\n");
- ret = 1;
- GNUNET_free (quota_str);
- return;
- }
- GNUNET_free (quota_str);
- quota_str = NULL;
-
- if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string(cfg, "ats",
"WAN_QUOTA_IN", "a_str))
- {
- fprintf (stderr, "Cannot load WAN inbound quota from configuration,
exit!\n");
- ret = 1;
- return;
- }
- if (GNUNET_SYSERR == GNUNET_STRINGS_fancy_size_to_bytes (quota_str,
&wan_quota_in))
- {
- fprintf (stderr, "Cannot load WAN inbound quota from configuration,
exit!\n");
- GNUNET_free (quota_str);
- ret = 1;
- return;
- }
- GNUNET_free (quota_str);
- quota_str = NULL;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Configured WAN inbound quota: %llu\n",
wan_quota_in);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Configured WAN outbound quota:
%llu\n", wan_quota_out);
-
-
- die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
-
- /* Connect to ATS scheduling */
- sched_ats = GNUNET_ATS_scheduling_init (cfg, &address_suggest_cb, NULL);
- if (sched_ats == NULL)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not connect to ATS
scheduling!\n");
- ret = 1;
- end ();
- return;
- }
-
- /* Set up peer 0 */
- if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID0,
&p[0].id.hashPubKey))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n");
- ret = GNUNET_SYSERR;
- end ();
- return;
- }
-
- GNUNET_assert (0 == strcmp (PEERID0, GNUNET_i2s_full (&p[0].id)));
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n",
- GNUNET_i2s(&p[0].id));
-
- /* Set up peer 1*/
- if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID1,
&p[1].id.hashPubKey))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n");
- ret = GNUNET_SYSERR;
- end ();
- return;
- }
-
- GNUNET_assert (0 == strcmp (PEERID1, GNUNET_i2s_full (&p[1].id)));
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n",
- GNUNET_i2s(&p[1].id));
-
- /* Prepare ATS Information */
- test_ats_info[0][0].type = htonl (GNUNET_ATS_NETWORK_TYPE);
- test_ats_info[0][0].value = htonl(GNUNET_ATS_NET_WAN);
- test_ats_info[0][1].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
- test_ats_info[0][1].value = htonl(1);
- test_ats_count = 2;
-
- /* Adding address with session */
- test_session[0] = &test_addr[0];
- create_test_address (&test_addr[0], "test0", test_session[0], "test0",
strlen ("test0") + 1);
- test_hello_address[0].peer = p[0].id;
- test_hello_address[0].transport_name = test_addr[0].plugin;
- test_hello_address[0].address = test_addr[0].addr;
- test_hello_address[0].address_length = test_addr[0].addr_len;
- GNUNET_ATS_address_add (sched_ats, &test_hello_address[0], test_session[0],
- test_ats_info[0], test_ats_count);
-
- GNUNET_ATS_suggest_address (sched_ats, &p[0].id);
-}
-
-
-int
-main (int argc, char *argv[])
-{
- if (0 != GNUNET_TESTING_peer_run ("test_ats_api_scheduling_check_min_bw_alt",
- "test_ats_api.conf",
- &run, NULL))
- return 1;
- return ret;
-}
-
-
-/* end of file test_ats_api_scheduling_check_min_bw_alt.c */
Deleted: gnunet/src/ats/test_ats_api_scheduling_destroy_inbound_connection.c
===================================================================
--- gnunet/src/ats/test_ats_api_scheduling_destroy_inbound_connection.c
2013-10-28 15:55:43 UTC (rev 30442)
+++ gnunet/src/ats/test_ats_api_scheduling_destroy_inbound_connection.c
2013-10-28 16:23:43 UTC (rev 30443)
@@ -1,223 +0,0 @@
-/*
- This file is part of GNUnet.
- (C) 2010,2011 Christian Grothoff (and other contributing authors)
-
- GNUnet is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-*/
-/**
- * @file ats/test_ats_api_scheduling_destroy_inbound_connection.c
- * @brief test destroying sessions for inbound connections: first add an
address with a session,
- * request the address and compare, delete the session, request and
- * compare again, delete whole address, request and wait for timeout,
- * shutdown
- * @author Christian Grothoff
- * @author Matthias Wachs
- *
- */
-#include "platform.h"
-#include "gnunet_ats_service.h"
-#include "gnunet_testing_lib.h"
-#include "ats.h"
-#include "test_ats_api_common.h"
-
-static GNUNET_SCHEDULER_TaskIdentifier die_task;
-
-static GNUNET_SCHEDULER_TaskIdentifier wait_task;
-
-#define SUGGESTION_WAIT_TIMEOUT GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_SECONDS, 5)
-
-
-/**
- * Scheduling handle
- */
-static struct GNUNET_ATS_SchedulingHandle *sched_ats;
-
-/**
- * Return value
- */
-static int ret;
-
-/**
- * Test address
- */
-static struct Test_Address test_addr;
-
-/**
- * Test peer
- */
-static struct PeerContext p;
-
-/**
- * HELLO address
- */
-struct GNUNET_HELLO_Address test_hello_address;
-
-/**
- * Session
- */
-static void *test_session;
-
-/**
- * Test ats info
- */
-struct GNUNET_ATS_Information test_ats_info[2];
-
-/**
- * Test ats count
- */
-uint32_t test_ats_count;
-
-
-static void
-end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
- die_task = GNUNET_SCHEDULER_NO_TASK;
- if (wait_task != GNUNET_SCHEDULER_NO_TASK)
- {
- GNUNET_SCHEDULER_cancel (wait_task);
- wait_task = GNUNET_SCHEDULER_NO_TASK;
- }
- if (sched_ats != NULL)
- GNUNET_ATS_scheduling_done (sched_ats);
- free_test_address (&test_addr);
- ret = GNUNET_SYSERR;
-}
-
-
-static void
-end ()
-{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down\n");
- wait_task = GNUNET_SCHEDULER_NO_TASK;
- if (die_task != GNUNET_SCHEDULER_NO_TASK)
- {
- GNUNET_SCHEDULER_cancel (die_task);
- die_task = GNUNET_SCHEDULER_NO_TASK;
- }
- free_test_address (&test_addr);
- GNUNET_ATS_scheduling_done (sched_ats);
- sched_ats = NULL;
-}
-
-
-static void
-address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address,
- struct Session *session,
- struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
- struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
- const struct GNUNET_ATS_Information *atsi,
- uint32_t ats_count)
-{
- static int stage = 0;
-
- if (0 == stage)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage 0: Received suggestion for
peer `%s'\n",
- GNUNET_i2s(&address->peer));
-
- GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id);
- if (GNUNET_OK == compare_addresses (address, session, &test_hello_address,
test_session))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage 0: Callback with correct
address `%s'\n",
- GNUNET_i2s (&address->peer));
- }
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage 0: Callback with invalid
address `%s'\n",
- GNUNET_i2s (&address->peer));
- GNUNET_SCHEDULER_add_now (&end, NULL);
- ret = 1;
- return;
- }
- stage ++;
- ret = 0;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Destroying address for `%s'\n",
- GNUNET_i2s (&address->peer));
- /* Destroying session for address */
- test_session = NULL;
- GNUNET_ATS_address_destroyed (sched_ats, &test_hello_address,
test_addr.session);
- /* Request address */
- GNUNET_ATS_suggest_address (sched_ats, &p.id);
-
- /* Wait for timeout */
- wait_task = GNUNET_SCHEDULER_add_delayed (SUGGESTION_WAIT_TIMEOUT, &end,
NULL);
- return;
- }
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Unexpected address
suggestion\n", stage);
- ret = 1;
-}
-
-
-static void
-run (void *cls,
- const struct GNUNET_CONFIGURATION_Handle *cfg,
- struct GNUNET_TESTING_Peer *peer)
-{
- die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
-
- /* Connect to ATS scheduling */
- sched_ats = GNUNET_ATS_scheduling_init (cfg, &address_suggest_cb, NULL);
- if (sched_ats == NULL)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not connect to ATS
scheduling!\n");
- ret = 1;
- end ();
- return;
- }
-
- /* Set up peer */
- if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID0,
&p.id.hashPubKey))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n");
- ret = GNUNET_SYSERR;
- end ();
- return;
- }
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n",
- GNUNET_i2s_full(&p.id));
-
- /* Prepare ATS Information */
- test_ats_info[0].type = htonl (GNUNET_ATS_NETWORK_TYPE);
- test_ats_info[0].value = htonl(GNUNET_ATS_NET_WAN);
- test_ats_info[1].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
- test_ats_info[1].value = htonl(1);
- test_ats_count = 2;
-
- /* Adding address with session */
- create_test_address (&test_addr, "test", &test_addr, NULL, 0);
- test_session = &test_addr;
- test_hello_address.peer = p.id;
- test_hello_address.transport_name = test_addr.plugin;
- test_hello_address.address = test_addr.addr;
- test_hello_address.address_length = test_addr.addr_len;
- GNUNET_ATS_address_add (sched_ats, &test_hello_address, test_addr.session,
test_ats_info, test_ats_count);
-
- /* Request address */
- GNUNET_ATS_suggest_address (sched_ats, &p.id);
-}
-
-
-int
-main (int argc, char *argv[])
-{
- if (0 != GNUNET_TESTING_peer_run ("test_ats_api_scheduling_add_address",
- "test_ats_api.conf",
- &run, NULL))
- return 1;
- return ret;
-}
-
-/* end of file test_ats_api_scheduling_destroy_inbound_connection.c */
Deleted: gnunet/src/ats/test_ats_api_scheduling_min_bw.c
===================================================================
--- gnunet/src/ats/test_ats_api_scheduling_min_bw.c 2013-10-28 15:55:43 UTC
(rev 30442)
+++ gnunet/src/ats/test_ats_api_scheduling_min_bw.c 2013-10-28 16:23:43 UTC
(rev 30443)
@@ -1,185 +0,0 @@
-/*
- This file is part of GNUnet.
- (C) 2010,2011 Christian Grothoff (and other contributing authors)
-
- GNUnet is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-*/
-/**
- * @file ats/test_ats_api_scheduling_min_bw.c
- * @brief add in address for a network where quota is below min bw: no suggest
expected
- * @author Christian Grothoff
- * @author Matthias Wachs
- */
-#include "platform.h"
-#include "gnunet_ats_service.h"
-#include "gnunet_testing_lib.h"
-#include "ats.h"
-#include "test_ats_api_common.h"
-
-#define WAIT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 3)
-
-static GNUNET_SCHEDULER_TaskIdentifier die_task;
-static GNUNET_SCHEDULER_TaskIdentifier wait_task;
-
-/**
- * Scheduling handle
- */
-static struct GNUNET_ATS_SchedulingHandle *sched_ats;
-
-/**
- * Return value
- */
-static int ret;
-
-/**
- * Test address
- */
-static struct Test_Address test_addr;
-
-/**
- * Test peer
- */
-static struct PeerContext p;
-
-/**
- * HELLO address
- */
-struct GNUNET_HELLO_Address test_hello_address;
-
-/**
- * Session
- */
-static void *test_session;
-
-/**
- * Test ats info
- */
-struct GNUNET_ATS_Information test_ats_info[2];
-
-/**
- * Test ats count
- */
-uint32_t test_ats_count;
-
-
-static void
-end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
- die_task = GNUNET_SCHEDULER_NO_TASK;
-
- if (sched_ats != NULL)
- GNUNET_ATS_scheduling_done (sched_ats);
- free_test_address (&test_addr);
- ret = GNUNET_SYSERR;
-}
-
-
-static void
-end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down\n");
- if (die_task != GNUNET_SCHEDULER_NO_TASK)
- {
- GNUNET_SCHEDULER_cancel (die_task);
- die_task = GNUNET_SCHEDULER_NO_TASK;
- }
- if (NULL != sched_ats)
- GNUNET_ATS_scheduling_done (sched_ats);
- sched_ats = NULL;
- free_test_address (&test_addr);
-}
-
-static void
-address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address,
- struct Session *session,
- struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
- struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
- const struct GNUNET_ATS_Information *atsi,
- uint32_t ats_count)
-{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Did not expect suggestion!\n");
- GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id);
- GNUNET_SCHEDULER_add_now (&end, NULL);
- ret = 1;
-}
-
-static void
-run (void *cls,
- const struct GNUNET_CONFIGURATION_Handle *cfg,
- struct GNUNET_TESTING_Peer *peer)
-{
-
- die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
-
- /* Connect to ATS scheduling */
- sched_ats = GNUNET_ATS_scheduling_init (cfg, &address_suggest_cb, NULL);
- if (sched_ats == NULL)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not connect to ATS
scheduling!\n");
- ret = 1;
- GNUNET_SCHEDULER_add_now (&end , NULL);
- return;
- }
-
- /* Set up peer */
- if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID0,
&p.id.hashPubKey))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n");
- ret = GNUNET_SYSERR;
- GNUNET_SCHEDULER_add_now (&end , NULL);
- return;
- }
-
- GNUNET_assert (0 == strcmp (PEERID0, GNUNET_i2s_full (&p.id)));
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n",
- GNUNET_i2s_full(&p.id));
-
- /* Prepare ATS Information */
- test_ats_info[0].type = htonl (GNUNET_ATS_NETWORK_TYPE);
- test_ats_info[0].value = htonl(GNUNET_ATS_NET_WLAN); /* WLAN quota is below
min bw */
- test_ats_info[1].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
- test_ats_info[1].value = htonl(1);
- test_ats_count = 2;
-
- /* Adding address without session */
- test_session = NULL;
- create_test_address (&test_addr, "test", test_session, "test", strlen
("test") + 1);
- test_hello_address.peer = p.id;
- test_hello_address.transport_name = test_addr.plugin;
- test_hello_address.address = test_addr.addr;
- test_hello_address.address_length = test_addr.addr_len;
- GNUNET_ATS_address_add (sched_ats, &test_hello_address, test_session,
test_ats_info, test_ats_count);
-
- GNUNET_ATS_suggest_address (sched_ats, &p.id);
-
- ret = 0;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Waiting for wait period for no
suggest...\n");
- wait_task = GNUNET_SCHEDULER_add_delayed (WAIT, &end, NULL);
-}
-
-
-int
-main (int argc, char *argv[])
-{
- if (0 != GNUNET_TESTING_peer_run ("test_ats_api_scheduling_add_address",
- "test_ats_api.conf",
- &run, NULL))
- return 1;
- return ret;
-}
-
-/* end of file test_ats_api_scheduling_min_bw.c */
Deleted: gnunet/src/ats/test_ats_api_scheduling_update_address.c
===================================================================
--- gnunet/src/ats/test_ats_api_scheduling_update_address.c 2013-10-28
15:55:43 UTC (rev 30442)
+++ gnunet/src/ats/test_ats_api_scheduling_update_address.c 2013-10-28
16:23:43 UTC (rev 30443)
@@ -1,238 +0,0 @@
-/*
- This file is part of GNUnet.
- (C) 2010,2011 Christian Grothoff (and other contributing authors)
-
- GNUnet is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-*/
-/**
- * @file ats/test_ats_api_scheduling_update_address.c
- * @brief test updating an address: add address, get and compare it, update it
- * get it again and compre
- * @author Christian Grothoff
- * @author Matthias Wachs
- */
-#include "platform.h"
-#include "gnunet_ats_service.h"
-#include "gnunet_testing_lib.h"
-#include "ats.h"
-#include "test_ats_api_common.h"
-
-static GNUNET_SCHEDULER_TaskIdentifier die_task;
-
-/**
- * Scheduling handle
- */
-static struct GNUNET_ATS_SchedulingHandle *sched_ats;
-
-/**
- * Return value
- */
-static int ret;
-
-/**
- * Test address
- */
-static struct Test_Address test_addr;
-
-/**
- * Test peer
- */
-static struct PeerContext p;
-
-/**
- * HELLO test address
- */
-
-struct GNUNET_HELLO_Address test_hello_address;
-
-/**
- * Test session
- */
-static void *test_session;
-
-/**
- * Test ats info
- */
-struct GNUNET_ATS_Information test_ats_info[3];
-
-/**
- * Test ats count
- */
-uint32_t test_ats_count;
-
-
-static void
-end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
- die_task = GNUNET_SCHEDULER_NO_TASK;
-
- if (sched_ats != NULL)
- GNUNET_ATS_scheduling_done (sched_ats);
- free_test_address (&test_addr);
- ret = GNUNET_SYSERR;
-}
-
-
-static void
-end ()
-{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down\n");
- if (die_task != GNUNET_SCHEDULER_NO_TASK)
- {
- GNUNET_SCHEDULER_cancel (die_task);
- die_task = GNUNET_SCHEDULER_NO_TASK;
- }
- GNUNET_ATS_scheduling_done (sched_ats);
- sched_ats = NULL;
- free_test_address (&test_addr);
-}
-
-
-static void
-address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address,
- struct Session *session,
- struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
- struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
- const struct GNUNET_ATS_Information *atsi,
- uint32_t ats_count)
-{
- static int stage = 0;
- if (0 == stage)
- {
- GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id);
- if (GNUNET_OK == compare_addresses(address, session, &test_hello_address,
test_session))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage 0: Callback for correct
address `%s'\n",
- GNUNET_i2s (&address->peer));
- ret = 0;
- }
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage 0: Callback with incorrect
address `%s'\n",
- GNUNET_i2s (&address->peer));
- ret = 1;
- GNUNET_SCHEDULER_add_now (&end, NULL);
- return;
- }
-
- if ((ats_count != test_ats_count) ||
- (GNUNET_OK != compare_ats(atsi, ats_count, test_ats_info,
test_ats_count)))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage 0: Callback with incorrect
ats info \n");
- ret = 1;
- GNUNET_SCHEDULER_add_now (&end, NULL);
- return;
- }
-
- /* Update address */
- /* Prepare ATS Information */
- test_ats_info[0].type = htonl (GNUNET_ATS_NETWORK_TYPE);
- test_ats_info[0].value = htonl(GNUNET_ATS_NET_WAN);
- test_ats_info[1].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
- test_ats_info[1].value = htonl(5);
- test_ats_info[2].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY);
- test_ats_info[2].value = htonl(30);
- test_ats_count = 3;
-
- GNUNET_ATS_address_update (sched_ats, &test_hello_address, test_session,
test_ats_info, test_ats_count);
-
- /* Request address */
- GNUNET_ATS_suggest_address (sched_ats, &p.id);
- stage ++;
- }
- else if (1 == stage)
- {
- GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id);
- if (GNUNET_OK == compare_addresses(address, session,
&test_hello_address, test_session))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage 1: Callback with correct
address `%s'\n",
- GNUNET_i2s (&address->peer));
- ret = 0;
- }
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage 1: Callback with incorrect
address `%s'\n",
- GNUNET_i2s (&address->peer));
- ret = 1;
- }
-
- if ((ats_count != test_ats_count) ||
- (GNUNET_OK != compare_ats(atsi, ats_count, test_ats_info,
test_ats_count)))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage 1: Callback with incorrect
ats info \n");
- ret = 1;
- GNUNET_SCHEDULER_add_now (&end, NULL);
- return;
- }
-
- GNUNET_SCHEDULER_add_now (&end, NULL);
- }
-}
-
-static void
-run (void *cls,
- const struct GNUNET_CONFIGURATION_Handle *cfg,
- struct GNUNET_TESTING_Peer *peer)
-{
- die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
-
- /* Connect to ATS scheduling */
- sched_ats = GNUNET_ATS_scheduling_init (cfg, &address_suggest_cb, NULL);
- if (sched_ats == NULL)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not connect to ATS
scheduling!\n");
- ret = 1;
- end ();
- return;
- }
-
- /* Set up peer */
- memset (&p.id, '1', sizeof (p.id));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n",
- GNUNET_i2s_full(&p.id));
-
- /* Prepare ATS Information */
- test_ats_info[0].type = htonl (GNUNET_ATS_NETWORK_TYPE);
- test_ats_info[0].value = htonl(GNUNET_ATS_NET_WAN);
- test_ats_info[1].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY);
- test_ats_info[1].value = htonl(10);
- test_ats_count = 2;
-
- /* Adding address without session */
- test_session = &test_addr;
- create_test_address (&test_addr, "test", &test_addr, "test", strlen ("test")
+ 1);
- test_hello_address.peer = p.id;
- test_hello_address.transport_name = test_addr.plugin;
- test_hello_address.address = test_addr.addr;
- test_hello_address.address_length = test_addr.addr_len;
- GNUNET_ATS_address_add (sched_ats, &test_hello_address, test_session,
test_ats_info, test_ats_count);
-
- /* Request address */
- GNUNET_ATS_suggest_address (sched_ats, &p.id);
-}
-
-
-int
-main (int argc, char *argv[])
-{
- if (0 != GNUNET_TESTING_peer_run ("test_ats_api_scheduling_update_address",
- "test_ats_api.conf",
- &run, NULL))
- return 1;
- return ret;
-}
-
-/* end of file test_ats_api_scheduling_update_address.c */
Deleted: gnunet/src/ats/test_ats_change_preference.c
===================================================================
--- gnunet/src/ats/test_ats_change_preference.c 2013-10-28 15:55:43 UTC (rev
30442)
+++ gnunet/src/ats/test_ats_change_preference.c 2013-10-28 16:23:43 UTC (rev
30443)
@@ -1,399 +0,0 @@
-/*
- This file is part of GNUnet.
- (C) 2010,2011 Christian Grothoff (and other contributing authors)
-
- GNUnet is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-*/
-/**
- * @file ats/test_ats_mlp.c
- * @brief test for the MLP solver
- * @author Christian Grothoff
- * @author Matthias Wachs
-
- */
-/**
- * @file ats/test_ats_change_preferences.c
- * @brief test for ats proportional solver preference aging:
- * Add 2 addresses and set high preference for one. Expect higher bw for
this
- * address, wait. Preferences should age and so bw assigned should
decrease.
- * @author Christian Grothoff
- * @author Matthias Wachs
- */
-#include "platform.h"
-#include "gnunet_ats_service.h"
-#include "gnunet_testing_lib.h"
-#include "ats.h"
-#include "test_ats_api_common.h"
-
-#define DEBUG_ATS_INFO GNUNET_NO
-
-static GNUNET_SCHEDULER_TaskIdentifier die_task;
-
-/**
- * Scheduling handle
- */
-static struct GNUNET_ATS_SchedulingHandle *sched_ats;
-
-/**
- * Performance handle
- */
-static struct GNUNET_ATS_PerformanceHandle *perf_ats;
-
-/**
- * Return value
- */
-static int ret;
-
-/**
- * Test address
- */
-static struct Test_Address test_addr[2];
-
-/**
- * Test peer
- */
-static struct PeerContext p[2];
-
-
-/**
- * HELLO address
- */
-struct GNUNET_HELLO_Address test_hello_address[2];
-
-/**
- * Session
- */
-static void *test_session[2];
-
-/**
- * Test ats info
- */
-struct GNUNET_ATS_Information test_ats_info[2];
-
-/**
- * Test ats count
- */
-uint32_t test_ats_count;
-
-/**
- * Configured WAN out quota
- */
-unsigned long long wan_quota_out;
-
-/**
- * Configured WAN in quota
- */
-unsigned long long wan_quota_in;
-
-
-static void
-end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
- die_task = GNUNET_SCHEDULER_NO_TASK;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Error! Shutting down\n");
- if (sched_ats != NULL)
- {
- GNUNET_ATS_scheduling_done (sched_ats);
- sched_ats = NULL;
- }
- if (perf_ats != NULL)
- {
- GNUNET_ATS_performance_done (perf_ats);
- perf_ats = NULL;
- }
- free_test_address (&test_addr[0]);
- ret = GNUNET_SYSERR;
-}
-
-
-static void
-end ()
-{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down\n");
- if (die_task != GNUNET_SCHEDULER_NO_TASK)
- {
- GNUNET_SCHEDULER_cancel (die_task);
- die_task = GNUNET_SCHEDULER_NO_TASK;
- }
-
- GNUNET_ATS_suggest_address_cancel (sched_ats, &p[0].id);
- GNUNET_ATS_suggest_address_cancel (sched_ats, &p[1].id);
-
- if (NULL != sched_ats)
- GNUNET_ATS_scheduling_done (sched_ats);
- if (NULL != perf_ats)
- GNUNET_ATS_performance_done (perf_ats);
- sched_ats = NULL;
- perf_ats = NULL;
- free_test_address (&test_addr[0]);
- free_test_address (&test_addr[1]);
-}
-
-
-static void
-address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address,
- struct Session *session,
- struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
- struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
- const struct GNUNET_ATS_Information *atsi,
- uint32_t ats_count)
-{
- static int stage = 0;
- static int sug_p0 = GNUNET_NO;
- static int sug_p1 = GNUNET_NO;
-
- static uint32_t p0_last_bandwidth_out;
- static uint32_t p0_last_bandwidth_in;
-
- static uint32_t p1_last_bandwidth_out;
- static uint32_t p1_last_bandwidth_in;
-
- uint32_t cur_bandwidth_out = ntohl (bandwidth_out.value__);
- uint32_t cur_bandwidth_in = ntohl (bandwidth_in.value__);
-
- if (0 == stage)
- {
- /* Callback for initial suggestion */
- if (0 == memcmp (&address->peer, &p[0].id, sizeof (p[0].id)))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Stage %u:
Callback for peer 0 `%s': (in/out) %llu/%llu\n",
- stage,
- GNUNET_i2s (&address->peer),
- ntohl (bandwidth_in.value__),
- ntohl (bandwidth_out.value__));
- sug_p0 = GNUNET_YES;
- p0_last_bandwidth_out =
ntohl(bandwidth_out.value__);
- p0_last_bandwidth_in =
ntohl(bandwidth_in.value__);
- }
- if (0 == memcmp (&address->peer, &p[1].id, sizeof (p[1].id)))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Stage %u:
Callback for peer 1 `%s': (in/out) %llu/%llu\n",
- stage,
- GNUNET_i2s (&address->peer),
- ntohl (bandwidth_in.value__),
- ntohl (bandwidth_out.value__));
- sug_p1 = GNUNET_YES;
- p1_last_bandwidth_out =
ntohl(bandwidth_out.value__);
- p1_last_bandwidth_in =
ntohl(bandwidth_in.value__);
- }
- if ((GNUNET_YES == sug_p0) && (GNUNET_YES == sug_p1))
- {
- /* Changing preference for peer 0 */
- stage ++;
- GNUNET_ATS_performance_change_preference (perf_ats,
&p[0].id, GNUNET_ATS_PREFERENCE_BANDWIDTH,(double) 1000,
GNUNET_ATS_PREFERENCE_END);
- sug_p0 = GNUNET_NO;
- sug_p1 = GNUNET_NO;
- return;
- }
-
- }
- if (1 == stage)
- {
- /* Callback due to preference change */
- if (0 == memcmp (&address->peer, &p[0].id, sizeof (p[0].id)))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Stage %u:
Callback for peer 0 `%s': (in/out) %llu/%llu\n",
- stage,
- GNUNET_i2s (&address->peer),
- ntohl (bandwidth_in.value__),
- ntohl (bandwidth_out.value__));
- sug_p0 = GNUNET_YES;
-
- /* Peer 0 should get more bandwidth */
- if (cur_bandwidth_out <= p0_last_bandwidth_out)
- GNUNET_break (0);
- if (cur_bandwidth_in <= p0_last_bandwidth_in)
- GNUNET_break (0);
- p0_last_bandwidth_out =
ntohl(bandwidth_out.value__);
- p0_last_bandwidth_in =
ntohl(bandwidth_in.value__);
- }
- if (0 == memcmp (&address->peer, &p[1].id, sizeof (p[1].id)))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Stage %u:
Callback for peer 1 `%s': (in/out) %llu/%llu\n",
- stage,
- GNUNET_i2s (&address->peer),
- ntohl (bandwidth_in.value__),
- ntohl (bandwidth_out.value__));
- sug_p1 = GNUNET_YES;
-
- /* Peer 1 should get less bandwidth */
- if (cur_bandwidth_out >= p1_last_bandwidth_out)
- {
- GNUNET_break (0);
- goto error;
- }
- if (cur_bandwidth_in >= p1_last_bandwidth_in)
- {
- GNUNET_break (0);
- goto error;
- }
- p1_last_bandwidth_out =
ntohl(bandwidth_out.value__);
- p1_last_bandwidth_in =
ntohl(bandwidth_in.value__);
- }
- if ((GNUNET_YES == sug_p0) && (GNUNET_YES == sug_p1))
- {
- /* Done ! */
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Done!\n");
- stage ++;
- ret = 0;
- GNUNET_SCHEDULER_add_now (&end,NULL);
- return;
- }
- }
- return;
-
-error:
- /* Error ! */
- ret = 1;
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Error!\n");
- GNUNET_SCHEDULER_add_now (&end,NULL);
-}
-
-static void
-run (void *cls,
- const struct GNUNET_CONFIGURATION_Handle *cfg,
- struct GNUNET_TESTING_Peer *peer)
-{
- char *quota_str;
-
- if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string(cfg, "ats",
"WAN_QUOTA_OUT", "a_str))
- {
- fprintf (stderr, "Cannot load WAN outbound quota from configuration,
exit!\n");
- ret = 1;
- return;
- }
- if (GNUNET_SYSERR == GNUNET_STRINGS_fancy_size_to_bytes (quota_str,
&wan_quota_out))
- {
- fprintf (stderr, "Cannot load WAN outbound quota from configuration,
exit!\n");
- ret = 1;
- GNUNET_free (quota_str);
- return;
- }
- GNUNET_free (quota_str);
- quota_str = NULL;
-
- if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string(cfg, "ats",
"WAN_QUOTA_IN", "a_str))
- {
- fprintf (stderr, "Cannot load WAN inbound quota from configuration,
exit!\n");
- ret = 1;
- return;
- }
- if (GNUNET_SYSERR == GNUNET_STRINGS_fancy_size_to_bytes (quota_str,
&wan_quota_in))
- {
- fprintf (stderr, "Cannot load WAN inbound quota from configuration,
exit!\n");
- GNUNET_free (quota_str);
- ret = 1;
- return;
- }
- GNUNET_free (quota_str);
- quota_str = NULL;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Configured WAN inbound quota: %llu\n",
wan_quota_in);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Configured WAN outbound quota:
%llu\n", wan_quota_out);
-
-
- die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
-
- /* Connect to ATS scheduling */
- sched_ats = GNUNET_ATS_scheduling_init (cfg, &address_suggest_cb, NULL);
- if (sched_ats == NULL)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not connect to ATS
scheduling!\n");
- ret = 1;
- end ();
- return;
- }
-
- /* Connect to ATS performance */
- perf_ats = GNUNET_ATS_performance_init(cfg, NULL, NULL);
- if (sched_ats == NULL)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not connect to ATS
scheduling!\n");
- ret = 1;
- end ();
- return;
- }
-
-
- /* Set up peer 0 */
- if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID0,
&p[0].id.hashPubKey))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n");
- ret = GNUNET_SYSERR;
- end ();
- return;
- }
-
- GNUNET_assert (0 == strcmp (PEERID0, GNUNET_i2s_full (&p[0].id)));
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n",
- GNUNET_i2s(&p[0].id));
-
- /* Set up peer 1*/
- if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID1,
&p[1].id.hashPubKey))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n");
- ret = GNUNET_SYSERR;
- end ();
- return;
- }
-
- GNUNET_assert (0 == strcmp (PEERID1, GNUNET_i2s_full (&p[1].id)));
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n",
- GNUNET_i2s(&p[1].id));
-
- /* Prepare ATS Information */
- test_ats_info[0].type = htonl (GNUNET_ATS_NETWORK_TYPE);
- test_ats_info[0].value = htonl(GNUNET_ATS_NET_WAN);
- test_ats_info[1].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
- test_ats_info[1].value = htonl(1);
- test_ats_count = 2;
-
- /* Peer 0: Adding address with session */
- test_session[0] = &test_addr[0];
- create_test_address (&test_addr[0], "test0", test_session[0], "test0",
strlen ("test0") + 1);
- test_hello_address[0].peer = p[0].id;
- test_hello_address[0].transport_name = test_addr[0].plugin;
- test_hello_address[0].address = test_addr[0].addr;
- test_hello_address[0].address_length = test_addr[0].addr_len;
- GNUNET_ATS_address_add (sched_ats, &test_hello_address[0], test_session[0],
test_ats_info, test_ats_count);
-
- /* Peer 1: Adding address with session */
- test_session[1] = &test_addr[1];
- create_test_address (&test_addr[1], "test1", test_session[1], "test1",
strlen ("test1") + 1);
- test_hello_address[1].peer = p[1].id;
- test_hello_address[1].transport_name = test_addr[1].plugin;
- test_hello_address[1].address = test_addr[1].addr;
- test_hello_address[1].address_length = test_addr[1].addr_len;
- GNUNET_ATS_address_add (sched_ats, &test_hello_address[1], test_session[1],
test_ats_info, test_ats_count);
-
- GNUNET_ATS_suggest_address (sched_ats, &p[0].id);
- GNUNET_ATS_suggest_address (sched_ats, &p[1].id);
-}
-
-
-int
-main (int argc, char *argv[])
-{
- if (0 != GNUNET_TESTING_peer_run ("test_ats_change_preferences",
- "test_ats_api.conf",
- &run, NULL))
- return 1;
- return ret;
-}
-
-
-/* end of file test_ats_change_preferences.c */
Deleted: gnunet/src/ats/test_ats_mlp.c
===================================================================
--- gnunet/src/ats/test_ats_mlp.c 2013-10-28 15:55:43 UTC (rev 30442)
+++ gnunet/src/ats/test_ats_mlp.c 2013-10-28 16:23:43 UTC (rev 30443)
@@ -1,330 +0,0 @@
-/*
- This file is part of GNUnet.
- (C) 2010,2011 Christian Grothoff (and other contributing authors)
-
- GNUnet is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-*/
-/**
- * @file ats/test_ats_mlp.c
- * @brief basic test for the MLP solver
- * @author Christian Grothoff
- * @author Matthias Wachs
-
- */
-#include "platform.h"
-#include "gnunet_util_lib.h"
-#include "gnunet_statistics_service.h"
-#include "gnunet_ats_service.h"
-#include "gnunet-service-ats-solver_mlp.h"
-#include "gnunet-service-ats_normalization.h"
-#include "gnunet_ats_service.h"
-#include "test_ats_api_common.h"
-
-/**
- * Return value
- */
-static int ret;
-
-/**
- * MLP solver handle
- */
-struct GAS_MLP_Handle *mlp;
-
-
-/**
- * Statistics handle
- */
-struct GNUNET_STATISTICS_Handle * stats;
-
-/**
- * Hashmap containing addresses
- */
-struct GNUNET_CONTAINER_MultiHashMap * addresses;
-
-/**
- * Peer
- */
-struct GNUNET_PeerIdentity p[2];
-
-/**
- * ATS Address
- */
-struct ATS_Address *address[3];
-
-/**
- * Timeout task
- */
-GNUNET_SCHEDULER_TaskIdentifier timeout_task;
-
-
-int addr_it (void *cls,
- const struct GNUNET_HashCode * key,
- void *value)
-{
- struct ATS_Address *address = (struct ATS_Address *) value;
- GAS_mlp_address_delete (mlp, address, GNUNET_NO);
- GNUNET_CONTAINER_multihashmap_remove (addresses, key, value);
- GNUNET_free (address);
- return GNUNET_OK;
-}
-
-
-static void
-end_now (int res)
-{
- if (GNUNET_SCHEDULER_NO_TASK != timeout_task)
- {
- GNUNET_SCHEDULER_cancel (timeout_task);
- timeout_task = GNUNET_SCHEDULER_NO_TASK;
- }
- if (NULL != stats)
- {
- GNUNET_STATISTICS_destroy(stats, GNUNET_NO);
- stats = NULL;
- }
- if (NULL != addresses)
- {
- GNUNET_CONTAINER_multihashmap_iterate (addresses, &addr_it,
NULL);
- GNUNET_CONTAINER_multihashmap_destroy (addresses);
- addresses = NULL ;
- }
- if (NULL != mlp)
- {
- GAS_mlp_done (mlp);
- mlp = NULL;
- }
- GAS_normalization_stop ();
- ret = res;
-}
-
-static void
-end_correctly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Test ending with success\n"));
- end_now (0);
-}
-
-static void
-end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
- GNUNET_break (0);
- timeout_task = GNUNET_SCHEDULER_NO_TASK;
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Test ending with timeout\n"));
- end_now (1);
-}
-
-
-const double *
-get_preferences_cb (void *cls, const struct GNUNET_PeerIdentity *id)
-{
- return GAS_normalization_get_preferences (id);
-}
-
-const double *
-get_property_cb (void *cls, const struct ATS_Address *address)
-{
- return GAS_normalization_get_properties ((struct ATS_Address *)
address);
-}
-
-static void
-normalized_property_changed_cb (void *cls,
-
struct ATS_Address *peer,
-
uint32_t type,
-
double prop_rel)
-{
- /* TODO */
-}
-
-
-static void
-bandwidth_changed_cb (void *cls, struct ATS_Address *address)
-{
- static int cb_p0 = GNUNET_NO;
- static int cb_p1 = GNUNET_NO;
-
- unsigned long long in = ntohl(address->assigned_bw_in.value__);
- unsigned long long out = ntohl(address->assigned_bw_out.value__);
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP suggests for peer `%s' address
`%s':`%s' in %llu out %llu \n",
- GNUNET_i2s(&address->peer),
- address->plugin,
- address->addr,
- in, out);
-
- if ((in > 0) && (out > 0) &&
- (0 == memcmp(&p[0], &address->peer, sizeof (address->peer))))
- cb_p0 ++;
-
- if ((in > 0) && (out > 0) &&
- (0 == memcmp(&p[1], &address->peer, sizeof (address->peer))))
- cb_p1 ++;
-
- if ((1 == cb_p0) && (1 == cb_p1))
- GNUNET_SCHEDULER_add_now (&end_correctly, NULL);
- else if ((1 < cb_p0) || (1 < cb_p1))
- {
- GNUNET_break (0);
- GNUNET_SCHEDULER_add_now (&end_badly, NULL);
- }
-}
-
-
-static void
-check (void *cls, char *const *args, const char *cfgfile,
- const struct GNUNET_CONFIGURATION_Handle *cfg)
-{
- int quotas[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkType;
- unsigned long long quotas_in[GNUNET_ATS_NetworkTypeCount];
- unsigned long long quotas_out[GNUNET_ATS_NetworkTypeCount];
-
-#if !HAVE_LIBGLPK
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "GLPK not installed!");
- ret = 1;
- return;
-#endif
-
- timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
-
- stats = GNUNET_STATISTICS_create("ats", cfg);
- if (NULL == stats)
- {
- GNUNET_break (0);
- end_now (1);
- return;
- }
-
- /* Load quotas */
- if (GNUNET_ATS_NetworkTypeCount != load_quotas (cfg, quotas_out, quotas_in,
- GNUNET_ATS_NetworkTypeCount))
- {
- GNUNET_break (0);
- end_now (1);
- return;
- }
- GAS_normalization_start (NULL, NULL, &normalized_property_changed_cb, NULL);
- /* Setup address hashmap */
- addresses = GNUNET_CONTAINER_multihashmap_create (10, GNUNET_NO);
-
- /* Init MLP solver */
- mlp = GAS_mlp_init (cfg, stats, addresses,
- quotas, quotas_out, quotas_in,
- GNUNET_ATS_NetworkTypeCount,
- &bandwidth_changed_cb, NULL,
- &get_preferences_cb, NULL,
- &get_property_cb, NULL);
- if (NULL == mlp)
- {
- GNUNET_break (0);
- end_now (1);
- return;
- }
- mlp->mlp_auto_solve = GNUNET_NO;
-
- /* Create peer 0 */
- if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID0,
&p[0].hashPubKey))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n");
- end_now (1);
- return;
- }
-
- /* Create peer 1 */
- if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID1,
&p[1].hashPubKey))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n");
- end_now (1);
- return;
- }
-
- /* Create address 0 */
- address[0] = create_address (&p[0], "test_plugin0", "test_addr0",
strlen("test_addr0")+1, 0);
- if (NULL == address[0])
- {
- GNUNET_break (0);
- end_now (1);
- return;
- }
- GNUNET_CONTAINER_multihashmap_put (addresses, &p[0].hashPubKey, address[0],
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
- /* Adding address 0 */
- GAS_mlp_address_add (mlp, address[0], GNUNET_ATS_NET_UNSPECIFIED);
-
- /* Create address 1 */
- address[1] = create_address (&p[0], "test_plugin1", "test_addr1",
strlen("test_addr1")+1, 0);
- if (NULL == address[1])
- {
- GNUNET_break (0);
- end_now (1);
- return;
- }
- GNUNET_CONTAINER_multihashmap_put (addresses, &p[0].hashPubKey, address[1],
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
- /* Adding address 1*/
- GAS_mlp_address_add (mlp, address[1], GNUNET_ATS_NET_UNSPECIFIED);
-
-
- /* Create address 3 */
- address[2] = create_address (&p[1], "test_plugin2", "test_addr2",
strlen("test_addr2")+1, 0);
- if (NULL == address[2])
- {
- GNUNET_break (0);
- end_now (1);
- return;
- }
- GNUNET_CONTAINER_multihashmap_put (addresses, &p[1].hashPubKey, address[2],
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
- /* Adding address 3*/
- GAS_mlp_address_add (mlp, address[2], GNUNET_ATS_NET_UNSPECIFIED);
-
-
- /* Updating address 0*/
- GAS_mlp_address_change_network(mlp, address[0], GNUNET_ATS_NET_UNSPECIFIED,
GNUNET_ATS_NET_WAN);
-
- /* Retrieving preferred address for peer and wait for callback */
- GAS_mlp_get_preferred_address (mlp, &p[0]);
- GAS_mlp_get_preferred_address (mlp, &p[1]);
-
- mlp->write_mip_mps = GNUNET_NO;
- mlp->write_mip_sol = GNUNET_NO;
-
- GAS_mlp_solve_problem (mlp);
-}
-
-
-int
-main (int argc, char *argv[])
-{
-
- static char *const argv2[] = { "test_ats_mlp",
- "-c",
- "test_ats_mlp.conf",
- "-L", "WARNING",
- NULL
- };
-
- static struct GNUNET_GETOPT_CommandLineOption options[] = {
- GNUNET_GETOPT_OPTION_END
- };
-
- GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2,
- "test_ats_mlp", "nohelp", options,
- &check, NULL);
-
-
- return ret;
-}
-
-/* end of file test_ats_api_bandwidth_consumption.c */
Deleted: gnunet/src/ats/test_ats_mlp_update.c
===================================================================
--- gnunet/src/ats/test_ats_mlp_update.c 2013-10-28 15:55:43 UTC (rev
30442)
+++ gnunet/src/ats/test_ats_mlp_update.c 2013-10-28 16:23:43 UTC (rev
30443)
@@ -1,312 +0,0 @@
-/*
- This file is part of GNUnet.
- (C) 2010,2011 Christian Grothoff (and other contributing authors)
-
- GNUnet is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-*/
-/**
- * @file ats/test_ats_mlp_updating.c
- * @brief basic test for updating ATS in MLP solver
- * @author Christian Grothoff
- * @author Matthias Wachs
-
- */
-#include "platform.h"
-#include "gnunet_util_lib.h"
-#include "gnunet_statistics_service.h"
-#include "gnunet_ats_service.h"
-#include "gnunet-service-ats-solver_mlp.h"
-#include "gnunet-service-ats_normalization.h"
-#include "test_ats_api_common.h"
-
-/**
- * Return value
- */
-static int ret;
-
-/**
- * ATS Information
- */
-struct GNUNET_ATS_Information ats[4];
-
-struct GNUNET_ATS_Information ats_prev[4];
-
-/**
- * MLP solver handle
- */
-struct GAS_MLP_Handle *mlp;
-
-
-/**
- * Statistics handle
- */
-struct GNUNET_STATISTICS_Handle * stats;
-
-/**
- * Hashmap containing addresses
- */
-struct GNUNET_CONTAINER_MultiHashMap * addresses;
-
-/**
- * Peer
- */
-struct GNUNET_PeerIdentity p[2];
-
-/**
- * ATS Address
- */
-struct ATS_Address *address[3];
-
-/**
- * Timeout task
- */
-GNUNET_SCHEDULER_TaskIdentifier timeout_task;
-
-
-int addr_it (void *cls,
- const struct GNUNET_HashCode * key,
- void *value)
-{
- struct ATS_Address *address = (struct ATS_Address *) value;
- GAS_mlp_address_delete (mlp, address, GNUNET_NO);
- GNUNET_CONTAINER_multihashmap_remove (addresses, key, value);
- GNUNET_free (address);
- return GNUNET_OK;
-}
-
-
-static void
-end_now (int res)
-{
- if (GNUNET_SCHEDULER_NO_TASK != timeout_task)
- {
- GNUNET_SCHEDULER_cancel (timeout_task);
- timeout_task = GNUNET_SCHEDULER_NO_TASK;
- }
- if (NULL != stats)
- {
- GNUNET_STATISTICS_destroy(stats, GNUNET_NO);
- stats = NULL;
- }
- if (NULL != addresses)
- {
- GNUNET_CONTAINER_multihashmap_iterate (addresses, &addr_it,
NULL);
- GNUNET_CONTAINER_multihashmap_destroy (addresses);
- addresses = NULL ;
- }
- if (NULL != mlp)
- {
- GAS_mlp_done (mlp);
- mlp = NULL;
- }
- GAS_normalization_stop ();
-
- ret = res;
-}
-
-static void
-end_correctly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Test ending with success\n"));
- end_now (0);
-}
-
-static void
-end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
- GNUNET_break (0);
- timeout_task = GNUNET_SCHEDULER_NO_TASK;
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Test ending with timeout\n"));
- end_now (1);
-}
-
-static const double *
-get_preferences_cb (void *cls, const struct GNUNET_PeerIdentity *id)
-{
- return GAS_normalization_get_preferences (id);
-}
-
-const double *
-get_property_cb (void *cls, const struct ATS_Address *address)
-{
- return GAS_normalization_get_properties ((struct ATS_Address *)
address);
-}
-
-static void
-normalized_property_changed_cb (void *cls,
-
struct ATS_Address *peer,
-
uint32_t type,
-
double prop_rel)
-{
- /* TODO */
-}
-
-
-static void
-bandwidth_changed_cb (void *cls, struct ATS_Address *address)
-{
- static int cb_p0 = GNUNET_NO;
-
- unsigned long long in = ntohl(address->assigned_bw_in.value__);
- unsigned long long out = ntohl(address->assigned_bw_out.value__);
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP suggests for peer `%s' address
`%s':`%s' in %llu out %llu \n",
- GNUNET_i2s(&address->peer),
- address->plugin,
- address->addr,
- in, out);
-
- if ((in > 0) && (out > 0) &&
- (0 == memcmp(&p[0], &address->peer, sizeof (address->peer))))
- cb_p0 ++;
-
- if (1 == cb_p0)
- GNUNET_SCHEDULER_add_now (&end_correctly, NULL);
-}
-
-
-static void
-check (void *cls, char *const *args, const char *cfgfile,
- const struct GNUNET_CONFIGURATION_Handle *cfg)
-{
- int quotas[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkType;
- unsigned long long quotas_in[GNUNET_ATS_NetworkTypeCount];
- unsigned long long quotas_out[GNUNET_ATS_NetworkTypeCount];
-
-#if !HAVE_LIBGLPK
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "GLPK not installed!");
- ret = 1;
- return;
-#endif
-
- timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
-
- stats = GNUNET_STATISTICS_create("ats", cfg);
- if (NULL == stats)
- {
- GNUNET_break (0);
- end_now (1);
- return;
- }
-
- /* Load quotas */
- if (GNUNET_ATS_NetworkTypeCount != load_quotas (cfg, quotas_out, quotas_in,
- GNUNET_ATS_NetworkTypeCount))
- {
- GNUNET_break (0);
- end_now (1);
- return;
- }
- GAS_normalization_start (NULL, NULL, &normalized_property_changed_cb, NULL);
-
- /* Setup address hashmap */
- addresses = GNUNET_CONTAINER_multihashmap_create (10, GNUNET_NO);
-
- /* Init MLP solver */
- mlp = GAS_mlp_init (cfg, stats, addresses,
- quotas, quotas_out, quotas_in,
- GNUNET_ATS_NetworkTypeCount,
- &bandwidth_changed_cb, NULL,
- &get_preferences_cb, NULL,
- &get_property_cb, NULL);
- if (NULL == mlp)
- {
- GNUNET_break (0);
- end_now (1);
- return;
- }
- mlp->mlp_auto_solve = GNUNET_NO;
-
- /* Create peer 0 */
- if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID0,
&p[0].hashPubKey))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n");
- end_now (1);
- return;
- }
-
- /* Create address 0 */
- address[0] = create_address (&p[0], "test_plugin0", "test_addr0",
strlen("test_addr0")+1, 0);
- if (NULL == address[0])
- {
- GNUNET_break (0);
- end_now (1);
- return;
- }
- GNUNET_CONTAINER_multihashmap_put (addresses, &p[0].hashPubKey, address[0],
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
- /* Adding address 0 */
- GAS_mlp_address_add (mlp, address[0], GNUNET_ATS_NET_UNSPECIFIED);
-
- /* Retrieving preferred address for peer and wait for callback */
- GAS_mlp_get_preferred_address (mlp, &p[0]);
-
- /* Solve problem to build matrix */
- GAS_mlp_solve_problem (mlp);
-
- address[0]->atsi = ats;
- address[0]->atsi_count = 4;
- /* Updating address 0*/
- ats[0].type = htonl (GNUNET_ATS_NETWORK_TYPE);
- ats[0].value = htonl (GNUNET_ATS_NET_WAN);
- ats[1].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY);
- ats[1].value = htonl (10);
- ats[2].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
- ats[2].value = htonl (1);
- ats[3].type = htonl (GNUNET_ATS_ARRAY_TERMINATOR);
- ats[3].value = htonl (GNUNET_ATS_ARRAY_TERMINATOR);
-
- ats_prev[0].type = htonl (GNUNET_ATS_NETWORK_TYPE);
- ats_prev[0].value = htonl (GNUNET_ATS_NET_UNSPECIFIED);
- ats_prev[1].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY);
- ats_prev[1].value = htonl (GNUNET_ATS_VALUE_UNDEFINED);
- ats_prev[2].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
- ats_prev[2].value = htonl (GNUNET_ATS_VALUE_UNDEFINED);
- ats_prev[3].type = htonl (GNUNET_ATS_ARRAY_TERMINATOR);
- ats_prev[3].value = htonl (GNUNET_ATS_VALUE_UNDEFINED);
-
- GAS_mlp_address_property_changed(mlp, address[0],
GNUNET_ATS_QUALITY_NET_DELAY, 10, 1.1);
- GAS_mlp_address_property_changed(mlp, address[0],
GNUNET_ATS_QUALITY_NET_DISTANCE, 1, 1.0);
-
- /* Solve problem to build matrix */
- GAS_mlp_solve_problem (mlp);
-}
-
-
-int
-main (int argc, char *argv[])
-{
-
- static char *const argv2[] = { "test_ats_mlp_updating",
- "-c",
- "test_ats_mlp.conf",
- "-L", "WARNING",
- NULL
- };
-
- static struct GNUNET_GETOPT_CommandLineOption options[] = {
- GNUNET_GETOPT_OPTION_END
- };
-
- GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2,
- "test_ats_mlp_updating", "nohelp", options,
- &check, NULL);
-
-
- return ret;
-}
-
-/* end of file test_ats_mlp_updating.c */
Deleted: gnunet/src/ats/test_ats_normalization_update_quality.c
===================================================================
--- gnunet/src/ats/test_ats_normalization_update_quality.c 2013-10-28
15:55:43 UTC (rev 30442)
+++ gnunet/src/ats/test_ats_normalization_update_quality.c 2013-10-28
16:23:43 UTC (rev 30443)
@@ -1,241 +0,0 @@
-/*
- This file is part of GNUnet.
- (C) 2010,2011 Christian Grothoff (and other contributing authors)
-
- GNUnet is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-*/
-/**
- * @file ats/test_ats_normalization_update_quality.c
- * @brief test updating an address
- * @author Christian Grothoff
- * @author Matthias Wachs
- */
-#include "platform.h"
-#include "gnunet_ats_service.h"
-#include "gnunet_testing_lib.h"
-#include "ats.h"
-#include "test_ats_api_common.h"
-
-static GNUNET_SCHEDULER_TaskIdentifier die_task;
-
-/**
- * Scheduling handle
- */
-static struct GNUNET_ATS_SchedulingHandle *sched_ats;
-
-/**
- * Return value
- */
-static int ret;
-
-/**
- * Test address
- */
-static struct Test_Address test_addr[3];
-
-/**
- * Test peer
- */
-static struct PeerContext p[2];
-
-/**
- * HELLO test address
- */
-
-struct GNUNET_HELLO_Address test_hello_address[3];
-
-/**
- * Test ats info
- */
-struct GNUNET_ATS_Information test_ats_info[3];
-
-/**
- * Test ats count
- */
-uint32_t test_ats_count;
-
-
-static void
-end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
- die_task = GNUNET_SCHEDULER_NO_TASK;
-
- if (sched_ats != NULL)
- GNUNET_ATS_scheduling_done (sched_ats);
- free_test_address (&test_addr[0]);
- free_test_address (&test_addr[1]);
- free_test_address (&test_addr[2]);
- ret = 0;
-}
-
-
-static void
-end ()
-{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down\n");
- if (die_task != GNUNET_SCHEDULER_NO_TASK)
- {
- GNUNET_SCHEDULER_cancel (die_task);
- die_task = GNUNET_SCHEDULER_NO_TASK;
- }
- GNUNET_ATS_scheduling_done (sched_ats);
- sched_ats = NULL;
- free_test_address (&test_addr[0]);
- free_test_address (&test_addr[1]);
- free_test_address (&test_addr[2]);
-}
-
-
-static void
-address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address,
- struct Session *session,
- struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
- struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
- const struct GNUNET_ATS_Information *atsi,
- uint32_t ats_count)
-{
- static int stage = 0;
- if (0 == stage)
- {
- GNUNET_ATS_suggest_address_cancel (sched_ats, &p[0].id);
-
- /* Update address */
- /* Prepare ATS Information */
-
- test_ats_info[0].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY);
- test_ats_info[0].value = htonl(20);
- test_ats_count = 1;
-
- GNUNET_ATS_address_update (sched_ats, &test_hello_address[0], NULL,
test_ats_info, test_ats_count);
-
- test_ats_info[0].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY);
- test_ats_info[0].value = htonl(20);
- test_ats_count = 1;
-
- GNUNET_ATS_address_update (sched_ats, &test_hello_address[0], NULL,
test_ats_info, test_ats_count);
-
-
- /* Request address */
- stage ++;
- }
-}
-
-static void
-run (void *cls,
- const struct GNUNET_CONFIGURATION_Handle *cfg,
- struct GNUNET_TESTING_Peer *peer)
-{
- die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
-
- /* Connect to ATS scheduling */
- sched_ats = GNUNET_ATS_scheduling_init (cfg, &address_suggest_cb, NULL);
- if (sched_ats == NULL)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not connect to ATS
scheduling!\n");
- ret = 1;
- end ();
- return;
- }
-
- /* Set up peer */
- if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID0,
&p[0].id.hashPubKey))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n");
- ret = GNUNET_SYSERR;
- end ();
- return;
- }
-
- GNUNET_assert (0 == strcmp (PEERID0, GNUNET_i2s_full (&p[0].id)));
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n",
- GNUNET_i2s_full(&p[0].id));
-
- /* Set up peer */
- if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID1,
&p[1].id.hashPubKey))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n");
- ret = GNUNET_SYSERR;
- end ();
- return;
- }
-
- GNUNET_assert (0 == strcmp (PEERID1, GNUNET_i2s_full (&p[1].id)));
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n",
- GNUNET_i2s_full(&p[1].id));
-
-
-
- /* Adding address for peer 0 */
- create_test_address (&test_addr[0], "test", &test_addr, "test_p0_a0", strlen
("test_p0_a0") + 1);
- /* Prepare ATS Information */
- test_ats_info[0].type = htonl (GNUNET_ATS_NETWORK_TYPE);
- test_ats_info[0].value = htonl(GNUNET_ATS_NET_WAN);
- test_ats_info[1].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY);
- test_ats_info[1].value = htonl(30);
- test_ats_count = 2;
-
- test_hello_address[0].peer = p[0].id;
- test_hello_address[0].transport_name = test_addr[0].plugin;
- test_hello_address[0].address = test_addr[0].addr;
- test_hello_address[0].address_length = test_addr[0].addr_len;
- GNUNET_ATS_address_add (sched_ats, &test_hello_address[0], NULL,
test_ats_info, test_ats_count);
-
- /* Adding address for peer 1 */
- create_test_address (&test_addr[1], "test", &test_addr, "test_p1_a0", strlen
("test_p1_a0") + 1);
- test_ats_info[0].type = htonl (GNUNET_ATS_NETWORK_TYPE);
- test_ats_info[0].value = htonl(GNUNET_ATS_NET_WAN);
- test_ats_info[1].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY);
- test_ats_info[1].value = htonl(10);
- test_ats_count = 2;
-
- test_hello_address[1].peer = p[1].id;
- test_hello_address[1].transport_name = test_addr[1].plugin;
- test_hello_address[1].address = test_addr[1].addr;
- test_hello_address[1].address_length = test_addr[1].addr_len;
- GNUNET_ATS_address_add (sched_ats, &test_hello_address[1], NULL,
test_ats_info, test_ats_count);
-
- /* Adding 2nd address for peer 1 */
- test_ats_info[0].type = htonl (GNUNET_ATS_NETWORK_TYPE);
- test_ats_info[0].value = htonl(GNUNET_ATS_NET_WAN);
- test_ats_info[1].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY);
- test_ats_info[1].value = htonl(20);
- test_ats_count = 2;
-
- create_test_address (&test_addr[2], "test", &test_addr, "test_p1_a1", strlen
("test_p1_a1") + 1);
- test_hello_address[2].peer = p[1].id;
- test_hello_address[2].transport_name = test_addr[2].plugin;
- test_hello_address[2].address = test_addr[2].addr;
- test_hello_address[2].address_length = test_addr[2].addr_len;
- GNUNET_ATS_address_add (sched_ats, &test_hello_address[2], NULL,
test_ats_info, test_ats_count);
-
- /* Request address */
- GNUNET_ATS_suggest_address (sched_ats, &p[0].id);
-}
-
-
-int
-main (int argc, char *argv[])
-{
- if (0 != GNUNET_TESTING_peer_run ("test_ats_normalization_update_quality",
- "test_ats_api.conf",
- &run, NULL))
- return 1;
- return ret;
-}
-
-/* end of file test_ats_normalization_update_quality.c*/
Deleted: gnunet/src/ats/test_ats_simplistic.c
===================================================================
--- gnunet/src/ats/test_ats_simplistic.c 2013-10-28 15:55:43 UTC (rev
30442)
+++ gnunet/src/ats/test_ats_simplistic.c 2013-10-28 16:23:43 UTC (rev
30443)
@@ -1,380 +0,0 @@
-/*
- This file is part of GNUnet.
- (C) 2010,2011 Christian Grothoff (and other contributing authors)
-
- GNUnet is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-*/
-/**
- * @file ats/test_ats_mlp.c
- * @brief test for the MLP solver
- * @author Christian Grothoff
- * @author Matthias Wachs
-
- */
-/**
- * @file ats/test_ats_api_scheduling_add_address.c
- * @brief test for ats simplistic solver
- * @author Christian Grothoff
- * @author Matthias Wachs
- */
-#include "platform.h"
-#include "gnunet_ats_service.h"
-#include "gnunet_testing_lib.h"
-#include "ats.h"
-#include "test_ats_api_common.h"
-
-#define DEBUG_ATS_INFO GNUNET_NO
-
-static GNUNET_SCHEDULER_TaskIdentifier die_task;
-
-/**
- * Scheduling handle
- */
-static struct GNUNET_ATS_SchedulingHandle *sched_ats;
-
-/**
- * Return value
- */
-static int ret;
-
-/**
- * Test address
- */
-static struct Test_Address test_addr[2];
-
-/**
- * Test peer
- */
-static struct PeerContext p[2];
-
-
-/**
- * HELLO address
- */
-struct GNUNET_HELLO_Address test_hello_address[2];
-
-/**
- * Session
- */
-static void *test_session[2];
-
-/**
- * Test ats info
- */
-struct GNUNET_ATS_Information test_ats_info[2];
-
-/**
- * Test ats count
- */
-uint32_t test_ats_count;
-
-/**
- * Configured WAN out quota
- */
-unsigned long long wan_quota_out;
-
-/**
- * Configured WAN in quota
- */
-unsigned long long wan_quota_in;
-
-
-static void
-end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
- die_task = GNUNET_SCHEDULER_NO_TASK;
-
- if (sched_ats != NULL)
- GNUNET_ATS_scheduling_done (sched_ats);
- free_test_address (&test_addr[0]);
- ret = GNUNET_SYSERR;
-}
-
-
-static void
-end ()
-{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down\n");
- if (die_task != GNUNET_SCHEDULER_NO_TASK)
- {
- GNUNET_SCHEDULER_cancel (die_task);
- die_task = GNUNET_SCHEDULER_NO_TASK;
- }
- GNUNET_ATS_scheduling_done (sched_ats);
- sched_ats = NULL;
- free_test_address (&test_addr[0]);
-}
-
-
-static void
-address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address,
- struct Session *session,
- struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
- struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
- const struct GNUNET_ATS_Information *atsi,
- uint32_t ats_count)
-{
- static int stage = 0;
- unsigned int bw_in = ntohl(bandwidth_in.value__);
- unsigned int bw_out = ntohl(bandwidth_out.value__);
- if (0 == stage)
- {
- if (GNUNET_OK == compare_addresses (address, session,
&test_hello_address[0], test_session[0]))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage 0: Callback with correct
address `%s'\n",
- GNUNET_i2s (&address->peer));
- ret = 0;
- }
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage 0: Callback with invalid
address `%s'\n",
- GNUNET_i2s (&address->peer));
- ret = 1;
- }
-
- if (GNUNET_OK != compare_ats(atsi, ats_count, test_ats_info,
test_ats_count))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage 0: Callback with incorrect
ats info \n");
- ret = 1;
- }
-
- if (bw_in > wan_quota_in)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Suggested WAN inbound quota %u
bigger than allowed quota %llu \n",
- bw_in, wan_quota_in);
- ret = 1;
- }
- else
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Suggested WAN inbound quota %u,
allowed quota %llu \n",
- bw_in, wan_quota_in);
-
- if (bw_out > wan_quota_out)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Suggested WAN outbound quota %u
bigger than allowed quota %llu \n",
- bw_out, wan_quota_out);
- ret = 1;
- }
- else
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Suggested WAN outbound quota %u,
allowed quota %llu \n",
- bw_out, wan_quota_out);
-
- if (1 == ret)
- {
- GNUNET_ATS_suggest_address_cancel (sched_ats, &p[0].id);
- GNUNET_SCHEDULER_add_now (&end, NULL);
- return;
- }
- p[0].bw_out_assigned = bw_out;
- p[0].bw_in_assigned = bw_in;
- stage ++;
-
- /* Add a 2nd address */
- /* Prepare ATS Information */
- test_ats_info[0].type = htonl (GNUNET_ATS_NETWORK_TYPE);
- test_ats_info[0].value = htonl(GNUNET_ATS_NET_WAN);
- test_ats_info[1].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
- test_ats_info[1].value = htonl(1);
- test_ats_count = 2;
-
- /* Adding address with session */
- test_session[1] = &test_addr[1];
- create_test_address (&test_addr[1], "test1", test_session[1], "test1",
strlen ("test1") + 1);
- test_hello_address[1].peer = p[1].id;
- test_hello_address[1].transport_name = test_addr[1].plugin;
- test_hello_address[1].address = test_addr[1].addr;
- test_hello_address[1].address_length = test_addr[1].addr_len;
- GNUNET_ATS_address_add (sched_ats, &test_hello_address[1],
test_session[1], test_ats_info, test_ats_count);
- }
- if (1 == stage)
- {
- /* Expecting callback for address[0] with updated quota and no callback
for address[1]*/
- if (GNUNET_OK == compare_addresses (address, session,
&test_hello_address[0], test_session[0]))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage 1: Callback with correct
address `%s'\n",
- GNUNET_i2s (&address->peer));
- ret = 0;
- }
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage 1: Callback with invalid
address `%s'\n",
- GNUNET_i2s (&address->peer));
- ret = 1;
- }
-
- if (GNUNET_OK != compare_ats(atsi, ats_count, test_ats_info,
test_ats_count))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage 1: Callback with incorrect
ats info \n");
- ret = 1;
- }
-
- if (bw_in > wan_quota_in)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Suggested WAN inbound quota %u
bigger than allowed quota %llu \n",
- bw_in, wan_quota_in);
- ret = 1;
- }
- else if (p[0].bw_in_assigned > bw_in)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Suggested WAN inbound quota %u
bigger than last quota %llu \n",
- bw_in, p[0].bw_in_assigned);
- ret = 1;
- }
- else
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Suggested WAN inbound quota %u,
allowed quota %llu \n",
- bw_in, wan_quota_in);
-
- if (bw_out > wan_quota_out)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Suggested WAN outbound quota
%u bigger than allowed quota %llu \n",
- bw_out, wan_quota_out);
- ret = 1;
- }
- else if (p[0].bw_out_assigned > bw_out)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Suggested WAN inbound quota %u
bigger than last quota %llu \n",
- bw_out, p[0].bw_out_assigned);
- ret = 1;
- }
- else
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Suggested WAN outbound quota %u,
allowed quota %llu \n",
- bw_out, wan_quota_out);
-
- if (1 == ret)
- {
- GNUNET_SCHEDULER_add_now (&end, NULL);
- return;
- }
- stage ++;
- GNUNET_SCHEDULER_add_now (&end, NULL);
- return;
- }
-
-}
-
-static void
-run (void *cls,
- const struct GNUNET_CONFIGURATION_Handle *cfg,
- struct GNUNET_TESTING_Peer *peer)
-{
- char *quota_str;
-
- if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string(cfg, "ats",
"WAN_QUOTA_OUT", "a_str))
- {
- fprintf (stderr, "Cannot load WAN outbound quota from configuration,
exit!\n");
- ret = 1;
- return;
- }
- if (GNUNET_SYSERR == GNUNET_STRINGS_fancy_size_to_bytes (quota_str,
&wan_quota_out))
- {
- fprintf (stderr, "Cannot load WAN outbound quota from configuration,
exit!\n");
- ret = 1;
- GNUNET_free (quota_str);
- return;
- }
- GNUNET_free (quota_str);
- quota_str = NULL;
-
- if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string(cfg, "ats",
"WAN_QUOTA_IN", "a_str))
- {
- fprintf (stderr, "Cannot load WAN inbound quota from configuration,
exit!\n");
- ret = 1;
- return;
- }
- if (GNUNET_SYSERR == GNUNET_STRINGS_fancy_size_to_bytes (quota_str,
&wan_quota_in))
- {
- fprintf (stderr, "Cannot load WAN inbound quota from configuration,
exit!\n");
- GNUNET_free (quota_str);
- ret = 1;
- return;
- }
- GNUNET_free (quota_str);
- quota_str = NULL;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Configured WAN inbound quota: %llu\n",
wan_quota_in);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Configured WAN outbound quota:
%llu\n", wan_quota_out);
-
-
- die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
-
- /* Connect to ATS scheduling */
- sched_ats = GNUNET_ATS_scheduling_init (cfg, &address_suggest_cb, NULL);
- if (sched_ats == NULL)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not connect to ATS
scheduling!\n");
- ret = 1;
- end ();
- return;
- }
-
- /* Set up peer 0 */
- if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID0,
&p[0].id.hashPubKey))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n");
- ret = GNUNET_SYSERR;
- end ();
- return;
- }
-
- GNUNET_assert (0 == strcmp (PEERID0, GNUNET_i2s_full (&p[0].id)));
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n",
- GNUNET_i2s(&p[0].id));
-
- /* Set up peer 1*/
- if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID1,
&p[1].id.hashPubKey))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n");
- ret = GNUNET_SYSERR;
- end ();
- return;
- }
-
- GNUNET_assert (0 == strcmp (PEERID1, GNUNET_i2s_full (&p[1].id)));
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n",
- GNUNET_i2s(&p[1].id));
-
- /* Prepare ATS Information */
- test_ats_info[0].type = htonl (GNUNET_ATS_NETWORK_TYPE);
- test_ats_info[0].value = htonl(GNUNET_ATS_NET_WAN);
- test_ats_info[1].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
- test_ats_info[1].value = htonl(1);
- test_ats_count = 2;
-
- /* Adding address with session */
- test_session[0] = &test_addr[0];
- create_test_address (&test_addr[0], "test0", test_session[0], "test0",
strlen ("test0") + 1);
- test_hello_address[0].peer = p[0].id;
- test_hello_address[0].transport_name = test_addr[0].plugin;
- test_hello_address[0].address = test_addr[0].addr;
- test_hello_address[0].address_length = test_addr[0].addr_len;
- GNUNET_ATS_address_add (sched_ats, &test_hello_address[0], test_session[0],
test_ats_info, test_ats_count);
-
- GNUNET_ATS_suggest_address (sched_ats, &p[0].id);
-}
-
-
-int
-main (int argc, char *argv[])
-{
- if (0 != GNUNET_TESTING_peer_run ("test_ats_simplististic",
- "test_ats_api.conf",
- &run, NULL))
- return 1;
- return ret;
-}
-
-
-/* end of file test_ats_api_bandwidth_consumption.c */
Deleted: gnunet/src/ats/test_ats_simplistic_change_preference.c
===================================================================
--- gnunet/src/ats/test_ats_simplistic_change_preference.c 2013-10-28
15:55:43 UTC (rev 30442)
+++ gnunet/src/ats/test_ats_simplistic_change_preference.c 2013-10-28
16:23:43 UTC (rev 30443)
@@ -1,418 +0,0 @@
-/*
- This file is part of GNUnet.
- (C) 2010,2011 Christian Grothoff (and other contributing authors)
-
- GNUnet is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-*/
-/**
- * @file ats/test_ats_mlp.c
- * @brief test for the MLP solver
- * @author Christian Grothoff
- * @author Matthias Wachs
-
- */
-/**
- * @file ats/test_ats_simplistic_change_preference.c
- * @brief test for changing preferences in ats proportional solver
- * @author Christian Grothoff
- * @author Matthias Wachs
- */
-#include "platform.h"
-#include "gnunet_ats_service.h"
-#include "gnunet_testing_lib.h"
-#include "ats.h"
-#include "test_ats_api_common.h"
-
-#define DEBUG_ATS_INFO GNUNET_NO
-
-#define SLEEP GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
-
-static GNUNET_SCHEDULER_TaskIdentifier die_task;
-
-/**
- * Scheduling handle
- */
-static struct GNUNET_ATS_SchedulingHandle *sched_ats;
-
-/**
- * Scheduling handle
- */
-static struct GNUNET_ATS_PerformanceHandle *perf_ats;
-
-
-/**
- * Return value
- */
-static int ret;
-
-/**
- * Test address
- */
-static struct Test_Address test_addr[2];
-
-/**
- * Test peer
- */
-static struct PeerContext p[2];
-
-
-/**
- * HELLO address
- */
-struct GNUNET_HELLO_Address test_hello_address[2];
-
-/**
- * Session
- */
-static void *test_session[2];
-
-/**
- * Test ats info
- */
-struct GNUNET_ATS_Information test_ats_info[2];
-
-/**
- * Test ats count
- */
-uint32_t test_ats_count;
-
-/**
- * Configured WAN out quota
- */
-unsigned long long wan_quota_out;
-
-/**
- * Configured WAN in quota
- */
-unsigned long long wan_quota_in;
-
-
-static void
-end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
- die_task = GNUNET_SCHEDULER_NO_TASK;
-
- if (sched_ats != NULL)
- GNUNET_ATS_scheduling_done (sched_ats);
- if (perf_ats != NULL)
- GNUNET_ATS_performance_done (perf_ats);
- free_test_address (&test_addr[0]);
- ret = GNUNET_SYSERR;
-}
-
-
-static void
-end ()
-{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down\n");
- if (die_task != GNUNET_SCHEDULER_NO_TASK)
- {
- GNUNET_SCHEDULER_cancel (die_task);
- die_task = GNUNET_SCHEDULER_NO_TASK;
- }
- GNUNET_ATS_performance_done (perf_ats);
- perf_ats = NULL;
- GNUNET_ATS_scheduling_done (sched_ats);
- sched_ats = NULL;
- free_test_address (&test_addr[0]);
-}
-
-
-static void
-address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address,
- struct Session *session,
- struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
- struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
- const struct GNUNET_ATS_Information *atsi,
- uint32_t ats_count)
-{
- static int stage = 0;
- unsigned int bw_in = ntohl(bandwidth_in.value__);
- unsigned int bw_out = ntohl(bandwidth_out.value__);
- if (0 == stage)
- {
- if (GNUNET_OK == compare_addresses (address, session,
&test_hello_address[0], test_session[0]))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Callback with correct
address `%s'\n",
- stage,
- GNUNET_i2s (&address->peer));
- ret = 0;
- }
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Callback with invalid
address `%s'\n",
- stage,
- GNUNET_i2s (&address->peer));
- ret = 1;
- }
-
- if (GNUNET_OK != compare_ats(atsi, ats_count, test_ats_info,
test_ats_count))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback with incorrect
ats info \n",
- stage);
- ret = 1;
- }
-
- if (bw_in > wan_quota_in)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Suggested WAN inbound quota %u
bigger than allowed quota %llu \n",
- bw_in, wan_quota_in);
- ret = 1;
- }
- else
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Suggested WAN inbound quota %u,
allowed quota %llu \n",
- bw_in, wan_quota_in);
-
- if (bw_out > wan_quota_out)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Suggested WAN outbound quota %u
bigger than allowed quota %llu \n",
- bw_out, wan_quota_out);
- ret = 1;
- }
- else
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Suggested WAN outbound quota %u,
allowed quota %llu \n",
- bw_out, wan_quota_out);
-
- if (1 == ret)
- {
- GNUNET_ATS_suggest_address_cancel (sched_ats, &p[0].id);
- GNUNET_SCHEDULER_add_now (&end, NULL);
- return;
- }
-
- stage ++;
-
- GNUNET_ATS_suggest_address_cancel (sched_ats, &p[0].id);
- GNUNET_ATS_suggest_address (sched_ats, &p[1].id);
- return;
- }
- if (1 == stage)
- {
- if (GNUNET_OK == compare_addresses (address, session,
&test_hello_address[1], test_session[1]))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Callback with correct
address `%s'\n",
- stage,
- GNUNET_i2s (&address->peer));
- ret = 0;
- }
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Callback with invalid
address `%s'\n",
- stage,
- GNUNET_i2s (&address->peer));
- ret = 1;
- }
-
- if (GNUNET_OK != compare_ats(atsi, ats_count, test_ats_info,
test_ats_count))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback with incorrect
ats info \n",
- stage);
- ret = 1;
- }
-
- if (bw_in > wan_quota_in)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Suggested WAN inbound quota %u
bigger than allowed quota %llu \n",
- bw_in, wan_quota_in);
- ret = 1;
- }
- else
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Suggested WAN inbound quota %u,
allowed quota %llu \n",
- bw_in, wan_quota_in);
-
- if (bw_out > wan_quota_out)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Suggested WAN outbound quota %u
bigger than allowed quota %llu \n",
- bw_out, wan_quota_out);
- ret = 1;
- }
- else
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Suggested WAN outbound quota %u,
allowed quota %llu \n",
- bw_out, wan_quota_out);
-
- if (1 == ret)
- {
- GNUNET_ATS_suggest_address_cancel (sched_ats, &p[0].id);
- GNUNET_SCHEDULER_add_now (&end, NULL);
- return;
- }
-
- stage ++;
- GNUNET_ATS_suggest_address_cancel (sched_ats, &p[1].id);
- GNUNET_SCHEDULER_add_now (&end, NULL);
-
- return;
- }
-}
-
-static void
-sleep_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
- GNUNET_ATS_suggest_address (sched_ats, &p[0].id);
-}
-
-static void
-run (void *cls,
- const struct GNUNET_CONFIGURATION_Handle *cfg,
- struct GNUNET_TESTING_Peer *peer)
-{
- char *quota_str;
-
- if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string(cfg, "ats",
"WAN_QUOTA_OUT", "a_str))
- {
- fprintf (stderr, "Cannot load WAN outbound quota from configuration,
exit!\n");
- ret = 1;
- return;
- }
- if (GNUNET_SYSERR == GNUNET_STRINGS_fancy_size_to_bytes (quota_str,
&wan_quota_out))
- {
- fprintf (stderr, "Cannot load WAN outbound quota from configuration,
exit!\n");
- ret = 1;
- GNUNET_free (quota_str);
- return;
- }
- GNUNET_free (quota_str);
- quota_str = NULL;
-
- if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string(cfg, "ats",
"WAN_QUOTA_IN", "a_str))
- {
- fprintf (stderr, "Cannot load WAN inbound quota from configuration,
exit!\n");
- ret = 1;
- return;
- }
- if (GNUNET_SYSERR == GNUNET_STRINGS_fancy_size_to_bytes (quota_str,
&wan_quota_in))
- {
- fprintf (stderr, "Cannot load WAN inbound quota from configuration,
exit!\n");
- GNUNET_free (quota_str);
- ret = 1;
- return;
- }
- GNUNET_free (quota_str);
- quota_str = NULL;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Configured WAN inbound quota: %llu\n",
wan_quota_in);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Configured WAN outbound quota:
%llu\n", wan_quota_out);
-
-
- die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
-
- /* Connect to ATS scheduling */
- sched_ats = GNUNET_ATS_scheduling_init (cfg, &address_suggest_cb, NULL);
- if (sched_ats == NULL)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not connect to ATS
scheduling!\n");
- ret = 1;
- end ();
- return;
- }
-
- perf_ats = GNUNET_ATS_performance_init (cfg, NULL, NULL);
- if (perf_ats == NULL)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not connect to ATS
performance!\n");
- ret = 1;
- end ();
- return;
- }
-
- /* Set up peer 0 */
- if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID0,
&p[0].id.hashPubKey))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n");
- ret = GNUNET_SYSERR;
- end ();
- return;
- }
-
- GNUNET_assert (0 == strcmp (PEERID0, GNUNET_i2s_full (&p[0].id)));
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n",
- GNUNET_i2s(&p[0].id));
-
-
- /* Set up peer 0 */
- if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID1,
&p[1].id.hashPubKey))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n");
- ret = GNUNET_SYSERR;
- end ();
- return;
- }
-
- GNUNET_assert (0 == strcmp (PEERID1, GNUNET_i2s_full (&p[1].id)));
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n",
- GNUNET_i2s(&p[1].id));
-
- /* Prepare ATS Information */
- test_ats_info[0].type = htonl (GNUNET_ATS_NETWORK_TYPE);
- test_ats_info[0].value = htonl(GNUNET_ATS_NET_WAN);
- test_ats_info[1].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
- test_ats_info[1].value = htonl(1);
- test_ats_count = 2;
-
- /* Adding address with session */
- test_session[0] = &test_addr[0];
- create_test_address (&test_addr[0], "test0", test_session[0], "test0",
strlen ("test0") + 1);
- test_hello_address[0].peer = p[0].id;
- test_hello_address[0].transport_name = test_addr[0].plugin;
- test_hello_address[0].address = test_addr[0].addr;
- test_hello_address[0].address_length = test_addr[0].addr_len;
- GNUNET_ATS_address_add (sched_ats, &test_hello_address[0], test_session[0],
test_ats_info, test_ats_count);
-
-
- /* Adding address with session */
- test_session[1] = &test_addr[1];
- create_test_address (&test_addr[1], "test1", test_session[1], "test1",
strlen ("test1") + 1);
- test_hello_address[1].peer = p[1].id;
- test_hello_address[1].transport_name = test_addr[0].plugin;
- test_hello_address[1].address = test_addr[0].addr;
- test_hello_address[1].address_length = test_addr[0].addr_len;
- GNUNET_ATS_address_add (sched_ats, &test_hello_address[1], test_session[1],
test_ats_info, test_ats_count);
-
-
- /* Change bandwidth preference */
- GNUNET_ATS_performance_change_preference (perf_ats,
- &p[0].id,
- GNUNET_ATS_PREFERENCE_BANDWIDTH,(double) 1000,
GNUNET_ATS_PREFERENCE_END);
- GNUNET_ATS_performance_change_preference (perf_ats,
- &p[1].id,
- GNUNET_ATS_PREFERENCE_BANDWIDTH,(double) 1000,
GNUNET_ATS_PREFERENCE_END);
-
-
- /* Change latency preference */
-
- GNUNET_ATS_performance_change_preference (perf_ats,
- &p[0].id,
- GNUNET_ATS_PREFERENCE_LATENCY,(double) 10, GNUNET_ATS_PREFERENCE_END);
- GNUNET_ATS_performance_change_preference (perf_ats,
- &p[1].id,
- GNUNET_ATS_PREFERENCE_LATENCY,(double) 100, GNUNET_ATS_PREFERENCE_END);
- GNUNET_SCHEDULER_add_delayed (SLEEP, &sleep_task, NULL);
-}
-
-
-int
-main (int argc, char *argv[])
-{
- if (0 != GNUNET_TESTING_peer_run ("test_ats_simplistic_change_preference",
- "test_ats_api.conf",
- &run, NULL))
- return 1;
- return ret;
-}
-
-
-/* end of file test_ats_simplistic_change_preference.c */
Deleted: gnunet/src/ats/test_ats_simplistic_switch_networks.c
===================================================================
--- gnunet/src/ats/test_ats_simplistic_switch_networks.c 2013-10-28
15:55:43 UTC (rev 30442)
+++ gnunet/src/ats/test_ats_simplistic_switch_networks.c 2013-10-28
16:23:43 UTC (rev 30443)
@@ -1,371 +0,0 @@
-/*
- This file is part of GNUnet.
- (C) 2010,2011 Christian Grothoff (and other contributing authors)
-
- GNUnet is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-*/
-/**
- * @file ats/test_ats_api_scheduling_update_address.c
- * @brief test updating networtk type of an address
- * @author Christian Grothoff
- * @author Matthias Wachs
- */
-#include "platform.h"
-#include "gnunet_ats_service.h"
-#include "gnunet_testing_lib.h"
-#include "ats.h"
-#include "test_ats_api_common.h"
-
-#define BIG_M_STRING "unlimited"
-
-
-static GNUNET_SCHEDULER_TaskIdentifier die_task;
-
-/**
- * Scheduling handle
- */
-static struct GNUNET_ATS_SchedulingHandle *sched_ats;
-
-/**
- * Return value
- */
-static int ret;
-
-/**
- * Test address
- */
-static struct Test_Address test_addr;
-
-/**
- * Test peer
- */
-static struct PeerContext p;
-
-/**
- * HELLO test address
- */
-
-struct GNUNET_HELLO_Address test_hello_address;
-
-/**
- * Test session
- */
-static void *test_session;
-
-/**
- * Test ats info
- */
-struct GNUNET_ATS_Information test_ats_info[3];
-
-/**
- * Test ats count
- */
-uint32_t test_ats_count;
-
-unsigned long long int quota_out[GNUNET_ATS_NetworkTypeCount];
-unsigned long long int quota_in[GNUNET_ATS_NetworkTypeCount];
-
-static void
-end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
- die_task = GNUNET_SCHEDULER_NO_TASK;
-
- if (sched_ats != NULL)
- GNUNET_ATS_scheduling_done (sched_ats);
- free_test_address (&test_addr);
- ret = GNUNET_SYSERR;
-}
-
-
-static void
-end ()
-{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down\n");
- if (die_task != GNUNET_SCHEDULER_NO_TASK)
- {
- GNUNET_SCHEDULER_cancel (die_task);
- die_task = GNUNET_SCHEDULER_NO_TASK;
- }
- GNUNET_ATS_scheduling_done (sched_ats);
- sched_ats = NULL;
- free_test_address (&test_addr);
-}
-
-static uint32_t
-find_ats_value (const struct GNUNET_ATS_Information *atsi,
- uint32_t ats_count,
- uint32_t value)
-{
- int c;
- for (c = 0; c < ats_count; c ++)
- {
- if (ntohl(atsi[c].type) == value)
- return ntohl (atsi[c].value);
- }
- GNUNET_break (0);
- return UINT32_MAX;
-}
-
-
-static void
-address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address,
- struct Session *session,
- struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
- struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
- const struct GNUNET_ATS_Information *atsi,
- uint32_t ats_count)
-{
- static int stage = 0;
- int level;
- char *text;
- if (0 == stage)
- {
- //GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id);
- if (GNUNET_OK == compare_addresses(address, session, &test_hello_address,
test_session))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Callback for correct
address `%s'\n",
- stage, GNUNET_i2s (&address->peer));
- ret = 0;
- }
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback with incorrect
address `%s'\n",
- stage, GNUNET_i2s (&address->peer));
- ret = 1;
- GNUNET_SCHEDULER_add_now (&end, NULL);
- return;
- }
-
- if (GNUNET_OK != compare_ats(atsi, ats_count, test_ats_info,
test_ats_count))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback with incorrect
ats info \n", stage);
- ret = 1;
- GNUNET_SCHEDULER_add_now (&end, NULL);
- return;
- }
-
- if (ntohl(bandwidth_out.value__) == quota_out[GNUNET_ATS_NET_WAN])
- {
- level = GNUNET_ERROR_TYPE_DEBUG;
- text = "correct";
- ret = 0;
- }
- else
- {
- level = GNUNET_ERROR_TYPE_ERROR;
- text = "wrong";
- ret = 1;
- }
-
- GNUNET_log (level, "Stage %u: WAN outbound quota out %s: Received %llu,
configured %llu\n",
- stage,
- text,
- (unsigned long long int) ntohl(bandwidth_out.value__),
- quota_out[GNUNET_ATS_NET_WAN]);
-
- if (ntohl(bandwidth_in.value__) == quota_in[GNUNET_ATS_NET_WAN])
- {
- level = GNUNET_ERROR_TYPE_DEBUG;
- text = "correct";
- ret = 0;
- }
- else
- {
- level = GNUNET_ERROR_TYPE_ERROR;
- text = "wrong";
- ret = 1;
- }
-
- GNUNET_log (level, "Stage %u: WAN inbound quota out %s: Received %llu,
configured %llu\n",
- stage,
- text,
- (unsigned long long int) ntohl(bandwidth_out.value__),
- quota_out[GNUNET_ATS_NET_WAN]);
-
- if (GNUNET_ATS_NET_WAN != find_ats_value (atsi, ats_count,
GNUNET_ATS_NETWORK_TYPE))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Incorrect network
type, exptected %s, got %s \n",
- stage,
- GNUNET_ATS_print_network_type(GNUNET_ATS_NET_WAN),
- GNUNET_ATS_print_network_type(find_ats_value (atsi, ats_count,
GNUNET_ATS_NETWORK_TYPE)));
- ret = 1;
- }
-
- if (1 == ret)
- {
- GNUNET_SCHEDULER_add_now (&end, NULL);
- return;
- }
-
- /* Update address */
- /* Prepare ATS Information: change network */
- test_ats_info[0].type = htonl (GNUNET_ATS_NETWORK_TYPE);
- test_ats_info[0].value = htonl(GNUNET_ATS_NET_LAN);
- test_ats_info[1].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
- test_ats_info[1].value = htonl(3);
- test_ats_info[1].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY);
- test_ats_info[1].value = htonl(30);
- test_ats_count = 2;
-
- GNUNET_ATS_address_update (sched_ats, &test_hello_address, test_session,
test_ats_info, test_ats_count);
-
- /* Request address */
- GNUNET_ATS_suggest_address (sched_ats, &p.id);
- stage ++;
- }
- else if (1 == stage)
- {
- GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id);
- if (GNUNET_OK == compare_addresses(address, session,
&test_hello_address, test_session))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Callback with correct
address `%s'\n", stage,
- GNUNET_i2s (&address->peer));
- ret = 0;
- }
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback with
incorrect address `%s'\n", stage,
- GNUNET_i2s (&address->peer));
- ret = 1;
- }
-
- if (GNUNET_OK != compare_ats(atsi, ats_count, test_ats_info,
test_ats_count))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback with
incorrect ats info \n");
- ret = 1;
- GNUNET_SCHEDULER_add_now (&end, NULL);
- return;
- }
-
- if (ntohl(bandwidth_out.value__) == quota_out[GNUNET_ATS_NET_LAN])
- {
- level = GNUNET_ERROR_TYPE_DEBUG;
- text = "correct";
- ret = 0;
- }
- else
- {
- level = GNUNET_ERROR_TYPE_ERROR;
- text = "wrong";
- ret = 1;
- }
-
- GNUNET_log (level, "Stage %u: LAN outbound quota out %s: Received %llu,
configured %llu\n",
- stage,
- text,
- (unsigned long long int) ntohl(bandwidth_out.value__),
- quota_out[GNUNET_ATS_NET_LAN]);
-
- if (ntohl(bandwidth_in.value__) == quota_in[GNUNET_ATS_NET_LAN])
- {
- level = GNUNET_ERROR_TYPE_DEBUG;
- text = "correct";
- ret = 0;
- }
- else
- {
- level = GNUNET_ERROR_TYPE_ERROR;
- text = "wrong";
- ret = 1;
- }
-
- GNUNET_log (level, "Stage %u: LAN inbound quota out %s: Received %llu,
configured %llu\n",
- stage,
- text,
- (unsigned long long int) ntohl(bandwidth_out.value__),
- quota_out[GNUNET_ATS_NET_LAN]);
-
- if (GNUNET_ATS_NET_LAN != find_ats_value (atsi, ats_count,
GNUNET_ATS_NETWORK_TYPE))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Incorrect network
type, exptected %s, got %s \n",
- stage,
- GNUNET_ATS_print_network_type(GNUNET_ATS_NET_LAN),
- GNUNET_ATS_print_network_type(find_ats_value (atsi, ats_count,
GNUNET_ATS_NETWORK_TYPE)));
- ret = 1;
- }
-
- GNUNET_SCHEDULER_add_now (&end, NULL);
- }
-}
-
-
-static void
-run (void *cls,
- const struct GNUNET_CONFIGURATION_Handle *cfg,
- struct GNUNET_TESTING_Peer *peer)
-{
- die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
-
- load_quotas (cfg, quota_out, quota_in, GNUNET_ATS_NetworkTypeCount);
-
- /* Connect to ATS scheduling */
- sched_ats = GNUNET_ATS_scheduling_init (cfg, &address_suggest_cb, NULL);
- if (sched_ats == NULL)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not connect to ATS
scheduling!\n");
- ret = 1;
- end ();
- return;
- }
-
- /* Set up peer */
- if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID0,
&p.id.hashPubKey))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n");
- ret = GNUNET_SYSERR;
- end ();
- return;
- }
-
- GNUNET_assert (0 == strcmp (PEERID0, GNUNET_i2s_full (&p.id)));
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n",
- GNUNET_i2s_full(&p.id));
-
- /* Prepare ATS Information */
- test_ats_info[0].type = htonl (GNUNET_ATS_NETWORK_TYPE);
- test_ats_info[0].value = htonl(GNUNET_ATS_NET_WAN);
- test_ats_info[1].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
- test_ats_info[1].value = htonl(1);
- test_ats_info[1].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY);
- test_ats_info[1].value = htonl(10);
- test_ats_count = 2;
-
- /* Adding address without session */
- test_session = &test_addr;
- create_test_address (&test_addr, "test", &test_addr, "test", strlen ("test")
+ 1);
- test_hello_address.peer = p.id;
- test_hello_address.transport_name = test_addr.plugin;
- test_hello_address.address = test_addr.addr;
- test_hello_address.address_length = test_addr.addr_len;
- GNUNET_ATS_address_add (sched_ats, &test_hello_address, test_session,
test_ats_info, test_ats_count);
-
- /* Request address */
- GNUNET_ATS_suggest_address (sched_ats, &p.id);
-}
-
-
-int
-main (int argc, char *argv[])
-{
- if (0 != GNUNET_TESTING_peer_run ("test_ats_api_scheduling_update_address",
- "test_ats_api.conf",
- &run, NULL))
- return 1;
- return ret;
-}
-
-/* end of file test_ats_api_scheduling_update_address.c */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r30443 - gnunet/src/ats,
gnunet <=