diff options
Diffstat (limited to 'src/testbed/test_testbed_api_peers_manage_services.c')
-rw-r--r-- | src/testbed/test_testbed_api_peers_manage_services.c | 133 |
1 files changed, 67 insertions, 66 deletions
diff --git a/src/testbed/test_testbed_api_peers_manage_services.c b/src/testbed/test_testbed_api_peers_manage_services.c index c5e2b2646..d6597890f 100644 --- a/src/testbed/test_testbed_api_peers_manage_services.c +++ b/src/testbed/test_testbed_api_peers_manage_services.c | |||
@@ -11,7 +11,7 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 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/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
@@ -47,7 +47,7 @@ static struct GNUNET_TESTBED_Operation *op; | |||
47 | /** | 47 | /** |
48 | * dummy pointer | 48 | * dummy pointer |
49 | */ | 49 | */ |
50 | static void *dummy_cls = (void *) 0xDEAD0001; | 50 | static void *dummy_cls = (void *)0xDEAD0001; |
51 | 51 | ||
52 | /** | 52 | /** |
53 | * Abort task identifier | 53 | * Abort task identifier |
@@ -58,7 +58,6 @@ static struct GNUNET_SCHEDULER_Task * abort_task; | |||
58 | * States in this test | 58 | * States in this test |
59 | */ | 59 | */ |
60 | enum { | 60 | enum { |
61 | |||
62 | /** | 61 | /** |
63 | * Test has just been initialized | 62 | * Test has just been initialized |
64 | */ | 63 | */ |
@@ -89,13 +88,13 @@ enum { | |||
89 | * Fail testcase | 88 | * Fail testcase |
90 | */ | 89 | */ |
91 | #define FAIL_TEST(cond, ret) do { \ | 90 | #define FAIL_TEST(cond, ret) do { \ |
92 | if (!(cond)) { \ | 91 | if (!(cond)) { \ |
93 | GNUNET_break(0); \ | 92 | GNUNET_break(0); \ |
94 | if (NULL != abort_task) \ | 93 | if (NULL != abort_task) \ |
95 | GNUNET_SCHEDULER_cancel (abort_task); \ | 94 | GNUNET_SCHEDULER_cancel (abort_task); \ |
96 | abort_task = GNUNET_SCHEDULER_add_now (&do_abort, NULL); \ | 95 | abort_task = GNUNET_SCHEDULER_add_now(&do_abort, NULL); \ |
97 | ret; \ | 96 | ret; \ |
98 | } \ | 97 | } \ |
99 | } while (0) | 98 | } while (0) |
100 | 99 | ||
101 | 100 | ||
@@ -105,15 +104,15 @@ enum { | |||
105 | * @param cls NULL | 104 | * @param cls NULL |
106 | */ | 105 | */ |
107 | static void | 106 | static void |
108 | do_abort (void *cls) | 107 | do_abort(void *cls) |
109 | { | 108 | { |
110 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Aborting\n"); | 109 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Aborting\n"); |
111 | abort_task = NULL; | 110 | abort_task = NULL; |
112 | if (NULL != op) | 111 | if (NULL != op) |
113 | { | 112 | { |
114 | GNUNET_TESTBED_operation_done (op); | 113 | GNUNET_TESTBED_operation_done(op); |
115 | op = NULL; | 114 | op = NULL; |
116 | } | 115 | } |
117 | GNUNET_SCHEDULER_shutdown(); | 116 | GNUNET_SCHEDULER_shutdown(); |
118 | } | 117 | } |
119 | 118 | ||
@@ -127,36 +126,38 @@ do_abort (void *cls) | |||
127 | * operation has executed successfully. | 126 | * operation has executed successfully. |
128 | */ | 127 | */ |
129 | static void | 128 | static void |
130 | op_comp_cb (void *cls, | 129 | op_comp_cb(void *cls, |
131 | struct GNUNET_TESTBED_Operation *op, | 130 | struct GNUNET_TESTBED_Operation *op, |
132 | const char *emsg) | 131 | const char *emsg) |
133 | { | 132 | { |
134 | FAIL_TEST (cls == dummy_cls, return); | 133 | FAIL_TEST(cls == dummy_cls, return ); |
135 | FAIL_TEST (NULL == emsg, return); | 134 | FAIL_TEST(NULL == emsg, return ); |
136 | GNUNET_TESTBED_operation_done (op); | 135 | GNUNET_TESTBED_operation_done(op); |
137 | op = NULL; | 136 | op = NULL; |
138 | switch (state) | 137 | switch (state) |
139 | { | 138 | { |
140 | case STATE_PEERS_STARTED: | 139 | case STATE_PEERS_STARTED: |
141 | state = STATE_SERVICE_DOWN; | 140 | state = STATE_SERVICE_DOWN; |
142 | op = GNUNET_TESTBED_peer_manage_service (dummy_cls, | 141 | op = GNUNET_TESTBED_peer_manage_service(dummy_cls, |
143 | peers[1], | 142 | peers[1], |
144 | "topology", | 143 | "topology", |
145 | op_comp_cb, | 144 | op_comp_cb, |
146 | dummy_cls, | 145 | dummy_cls, |
147 | 0); | 146 | 0); |
148 | GNUNET_assert (NULL != op); | 147 | GNUNET_assert(NULL != op); |
149 | break; | 148 | break; |
150 | case STATE_SERVICE_DOWN: | 149 | |
151 | state = STATE_SERVICE_UP; | 150 | case STATE_SERVICE_DOWN: |
152 | GNUNET_SCHEDULER_cancel (abort_task); | 151 | state = STATE_SERVICE_UP; |
153 | abort_task = NULL; | 152 | GNUNET_SCHEDULER_cancel(abort_task); |
154 | state = STATE_OK; | 153 | abort_task = NULL; |
155 | GNUNET_SCHEDULER_shutdown (); | 154 | state = STATE_OK; |
156 | break; | 155 | GNUNET_SCHEDULER_shutdown(); |
157 | default: | 156 | break; |
158 | FAIL_TEST (0, return); | 157 | |
159 | } | 158 | default: |
159 | FAIL_TEST(0, return ); | ||
160 | } | ||
160 | } | 161 | } |
161 | 162 | ||
162 | 163 | ||
@@ -173,26 +174,26 @@ op_comp_cb (void *cls, | |||
173 | * failed | 174 | * failed |
174 | */ | 175 | */ |
175 | static void | 176 | static void |
176 | test_master (void *cls, | 177 | test_master(void *cls, |
177 | struct GNUNET_TESTBED_RunHandle *h, | 178 | struct GNUNET_TESTBED_RunHandle *h, |
178 | unsigned int num_peers, | 179 | unsigned int num_peers, |
179 | struct GNUNET_TESTBED_Peer **peers_, | 180 | struct GNUNET_TESTBED_Peer **peers_, |
180 | unsigned int links_succeeded, | 181 | unsigned int links_succeeded, |
181 | unsigned int links_failed) | 182 | unsigned int links_failed) |
182 | { | 183 | { |
183 | FAIL_TEST (NUM_PEERS == num_peers, return); | 184 | FAIL_TEST(NUM_PEERS == num_peers, return ); |
184 | state = STATE_PEERS_STARTED; | 185 | state = STATE_PEERS_STARTED; |
185 | peers = peers_; | 186 | peers = peers_; |
186 | op = GNUNET_TESTBED_peer_manage_service (dummy_cls, | 187 | op = GNUNET_TESTBED_peer_manage_service(dummy_cls, |
187 | peers[1], | 188 | peers[1], |
188 | "topology", | 189 | "topology", |
189 | op_comp_cb, | 190 | op_comp_cb, |
190 | dummy_cls, | 191 | dummy_cls, |
191 | 1); | 192 | 1); |
192 | FAIL_TEST (NULL != op, return); | 193 | FAIL_TEST(NULL != op, return ); |
193 | abort_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 194 | abort_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply |
194 | (GNUNET_TIME_UNIT_MINUTES, 1), | 195 | (GNUNET_TIME_UNIT_MINUTES, 1), |
195 | &do_abort, NULL); | 196 | &do_abort, NULL); |
196 | } | 197 | } |
197 | 198 | ||
198 | 199 | ||
@@ -200,14 +201,14 @@ test_master (void *cls, | |||
200 | * Main function | 201 | * Main function |
201 | */ | 202 | */ |
202 | int | 203 | int |
203 | main (int argc, char **argv) | 204 | main(int argc, char **argv) |
204 | { | 205 | { |
205 | state = STATE_INIT; | 206 | state = STATE_INIT; |
206 | (void) GNUNET_TESTBED_test_run ("test_testbed_api_peers_manage_services", | 207 | (void)GNUNET_TESTBED_test_run("test_testbed_api_peers_manage_services", |
207 | "test_testbed_api.conf", | 208 | "test_testbed_api.conf", |
208 | NUM_PEERS, | 209 | NUM_PEERS, |
209 | 1LL, NULL, NULL, | 210 | 1LL, NULL, NULL, |
210 | &test_master, NULL); | 211 | &test_master, NULL); |
211 | if (STATE_OK != state) | 212 | if (STATE_OK != state) |
212 | return 1; | 213 | return 1; |
213 | return 0; | 214 | return 0; |