diff options
Diffstat (limited to 'src/ats/test_ats_reservation_api.c')
-rw-r--r-- | src/ats/test_ats_reservation_api.c | 181 |
1 files changed, 0 insertions, 181 deletions
diff --git a/src/ats/test_ats_reservation_api.c b/src/ats/test_ats_reservation_api.c deleted file mode 100644 index f6a964df4..000000000 --- a/src/ats/test_ats_reservation_api.c +++ /dev/null | |||
@@ -1,181 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2010-2015 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | /** | ||
21 | * @file ats/test_ats_reservation_api.c | ||
22 | * @brief test ATS bandwidth reservation API | ||
23 | * @author Christian Grothoff | ||
24 | */ | ||
25 | #include "platform.h" | ||
26 | #include "test_ats_lib.h" | ||
27 | |||
28 | /** | ||
29 | * Global timeout for the testcase. | ||
30 | */ | ||
31 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15) | ||
32 | |||
33 | /** | ||
34 | * Definition of the test as a sequence of commands. | ||
35 | */ | ||
36 | static struct Command test_commands[] = { | ||
37 | /* 0: add initial address */ | ||
38 | { | ||
39 | .code = CMD_ADD_ADDRESS, | ||
40 | .label = "add-address-0-0", | ||
41 | .details.add_address = { | ||
42 | .pid = 0, | ||
43 | .addr_num = 0, | ||
44 | .session = 0, | ||
45 | .properties = { | ||
46 | /* use network with 65k quota! */ | ||
47 | .scope = GNUNET_NT_WAN | ||
48 | } | ||
49 | |||
50 | |||
51 | } | ||
52 | |||
53 | |||
54 | }, | ||
55 | /* 1: some solver still require explicit start */ | ||
56 | { | ||
57 | .code = CMD_REQUEST_CONNECTION_START, | ||
58 | .label = "request-0", | ||
59 | .details.request_connection_start = { | ||
60 | .pid = 0 | ||
61 | } | ||
62 | |||
63 | |||
64 | }, | ||
65 | /* 2: check we got an address */ | ||
66 | { | ||
67 | .code = CMD_AWAIT_ADDRESS_SUGGESTION, | ||
68 | .details.await_address_suggestion = { | ||
69 | .add_label = "add-address-0-0" | ||
70 | } | ||
71 | |||
72 | |||
73 | }, | ||
74 | /* 3: sleep 7s, should give us 5s * 64k/s = 320k buffer; | ||
75 | Note that this depends on MAX_BANDWIDTH_CARRY_S. We | ||
76 | sleep more than 5s to show that only MAX_BANDWIDTH carries. */ | ||
77 | { | ||
78 | .code = CMD_SLEEP, | ||
79 | .label = "sleep", | ||
80 | .details.sleep.delay = { 7 * 1000LL * 1000LL } | ||
81 | }, | ||
82 | /* 4: reserve 128k -- should work (5s carry, so we had 320k) */ | ||
83 | { | ||
84 | .code = CMD_RESERVE_BANDWIDTH, | ||
85 | .details.reserve_bandwidth = { | ||
86 | .pid = 0, | ||
87 | .amount = 128 * 1024, | ||
88 | .expected_result = GNUNET_YES | ||
89 | } | ||
90 | |||
91 | |||
92 | }, | ||
93 | /* 5: reserve another 192k -- should just work (now exactly pushing the limit) */ | ||
94 | { | ||
95 | .code = CMD_RESERVE_BANDWIDTH, | ||
96 | .label = "big reservation", | ||
97 | .details.reserve_bandwidth = { | ||
98 | .pid = 0, | ||
99 | .amount = 192 * 1024, | ||
100 | .expected_result = GNUNET_YES | ||
101 | } | ||
102 | |||
103 | |||
104 | }, | ||
105 | /* 6: reserve another 32M -- should now fail (if MAX_BANDWIDTH_CARRY_S | ||
106 | is precisely observed) */ | ||
107 | { | ||
108 | .code = CMD_RESERVE_BANDWIDTH, | ||
109 | .label = "failing reservation", | ||
110 | .details.reserve_bandwidth = { | ||
111 | .pid = 0, | ||
112 | .amount = 32 * 1024 * 1024, | ||
113 | .expected_result = GNUNET_SYSERR | ||
114 | } | ||
115 | |||
116 | |||
117 | }, | ||
118 | /* 7: sleep 3s, should give us 3s * 64k/s - 32k = 160k buffer */ | ||
119 | { | ||
120 | .code = CMD_SLEEP, | ||
121 | .label = "sleep", | ||
122 | .details.sleep.delay = { 6 * 1000LL * 1000LL } | ||
123 | }, | ||
124 | /* 8: reserve another 160k -- should now work */ | ||
125 | { | ||
126 | .code = CMD_RESERVE_BANDWIDTH, | ||
127 | .label = "successful final reservation", | ||
128 | .details.reserve_bandwidth = { | ||
129 | .pid = 0, | ||
130 | .amount = 160 * 1024, | ||
131 | .expected_result = GNUNET_YES | ||
132 | } | ||
133 | |||
134 | |||
135 | }, | ||
136 | /* 9: remove address */ | ||
137 | { | ||
138 | .code = CMD_DEL_ADDRESS, | ||
139 | .details.del_address = { | ||
140 | .add_label = "add-address-0-0" | ||
141 | } | ||
142 | |||
143 | |||
144 | }, | ||
145 | /* 10: check we got disconnected */ | ||
146 | { | ||
147 | .code = CMD_AWAIT_DISCONNECT_SUGGESTION, | ||
148 | .details.await_disconnect_suggestion = { | ||
149 | .pid = 0 | ||
150 | } | ||
151 | |||
152 | |||
153 | }, | ||
154 | /* 11: just for symmetry, also stop asking for the connection */ | ||
155 | { | ||
156 | .code = CMD_REQUEST_CONNECTION_STOP, | ||
157 | .details.request_connection_stop = { | ||
158 | .connect_label = "request-0", | ||
159 | } | ||
160 | |||
161 | |||
162 | }, | ||
163 | /* Test ends successfully */ | ||
164 | { | ||
165 | .code = CMD_END_PASS | ||
166 | } | ||
167 | }; | ||
168 | |||
169 | |||
170 | int | ||
171 | main (int argc, | ||
172 | char *argv[]) | ||
173 | { | ||
174 | return TEST_ATS_run (argc, | ||
175 | argv, | ||
176 | test_commands, | ||
177 | TIMEOUT); | ||
178 | } | ||
179 | |||
180 | |||
181 | /* end of file test_ats_reservation_api.c */ | ||