diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2013-07-05 09:56:33 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2013-07-05 09:56:33 +0000 |
commit | 13f41d9f0f187394ce3d58842cc36f0dffe4c09a (patch) | |
tree | 4a8e48b816b0762660000217e258a1a63b1e3546 /src/ats | |
parent | 98dce660a7b76c70da2462995729d0445749233b (diff) | |
download | gnunet-13f41d9f0f187394ce3d58842cc36f0dffe4c09a.tar.gz gnunet-13f41d9f0f187394ce3d58842cc36f0dffe4c09a.zip |
updating tests to match api
Diffstat (limited to 'src/ats')
-rw-r--r-- | src/ats/perf_ats_mlp.c | 26 | ||||
-rw-r--r-- | src/ats/test_ats_mlp.c | 10 | ||||
-rw-r--r-- | src/ats/test_ats_simplistic_switch_networks.c | 2 |
3 files changed, 18 insertions, 20 deletions
diff --git a/src/ats/perf_ats_mlp.c b/src/ats/perf_ats_mlp.c index b6955b766..5f39c24d7 100644 --- a/src/ats/perf_ats_mlp.c +++ b/src/ats/perf_ats_mlp.c | |||
@@ -143,7 +143,7 @@ bandwidth_changed_cb (void *cls, struct ATS_Address *address) | |||
143 | 143 | ||
144 | static void | 144 | static void |
145 | normalized_property_changed_cb (void *cls, | 145 | normalized_property_changed_cb (void *cls, |
146 | const struct ATS_Address *peer, | 146 | struct ATS_Address *peer, |
147 | uint32_t type, | 147 | uint32_t type, |
148 | double prop_rel) | 148 | double prop_rel) |
149 | { | 149 | { |
@@ -184,13 +184,13 @@ perf_create_address (int cp, int ca) | |||
184 | static void | 184 | static void |
185 | address_initial_update (void *solver, struct GNUNET_CONTAINER_MultiHashMap * addresses, struct ATS_Address *address) | 185 | address_initial_update (void *solver, struct GNUNET_CONTAINER_MultiHashMap * addresses, struct ATS_Address *address) |
186 | { | 186 | { |
187 | ats[0].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY); | 187 | GAS_mlp_address_property_changed (mlp, address, |
188 | ats[0].value = htonl (GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, 100)); | 188 | GNUNET_ATS_QUALITY_NET_DELAY, 100, |
189 | (double)(100 + GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, 100)) / 100); | ||
189 | 190 | ||
190 | ats[1].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE); | 191 | GAS_mlp_address_property_changed (mlp, address, |
191 | ats[1].value = htonl (GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, 10)); | 192 | GNUNET_ATS_QUALITY_NET_DISTANCE, 10, |
192 | 193 | (double)(100 + GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, 100)) / 100); | |
193 | GAS_mlp_address_update (mlp, address, 0, GNUNET_YES, ats, 2); | ||
194 | } | 194 | } |
195 | 195 | ||
196 | 196 | ||
@@ -204,24 +204,26 @@ update_single_addresses (struct ATS_Address *cur) | |||
204 | switch (r_type) { | 204 | switch (r_type) { |
205 | case 0: | 205 | case 0: |
206 | r_val = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, 100); | 206 | r_val = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, 100); |
207 | ats[0].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY); | ||
208 | ats[0].value = htonl (r_val); | ||
209 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating peer `%s' address %p type %s val %u\n", | 207 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating peer `%s' address %p type %s val %u\n", |
210 | GNUNET_i2s (&cur->peer), cur, | 208 | GNUNET_i2s (&cur->peer), cur, |
211 | "GNUNET_ATS_QUALITY_NET_DELAY", r_val); | 209 | "GNUNET_ATS_QUALITY_NET_DELAY", r_val); |
210 | GAS_mlp_address_property_changed (mlp, cur, GNUNET_ATS_QUALITY_NET_DELAY, r_val, | ||
211 | (double)(100 + r_val / 100)); | ||
212 | break; | 212 | break; |
213 | case 1: | 213 | case 1: |
214 | r_val = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, 10); | 214 | r_val = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, 10); |
215 | ats[0].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE); | 215 | |
216 | ats[0].value = htonl (r_val); | ||
217 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating peer `%s' address %p type %s val %u\n", | 216 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating peer `%s' address %p type %s val %u\n", |
218 | GNUNET_i2s (&cur->peer), cur, | 217 | GNUNET_i2s (&cur->peer), cur, |
219 | "GNUNET_ATS_QUALITY_NET_DISTANCE", r_val); | 218 | "GNUNET_ATS_QUALITY_NET_DISTANCE", r_val); |
219 | GAS_mlp_address_property_changed (mlp, cur, GNUNET_ATS_QUALITY_NET_DISTANCE, r_val, | ||
220 | (double)(100 + r_val) / 100); | ||
220 | break; | 221 | break; |
221 | default: | 222 | default: |
222 | break; | 223 | break; |
223 | } | 224 | } |
224 | GAS_mlp_address_update (mlp, cur, 0, GNUNET_YES, ats, 1); | 225 | GAS_mlp_address_inuse_changed(mlp, cur, 0, GNUNET_YES); |
226 | |||
225 | } | 227 | } |
226 | 228 | ||
227 | static void | 229 | static void |
diff --git a/src/ats/test_ats_mlp.c b/src/ats/test_ats_mlp.c index ea1e5076a..be5e39fcf 100644 --- a/src/ats/test_ats_mlp.c +++ b/src/ats/test_ats_mlp.c | |||
@@ -127,7 +127,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
127 | } | 127 | } |
128 | 128 | ||
129 | 129 | ||
130 | static const double * | 130 | const double * |
131 | get_preferences_cb (void *cls, const struct GNUNET_PeerIdentity *id) | 131 | get_preferences_cb (void *cls, const struct GNUNET_PeerIdentity *id) |
132 | { | 132 | { |
133 | return GAS_normalization_get_preferences (id); | 133 | return GAS_normalization_get_preferences (id); |
@@ -139,10 +139,9 @@ get_property_cb (void *cls, const struct ATS_Address *address) | |||
139 | return GAS_normalization_get_properties ((struct ATS_Address *) address); | 139 | return GAS_normalization_get_properties ((struct ATS_Address *) address); |
140 | } | 140 | } |
141 | 141 | ||
142 | |||
143 | static void | 142 | static void |
144 | normalized_property_changed_cb (void *cls, | 143 | normalized_property_changed_cb (void *cls, |
145 | const struct ATS_Address *peer, | 144 | struct ATS_Address *peer, |
146 | uint32_t type, | 145 | uint32_t type, |
147 | double prop_rel) | 146 | double prop_rel) |
148 | { | 147 | { |
@@ -190,7 +189,6 @@ check (void *cls, char *const *args, const char *cfgfile, | |||
190 | int quotas[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkType; | 189 | int quotas[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkType; |
191 | unsigned long long quotas_in[GNUNET_ATS_NetworkTypeCount]; | 190 | unsigned long long quotas_in[GNUNET_ATS_NetworkTypeCount]; |
192 | unsigned long long quotas_out[GNUNET_ATS_NetworkTypeCount]; | 191 | unsigned long long quotas_out[GNUNET_ATS_NetworkTypeCount]; |
193 | struct GNUNET_ATS_Information ats; | ||
194 | 192 | ||
195 | #if !HAVE_LIBGLPK | 193 | #if !HAVE_LIBGLPK |
196 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "GLPK not installed!"); | 194 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "GLPK not installed!"); |
@@ -293,9 +291,7 @@ check (void *cls, char *const *args, const char *cfgfile, | |||
293 | 291 | ||
294 | 292 | ||
295 | /* Updating address 0*/ | 293 | /* Updating address 0*/ |
296 | ats.type = htonl (GNUNET_ATS_NETWORK_TYPE); | 294 | GAS_mlp_address_change_network(mlp, address[0], GNUNET_ATS_NET_UNSPECIFIED, GNUNET_ATS_NET_WAN); |
297 | ats.value = htonl (GNUNET_ATS_NET_WAN); | ||
298 | GAS_mlp_address_update (mlp, address[0], 1, GNUNET_NO, &ats, 1); | ||
299 | 295 | ||
300 | /* Retrieving preferred address for peer and wait for callback */ | 296 | /* Retrieving preferred address for peer and wait for callback */ |
301 | GAS_mlp_get_preferred_address (mlp, &p[0]); | 297 | GAS_mlp_get_preferred_address (mlp, &p[0]); |
diff --git a/src/ats/test_ats_simplistic_switch_networks.c b/src/ats/test_ats_simplistic_switch_networks.c index 6d1548651..53df468a0 100644 --- a/src/ats/test_ats_simplistic_switch_networks.c +++ b/src/ats/test_ats_simplistic_switch_networks.c | |||
@@ -133,7 +133,7 @@ address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address, | |||
133 | char *text; | 133 | char *text; |
134 | if (0 == stage) | 134 | if (0 == stage) |
135 | { | 135 | { |
136 | GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id); | 136 | //GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id); |
137 | if (GNUNET_OK == compare_addresses(address, session, &test_hello_address, test_session)) | 137 | if (GNUNET_OK == compare_addresses(address, session, &test_hello_address, test_session)) |
138 | { | 138 | { |
139 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Callback for correct address `%s'\n", | 139 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Callback for correct address `%s'\n", |