diff options
Diffstat (limited to 'src/ats/test_ats2_lib.c')
-rw-r--r-- | src/ats/test_ats2_lib.c | 141 |
1 files changed, 70 insertions, 71 deletions
diff --git a/src/ats/test_ats2_lib.c b/src/ats/test_ats2_lib.c index 1b9f0e234..f2a8eb1ea 100644 --- a/src/ats/test_ats2_lib.c +++ b/src/ats/test_ats2_lib.c | |||
@@ -76,13 +76,13 @@ static struct GNUNET_ATS_SessionRecord *sr; | |||
76 | * @return | 76 | * @return |
77 | */ | 77 | */ |
78 | static void | 78 | static void |
79 | allocation_cb(void *cls, | 79 | allocation_cb (void *cls, |
80 | struct GNUNET_ATS_Session *session, | 80 | struct GNUNET_ATS_Session *session, |
81 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, | 81 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, |
82 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in) | 82 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in) |
83 | { | 83 | { |
84 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 84 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
85 | "allocation_cb() called\n"); | 85 | "allocation_cb() called\n"); |
86 | } | 86 | } |
87 | 87 | ||
88 | 88 | ||
@@ -96,12 +96,12 @@ allocation_cb(void *cls, | |||
96 | * @param address | 96 | * @param address |
97 | */ | 97 | */ |
98 | static void | 98 | static void |
99 | suggestion_cb(void *cls, | 99 | suggestion_cb (void *cls, |
100 | const struct GNUNET_PeerIdentity *pid, | 100 | const struct GNUNET_PeerIdentity *pid, |
101 | const char *address) | 101 | const char *address) |
102 | { | 102 | { |
103 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 103 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
104 | "suggestion_cb() called\n"); | 104 | "suggestion_cb() called\n"); |
105 | ret = 0; | 105 | ret = 0; |
106 | } | 106 | } |
107 | 107 | ||
@@ -112,16 +112,16 @@ suggestion_cb(void *cls, | |||
112 | * Initialises the application and transportation side of ATS. | 112 | * Initialises the application and transportation side of ATS. |
113 | */ | 113 | */ |
114 | static void | 114 | static void |
115 | init_both(const struct GNUNET_CONFIGURATION_Handle *cfg) | 115 | init_both (const struct GNUNET_CONFIGURATION_Handle *cfg) |
116 | { | 116 | { |
117 | ah = GNUNET_ATS_application_init(cfg); | 117 | ah = GNUNET_ATS_application_init (cfg); |
118 | GNUNET_assert(NULL != ah); | 118 | GNUNET_assert (NULL != ah); |
119 | th = GNUNET_ATS_transport_init(cfg, | 119 | th = GNUNET_ATS_transport_init (cfg, |
120 | &allocation_cb, | 120 | &allocation_cb, |
121 | NULL, | 121 | NULL, |
122 | &suggestion_cb, | 122 | &suggestion_cb, |
123 | NULL); | 123 | NULL); |
124 | GNUNET_assert(NULL != ah); | 124 | GNUNET_assert (NULL != ah); |
125 | } | 125 | } |
126 | 126 | ||
127 | 127 | ||
@@ -129,11 +129,11 @@ init_both(const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
129 | * @brief Disconnect both 'sides' of ATS | 129 | * @brief Disconnect both 'sides' of ATS |
130 | */ | 130 | */ |
131 | static void | 131 | static void |
132 | finish_both(void) | 132 | finish_both (void) |
133 | { | 133 | { |
134 | GNUNET_ATS_application_done(ah); | 134 | GNUNET_ATS_application_done (ah); |
135 | ah = NULL; | 135 | ah = NULL; |
136 | GNUNET_ATS_transport_done(th); | 136 | GNUNET_ATS_transport_done (th); |
137 | th = NULL; | 137 | th = NULL; |
138 | } | 138 | } |
139 | 139 | ||
@@ -142,10 +142,9 @@ finish_both(void) | |||
142 | * @brief Provide information about the start of an imaginary connection | 142 | * @brief Provide information about the start of an imaginary connection |
143 | */ | 143 | */ |
144 | static void | 144 | static void |
145 | provide_info_start(void) | 145 | provide_info_start (void) |
146 | { | 146 | { |
147 | struct GNUNET_ATS_Properties prop = | 147 | struct GNUNET_ATS_Properties prop = { |
148 | { | ||
149 | .delay = GNUNET_TIME_UNIT_FOREVER_REL, | 148 | .delay = GNUNET_TIME_UNIT_FOREVER_REL, |
150 | .goodput_out = 1048576, | 149 | .goodput_out = 1048576, |
151 | .goodput_in = 1048576, | 150 | .goodput_in = 1048576, |
@@ -157,12 +156,12 @@ provide_info_start(void) | |||
157 | .cc = GNUNET_TRANSPORT_CC_UNKNOWN, | 156 | .cc = GNUNET_TRANSPORT_CC_UNKNOWN, |
158 | }; | 157 | }; |
159 | 158 | ||
160 | sr = GNUNET_ATS_session_add(th, | 159 | sr = GNUNET_ATS_session_add (th, |
161 | &other_peer, | 160 | &other_peer, |
162 | "test-address", | 161 | "test-address", |
163 | NULL, | 162 | NULL, |
164 | &prop); | 163 | &prop); |
165 | GNUNET_assert(NULL != sr); | 164 | GNUNET_assert (NULL != sr); |
166 | } | 165 | } |
167 | 166 | ||
168 | 167 | ||
@@ -170,9 +169,9 @@ provide_info_start(void) | |||
170 | * @brief Provide information about the end of an imaginary connection | 169 | * @brief Provide information about the end of an imaginary connection |
171 | */ | 170 | */ |
172 | static void | 171 | static void |
173 | provide_info_end(void) | 172 | provide_info_end (void) |
174 | { | 173 | { |
175 | GNUNET_ATS_session_del(sr); | 174 | GNUNET_ATS_session_del (sr); |
176 | } | 175 | } |
177 | 176 | ||
178 | 177 | ||
@@ -180,24 +179,24 @@ provide_info_end(void) | |||
180 | * @brief Inform ATS about the need of a connection towards a peer | 179 | * @brief Inform ATS about the need of a connection towards a peer |
181 | */ | 180 | */ |
182 | static void | 181 | static void |
183 | get_suggestion(void) | 182 | get_suggestion (void) |
184 | { | 183 | { |
185 | struct GNUNET_ATS_ApplicationSuggestHandle *ash; | 184 | struct GNUNET_ATS_ApplicationSuggestHandle *ash; |
186 | 185 | ||
187 | ash = GNUNET_ATS_application_suggest(ah, | 186 | ash = GNUNET_ATS_application_suggest (ah, |
188 | &other_peer, | 187 | &other_peer, |
189 | GNUNET_MQ_PREFERENCE_NONE, | 188 | GNUNET_MQ_PREFERENCE_NONE, |
190 | GNUNET_BANDWIDTH_VALUE_MAX); | 189 | GNUNET_BANDWIDTH_VALUE_MAX); |
191 | GNUNET_assert(NULL != ash); | 190 | GNUNET_assert (NULL != ash); |
192 | } | 191 | } |
193 | 192 | ||
194 | 193 | ||
195 | static void | 194 | static void |
196 | on_shutdown(void *cls) | 195 | on_shutdown (void *cls) |
197 | { | 196 | { |
198 | provide_info_end(); | 197 | provide_info_end (); |
199 | finish_both(); | 198 | finish_both (); |
200 | GNUNET_SCHEDULER_shutdown(); | 199 | GNUNET_SCHEDULER_shutdown (); |
201 | } | 200 | } |
202 | 201 | ||
203 | 202 | ||
@@ -209,16 +208,16 @@ on_shutdown(void *cls) | |||
209 | * @param peer handle to the peer | 208 | * @param peer handle to the peer |
210 | */ | 209 | */ |
211 | static void | 210 | static void |
212 | run(void *cls, | 211 | run (void *cls, |
213 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 212 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
214 | struct GNUNET_TESTING_Peer *peer) | 213 | struct GNUNET_TESTING_Peer *peer) |
215 | { | 214 | { |
216 | init_both(cfg); | 215 | init_both (cfg); |
217 | provide_info_start(); | 216 | provide_info_start (); |
218 | get_suggestion(); | 217 | get_suggestion (); |
219 | (void)GNUNET_SCHEDULER_add_delayed(timeout, | 218 | (void) GNUNET_SCHEDULER_add_delayed (timeout, |
220 | &on_shutdown, | 219 | &on_shutdown, |
221 | NULL); | 220 | NULL); |
222 | } | 221 | } |
223 | 222 | ||
224 | 223 | ||
@@ -231,27 +230,27 @@ run(void *cls, | |||
231 | * @return | 230 | * @return |
232 | */ | 231 | */ |
233 | int | 232 | int |
234 | main(int argc, | 233 | main (int argc, |
235 | char *argv[]) | 234 | char *argv[]) |
236 | { | 235 | { |
237 | ret = 1; | 236 | ret = 1; |
238 | memset(&other_peer, 0, sizeof(struct GNUNET_PeerIdentity)); | 237 | memset (&other_peer, 0, sizeof(struct GNUNET_PeerIdentity)); |
239 | timeout = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, | 238 | timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, |
240 | 2); | 239 | 2); |
241 | if (0 != GNUNET_TESTING_peer_run("test-ats2-lib", | 240 | if (0 != GNUNET_TESTING_peer_run ("test-ats2-lib", |
242 | "test_ats2_lib.conf", | 241 | "test_ats2_lib.conf", |
243 | &run, NULL)) | 242 | &run, NULL)) |
244 | { | 243 | { |
245 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 244 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
246 | "Running the testing peer failed.\n"); | 245 | "Running the testing peer failed.\n"); |
247 | return 1; | 246 | return 1; |
248 | } | 247 | } |
249 | if (0 != ret) | 248 | if (0 != ret) |
250 | { | 249 | { |
251 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, | 250 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
252 | "Global status indicates unsuccessful testrun - probably allocation_cb was not called.\n"); | 251 | "Global status indicates unsuccessful testrun - probably allocation_cb was not called.\n"); |
253 | ret = 77; // SKIP test, test not yet right! | 252 | ret = 77; // SKIP test, test not yet right! |
254 | } | 253 | } |
255 | return ret; | 254 | return ret; |
256 | } | 255 | } |
257 | 256 | ||