aboutsummaryrefslogtreecommitdiff
path: root/src/ats/test_ats_simplistic_change_preference.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ats/test_ats_simplistic_change_preference.c')
-rw-r--r--src/ats/test_ats_simplistic_change_preference.c48
1 files changed, 29 insertions, 19 deletions
diff --git a/src/ats/test_ats_simplistic_change_preference.c b/src/ats/test_ats_simplistic_change_preference.c
index ecde45825..6ded2a93b 100644
--- a/src/ats/test_ats_simplistic_change_preference.c
+++ b/src/ats/test_ats_simplistic_change_preference.c
@@ -46,6 +46,12 @@ static GNUNET_SCHEDULER_TaskIdentifier die_task;
46static struct GNUNET_ATS_SchedulingHandle *sched_ats; 46static struct GNUNET_ATS_SchedulingHandle *sched_ats;
47 47
48/** 48/**
49 * Scheduling handle
50 */
51static struct GNUNET_ATS_PerformanceHandle *perf_ats;
52
53
54/**
49 * Return value 55 * Return value
50 */ 56 */
51static int ret; 57static int ret;
@@ -99,6 +105,8 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
99 105
100 if (sched_ats != NULL) 106 if (sched_ats != NULL)
101 GNUNET_ATS_scheduling_done (sched_ats); 107 GNUNET_ATS_scheduling_done (sched_ats);
108 if (perf_ats != NULL)
109 GNUNET_ATS_performance_done (perf_ats);
102 free_test_address (&test_addr[0]); 110 free_test_address (&test_addr[0]);
103 ret = GNUNET_SYSERR; 111 ret = GNUNET_SYSERR;
104} 112}
@@ -113,6 +121,8 @@ end ()
113 GNUNET_SCHEDULER_cancel (die_task); 121 GNUNET_SCHEDULER_cancel (die_task);
114 die_task = GNUNET_SCHEDULER_NO_TASK; 122 die_task = GNUNET_SCHEDULER_NO_TASK;
115 } 123 }
124 GNUNET_ATS_performance_done (perf_ats);
125 perf_ats = NULL;
116 GNUNET_ATS_scheduling_done (sched_ats); 126 GNUNET_ATS_scheduling_done (sched_ats);
117 sched_ats = NULL; 127 sched_ats = NULL;
118 free_test_address (&test_addr[0]); 128 free_test_address (&test_addr[0]);
@@ -177,26 +187,17 @@ address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address,
177 GNUNET_SCHEDULER_add_now (&end, NULL); 187 GNUNET_SCHEDULER_add_now (&end, NULL);
178 return; 188 return;
179 } 189 }
180 p[0].bw_out_assigned = bw_out; 190
181 p[0].bw_in_assigned = bw_in;
182 stage ++; 191 stage ++;
183 192
184 /* Add a 2nd address */ 193 /* Change preference */
185 /* Prepare ATS Information */ 194 GNUNET_ATS_change_preference (perf_ats,
186 test_ats_info[0].type = htonl (GNUNET_ATS_NETWORK_TYPE); 195 &p[0].id,
187 test_ats_info[0].value = htonl(GNUNET_ATS_NET_WAN); 196 GNUNET_ATS_PREFERENCE_BANDWIDTH,(double) 1000, GNUNET_ATS_PREFERENCE_END);
188 test_ats_info[1].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE); 197
189 test_ats_info[1].value = htonl(1); 198 /* Request address */
190 test_ats_count = 2; 199 GNUNET_ATS_suggest_address (sched_ats, &p[0].id);
191 200 return;
192 /* Adding address with session */
193 test_session[1] = &test_addr[1];
194 create_test_address (&test_addr[1], "test1", test_session[1], "test1", strlen ("test1") + 1);
195 test_hello_address[1].peer = p[1].id;
196 test_hello_address[1].transport_name = test_addr[1].plugin;
197 test_hello_address[1].address = test_addr[1].addr;
198 test_hello_address[1].address_length = test_addr[1].addr_len;
199 GNUNET_ATS_address_add (sched_ats, &test_hello_address[1], test_session[1], test_ats_info, test_ats_count);
200 } 201 }
201 if (1 == stage) 202 if (1 == stage)
202 { 203 {
@@ -321,6 +322,15 @@ run (void *cls,
321 return; 322 return;
322 } 323 }
323 324
325 perf_ats = GNUNET_ATS_performance_init (cfg, NULL, NULL);
326 if (perf_ats == NULL)
327 {
328 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not connect to ATS performance!\n");
329 ret = 1;
330 end ();
331 return;
332 }
333
324 /* Set up peer 0 */ 334 /* Set up peer 0 */
325 if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID0, &p[0].id.hashPubKey)) 335 if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID0, &p[0].id.hashPubKey))
326 { 336 {
@@ -372,7 +382,7 @@ run (void *cls,
372int 382int
373main (int argc, char *argv[]) 383main (int argc, char *argv[])
374{ 384{
375 if (0 != GNUNET_TESTING_peer_run ("test_ats_simplististic", 385 if (0 != GNUNET_TESTING_peer_run ("test_ats_simplistic_change_preference",
376 "test_ats_api.conf", 386 "test_ats_api.conf",
377 &run, NULL)) 387 &run, NULL))
378 return 1; 388 return 1;