diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-07-17 20:26:02 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-07-17 20:26:02 +0000 |
commit | aabe756fa2d764481c337060d27ff03c74b9e320 (patch) | |
tree | 4f0f5222a0e8cab9d7e99ca6a0f16c6752562472 /src/identity/test_identity_defaults.c | |
parent | 4fbefa9b5336452df611c4f02232a45caa1d0e6f (diff) | |
download | gnunet-aabe756fa2d764481c337060d27ff03c74b9e320.tar.gz gnunet-aabe756fa2d764481c337060d27ff03c74b9e320.zip |
-misc bugfixes and test-fixes
Diffstat (limited to 'src/identity/test_identity_defaults.c')
-rw-r--r-- | src/identity/test_identity_defaults.c | 93 |
1 files changed, 30 insertions, 63 deletions
diff --git a/src/identity/test_identity_defaults.c b/src/identity/test_identity_defaults.c index c0b6efc50..2caf03a1e 100644 --- a/src/identity/test_identity_defaults.c +++ b/src/identity/test_identity_defaults.c | |||
@@ -119,58 +119,6 @@ end () | |||
119 | 119 | ||
120 | 120 | ||
121 | /** | 121 | /** |
122 | * Called with events about egos. | ||
123 | * | ||
124 | * @param cls NULL | ||
125 | * @param ego ego handle | ||
126 | * @param ego_ctx context for application to store data for this ego | ||
127 | * (during the lifetime of this process, initially NULL) | ||
128 | * @param identifier identifier assigned by the user for this ego, | ||
129 | * NULL if the user just deleted the ego and it | ||
130 | * must thus no longer be used | ||
131 | */ | ||
132 | static void | ||
133 | notification_cb (void *cls, | ||
134 | struct GNUNET_IDENTITY_Ego *ego, | ||
135 | void **ctx, | ||
136 | const char *identifier) | ||
137 | { | ||
138 | #if 0 | ||
139 | static struct GNUNET_IDENTITY_Ego *my_ego; | ||
140 | static int round; | ||
141 | |||
142 | switch (round) | ||
143 | { | ||
144 | case 0: /* end of initial iteration */ | ||
145 | GNUNET_assert (NULL == ego); | ||
146 | GNUNET_assert (NULL == identifier); | ||
147 | break; | ||
148 | case 1: /* create */ | ||
149 | GNUNET_assert (NULL != ego); | ||
150 | GNUNET_assert (0 == strcmp (identifier, "test-id")); | ||
151 | my_ego = ego; | ||
152 | *ctx = &round; | ||
153 | break; | ||
154 | case 2: /* rename */ | ||
155 | GNUNET_assert (my_ego == ego); | ||
156 | GNUNET_assert (0 == strcmp (identifier, "test")); | ||
157 | GNUNET_assert (*ctx == &round); | ||
158 | break; | ||
159 | case 3: /* delete */ | ||
160 | GNUNET_assert (my_ego == ego); | ||
161 | GNUNET_assert (NULL == identifier); | ||
162 | GNUNET_assert (*ctx == &round); | ||
163 | *ctx = NULL; | ||
164 | break; | ||
165 | default: | ||
166 | GNUNET_break (0); | ||
167 | } | ||
168 | round++; | ||
169 | #endif | ||
170 | } | ||
171 | |||
172 | |||
173 | /** | ||
174 | * Continuation called from successful delete operation. | 122 | * Continuation called from successful delete operation. |
175 | * | 123 | * |
176 | * @param cls NULL | 124 | * @param cls NULL |
@@ -198,8 +146,8 @@ get_cb (void *cls, | |||
198 | void **ctx, | 146 | void **ctx, |
199 | const char *identifier) | 147 | const char *identifier) |
200 | { | 148 | { |
201 | GNUNET_assert (NULL != emsg); | 149 | GNUNET_assert (NULL != ego); |
202 | GNUNET_assert (my_ego == ego); | 150 | GNUNET_assert (NULL != identifier); |
203 | GNUNET_assert (0 == strcmp (identifier, "test-id")); | 151 | GNUNET_assert (0 == strcmp (identifier, "test-id")); |
204 | op = GNUNET_IDENTITY_delete (h, | 152 | op = GNUNET_IDENTITY_delete (h, |
205 | "test-id", | 153 | "test-id", |
@@ -222,7 +170,7 @@ run_get (void *cls, | |||
222 | { | 170 | { |
223 | endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, | 171 | endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, |
224 | &endbadly, NULL); | 172 | &endbadly, NULL); |
225 | h = GNUNET_IDENTITY_connect (cfg, ¬ification_cb, NULL); | 173 | h = GNUNET_IDENTITY_connect (cfg, NULL, NULL); |
226 | GNUNET_assert (NULL != h); | 174 | GNUNET_assert (NULL != h); |
227 | op = GNUNET_IDENTITY_get (h, | 175 | op = GNUNET_IDENTITY_get (h, |
228 | "test-service", | 176 | "test-service", |
@@ -248,7 +196,7 @@ success_set_cont (void *cls, | |||
248 | 196 | ||
249 | 197 | ||
250 | /** | 198 | /** |
251 | * Called with events about created ego. | 199 | * Called with events about egos. |
252 | * | 200 | * |
253 | * @param cls NULL | 201 | * @param cls NULL |
254 | * @param ego ego handle | 202 | * @param ego ego handle |
@@ -259,11 +207,13 @@ success_set_cont (void *cls, | |||
259 | * must thus no longer be used | 207 | * must thus no longer be used |
260 | */ | 208 | */ |
261 | static void | 209 | static void |
262 | create_cb (void *cls, | 210 | notification_cb (void *cls, |
263 | struct GNUNET_IDENTITY_Ego *ego, | 211 | struct GNUNET_IDENTITY_Ego *ego, |
264 | void **ctx, | 212 | void **ctx, |
265 | const char *identifier) | 213 | const char *identifier) |
266 | { | 214 | { |
215 | if (NULL == ego) | ||
216 | return; /* skip first call */ | ||
267 | op = GNUNET_IDENTITY_set (h, | 217 | op = GNUNET_IDENTITY_set (h, |
268 | "test-service", | 218 | "test-service", |
269 | ego, | 219 | ego, |
@@ -273,6 +223,21 @@ create_cb (void *cls, | |||
273 | 223 | ||
274 | 224 | ||
275 | /** | 225 | /** |
226 | * Called with events about created ego. | ||
227 | * | ||
228 | * @param cls NULL | ||
229 | * @param emsg error message | ||
230 | */ | ||
231 | static void | ||
232 | create_cb (void *cls, | ||
233 | const char *emsg) | ||
234 | { | ||
235 | GNUNET_assert (NULL == emsg); | ||
236 | op = NULL; | ||
237 | } | ||
238 | |||
239 | |||
240 | /** | ||
276 | * Main function of the test, run from scheduler. | 241 | * Main function of the test, run from scheduler. |
277 | * | 242 | * |
278 | * @param cls NULL | 243 | * @param cls NULL |
@@ -299,21 +264,23 @@ run_set (void *cls, | |||
299 | int | 264 | int |
300 | main (int argc, char *argv[]) | 265 | main (int argc, char *argv[]) |
301 | { | 266 | { |
267 | GNUNET_DISK_directory_remove ("/tmp/test-identity-service"); | ||
302 | res = 1; | 268 | res = 1; |
303 | if (0 != | 269 | if (0 != |
304 | GNUNET_TESTING_service_run ("test-identity", | 270 | GNUNET_TESTING_service_run ("test-identity-defaults", |
305 | "identity", | 271 | "identity", |
306 | "test_identity.conf", | 272 | "test_identity.conf", |
307 | &run_set, | 273 | &run_set, |
308 | NULL)) | 274 | NULL)) |
309 | return 1; | 275 | return 1; |
310 | if (0 != | 276 | if (0 != |
311 | GNUNET_TESTING_service_run ("test-identity", | 277 | GNUNET_TESTING_service_run ("test-identity-defaults", |
312 | "identity", | 278 | "identity", |
313 | "test_identity.conf", | 279 | "test_identity.conf", |
314 | &run_get, | 280 | &run_get, |
315 | NULL)) | 281 | NULL)) |
316 | return 1; | 282 | return 1; |
283 | GNUNET_DISK_directory_remove ("/tmp/test-identity-service"); | ||
317 | return res; | 284 | return res; |
318 | } | 285 | } |
319 | 286 | ||