diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-10-05 15:09:28 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-10-05 15:09:28 +0200 |
commit | c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207 (patch) | |
tree | cac3ce030d77b4cbe7c7dc62ed58cfe6d24f73e1 /src/datastore/test_plugin_datastore.c | |
parent | fbb71d527c7d6babf269a8fefce1db291b9f7068 (diff) | |
download | gnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.tar.gz gnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.zip |
global reindent, now with uncrustify hook enabled
Diffstat (limited to 'src/datastore/test_plugin_datastore.c')
-rw-r--r-- | src/datastore/test_plugin_datastore.c | 450 |
1 files changed, 227 insertions, 223 deletions
diff --git a/src/datastore/test_plugin_datastore.c b/src/datastore/test_plugin_datastore.c index a260e1575..15fead3b7 100644 --- a/src/datastore/test_plugin_datastore.c +++ b/src/datastore/test_plugin_datastore.c | |||
@@ -44,7 +44,8 @@ static const char *plugin_name; | |||
44 | 44 | ||
45 | static int ok; | 45 | static int ok; |
46 | 46 | ||
47 | enum RunPhase { | 47 | enum RunPhase |
48 | { | ||
48 | RP_ERROR = 0, | 49 | RP_ERROR = 0, |
49 | RP_PUT, | 50 | RP_PUT, |
50 | RP_GET, | 51 | RP_GET, |
@@ -56,7 +57,8 @@ enum RunPhase { | |||
56 | }; | 57 | }; |
57 | 58 | ||
58 | 59 | ||
59 | struct CpsRunContext { | 60 | struct CpsRunContext |
61 | { | ||
60 | const struct GNUNET_CONFIGURATION_Handle *cfg; | 62 | const struct GNUNET_CONFIGURATION_Handle *cfg; |
61 | struct GNUNET_DATASTORE_PluginFunctions *api; | 63 | struct GNUNET_DATASTORE_PluginFunctions *api; |
62 | enum RunPhase phase; | 64 | enum RunPhase phase; |
@@ -74,14 +76,14 @@ struct CpsRunContext { | |||
74 | * 0 for "reset to empty" | 76 | * 0 for "reset to empty" |
75 | */ | 77 | */ |
76 | static void | 78 | static void |
77 | disk_utilization_change_cb(void *cls, int delta) | 79 | disk_utilization_change_cb (void *cls, int delta) |
78 | { | 80 | { |
79 | /* do nothing */ | 81 | /* do nothing */ |
80 | } | 82 | } |
81 | 83 | ||
82 | 84 | ||
83 | static void | 85 | static void |
84 | test(void *cls); | 86 | test (void *cls); |
85 | 87 | ||
86 | 88 | ||
87 | /** | 89 | /** |
@@ -94,47 +96,47 @@ test(void *cls); | |||
94 | * @param msg error message on error | 96 | * @param msg error message on error |
95 | */ | 97 | */ |
96 | static void | 98 | static void |
97 | put_continuation(void *cls, | 99 | put_continuation (void *cls, |
98 | const struct GNUNET_HashCode *key, | 100 | const struct GNUNET_HashCode *key, |
99 | uint32_t size, | 101 | uint32_t size, |
100 | int status, | 102 | int status, |
101 | const char *msg) | 103 | const char *msg) |
102 | { | 104 | { |
103 | struct CpsRunContext *crc = cls; | 105 | struct CpsRunContext *crc = cls; |
104 | static unsigned long long os; | 106 | static unsigned long long os; |
105 | unsigned long long cs; | 107 | unsigned long long cs; |
106 | 108 | ||
107 | if (GNUNET_OK != status) | 109 | if (GNUNET_OK != status) |
108 | { | 110 | { |
109 | fprintf(stderr, | 111 | fprintf (stderr, |
110 | "ERROR: `%s'\n", | 112 | "ERROR: `%s'\n", |
111 | msg); | 113 | msg); |
112 | } | 114 | } |
113 | else | 115 | else |
114 | { | 116 | { |
115 | crc->api->estimate_size(crc->api->cls, | 117 | crc->api->estimate_size (crc->api->cls, |
116 | &cs); | 118 | &cs); |
117 | GNUNET_assert(os <= cs); | 119 | GNUNET_assert (os <= cs); |
118 | os = cs; | 120 | os = cs; |
119 | stored_bytes += size; | 121 | stored_bytes += size; |
120 | stored_ops++; | 122 | stored_ops++; |
121 | stored_entries++; | 123 | stored_entries++; |
122 | } | 124 | } |
123 | GNUNET_SCHEDULER_add_now(&test, crc); | 125 | GNUNET_SCHEDULER_add_now (&test, crc); |
124 | } | 126 | } |
125 | 127 | ||
126 | 128 | ||
127 | static void | 129 | static void |
128 | gen_key(int i, struct GNUNET_HashCode * key) | 130 | gen_key (int i, struct GNUNET_HashCode *key) |
129 | { | 131 | { |
130 | memset(key, 0, sizeof(struct GNUNET_HashCode)); | 132 | memset (key, 0, sizeof(struct GNUNET_HashCode)); |
131 | key->bits[0] = (unsigned int)i; | 133 | key->bits[0] = (unsigned int) i; |
132 | GNUNET_CRYPTO_hash(key, sizeof(struct GNUNET_HashCode), key); | 134 | GNUNET_CRYPTO_hash (key, sizeof(struct GNUNET_HashCode), key); |
133 | } | 135 | } |
134 | 136 | ||
135 | 137 | ||
136 | static void | 138 | static void |
137 | do_put(struct CpsRunContext *crc) | 139 | do_put (struct CpsRunContext *crc) |
138 | { | 140 | { |
139 | char value[65536]; | 141 | char value[65536]; |
140 | size_t size; | 142 | size_t size; |
@@ -143,45 +145,46 @@ do_put(struct CpsRunContext *crc) | |||
143 | static int i; | 145 | static int i; |
144 | 146 | ||
145 | if (PUT_10 == i) | 147 | if (PUT_10 == i) |
146 | { | 148 | { |
147 | i = 0; | 149 | i = 0; |
148 | crc->phase++; | 150 | crc->phase++; |
149 | GNUNET_SCHEDULER_add_now(&test, crc); | 151 | GNUNET_SCHEDULER_add_now (&test, crc); |
150 | return; | 152 | return; |
151 | } | 153 | } |
152 | /* most content is 32k */ | 154 | /* most content is 32k */ |
153 | size = 32 * 1024; | 155 | size = 32 * 1024; |
154 | 156 | ||
155 | if (0 != i && GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, 16) == 0) /* but some of it is less! */ | 157 | if ((0 != i)&&(GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 16) == |
156 | size = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, 32 * 1024); | 158 | 0) ) /* but some of it is less! */ |
159 | size = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 32 * 1024); | ||
157 | size = size - (size & 7); /* always multiple of 8 */ | 160 | size = size - (size & 7); /* always multiple of 8 */ |
158 | 161 | ||
159 | /* generate random key */ | 162 | /* generate random key */ |
160 | gen_key(i, &key); | 163 | gen_key (i, &key); |
161 | memset(value, i, size); | 164 | memset (value, i, size); |
162 | if (i > 255) | 165 | if (i > 255) |
163 | memset(value, i - 255, size / 2); | 166 | memset (value, i - 255, size / 2); |
164 | value[0] = crc->i; | 167 | value[0] = crc->i; |
165 | prio = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, 100); | 168 | prio = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100); |
166 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 169 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
167 | "putting type %u, anon %u under key %s\n", i + 1, i, | 170 | "putting type %u, anon %u under key %s\n", i + 1, i, |
168 | GNUNET_h2s(&key)); | 171 | GNUNET_h2s (&key)); |
169 | crc->api->put(crc->api->cls, | 172 | crc->api->put (crc->api->cls, |
170 | &key, | 173 | &key, |
171 | false /* absent */, | 174 | false /* absent */, |
172 | size, | 175 | size, |
173 | value, i + 1 /* type */, | 176 | value, i + 1 /* type */, |
174 | prio, | 177 | prio, |
175 | i /* anonymity */, | 178 | i /* anonymity */, |
176 | 0 /* replication */, | 179 | 0 /* replication */, |
177 | GNUNET_TIME_relative_to_absolute | 180 | GNUNET_TIME_relative_to_absolute |
178 | (GNUNET_TIME_relative_multiply | 181 | (GNUNET_TIME_relative_multiply |
179 | (GNUNET_TIME_UNIT_MILLISECONDS, | 182 | (GNUNET_TIME_UNIT_MILLISECONDS, |
180 | 60 * 60 * 60 * 1000 + | 183 | 60 * 60 * 60 * 1000 |
181 | GNUNET_CRYPTO_random_u32 | 184 | + GNUNET_CRYPTO_random_u32 |
182 | (GNUNET_CRYPTO_QUALITY_WEAK, 1000))), | 185 | (GNUNET_CRYPTO_QUALITY_WEAK, 1000))), |
183 | put_continuation, | 186 | put_continuation, |
184 | crc); | 187 | crc); |
185 | i++; | 188 | i++; |
186 | } | 189 | } |
187 | 190 | ||
@@ -190,51 +193,51 @@ static uint64_t guid; | |||
190 | 193 | ||
191 | 194 | ||
192 | static int | 195 | static int |
193 | iterate_one_shot(void *cls, | 196 | iterate_one_shot (void *cls, |
194 | const struct GNUNET_HashCode *key, | 197 | const struct GNUNET_HashCode *key, |
195 | uint32_t size, | 198 | uint32_t size, |
196 | const void *data, | 199 | const void *data, |
197 | enum GNUNET_BLOCK_Type type, | 200 | enum GNUNET_BLOCK_Type type, |
198 | uint32_t priority, | 201 | uint32_t priority, |
199 | uint32_t anonymity, | 202 | uint32_t anonymity, |
200 | uint32_t replication, | 203 | uint32_t replication, |
201 | struct GNUNET_TIME_Absolute expiration, | 204 | struct GNUNET_TIME_Absolute expiration, |
202 | uint64_t uid) | 205 | uint64_t uid) |
203 | { | 206 | { |
204 | struct CpsRunContext *crc = cls; | 207 | struct CpsRunContext *crc = cls; |
205 | 208 | ||
206 | GNUNET_assert(NULL != key); | 209 | GNUNET_assert (NULL != key); |
207 | guid = uid; | 210 | guid = uid; |
208 | crc->phase++; | 211 | crc->phase++; |
209 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 212 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
210 | "Found result type=%u, priority=%u, size=%u, expire=%s, key %s\n", | 213 | "Found result type=%u, priority=%u, size=%u, expire=%s, key %s\n", |
211 | (unsigned int)type, | 214 | (unsigned int) type, |
212 | (unsigned int)priority, | 215 | (unsigned int) priority, |
213 | (unsigned int)size, | 216 | (unsigned int) size, |
214 | GNUNET_STRINGS_absolute_time_to_string(expiration), | 217 | GNUNET_STRINGS_absolute_time_to_string (expiration), |
215 | GNUNET_h2s(key)); | 218 | GNUNET_h2s (key)); |
216 | GNUNET_SCHEDULER_add_now(&test, | 219 | GNUNET_SCHEDULER_add_now (&test, |
217 | crc); | 220 | crc); |
218 | return GNUNET_OK; | 221 | return GNUNET_OK; |
219 | } | 222 | } |
220 | 223 | ||
221 | 224 | ||
222 | static void | 225 | static void |
223 | remove_continuation(void *cls, | 226 | remove_continuation (void *cls, |
224 | const struct GNUNET_HashCode *key, | 227 | const struct GNUNET_HashCode *key, |
225 | uint32_t size, | 228 | uint32_t size, |
226 | int status, | 229 | int status, |
227 | const char *msg) | 230 | const char *msg) |
228 | { | 231 | { |
229 | struct CpsRunContext *crc = cls; | 232 | struct CpsRunContext *crc = cls; |
230 | 233 | ||
231 | GNUNET_assert(NULL != key); | 234 | GNUNET_assert (NULL != key); |
232 | GNUNET_assert(32768 == size); | 235 | GNUNET_assert (32768 == size); |
233 | GNUNET_assert(GNUNET_OK == status); | 236 | GNUNET_assert (GNUNET_OK == status); |
234 | GNUNET_assert(NULL == msg); | 237 | GNUNET_assert (NULL == msg); |
235 | crc->phase++; | 238 | crc->phase++; |
236 | GNUNET_SCHEDULER_add_now(&test, | 239 | GNUNET_SCHEDULER_add_now (&test, |
237 | crc); | 240 | crc); |
238 | } | 241 | } |
239 | 242 | ||
240 | 243 | ||
@@ -246,28 +249,28 @@ remove_continuation(void *cls, | |||
246 | * @param cfg configuration to use | 249 | * @param cfg configuration to use |
247 | */ | 250 | */ |
248 | static void | 251 | static void |
249 | unload_plugin(struct GNUNET_DATASTORE_PluginFunctions *api, | 252 | unload_plugin (struct GNUNET_DATASTORE_PluginFunctions *api, |
250 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 253 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
251 | { | 254 | { |
252 | char *name; | 255 | char *name; |
253 | char *libname; | 256 | char *libname; |
254 | 257 | ||
255 | if (GNUNET_OK != | 258 | if (GNUNET_OK != |
256 | GNUNET_CONFIGURATION_get_value_string(cfg, | 259 | GNUNET_CONFIGURATION_get_value_string (cfg, |
257 | "DATASTORE", | 260 | "DATASTORE", |
258 | "DATABASE", | 261 | "DATABASE", |
259 | &name)) | 262 | &name)) |
260 | { | 263 | { |
261 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 264 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
262 | _("No `%s' specified for `%s' in configuration!\n"), | 265 | _ ("No `%s' specified for `%s' in configuration!\n"), |
263 | "DATABASE", | 266 | "DATABASE", |
264 | "DATASTORE"); | 267 | "DATASTORE"); |
265 | return; | 268 | return; |
266 | } | 269 | } |
267 | GNUNET_asprintf(&libname, "libgnunet_plugin_datastore_%s", name); | 270 | GNUNET_asprintf (&libname, "libgnunet_plugin_datastore_%s", name); |
268 | GNUNET_break(NULL == GNUNET_PLUGIN_unload(libname, api)); | 271 | GNUNET_break (NULL == GNUNET_PLUGIN_unload (libname, api)); |
269 | GNUNET_free(libname); | 272 | GNUNET_free (libname); |
270 | GNUNET_free(name); | 273 | GNUNET_free (name); |
271 | } | 274 | } |
272 | 275 | ||
273 | 276 | ||
@@ -277,99 +280,99 @@ unload_plugin(struct GNUNET_DATASTORE_PluginFunctions *api, | |||
277 | * the transport and core. | 280 | * the transport and core. |
278 | */ | 281 | */ |
279 | static void | 282 | static void |
280 | cleaning_task(void *cls) | 283 | cleaning_task (void *cls) |
281 | { | 284 | { |
282 | struct CpsRunContext *crc = cls; | 285 | struct CpsRunContext *crc = cls; |
283 | 286 | ||
284 | unload_plugin(crc->api, crc->cfg); | 287 | unload_plugin (crc->api, crc->cfg); |
285 | GNUNET_free(crc); | 288 | GNUNET_free (crc); |
286 | } | 289 | } |
287 | 290 | ||
288 | 291 | ||
289 | static void | 292 | static void |
290 | test(void *cls) | 293 | test (void *cls) |
291 | { | 294 | { |
292 | struct CpsRunContext *crc = cls; | 295 | struct CpsRunContext *crc = cls; |
293 | struct GNUNET_HashCode key; | 296 | struct GNUNET_HashCode key; |
294 | 297 | ||
295 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 298 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
296 | "In phase %d, iteration %u\n", crc->phase, crc->cnt); | 299 | "In phase %d, iteration %u\n", crc->phase, crc->cnt); |
297 | switch (crc->phase) | 300 | switch (crc->phase) |
301 | { | ||
302 | case RP_ERROR: | ||
303 | ok = 1; | ||
304 | GNUNET_break (0); | ||
305 | crc->api->drop (crc->api->cls); | ||
306 | GNUNET_SCHEDULER_add_now (&cleaning_task, crc); | ||
307 | break; | ||
308 | |||
309 | case RP_PUT: | ||
310 | do_put (crc); | ||
311 | break; | ||
312 | |||
313 | case RP_GET: | ||
314 | if (crc->cnt == 1) | ||
298 | { | 315 | { |
299 | case RP_ERROR: | 316 | crc->cnt = 0; |
300 | ok = 1; | 317 | crc->phase++; |
301 | GNUNET_break(0); | 318 | GNUNET_SCHEDULER_add_now (&test, crc); |
302 | crc->api->drop(crc->api->cls); | ||
303 | GNUNET_SCHEDULER_add_now(&cleaning_task, crc); | ||
304 | break; | ||
305 | |||
306 | case RP_PUT: | ||
307 | do_put(crc); | ||
308 | break; | ||
309 | |||
310 | case RP_GET: | ||
311 | if (crc->cnt == 1) | ||
312 | { | ||
313 | crc->cnt = 0; | ||
314 | crc->phase++; | ||
315 | GNUNET_SCHEDULER_add_now(&test, crc); | ||
316 | break; | ||
317 | } | ||
318 | gen_key(5, &key); | ||
319 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
320 | "Looking for %s\n", | ||
321 | GNUNET_h2s(&key)); | ||
322 | crc->api->get_key(crc->api->cls, | ||
323 | 0, | ||
324 | false, | ||
325 | &key, | ||
326 | GNUNET_BLOCK_TYPE_ANY, | ||
327 | &iterate_one_shot, | ||
328 | crc); | ||
329 | break; | 319 | break; |
330 | 320 | } | |
331 | case RP_ITER_ZERO: | 321 | gen_key (5, &key); |
332 | if (crc->cnt == 1) | 322 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
333 | { | 323 | "Looking for %s\n", |
334 | crc->cnt = 0; | 324 | GNUNET_h2s (&key)); |
335 | crc->phase++; | 325 | crc->api->get_key (crc->api->cls, |
336 | GNUNET_SCHEDULER_add_now(&test, crc); | 326 | 0, |
337 | break; | 327 | false, |
338 | } | 328 | &key, |
339 | crc->api->get_zero_anonymity(crc->api->cls, 0, 1, &iterate_one_shot, crc); | 329 | GNUNET_BLOCK_TYPE_ANY, |
330 | &iterate_one_shot, | ||
331 | crc); | ||
332 | break; | ||
333 | |||
334 | case RP_ITER_ZERO: | ||
335 | if (crc->cnt == 1) | ||
336 | { | ||
337 | crc->cnt = 0; | ||
338 | crc->phase++; | ||
339 | GNUNET_SCHEDULER_add_now (&test, crc); | ||
340 | break; | 340 | break; |
341 | } | ||
342 | crc->api->get_zero_anonymity (crc->api->cls, 0, 1, &iterate_one_shot, crc); | ||
343 | break; | ||
341 | 344 | ||
342 | case RP_REPL_GET: | 345 | case RP_REPL_GET: |
343 | crc->api->get_replication(crc->api->cls, &iterate_one_shot, crc); | 346 | crc->api->get_replication (crc->api->cls, &iterate_one_shot, crc); |
344 | break; | 347 | break; |
345 | 348 | ||
346 | case RP_EXPI_GET: | 349 | case RP_EXPI_GET: |
347 | crc->api->get_expiration(crc->api->cls, &iterate_one_shot, crc); | 350 | crc->api->get_expiration (crc->api->cls, &iterate_one_shot, crc); |
348 | break; | 351 | break; |
349 | 352 | ||
350 | case RP_REMOVE: | 353 | case RP_REMOVE: |
351 | { | 354 | { |
352 | struct GNUNET_HashCode key; | 355 | struct GNUNET_HashCode key; |
353 | uint32_t size = 32768; | 356 | uint32_t size = 32768; |
354 | char value[size]; | 357 | char value[size]; |
355 | 358 | ||
356 | gen_key(0, &key); | 359 | gen_key (0, &key); |
357 | memset(value, 0, size); | 360 | memset (value, 0, size); |
358 | value[0] = crc->i; | 361 | value[0] = crc->i; |
359 | crc->api->remove_key(crc->api->cls, | 362 | crc->api->remove_key (crc->api->cls, |
360 | &key, | 363 | &key, |
361 | size, | 364 | size, |
362 | value, | 365 | value, |
363 | &remove_continuation, | 366 | &remove_continuation, |
364 | crc); | 367 | crc); |
365 | break; | 368 | break; |
366 | } | 369 | } |
367 | 370 | ||
368 | case RP_DROP: | 371 | case RP_DROP: |
369 | crc->api->drop(crc->api->cls); | 372 | crc->api->drop (crc->api->cls); |
370 | GNUNET_SCHEDULER_add_now(&cleaning_task, crc); | 373 | GNUNET_SCHEDULER_add_now (&cleaning_task, crc); |
371 | break; | 374 | break; |
372 | } | 375 | } |
373 | } | 376 | } |
374 | 377 | ||
375 | 378 | ||
@@ -377,7 +380,7 @@ test(void *cls) | |||
377 | * Load the datastore plugin. | 380 | * Load the datastore plugin. |
378 | */ | 381 | */ |
379 | static struct GNUNET_DATASTORE_PluginFunctions * | 382 | static struct GNUNET_DATASTORE_PluginFunctions * |
380 | load_plugin(const struct GNUNET_CONFIGURATION_Handle *cfg) | 383 | load_plugin (const struct GNUNET_CONFIGURATION_Handle *cfg) |
381 | { | 384 | { |
382 | static struct GNUNET_DATASTORE_PluginEnvironment env; | 385 | static struct GNUNET_DATASTORE_PluginEnvironment env; |
383 | struct GNUNET_DATASTORE_PluginFunctions *ret; | 386 | struct GNUNET_DATASTORE_PluginFunctions *ret; |
@@ -385,61 +388,62 @@ load_plugin(const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
385 | char *libname; | 388 | char *libname; |
386 | 389 | ||
387 | if (GNUNET_OK != | 390 | if (GNUNET_OK != |
388 | GNUNET_CONFIGURATION_get_value_string(cfg, | 391 | GNUNET_CONFIGURATION_get_value_string (cfg, |
389 | "DATASTORE", | 392 | "DATASTORE", |
390 | "DATABASE", | 393 | "DATABASE", |
391 | &name)) | 394 | &name)) |
392 | { | 395 | { |
393 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 396 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
394 | _("No `%s' specified for `%s' in configuration!\n"), | 397 | _ ("No `%s' specified for `%s' in configuration!\n"), |
395 | "DATABASE", | 398 | "DATABASE", |
396 | "DATASTORE"); | 399 | "DATASTORE"); |
397 | return NULL; | 400 | return NULL; |
398 | } | 401 | } |
399 | env.cfg = cfg; | 402 | env.cfg = cfg; |
400 | env.duc = &disk_utilization_change_cb; | 403 | env.duc = &disk_utilization_change_cb; |
401 | env.cls = NULL; | 404 | env.cls = NULL; |
402 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Loading `%s' datastore plugin\n"), | 405 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _ ("Loading `%s' datastore plugin\n"), |
403 | name); | 406 | name); |
404 | GNUNET_asprintf(&libname, "libgnunet_plugin_datastore_%s", name); | 407 | GNUNET_asprintf (&libname, "libgnunet_plugin_datastore_%s", name); |
405 | if (NULL == (ret = GNUNET_PLUGIN_load(libname, &env))) | 408 | if (NULL == (ret = GNUNET_PLUGIN_load (libname, &env))) |
406 | { | 409 | { |
407 | fprintf(stderr, "Failed to load plugin `%s'!\n", name); | 410 | fprintf (stderr, "Failed to load plugin `%s'!\n", name); |
408 | GNUNET_free(libname); | 411 | GNUNET_free (libname); |
409 | GNUNET_free(name); | 412 | GNUNET_free (name); |
410 | ok = 77; /* mark test as skipped */ | 413 | ok = 77; /* mark test as skipped */ |
411 | return NULL; | 414 | return NULL; |
412 | } | 415 | } |
413 | GNUNET_free(libname); | 416 | GNUNET_free (libname); |
414 | GNUNET_free(name); | 417 | GNUNET_free (name); |
415 | return ret; | 418 | return ret; |
416 | } | 419 | } |
417 | 420 | ||
418 | 421 | ||
419 | static void | 422 | static void |
420 | run(void *cls, char *const *args, const char *cfgfile, | 423 | run (void *cls, char *const *args, const char *cfgfile, |
421 | const struct GNUNET_CONFIGURATION_Handle *c) | 424 | const struct GNUNET_CONFIGURATION_Handle *c) |
422 | { | 425 | { |
423 | struct GNUNET_DATASTORE_PluginFunctions *api; | 426 | struct GNUNET_DATASTORE_PluginFunctions *api; |
424 | struct CpsRunContext *crc; | 427 | struct CpsRunContext *crc; |
425 | 428 | ||
426 | api = load_plugin(c); | 429 | api = load_plugin (c); |
427 | if (api == NULL) | 430 | if (api == NULL) |
428 | { | 431 | { |
429 | fprintf(stderr, | 432 | fprintf (stderr, |
430 | "%s", "Could not initialize plugin, assuming database not configured. Test not run!\n"); | 433 | "%s", |
431 | return; | 434 | "Could not initialize plugin, assuming database not configured. Test not run!\n"); |
432 | } | 435 | return; |
433 | crc = GNUNET_new(struct CpsRunContext); | 436 | } |
437 | crc = GNUNET_new (struct CpsRunContext); | ||
434 | crc->api = api; | 438 | crc->api = api; |
435 | crc->cfg = c; | 439 | crc->cfg = c; |
436 | crc->phase = RP_PUT; | 440 | crc->phase = RP_PUT; |
437 | GNUNET_SCHEDULER_add_now(&test, crc); | 441 | GNUNET_SCHEDULER_add_now (&test, crc); |
438 | } | 442 | } |
439 | 443 | ||
440 | 444 | ||
441 | int | 445 | int |
442 | main(int argc, char *argv[]) | 446 | main (int argc, char *argv[]) |
443 | { | 447 | { |
444 | char dir_name[PATH_MAX]; | 448 | char dir_name[PATH_MAX]; |
445 | char cfg_name[PATH_MAX]; | 449 | char cfg_name[PATH_MAX]; |
@@ -454,20 +458,20 @@ main(int argc, char *argv[]) | |||
454 | }; | 458 | }; |
455 | 459 | ||
456 | /* determine name of plugin to use */ | 460 | /* determine name of plugin to use */ |
457 | plugin_name = GNUNET_TESTING_get_testname_from_underscore(argv[0]); | 461 | plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); |
458 | GNUNET_snprintf(dir_name, sizeof(dir_name), | 462 | GNUNET_snprintf (dir_name, sizeof(dir_name), |
459 | "/tmp/test-gnunet-datastore-plugin-%s", plugin_name); | 463 | "/tmp/test-gnunet-datastore-plugin-%s", plugin_name); |
460 | GNUNET_DISK_directory_remove(dir_name); | 464 | GNUNET_DISK_directory_remove (dir_name); |
461 | GNUNET_log_setup("test-plugin-datastore", | 465 | GNUNET_log_setup ("test-plugin-datastore", |
462 | "WARNING", | 466 | "WARNING", |
463 | NULL); | 467 | NULL); |
464 | GNUNET_snprintf(cfg_name, sizeof(cfg_name), | 468 | GNUNET_snprintf (cfg_name, sizeof(cfg_name), |
465 | "test_plugin_datastore_data_%s.conf", plugin_name); | 469 | "test_plugin_datastore_data_%s.conf", plugin_name); |
466 | GNUNET_PROGRAM_run((sizeof(xargv) / sizeof(char *)) - 1, xargv, | 470 | GNUNET_PROGRAM_run ((sizeof(xargv) / sizeof(char *)) - 1, xargv, |
467 | "test-plugin-datastore", "nohelp", options, &run, NULL); | 471 | "test-plugin-datastore", "nohelp", options, &run, NULL); |
468 | if ((0 != ok) && (77 != ok)) | 472 | if ((0 != ok) && (77 != ok)) |
469 | fprintf(stderr, "Missed some testcases: %u\n", ok); | 473 | fprintf (stderr, "Missed some testcases: %u\n", ok); |
470 | GNUNET_DISK_directory_remove(dir_name); | 474 | GNUNET_DISK_directory_remove (dir_name); |
471 | return ok; | 475 | return ok; |
472 | } | 476 | } |
473 | 477 | ||