*/
/**
* @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
+ * @brief test updating networtk type of an address
* @author Christian Grothoff
* @author Matthias Wachs
*/
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,
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 (ntohl(bandwidth_out.value__) == quota_out[GNUNET_ATS_NET_WAN])
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: WAN quota out correct \n", stage);
+ level = GNUNET_ERROR_TYPE_DEBUG;
+ text = "correct";
+ ret = 0;
}
else
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: WAN quota out wrong \n", stage);
+ 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])
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: WAN quota in correct \n", stage);
+ level = GNUNET_ERROR_TYPE_DEBUG;
+ text = "correct";
+ ret = 0;
}
else
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: WAN quota in wrong \n", stage);
+ 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 */
if (ntohl(bandwidth_out.value__) == quota_out[GNUNET_ATS_NET_LAN])
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: LAN quota out correct \n", stage);
+ level = GNUNET_ERROR_TYPE_DEBUG;
+ text = "correct";
ret = 0;
}
else
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: LAN quota out wrong \n", stage);
+ 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])
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: LAN quota in correct \n", stage);
- }
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: LAN quota in wrong \n", stage);
- ret = 1;
- }
+ {
+ 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);
}