summaryrefslogtreecommitdiff
path: root/src/identity/test_identity_defaults.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/identity/test_identity_defaults.c')
-rw-r--r--src/identity/test_identity_defaults.c178
1 files changed, 89 insertions, 89 deletions
diff --git a/src/identity/test_identity_defaults.c b/src/identity/test_identity_defaults.c
index 71e70e7ba..6e14022c6 100644
--- a/src/identity/test_identity_defaults.c
+++ b/src/identity/test_identity_defaults.c
@@ -16,7 +16,7 @@
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 identity/test_identity.c 22 * @file identity/test_identity.c
@@ -29,7 +29,7 @@
29#include "gnunet_testing_lib.h" 29#include "gnunet_testing_lib.h"
30 30
31 31
32#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) 32#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10)
33 33
34 34
35/** 35/**
@@ -54,33 +54,33 @@ static struct GNUNET_SCHEDULER_Task *endbadly_task;
54 54
55#define CHECK(cond) \ 55#define CHECK(cond) \
56 do \ 56 do \
57 { \ 57 { \
58 if (! (cond)) \ 58 if (!(cond)) \
59 { \ 59 { \
60 GNUNET_break (0); \ 60 GNUNET_break(0); \
61 end (); \ 61 end(); \
62 return; \ 62 return; \
63 } \ 63 } \
64 } while (0) 64 } while (0)
65 65
66 66
67/** 67/**
68 * Clean up all resources used. 68 * Clean up all resources used.
69 */ 69 */
70static void 70static void
71cleanup (void *cls) 71cleanup(void *cls)
72{ 72{
73 (void) cls; 73 (void)cls;
74 if (NULL != op) 74 if (NULL != op)
75 { 75 {
76 GNUNET_IDENTITY_cancel (op); 76 GNUNET_IDENTITY_cancel(op);
77 op = NULL; 77 op = NULL;
78 } 78 }
79 if (NULL != h) 79 if (NULL != h)
80 { 80 {
81 GNUNET_IDENTITY_disconnect (h); 81 GNUNET_IDENTITY_disconnect(h);
82 h = NULL; 82 h = NULL;
83 } 83 }
84} 84}
85 85
86 86
@@ -90,9 +90,9 @@ cleanup (void *cls)
90 * @param cls NULL 90 * @param cls NULL
91 */ 91 */
92static void 92static void
93endbadly (void *cls) 93endbadly(void *cls)
94{ 94{
95 GNUNET_SCHEDULER_shutdown (); 95 GNUNET_SCHEDULER_shutdown();
96 res = 1; 96 res = 1;
97} 97}
98 98
@@ -101,14 +101,14 @@ endbadly (void *cls)
101 * Termiante the testcase. 101 * Termiante the testcase.
102 */ 102 */
103static void 103static void
104end () 104end()
105{ 105{
106 if (NULL != endbadly_task) 106 if (NULL != endbadly_task)
107 { 107 {
108 GNUNET_SCHEDULER_cancel (endbadly_task); 108 GNUNET_SCHEDULER_cancel(endbadly_task);
109 endbadly_task = NULL; 109 endbadly_task = NULL;
110 } 110 }
111 GNUNET_SCHEDULER_shutdown (); 111 GNUNET_SCHEDULER_shutdown();
112} 112}
113 113
114 114
@@ -119,12 +119,12 @@ end ()
119 * @param emsg (should also be NULL) 119 * @param emsg (should also be NULL)
120 */ 120 */
121static void 121static void
122delete_cont (void *cls, const char *emsg) 122delete_cont(void *cls, const char *emsg)
123{ 123{
124 op = NULL; 124 op = NULL;
125 CHECK (NULL == emsg); 125 CHECK(NULL == emsg);
126 res = 0; 126 res = 0;
127 end (); 127 end();
128} 128}
129 129
130 130
@@ -135,16 +135,16 @@ delete_cont (void *cls, const char *emsg)
135 * @param emsg (should also be NULL) 135 * @param emsg (should also be NULL)
136 */ 136 */
137static void 137static void
138get_cb (void *cls, 138get_cb(void *cls,
139 struct GNUNET_IDENTITY_Ego *ego, 139 struct GNUNET_IDENTITY_Ego *ego,
140 void **ctx, 140 void **ctx,
141 const char *identifier) 141 const char *identifier)
142{ 142{
143 op = NULL; 143 op = NULL;
144 CHECK (NULL != ego); 144 CHECK(NULL != ego);
145 CHECK (NULL != identifier); 145 CHECK(NULL != identifier);
146 CHECK (0 == strcmp (identifier, "test-id")); 146 CHECK(0 == strcmp(identifier, "test-id"));
147 op = GNUNET_IDENTITY_delete (h, "test-id", &delete_cont, NULL); 147 op = GNUNET_IDENTITY_delete(h, "test-id", &delete_cont, NULL);
148} 148}
149 149
150 150
@@ -160,15 +160,15 @@ get_cb (void *cls,
160 * must thus no longer be used 160 * must thus no longer be used
161 */ 161 */
162static void 162static void
163dummy_cb (void *cls, 163dummy_cb(void *cls,
164 struct GNUNET_IDENTITY_Ego *ego, 164 struct GNUNET_IDENTITY_Ego *ego,
165 void **ctx, 165 void **ctx,
166 const char *identifier) 166 const char *identifier)
167{ 167{
168 (void) cls; 168 (void)cls;
169 (void) ego; 169 (void)ego;
170 (void) ctx; 170 (void)ctx;
171 (void) identifier; 171 (void)identifier;
172} 172}
173 173
174 174
@@ -180,15 +180,15 @@ dummy_cb (void *cls,
180 * @param peer handle to access more of the peer (not used) 180 * @param peer handle to access more of the peer (not used)
181 */ 181 */
182static void 182static void
183run_get (void *cls, 183run_get(void *cls,
184 const struct GNUNET_CONFIGURATION_Handle *cfg, 184 const struct GNUNET_CONFIGURATION_Handle *cfg,
185 struct GNUNET_TESTING_Peer *peer) 185 struct GNUNET_TESTING_Peer *peer)
186{ 186{
187 endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &endbadly, NULL); 187 endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT, &endbadly, NULL);
188 GNUNET_SCHEDULER_add_shutdown (&cleanup, NULL); 188 GNUNET_SCHEDULER_add_shutdown(&cleanup, NULL);
189 h = GNUNET_IDENTITY_connect (cfg, &dummy_cb, NULL); 189 h = GNUNET_IDENTITY_connect(cfg, &dummy_cb, NULL);
190 CHECK (NULL != h); 190 CHECK(NULL != h);
191 op = GNUNET_IDENTITY_get (h, "test-service", &get_cb, NULL); 191 op = GNUNET_IDENTITY_get(h, "test-service", &get_cb, NULL);
192} 192}
193 193
194 194
@@ -199,11 +199,11 @@ run_get (void *cls,
199 * @param emsg (should also be NULL) 199 * @param emsg (should also be NULL)
200 */ 200 */
201static void 201static void
202success_set_cont (void *cls, const char *emsg) 202success_set_cont(void *cls, const char *emsg)
203{ 203{
204 op = NULL; 204 op = NULL;
205 CHECK (NULL == emsg); 205 CHECK(NULL == emsg);
206 end (); 206 end();
207} 207}
208 208
209 209
@@ -219,16 +219,16 @@ success_set_cont (void *cls, const char *emsg)
219 * must thus no longer be used 219 * must thus no longer be used
220 */ 220 */
221static void 221static void
222notification_cb (void *cls, 222notification_cb(void *cls,
223 struct GNUNET_IDENTITY_Ego *ego, 223 struct GNUNET_IDENTITY_Ego *ego,
224 void **ctx, 224 void **ctx,
225 const char *identifier) 225 const char *identifier)
226{ 226{
227 if (NULL == ego) 227 if (NULL == ego)
228 return; /* skip first call */ 228 return; /* skip first call */
229 if (NULL == identifier) 229 if (NULL == identifier)
230 return; /* deletion / shutdown */ 230 return; /* deletion / shutdown */
231 op = GNUNET_IDENTITY_set (h, "test-service", ego, &success_set_cont, NULL); 231 op = GNUNET_IDENTITY_set(h, "test-service", ego, &success_set_cont, NULL);
232} 232}
233 233
234 234
@@ -240,12 +240,12 @@ notification_cb (void *cls,
240 * @param emsg error message 240 * @param emsg error message
241 */ 241 */
242static void 242static void
243create_cb (void *cls, 243create_cb(void *cls,
244 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk, 244 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk,
245 const char *emsg) 245 const char *emsg)
246{ 246{
247 CHECK (NULL == emsg); 247 CHECK(NULL == emsg);
248 CHECK (NULL != pk); 248 CHECK(NULL != pk);
249 op = NULL; 249 op = NULL;
250} 250}
251 251
@@ -258,36 +258,36 @@ create_cb (void *cls,
258 * @param peer handle to access more of the peer (not used) 258 * @param peer handle to access more of the peer (not used)
259 */ 259 */
260static void 260static void
261run_set (void *cls, 261run_set(void *cls,
262 const struct GNUNET_CONFIGURATION_Handle *cfg, 262 const struct GNUNET_CONFIGURATION_Handle *cfg,
263 struct GNUNET_TESTING_Peer *peer) 263 struct GNUNET_TESTING_Peer *peer)
264{ 264{
265 endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &endbadly, NULL); 265 endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT, &endbadly, NULL);
266 GNUNET_SCHEDULER_add_shutdown (&cleanup, NULL); 266 GNUNET_SCHEDULER_add_shutdown(&cleanup, NULL);
267 h = GNUNET_IDENTITY_connect (cfg, &notification_cb, NULL); 267 h = GNUNET_IDENTITY_connect(cfg, &notification_cb, NULL);
268 CHECK (NULL != h); 268 CHECK(NULL != h);
269 op = GNUNET_IDENTITY_create (h, "test-id", &create_cb, NULL); 269 op = GNUNET_IDENTITY_create(h, "test-id", &create_cb, NULL);
270} 270}
271 271
272 272
273int 273int
274main (int argc, char *argv[]) 274main(int argc, char *argv[])
275{ 275{
276 GNUNET_DISK_directory_remove ("/tmp/gnunet/test-identity-service"); 276 GNUNET_DISK_directory_remove("/tmp/gnunet/test-identity-service");
277 res = 1; 277 res = 1;
278 if (0 != GNUNET_TESTING_service_run ("test-identity-defaults", 278 if (0 != GNUNET_TESTING_service_run("test-identity-defaults",
279 "identity", 279 "identity",
280 "test_identity.conf", 280 "test_identity.conf",
281 &run_set, 281 &run_set,
282 NULL)) 282 NULL))
283 return 1; 283 return 1;
284 if (0 != GNUNET_TESTING_service_run ("test-identity-defaults", 284 if (0 != GNUNET_TESTING_service_run("test-identity-defaults",
285 "identity", 285 "identity",
286 "test_identity.conf", 286 "test_identity.conf",
287 &run_get, 287 &run_get,
288 NULL)) 288 NULL))
289 return 1; 289 return 1;
290 GNUNET_DISK_directory_remove ("/tmp/gnunet/test-identity-service"); 290 GNUNET_DISK_directory_remove("/tmp/gnunet/test-identity-service");
291 return res; 291 return res;
292} 292}
293 293