* @file testing/test_transport_ats_multiple_peers.c
* @brief testcase for ats functionality by starting multiple peers
*/
+
#include "platform.h"
+#include "gnunet_util_lib.h"
+
#include "gnunet_testing_lib.h"
#include "gnunet_transport_service.h"
-#include "gnunet_scheduler_lib.h"
#include "gauger.h"
+#include "gnunet-service-transport_ats.h"
#define VERBOSE GNUNET_NO
#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 300)
#define SEND_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
-#define ATS_NEW 0
-#define ATS_Q_UPDATED 1
-#define ATS_C_UPDATED 2
-#define ATS_QC_UPDATED 3
-#define ATS_UNMODIFIED 4
-
static int ok;
static int peers_left;
int is_persistent)
{
static int printed = GNUNET_NO;
- //GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s = %llu\n", name ,value);
+#if VERBOSE_ATS
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s = %llu\n", name ,value);
+#endif
if (0 == strcmp (name,"ATS invalid solutions"))
{
if (stats_task != GNUNET_SCHEDULER_NO_TASK)
}
}
- if (current.state == ATS_Q_UPDATED)
+ if (current.state == ATS_QUALITY_UPDATED)
{
if (c_modified < MEASUREMENTS)
{
if (0 == strcmp (name,"ATS state"))
{
current.state = value;
- char * cont;
- if (value == ATS_NEW)
- cont = "NEW";
- if (value == ATS_C_UPDATED)
- cont = "C_UPDATED";
- if (value == ATS_Q_UPDATED)
- cont = "Q_UPDATED";
- if (value == ATS_QC_UPDATED)
- cont = "QC_UPDATED";
- if (value == ATS_UNMODIFIED)
- cont = "UNMODIFIED";
+ const char * cont;
+ switch (value)
+ {
+ case ATS_NEW:
+ cont = "NEW";
+ break;
+ case ATS_COST_UPDATED:
+ cont = "C_UPDATED";
+ break;
+ case ATS_QUALITY_UPDATED:
+ cont = "Q_UPDATED";
+ break;
+ case ATS_QUALITY_COST_UPDATED:
+ cont = "QC_UPDATED";
+ break;
+ case ATS_UNMODIFIED:
+ cont = "UNMODIFIED";
+ break;
+ default:
+ GNUNET_break (0);
+ cont = "<undefined>";
+ break;
+ }
if (printed == GNUNET_NO)
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "[%i] ATS state: %s\n", count, cont);
+ "[%i] ATS state: %s\n",
+ count,
+ cont);
}
}
return GNUNET_OK;
shutdown_task = GNUNET_SCHEDULER_add_delayed(DELAY, &delay, NULL);
}
+
+/* To make compiler happy */
+void dummy(void)
+{
+ struct ATS_quality_metric * q = qm;
+ q = NULL;
+ q++;
+ struct ATS_ressource * r = ressources;
+ r = NULL;
+ r++;
+}
+
static size_t
send_dummy_data_task (void *cls, size_t size, void *buf)
{
hdr.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_ATS);
if (force_rebuild)
hdr.num = htonl (1);
- if (force_q_updates)
+ else if (force_q_updates)
hdr.num = htonl (2);
- memcpy (buf,&hdr, s);
+ else
+ hdr.num = htonl (0);
+ memcpy (buf, &hdr, s);
// GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Sent bytes: %i of %i\n", s, s);
- t = NULL;
+ t = NULL;
return s;
}
GNUNET_GETOPT_OPTION_END
};
GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
- argv, "test-transport-ats", "nohelp",
+ argv, "test_transport_ats_multiple_peers", "nohelp",
options, &run, &ok);
return ok;
}
-
int
main (int argc, char *argv[])
{
- int ret;
+ int ret = 0;
GNUNET_log_setup ("test-transport-ats-multiple-peers",
#if VERBOSE
#endif
NULL);
-#if !HAVE_LIBGLPK && !HAVE_GLPK
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "GLPK not installed, exiting testcase\n");
- return 0;
-#endif
-
GNUNET_DISK_directory_remove ("/tmp/test-gnunet-testing");
machine_parsable = GNUNET_NO;
peers = NUM_PEERS;
}
}
-
-
ret = check ();
/**
* Still need to remove the base testing directory here,