diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-02-11 17:10:31 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-02-11 17:10:31 +0000 |
commit | 81defaa37bf4211f443f74384944642030807018 (patch) | |
tree | 7487470c9a7523644f53f6fb9a5f92ba5d2af8c1 /src/ats/test_ats_reservation_api.c | |
parent | 9e8d96ae528a7bc3e38d212129ee63727a21d612 (diff) | |
download | gnunet-81defaa37bf4211f443f74384944642030807018.tar.gz gnunet-81defaa37bf4211f443f74384944642030807018.zip |
add proper test for bandwidth reservation
Diffstat (limited to 'src/ats/test_ats_reservation_api.c')
-rw-r--r-- | src/ats/test_ats_reservation_api.c | 144 |
1 files changed, 144 insertions, 0 deletions
diff --git a/src/ats/test_ats_reservation_api.c b/src/ats/test_ats_reservation_api.c new file mode 100644 index 000000000..e45ffe2cc --- /dev/null +++ b/src/ats/test_ats_reservation_api.c | |||
@@ -0,0 +1,144 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2010-2015 Christian Grothoff (and other contributing authors) | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | 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 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | /** | ||
21 | * @file ats/test_ats_reservation_api.c | ||
22 | * @brief test ATS | ||
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, 3) | ||
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_ATS_NET_WAN | ||
48 | } | ||
49 | } | ||
50 | }, | ||
51 | /* 1: some solver still require explicit start */ | ||
52 | { | ||
53 | .code = CMD_REQUEST_CONNECTION_START, | ||
54 | .label = "request-0", | ||
55 | .details.request_connection_start = { | ||
56 | .pid = 0 | ||
57 | } | ||
58 | }, | ||
59 | /* 2: check we got an address */ | ||
60 | { | ||
61 | .code = CMD_AWAIT_ADDRESS_SUGGESTION, | ||
62 | .details.await_address_suggestion = { | ||
63 | .add_label = "add-address-0-0" | ||
64 | } | ||
65 | }, | ||
66 | /* 3: reserve 32k -- should work */ | ||
67 | { | ||
68 | .code = CMD_RESERVE_BANDWIDTH, | ||
69 | .label = "initial reservation", | ||
70 | .details.reserve_bandwidth = { | ||
71 | .pid = 0, | ||
72 | .amount = 32 * 1024, | ||
73 | .expected_result = GNUNET_OK | ||
74 | } | ||
75 | }, | ||
76 | /* 4: reserve another 32k -- might work */ | ||
77 | { | ||
78 | .code = CMD_RESERVE_BANDWIDTH, | ||
79 | .details.reserve_bandwidth = { | ||
80 | .pid = 0, | ||
81 | .amount = 32 * 1024, | ||
82 | .expected_result = GNUNET_NO | ||
83 | } | ||
84 | }, | ||
85 | /* 5: reserve another 128k -- might work */ | ||
86 | { | ||
87 | .code = CMD_RESERVE_BANDWIDTH, | ||
88 | .label = "big reservation", | ||
89 | .details.reserve_bandwidth = { | ||
90 | .pid = 0, | ||
91 | .amount = 128 * 1024, | ||
92 | .expected_result = GNUNET_NO | ||
93 | } | ||
94 | }, | ||
95 | /* 6: reserve another 32k -- should now fail */ | ||
96 | { | ||
97 | .code = CMD_RESERVE_BANDWIDTH, | ||
98 | .label = "failing reservation", | ||
99 | .details.reserve_bandwidth = { | ||
100 | .pid = 0, | ||
101 | .amount = 32 * 1024, | ||
102 | .expected_result = GNUNET_SYSERR | ||
103 | } | ||
104 | }, | ||
105 | /* 7: remove address */ | ||
106 | { | ||
107 | .code = CMD_DEL_ADDRESS, | ||
108 | .details.del_address = { | ||
109 | .add_label = "add-address-0-0" | ||
110 | } | ||
111 | }, | ||
112 | /* 8: check we got disconnected */ | ||
113 | { | ||
114 | .code = CMD_AWAIT_DISCONNECT_SUGGESTION, | ||
115 | .details.await_disconnect_suggestion = { | ||
116 | .pid = 0 | ||
117 | } | ||
118 | }, | ||
119 | /* 9: just for symmetry, also stop asking for the connection */ | ||
120 | { | ||
121 | .code = CMD_REQUEST_CONNECTION_STOP, | ||
122 | .details.request_connection_stop = { | ||
123 | .connect_label = "request-0", | ||
124 | } | ||
125 | }, | ||
126 | /* Test ends successfully */ | ||
127 | { | ||
128 | .code = CMD_END_PASS | ||
129 | } | ||
130 | }; | ||
131 | |||
132 | |||
133 | int | ||
134 | main (int argc, | ||
135 | char *argv[]) | ||
136 | { | ||
137 | return TEST_ATS_run (argc, | ||
138 | argv, | ||
139 | test_commands, | ||
140 | TIMEOUT); | ||
141 | } | ||
142 | |||
143 | |||
144 | /* end of file test_ats_reservation_api.c */ | ||