diff options
author | ng0 <ng0@n0.is> | 2019-09-08 12:33:09 +0000 |
---|---|---|
committer | ng0 <ng0@n0.is> | 2019-09-08 12:33:09 +0000 |
commit | d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb (patch) | |
tree | 9efd18ea7d425652085ed0bd5e8e45604bc5f6b9 /src/testbed/test_testbed_api_peer_reconfiguration.c | |
parent | a0fce305c565c0937d917a92712f15e9c5736260 (diff) | |
download | gnunet-d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb.tar.gz gnunet-d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb.zip |
uncrustify as demanded.
Diffstat (limited to 'src/testbed/test_testbed_api_peer_reconfiguration.c')
-rw-r--r-- | src/testbed/test_testbed_api_peer_reconfiguration.c | 108 |
1 files changed, 53 insertions, 55 deletions
diff --git a/src/testbed/test_testbed_api_peer_reconfiguration.c b/src/testbed/test_testbed_api_peer_reconfiguration.c index e79876997..40791a9cc 100644 --- a/src/testbed/test_testbed_api_peer_reconfiguration.c +++ b/src/testbed/test_testbed_api_peer_reconfiguration.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 | ||
@@ -53,7 +53,6 @@ static struct GNUNET_SCHEDULER_Task * abort_task; | |||
53 | * States in this test | 53 | * States in this test |
54 | */ | 54 | */ |
55 | enum { | 55 | enum { |
56 | |||
57 | /** | 56 | /** |
58 | * Test has just been initialized | 57 | * Test has just been initialized |
59 | */ | 58 | */ |
@@ -68,20 +67,19 @@ enum { | |||
68 | * Peer has been reconfigured. Test completed successfully | 67 | * Peer has been reconfigured. Test completed successfully |
69 | */ | 68 | */ |
70 | STATE_PEER_RECONFIGURED | 69 | STATE_PEER_RECONFIGURED |
71 | |||
72 | } state; | 70 | } state; |
73 | 71 | ||
74 | /** | 72 | /** |
75 | * Fail testcase | 73 | * Fail testcase |
76 | */ | 74 | */ |
77 | #define FAIL_TEST(cond, ret) do { \ | 75 | #define FAIL_TEST(cond, ret) do { \ |
78 | if (!(cond)) { \ | 76 | if (!(cond)) { \ |
79 | GNUNET_break(0); \ | 77 | GNUNET_break(0); \ |
80 | if (NULL != abort_task) \ | 78 | if (NULL != abort_task) \ |
81 | GNUNET_SCHEDULER_cancel (abort_task); \ | 79 | GNUNET_SCHEDULER_cancel (abort_task); \ |
82 | abort_task = GNUNET_SCHEDULER_add_now (&do_abort, NULL); \ | 80 | abort_task = GNUNET_SCHEDULER_add_now(&do_abort, NULL); \ |
83 | ret; \ | 81 | ret; \ |
84 | } \ | 82 | } \ |
85 | } while (0) | 83 | } while (0) |
86 | 84 | ||
87 | 85 | ||
@@ -91,15 +89,15 @@ enum { | |||
91 | * @param cls NULL | 89 | * @param cls NULL |
92 | */ | 90 | */ |
93 | static void | 91 | static void |
94 | do_abort (void *cls) | 92 | do_abort(void *cls) |
95 | { | 93 | { |
96 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Aborting\n"); | 94 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Aborting\n"); |
97 | abort_task = NULL; | 95 | abort_task = NULL; |
98 | if (NULL != op) | 96 | if (NULL != op) |
99 | { | 97 | { |
100 | GNUNET_TESTBED_operation_done (op); | 98 | GNUNET_TESTBED_operation_done(op); |
101 | op = NULL; | 99 | op = NULL; |
102 | } | 100 | } |
103 | GNUNET_SCHEDULER_shutdown(); | 101 | GNUNET_SCHEDULER_shutdown(); |
104 | } | 102 | } |
105 | 103 | ||
@@ -112,29 +110,29 @@ do_abort (void *cls) | |||
112 | * @param event information about the event | 110 | * @param event information about the event |
113 | */ | 111 | */ |
114 | static void | 112 | static void |
115 | controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event) | 113 | controller_cb(void *cls, const struct GNUNET_TESTBED_EventInformation *event) |
116 | { | 114 | { |
117 | if (STATE_PEER_STARTED != state) | 115 | if (STATE_PEER_STARTED != state) |
118 | return; | 116 | return; |
119 | if (GNUNET_TESTBED_ET_OPERATION_FINISHED != event->type) | 117 | if (GNUNET_TESTBED_ET_OPERATION_FINISHED != event->type) |
120 | { | 118 | { |
121 | GNUNET_TESTBED_operation_done (op); | 119 | GNUNET_TESTBED_operation_done(op); |
122 | op = NULL; | 120 | op = NULL; |
123 | FAIL_TEST (0, return); | 121 | FAIL_TEST(0, return ); |
124 | } | 122 | } |
125 | if (NULL != event->details.operation_finished.emsg) | 123 | if (NULL != event->details.operation_finished.emsg) |
126 | { | 124 | { |
127 | fprintf (stderr, "Operation failed: %s\n", | 125 | fprintf(stderr, "Operation failed: %s\n", |
128 | event->details.operation_finished.emsg); | 126 | event->details.operation_finished.emsg); |
129 | GNUNET_TESTBED_operation_done (op); | 127 | GNUNET_TESTBED_operation_done(op); |
130 | op = NULL; | 128 | op = NULL; |
131 | FAIL_TEST (0, return); | 129 | FAIL_TEST(0, return ); |
132 | } | 130 | } |
133 | GNUNET_TESTBED_operation_done (op); | 131 | GNUNET_TESTBED_operation_done(op); |
134 | state = STATE_PEER_RECONFIGURED; | 132 | state = STATE_PEER_RECONFIGURED; |
135 | GNUNET_SCHEDULER_cancel (abort_task); | 133 | GNUNET_SCHEDULER_cancel(abort_task); |
136 | abort_task = NULL; | 134 | abort_task = NULL; |
137 | GNUNET_SCHEDULER_shutdown (); | 135 | GNUNET_SCHEDULER_shutdown(); |
138 | } | 136 | } |
139 | 137 | ||
140 | 138 | ||
@@ -151,27 +149,27 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event) | |||
151 | * failed | 149 | * failed |
152 | */ | 150 | */ |
153 | static void | 151 | static void |
154 | test_master (void *cls, | 152 | test_master(void *cls, |
155 | struct GNUNET_TESTBED_RunHandle *h, | 153 | struct GNUNET_TESTBED_RunHandle *h, |
156 | unsigned int num_peers, | 154 | unsigned int num_peers, |
157 | struct GNUNET_TESTBED_Peer **peers_, | 155 | struct GNUNET_TESTBED_Peer **peers_, |
158 | unsigned int links_succeeded, | 156 | unsigned int links_succeeded, |
159 | unsigned int links_failed) | 157 | unsigned int links_failed) |
160 | { | 158 | { |
161 | struct GNUNET_CONFIGURATION_Handle *cfg; | 159 | struct GNUNET_CONFIGURATION_Handle *cfg; |
162 | 160 | ||
163 | FAIL_TEST (NUM_PEERS == num_peers, return); | 161 | FAIL_TEST(NUM_PEERS == num_peers, return ); |
164 | state = STATE_PEER_STARTED; | 162 | state = STATE_PEER_STARTED; |
165 | peers = peers_; | 163 | peers = peers_; |
166 | cfg = GNUNET_CONFIGURATION_create (); | 164 | cfg = GNUNET_CONFIGURATION_create(); |
167 | FAIL_TEST (GNUNET_OK == GNUNET_CONFIGURATION_load | 165 | FAIL_TEST(GNUNET_OK == GNUNET_CONFIGURATION_load |
168 | (cfg, "test_testbed_api_testbed_run_topologyrandom.conf"), return); | 166 | (cfg, "test_testbed_api_testbed_run_topologyrandom.conf"), return ); |
169 | op = GNUNET_TESTBED_peer_update_configuration (peers[0], cfg); | 167 | op = GNUNET_TESTBED_peer_update_configuration(peers[0], cfg); |
170 | GNUNET_CONFIGURATION_destroy (cfg); | 168 | GNUNET_CONFIGURATION_destroy(cfg); |
171 | FAIL_TEST (NULL != op, return); | 169 | FAIL_TEST(NULL != op, return ); |
172 | abort_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 170 | abort_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply |
173 | (GNUNET_TIME_UNIT_SECONDS, 30), | 171 | (GNUNET_TIME_UNIT_SECONDS, 30), |
174 | &do_abort, NULL); | 172 | &do_abort, NULL); |
175 | } | 173 | } |
176 | 174 | ||
177 | 175 | ||
@@ -179,15 +177,15 @@ test_master (void *cls, | |||
179 | * Main function | 177 | * Main function |
180 | */ | 178 | */ |
181 | int | 179 | int |
182 | main (int argc, char **argv) | 180 | main(int argc, char **argv) |
183 | { | 181 | { |
184 | state = STATE_INIT; | 182 | state = STATE_INIT; |
185 | (void) GNUNET_TESTBED_test_run ("test_testbed_api_peer_reconfiguration", | 183 | (void)GNUNET_TESTBED_test_run("test_testbed_api_peer_reconfiguration", |
186 | "test_testbed_api.conf", | 184 | "test_testbed_api.conf", |
187 | NUM_PEERS, | 185 | NUM_PEERS, |
188 | 1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED, | 186 | 1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED, |
189 | &controller_cb, NULL, | 187 | &controller_cb, NULL, |
190 | &test_master, NULL); | 188 | &test_master, NULL); |
191 | if (STATE_PEER_RECONFIGURED != state) | 189 | if (STATE_PEER_RECONFIGURED != state) |
192 | return 1; | 190 | return 1; |
193 | return 0; | 191 | return 0; |