aboutsummaryrefslogtreecommitdiff
path: root/src/transport/test_quota_compliance.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2010-10-22 15:35:29 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2010-10-22 15:35:29 +0000
commit16c5255cb5610343f67de5318e3c5c7df18eede7 (patch)
treee3803c7f133251149cda3181ebd8d73ac9f2af09 /src/transport/test_quota_compliance.c
parentfdb5a20adad300cab0166a7afea32f59eca746eb (diff)
downloadgnunet-16c5255cb5610343f67de5318e3c5c7df18eede7.tar.gz
gnunet-16c5255cb5610343f67de5318e3c5c7df18eede7.zip
test now works
Diffstat (limited to 'src/transport/test_quota_compliance.c')
-rw-r--r--src/transport/test_quota_compliance.c44
1 files changed, 33 insertions, 11 deletions
diff --git a/src/transport/test_quota_compliance.c b/src/transport/test_quota_compliance.c
index c6da0e024..65c5e55f4 100644
--- a/src/transport/test_quota_compliance.c
+++ b/src/transport/test_quota_compliance.c
@@ -34,7 +34,7 @@
34#include "gnunet_transport_service.h" 34#include "gnunet_transport_service.h"
35#include "transport.h" 35#include "transport.h"
36 36
37#define VERBOSE GNUNET_YES 37#define VERBOSE GNUNET_NO
38 38
39#define VERBOSE_ARM GNUNET_NO 39#define VERBOSE_ARM GNUNET_NO
40 40
@@ -118,7 +118,7 @@ end ()
118 GNUNET_SCHEDULER_cancel (sched, measurement_counter_task); 118 GNUNET_SCHEDULER_cancel (sched, measurement_counter_task);
119 measurement_counter_task = GNUNET_SCHEDULER_NO_TASK; 119 measurement_counter_task = GNUNET_SCHEDULER_NO_TASK;
120 } 120 }
121 121 GNUNET_SCHEDULER_shutdown (sched);
122#if VERBOSE 122#if VERBOSE
123 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from transports!\n"); 123 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from transports!\n");
124#endif 124#endif
@@ -128,8 +128,7 @@ end ()
128 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 128 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
129 "Transports disconnected, returning success!\n"); 129 "Transports disconnected, returning success!\n");
130#endif 130#endif
131 ok = 0; 131 GNUNET_SCHEDULER_shutdown (sched);
132
133} 132}
134 133
135 134
@@ -218,6 +217,9 @@ notify_ready_new (void *cls, size_t size, void *buf)
218 217
219 transmit_handle = NULL; 218 transmit_handle = NULL;
220 219
220 if (measurement_task == GNUNET_SCHEDULER_NO_TASK)
221 return 0;
222
221 if (buf == NULL) 223 if (buf == NULL)
222 { 224 {
223 GNUNET_break (0); 225 GNUNET_break (0);
@@ -270,6 +272,7 @@ static void measurement_counter
270 272
271 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 273 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
272 return; 274 return;
275
273#if VERBOSE 276#if VERBOSE
274 fprintf(stderr,"."); 277 fprintf(stderr,".");
275#endif 278#endif
@@ -294,13 +297,29 @@ measurement_end (void *cls,
294 GNUNET_SCHEDULER_cancel (sched, measurement_counter_task); 297 GNUNET_SCHEDULER_cancel (sched, measurement_counter_task);
295 measurement_counter_task = GNUNET_SCHEDULER_NO_TASK; 298 measurement_counter_task = GNUNET_SCHEDULER_NO_TASK;
296 } 299 }
297/* 300
298 if (transmit_handle != NULL) 301 if (transmit_handle != NULL)
302 {
299 GNUNET_TRANSPORT_notify_transmit_ready_cancel(transmit_handle); 303 GNUNET_TRANSPORT_notify_transmit_ready_cancel(transmit_handle);
300*/ 304 transmit_handle = NULL;
301 fprintf (stderr, "\n"); 305 }
302 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 306 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
303 "Measurement finished: \n Quota allowed: %llu kb/s\n Throughput: %llu kb/s\n", (current_quota_p1 / (1024)) , (total_bytes/(duration.value / 1000)/1024)); 307 "\n Measurement finished: \n Quota allowed: %llu kb/s\n Throughput: %llu kb/s\n", (current_quota_p1 / (1024)) , (total_bytes/(duration.value / 1000)/1024));
308
309 if (current_quota_p1 < total_bytes/(duration.value / 1000))
310 {
311 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
312 "\nQuota compliance failed: \n"\
313 "Quota allowed: %llu kb/s\n"\
314 "Throughput : %llu kb/s\n", (current_quota_p1 / (1024)) , (total_bytes/(duration.value / 1000)/1024));
315 ok = 1;
316 end();
317 return;
318 }
319 else
320 {
321 ok = 0;
322 }
304 if (current_quota_p1 < (MEASUREMENT_MIN_QUOTA)) 323 if (current_quota_p1 < (MEASUREMENT_MIN_QUOTA))
305 end(); 324 end();
306 else 325 else
@@ -327,7 +346,11 @@ static void measure (unsigned long long quota_p1, unsigned long long quota_p2 )
327 GNUNET_BANDWIDTH_value_init (current_quota_p2), 346 GNUNET_BANDWIDTH_value_init (current_quota_p2),
328 GNUNET_TIME_UNIT_FOREVER_REL, 347 GNUNET_TIME_UNIT_FOREVER_REL,
329 NULL, NULL); 348 NULL, NULL);
330 transmit_handle =GNUNET_TRANSPORT_notify_transmit_ready (p2.th, 349
350 if (transmit_handle != NULL)
351 GNUNET_TRANSPORT_notify_transmit_ready_cancel(transmit_handle);
352
353 transmit_handle = GNUNET_TRANSPORT_notify_transmit_ready (p2.th,
331 &p1.id, 354 &p1.id,
332 get_size_new (0), 0, TIMEOUT, 355 get_size_new (0), 0, TIMEOUT,
333 &notify_ready_new, 356 &notify_ready_new,
@@ -509,7 +532,6 @@ main (int argc, char *argv[])
509 argv1, "test-quota-compliance", "nohelp", 532 argv1, "test-quota-compliance", "nohelp",
510 options, &run, &ok); 533 options, &run, &ok);
511 ret = ok; 534 ret = ok;
512
513 stop_arm (&p1); 535 stop_arm (&p1);
514 stop_arm (&p2); 536 stop_arm (&p2);
515 GNUNET_DISK_directory_remove ("/tmp/test_quota_compliance_peer1"); 537 GNUNET_DISK_directory_remove ("/tmp/test_quota_compliance_peer1");