diff options
Diffstat (limited to 'src/testbed/test_testbed_api_topology_clique.c')
-rw-r--r-- | src/testbed/test_testbed_api_topology_clique.c | 142 |
1 files changed, 72 insertions, 70 deletions
diff --git a/src/testbed/test_testbed_api_topology_clique.c b/src/testbed/test_testbed_api_topology_clique.c index 4cc34dfaf..866ec83c5 100644 --- a/src/testbed/test_testbed_api_topology_clique.c +++ b/src/testbed/test_testbed_api_topology_clique.c | |||
@@ -1,22 +1,22 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | Copyright (C) 2008--2013 GNUnet e.V. | 3 | Copyright (C) 2008--2013 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 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 | 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, | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | or (at your option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
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 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file src/testbed/test_testbed_api_topology.c | 22 | * @file src/testbed/test_testbed_api_topology.c |
@@ -65,15 +65,15 @@ static unsigned int overlay_connects; | |||
65 | * @param cls NULL | 65 | * @param cls NULL |
66 | */ | 66 | */ |
67 | static void | 67 | static void |
68 | do_shutdown (void *cls) | 68 | do_shutdown(void *cls) |
69 | { | 69 | { |
70 | shutdown_task = NULL; | 70 | shutdown_task = NULL; |
71 | if (NULL != op) | 71 | if (NULL != op) |
72 | { | 72 | { |
73 | GNUNET_TESTBED_operation_done (op); | 73 | GNUNET_TESTBED_operation_done(op); |
74 | op = NULL; | 74 | op = NULL; |
75 | } | 75 | } |
76 | GNUNET_SCHEDULER_shutdown (); | 76 | GNUNET_SCHEDULER_shutdown(); |
77 | } | 77 | } |
78 | 78 | ||
79 | /** | 79 | /** |
@@ -83,29 +83,31 @@ do_shutdown (void *cls) | |||
83 | * @param event the controller event | 83 | * @param event the controller event |
84 | */ | 84 | */ |
85 | static void | 85 | static void |
86 | controller_event_cb (void *cls, | 86 | controller_event_cb(void *cls, |
87 | const struct GNUNET_TESTBED_EventInformation *event) | 87 | const struct GNUNET_TESTBED_EventInformation *event) |
88 | { | 88 | { |
89 | switch (event->type) | 89 | switch (event->type) |
90 | { | ||
91 | case GNUNET_TESTBED_ET_CONNECT: | ||
92 | overlay_connects++; | ||
93 | if ((NUM_PEERS * (NUM_PEERS - 1)) == overlay_connects) | ||
94 | { | 90 | { |
95 | result = GNUNET_OK; | 91 | case GNUNET_TESTBED_ET_CONNECT: |
96 | GNUNET_SCHEDULER_cancel (shutdown_task); | 92 | overlay_connects++; |
97 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | 93 | if ((NUM_PEERS * (NUM_PEERS - 1)) == overlay_connects) |
94 | { | ||
95 | result = GNUNET_OK; | ||
96 | GNUNET_SCHEDULER_cancel(shutdown_task); | ||
97 | shutdown_task = GNUNET_SCHEDULER_add_now(&do_shutdown, NULL); | ||
98 | } | ||
99 | break; | ||
100 | |||
101 | case GNUNET_TESTBED_ET_OPERATION_FINISHED: | ||
102 | GNUNET_assert(NULL != event->details.operation_finished.emsg); | ||
103 | break; | ||
104 | |||
105 | default: | ||
106 | GNUNET_break(0); | ||
107 | result = GNUNET_SYSERR; | ||
108 | GNUNET_SCHEDULER_cancel(shutdown_task); | ||
109 | shutdown_task = GNUNET_SCHEDULER_add_now(&do_shutdown, NULL); | ||
98 | } | 110 | } |
99 | break; | ||
100 | case GNUNET_TESTBED_ET_OPERATION_FINISHED: | ||
101 | GNUNET_assert (NULL != event->details.operation_finished.emsg); | ||
102 | break; | ||
103 | default: | ||
104 | GNUNET_break (0); | ||
105 | result = GNUNET_SYSERR; | ||
106 | GNUNET_SCHEDULER_cancel (shutdown_task); | ||
107 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | ||
108 | } | ||
109 | } | 111 | } |
110 | 112 | ||
111 | 113 | ||
@@ -122,38 +124,38 @@ controller_event_cb (void *cls, | |||
122 | * failed | 124 | * failed |
123 | */ | 125 | */ |
124 | static void | 126 | static void |
125 | test_master (void *cls, | 127 | test_master(void *cls, |
126 | struct GNUNET_TESTBED_RunHandle *h, | 128 | struct GNUNET_TESTBED_RunHandle *h, |
127 | unsigned int num_peers, | 129 | unsigned int num_peers, |
128 | struct GNUNET_TESTBED_Peer **peers_, | 130 | struct GNUNET_TESTBED_Peer **peers_, |
129 | unsigned int links_succeeded, | 131 | unsigned int links_succeeded, |
130 | unsigned int links_failed) | 132 | unsigned int links_failed) |
131 | { | 133 | { |
132 | unsigned int peer; | 134 | unsigned int peer; |
133 | 135 | ||
134 | GNUNET_assert (NULL == cls); | 136 | GNUNET_assert(NULL == cls); |
135 | if (NULL == peers_) | 137 | if (NULL == peers_) |
136 | { | 138 | { |
137 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failing test due to timeout\n"); | 139 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failing test due to timeout\n"); |
138 | return; | 140 | return; |
139 | } | 141 | } |
140 | GNUNET_assert (NUM_PEERS == num_peers); | 142 | GNUNET_assert(NUM_PEERS == num_peers); |
141 | for (peer = 0; peer < num_peers; peer++) | 143 | for (peer = 0; peer < num_peers; peer++) |
142 | GNUNET_assert (NULL != peers_[peer]); | 144 | GNUNET_assert(NULL != peers_[peer]); |
143 | peers = peers_; | 145 | peers = peers_; |
144 | overlay_connects = 0; | 146 | overlay_connects = 0; |
145 | op = GNUNET_TESTBED_overlay_configure_topology (NULL, NUM_PEERS, peers, NULL, | 147 | op = GNUNET_TESTBED_overlay_configure_topology(NULL, NUM_PEERS, peers, NULL, |
146 | NULL, | 148 | NULL, |
147 | NULL, | 149 | NULL, |
148 | GNUNET_TESTBED_TOPOLOGY_CLIQUE, | 150 | GNUNET_TESTBED_TOPOLOGY_CLIQUE, |
149 | /* GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI, */ | 151 | /* GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI, */ |
150 | /* NUM_PEERS, */ | 152 | /* NUM_PEERS, */ |
151 | GNUNET_TESTBED_TOPOLOGY_OPTION_END); | 153 | GNUNET_TESTBED_TOPOLOGY_OPTION_END); |
152 | GNUNET_assert (NULL != op); | 154 | GNUNET_assert(NULL != op); |
153 | shutdown_task = | 155 | shutdown_task = |
154 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 156 | GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply |
155 | (GNUNET_TIME_UNIT_SECONDS, 300), | 157 | (GNUNET_TIME_UNIT_SECONDS, 300), |
156 | do_shutdown, NULL); | 158 | do_shutdown, NULL); |
157 | } | 159 | } |
158 | 160 | ||
159 | 161 | ||
@@ -161,7 +163,7 @@ test_master (void *cls, | |||
161 | * Main function | 163 | * Main function |
162 | */ | 164 | */ |
163 | int | 165 | int |
164 | main (int argc, char **argv) | 166 | main(int argc, char **argv) |
165 | { | 167 | { |
166 | uint64_t event_mask; | 168 | uint64_t event_mask; |
167 | 169 | ||
@@ -169,10 +171,10 @@ main (int argc, char **argv) | |||
169 | event_mask = 0; | 171 | event_mask = 0; |
170 | event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT); | 172 | event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT); |
171 | event_mask |= (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED); | 173 | event_mask |= (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED); |
172 | (void) GNUNET_TESTBED_test_run ("test_testbed_api_test", | 174 | (void)GNUNET_TESTBED_test_run("test_testbed_api_test", |
173 | "test_testbed_api.conf", NUM_PEERS, | 175 | "test_testbed_api.conf", NUM_PEERS, |
174 | event_mask, &controller_event_cb, NULL, | 176 | event_mask, &controller_event_cb, NULL, |
175 | &test_master, NULL); | 177 | &test_master, NULL); |
176 | if (GNUNET_OK != result) | 178 | if (GNUNET_OK != result) |
177 | return 1; | 179 | return 1; |
178 | return 0; | 180 | return 0; |