aboutsummaryrefslogtreecommitdiff
path: root/src/ats/test_ats_lib.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-02-11 17:00:40 +0000
committerChristian Grothoff <christian@grothoff.org>2015-02-11 17:00:40 +0000
commit9e8d96ae528a7bc3e38d212129ee63727a21d612 (patch)
treea513add7584b81069f0aff2d7886c5fd91731c8c /src/ats/test_ats_lib.c
parent06081068ed6315a01d9ecd201d6c3bccb9ebfecd (diff)
downloadgnunet-9e8d96ae528a7bc3e38d212129ee63727a21d612.tar.gz
gnunet-9e8d96ae528a7bc3e38d212129ee63727a21d612.zip
add command to test reservations
Diffstat (limited to 'src/ats/test_ats_lib.c')
-rw-r--r--src/ats/test_ats_lib.c70
1 files changed, 69 insertions, 1 deletions
diff --git a/src/ats/test_ats_lib.c b/src/ats/test_ats_lib.c
index 74cff1e61..b55881b6e 100644
--- a/src/ats/test_ats_lib.c
+++ b/src/ats/test_ats_lib.c
@@ -404,7 +404,8 @@ make_address (uint32_t pid,
404/** 404/**
405 * Our dummy sessions. 405 * Our dummy sessions.
406 */ 406 */
407struct Session { 407struct Session
408{
408 /** 409 /**
409 * Field to avoid `0 == sizeof(struct Session)`. 410 * Field to avoid `0 == sizeof(struct Session)`.
410 */ 411 */
@@ -522,6 +523,59 @@ info_cb (void *cls,
522 523
523 524
524/** 525/**
526 * Function called with reservation result.
527 *
528 * @param cls closure with the reservation command (`struct Command`)
529 * @param peer identifies the peer
530 * @param amount set to the amount that was actually reserved or unreserved;
531 * either the full requested amount or zero (no partial reservations)
532 * @param res_delay if the reservation could not be satisfied (amount was 0), how
533 * long should the client wait until re-trying?
534 */
535static void
536reservation_cb (void *cls,
537 const struct GNUNET_PeerIdentity *peer,
538 int32_t amount,
539 struct GNUNET_TIME_Relative res_delay)
540{
541 struct Command *cmd = cls;
542 struct GNUNET_PeerIdentity pid;
543
544 make_peer (cmd->details.reserve_bandwidth.pid,
545 &pid);
546 GNUNET_assert (0 == memcmp (peer,
547 &pid,
548 sizeof (struct GNUNET_PeerIdentity)));
549 switch (cmd->details.reserve_bandwidth.expected_result)
550 {
551 case GNUNET_OK:
552 if (amount != cmd->details.reserve_bandwidth.amount)
553 {
554 GNUNET_break (0);
555 GNUNET_SCHEDULER_shutdown ();
556 return;
557 }
558 break;
559 case GNUNET_NO:
560 GNUNET_break ( (0 != amount) ||
561 (0 != res_delay.rel_value_us) );
562 break;
563 case GNUNET_SYSERR:
564 if ( (amount != cmd->details.reserve_bandwidth.amount) ||
565 (0 == res_delay.rel_value_us) )
566 {
567 GNUNET_break (0);
568 GNUNET_SCHEDULER_shutdown ();
569 return;
570 }
571 break;
572 }
573 off++;
574 run_interpreter ();
575}
576
577
578/**
525 * Main interpreter loop. Runs the steps of the test. 579 * Main interpreter loop. Runs the steps of the test.
526 * 580 *
527 * @param cls NULL 581 * @param cls NULL
@@ -779,6 +833,20 @@ interpreter (void *cls,
779 cmd); 833 cmd);
780 return; 834 return;
781 } 835 }
836 case CMD_RESERVE_BANDWIDTH:
837 {
838 struct GNUNET_PeerIdentity pid;
839
840 make_peer (cmd->details.reserve_bandwidth.pid,
841 &pid);
842 cmd->details.reserve_bandwidth.rc
843 = GNUNET_ATS_reserve_bandwidth (perf_ats,
844 &pid,
845 cmd->details.reserve_bandwidth.amount,
846 &reservation_cb,
847 cmd);
848 return;
849 }
782 } /* end switch */ 850 } /* end switch */
783 } /* end while(1) */ 851 } /* end while(1) */
784} 852}