[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r35228 - gnunet/src/ats
From: |
gnunet |
Subject: |
[GNUnet-SVN] r35228 - gnunet/src/ats |
Date: |
Wed, 11 Feb 2015 18:00:40 +0100 |
Author: grothoff
Date: 2015-02-11 18:00:40 +0100 (Wed, 11 Feb 2015)
New Revision: 35228
Modified:
gnunet/src/ats/test_ats_lib.c
gnunet/src/ats/test_ats_lib.h
Log:
add command to test reservations
Modified: gnunet/src/ats/test_ats_lib.c
===================================================================
--- gnunet/src/ats/test_ats_lib.c 2015-02-11 16:45:35 UTC (rev 35227)
+++ gnunet/src/ats/test_ats_lib.c 2015-02-11 17:00:40 UTC (rev 35228)
@@ -404,7 +404,8 @@
/**
* Our dummy sessions.
*/
-struct Session {
+struct Session
+{
/**
* Field to avoid `0 == sizeof(struct Session)`.
*/
@@ -522,6 +523,59 @@
/**
+ * Function called with reservation result.
+ *
+ * @param cls closure with the reservation command (`struct Command`)
+ * @param peer identifies the peer
+ * @param amount set to the amount that was actually reserved or unreserved;
+ * either the full requested amount or zero (no partial
reservations)
+ * @param res_delay if the reservation could not be satisfied (amount was 0),
how
+ * long should the client wait until re-trying?
+ */
+static void
+reservation_cb (void *cls,
+ const struct GNUNET_PeerIdentity *peer,
+ int32_t amount,
+ struct GNUNET_TIME_Relative res_delay)
+{
+ struct Command *cmd = cls;
+ struct GNUNET_PeerIdentity pid;
+
+ make_peer (cmd->details.reserve_bandwidth.pid,
+ &pid);
+ GNUNET_assert (0 == memcmp (peer,
+ &pid,
+ sizeof (struct GNUNET_PeerIdentity)));
+ switch (cmd->details.reserve_bandwidth.expected_result)
+ {
+ case GNUNET_OK:
+ if (amount != cmd->details.reserve_bandwidth.amount)
+ {
+ GNUNET_break (0);
+ GNUNET_SCHEDULER_shutdown ();
+ return;
+ }
+ break;
+ case GNUNET_NO:
+ GNUNET_break ( (0 != amount) ||
+ (0 != res_delay.rel_value_us) );
+ break;
+ case GNUNET_SYSERR:
+ if ( (amount != cmd->details.reserve_bandwidth.amount) ||
+ (0 == res_delay.rel_value_us) )
+ {
+ GNUNET_break (0);
+ GNUNET_SCHEDULER_shutdown ();
+ return;
+ }
+ break;
+ }
+ off++;
+ run_interpreter ();
+}
+
+
+/**
* Main interpreter loop. Runs the steps of the test.
*
* @param cls NULL
@@ -779,6 +833,20 @@
cmd);
return;
}
+ case CMD_RESERVE_BANDWIDTH:
+ {
+ struct GNUNET_PeerIdentity pid;
+
+ make_peer (cmd->details.reserve_bandwidth.pid,
+ &pid);
+ cmd->details.reserve_bandwidth.rc
+ = GNUNET_ATS_reserve_bandwidth (perf_ats,
+ &pid,
+
cmd->details.reserve_bandwidth.amount,
+ &reservation_cb,
+ cmd);
+ return;
+ }
} /* end switch */
} /* end while(1) */
}
Modified: gnunet/src/ats/test_ats_lib.h
===================================================================
--- gnunet/src/ats/test_ats_lib.h 2015-02-11 16:45:35 UTC (rev 35227)
+++ gnunet/src/ats/test_ats_lib.h 2015-02-11 17:00:40 UTC (rev 35228)
@@ -111,9 +111,13 @@
* Obtain list of all addresses, testing
* #GNUNET_ATS_performance_list_addresses().
*/
- CMD_LIST_ADDRESSES
+ CMD_LIST_ADDRESSES,
- /* TODO: reserve bandwidth */
+ /**
+ * Reserve bandwidth, testing
+ * #GNUNET_ATS_reserve_bandwidth().
+ */
+ CMD_RESERVE_BANDWIDTH
};
@@ -399,6 +403,38 @@
/**
+ * Details for the #CMD_RESERVE_BANDWIDTH command.
+ */
+struct CommandReserveBandwidth
+{
+ /**
+ * For which peer do we reserve bandwidth?
+ */
+ unsigned int pid;
+
+ /**
+ * How much should we try to reserve?
+ */
+ int32_t amount;
+
+ /**
+ * Should we expect this to work or fail?
+ * #GNUNET_YES: must work
+ * #GNUNET_NO: may work or fail
+ * #GNUNET_SYSERR: must fail
+ */
+ int expected_result;
+
+ /**
+ * Location where we store the return value from
+ * #GNUNET_ATS_reserve_bandwidth().
+ */
+ struct GNUNET_ATS_ReservationContext *rc;
+
+};
+
+
+/**
* A command for the test case interpreter.
*/
struct Command
@@ -444,6 +480,8 @@
struct CommandListAddresses list_addresses;
+ struct CommandReserveBandwidth reserve_bandwidth;
+
} details;
};
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r35228 - gnunet/src/ats,
gnunet <=