diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-08-15 21:54:06 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-08-15 21:54:06 +0000 |
commit | 5746309cb4be2073d550ad7a6885e918631dbc38 (patch) | |
tree | 89455bc4aadf977816b38df13f990372cd81d71a /src/datastore/test_datastore_api_management.c | |
parent | 6fd3e715cae09fa6e657c96f1c6f9711ee51f42f (diff) | |
download | gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.tar.gz gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.zip |
indentation
Diffstat (limited to 'src/datastore/test_datastore_api_management.c')
-rw-r--r-- | src/datastore/test_datastore_api_management.c | 125 |
1 files changed, 51 insertions, 74 deletions
diff --git a/src/datastore/test_datastore_api_management.c b/src/datastore/test_datastore_api_management.c index b2146a915..230b7eb67 100644 --- a/src/datastore/test_datastore_api_management.c +++ b/src/datastore/test_datastore_api_management.c | |||
@@ -117,8 +117,8 @@ struct CpsRunContext | |||
117 | }; | 117 | }; |
118 | 118 | ||
119 | 119 | ||
120 | static void | 120 | static void run_continuation (void *cls, |
121 | run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | 121 | const struct GNUNET_SCHEDULER_TaskContext *tc); |
122 | 122 | ||
123 | 123 | ||
124 | static void | 124 | static void |
@@ -131,20 +131,16 @@ check_success (void *cls, int success, const char *msg) | |||
131 | GNUNET_assert (GNUNET_OK == success); | 131 | GNUNET_assert (GNUNET_OK == success); |
132 | GNUNET_free_non_null (crc->data); | 132 | GNUNET_free_non_null (crc->data); |
133 | crc->data = NULL; | 133 | crc->data = NULL; |
134 | GNUNET_SCHEDULER_add_continuation (&run_continuation, | 134 | GNUNET_SCHEDULER_add_continuation (&run_continuation, crc, |
135 | crc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); | 135 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); |
136 | } | 136 | } |
137 | 137 | ||
138 | 138 | ||
139 | static void | 139 | static void |
140 | check_value (void *cls, | 140 | check_value (void *cls, const GNUNET_HashCode * key, size_t size, |
141 | const GNUNET_HashCode * key, | 141 | const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority, |
142 | size_t size, | 142 | uint32_t anonymity, struct GNUNET_TIME_Absolute expiration, |
143 | const void *data, | 143 | uint64_t uid) |
144 | enum GNUNET_BLOCK_Type type, | ||
145 | uint32_t priority, | ||
146 | uint32_t anonymity, | ||
147 | struct GNUNET_TIME_Absolute expiration, uint64_t uid) | ||
148 | { | 144 | { |
149 | struct CpsRunContext *crc = cls; | 145 | struct CpsRunContext *crc = cls; |
150 | int i; | 146 | int i; |
@@ -152,8 +148,7 @@ check_value (void *cls, | |||
152 | if (NULL == key) | 148 | if (NULL == key) |
153 | { | 149 | { |
154 | crc->phase = RP_GET_FAIL; | 150 | crc->phase = RP_GET_FAIL; |
155 | GNUNET_SCHEDULER_add_continuation (&run_continuation, | 151 | GNUNET_SCHEDULER_add_continuation (&run_continuation, crc, |
156 | crc, | ||
157 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); | 152 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); |
158 | return; | 153 | return; |
159 | } | 154 | } |
@@ -168,28 +163,24 @@ check_value (void *cls, | |||
168 | crc->i--; | 163 | crc->i--; |
169 | if (crc->i == 0) | 164 | if (crc->i == 0) |
170 | crc->phase = RP_DONE; | 165 | crc->phase = RP_DONE; |
171 | GNUNET_SCHEDULER_add_continuation (&run_continuation, | 166 | GNUNET_SCHEDULER_add_continuation (&run_continuation, crc, |
172 | crc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); | 167 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); |
173 | } | 168 | } |
174 | 169 | ||
175 | 170 | ||
176 | static void | 171 | static void |
177 | check_nothing (void *cls, | 172 | check_nothing (void *cls, const GNUNET_HashCode * key, size_t size, |
178 | const GNUNET_HashCode * key, | 173 | const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority, |
179 | size_t size, | 174 | uint32_t anonymity, struct GNUNET_TIME_Absolute expiration, |
180 | const void *data, | 175 | uint64_t uid) |
181 | enum GNUNET_BLOCK_Type type, | ||
182 | uint32_t priority, | ||
183 | uint32_t anonymity, | ||
184 | struct GNUNET_TIME_Absolute expiration, uint64_t uid) | ||
185 | { | 176 | { |
186 | struct CpsRunContext *crc = cls; | 177 | struct CpsRunContext *crc = cls; |
187 | 178 | ||
188 | GNUNET_assert (key == NULL); | 179 | GNUNET_assert (key == NULL); |
189 | if (0 == --crc->i) | 180 | if (0 == --crc->i) |
190 | crc->phase = RP_DONE; | 181 | crc->phase = RP_DONE; |
191 | GNUNET_SCHEDULER_add_continuation (&run_continuation, | 182 | GNUNET_SCHEDULER_add_continuation (&run_continuation, crc, |
192 | crc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); | 183 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); |
193 | } | 184 | } |
194 | 185 | ||
195 | 186 | ||
@@ -203,21 +194,15 @@ run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
203 | { | 194 | { |
204 | case RP_PUT: | 195 | case RP_PUT: |
205 | #if VERBOSE | 196 | #if VERBOSE |
206 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 197 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing `%s' number %u\n", "PUT", |
207 | "Executing `%s' number %u\n", "PUT", crc->i); | 198 | crc->i); |
208 | #endif | 199 | #endif |
209 | GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); | 200 | GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); |
210 | GNUNET_DATASTORE_put (datastore, | 201 | GNUNET_DATASTORE_put (datastore, 0, &crc->key, get_size (crc->i), |
211 | 0, | 202 | get_data (crc->i), get_type (crc->i), |
212 | &crc->key, | 203 | get_priority (crc->i), get_anonymity (crc->i), 0, |
213 | get_size (crc->i), | 204 | get_expiration (crc->i), 1, 1, TIMEOUT, |
214 | get_data (crc->i), | 205 | &check_success, crc); |
215 | get_type (crc->i), | ||
216 | get_priority (crc->i), | ||
217 | get_anonymity (crc->i), | ||
218 | 0, | ||
219 | get_expiration (crc->i), | ||
220 | 1, 1, TIMEOUT, &check_success, crc); | ||
221 | crc->i++; | 206 | crc->i++; |
222 | if (crc->i == ITERATIONS) | 207 | if (crc->i == ITERATIONS) |
223 | { | 208 | { |
@@ -230,27 +215,23 @@ run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
230 | break; | 215 | break; |
231 | case RP_GET: | 216 | case RP_GET: |
232 | #if VERBOSE | 217 | #if VERBOSE |
233 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 218 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing `%s' number %u\n", "GET", |
234 | "Executing `%s' number %u\n", "GET", crc->i); | 219 | crc->i); |
235 | #endif | 220 | #endif |
236 | GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); | 221 | GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); |
237 | GNUNET_DATASTORE_get_key (datastore, | 222 | GNUNET_DATASTORE_get_key (datastore, crc->offset++, &crc->key, |
238 | crc->offset++, | 223 | get_type (crc->i), 1, 1, TIMEOUT, &check_value, |
239 | &crc->key, | 224 | crc); |
240 | get_type (crc->i), | ||
241 | 1, 1, TIMEOUT, &check_value, crc); | ||
242 | break; | 225 | break; |
243 | case RP_GET_FAIL: | 226 | case RP_GET_FAIL: |
244 | #if VERBOSE | 227 | #if VERBOSE |
245 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 228 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing `%s' number %u\n", "GET(f)", |
246 | "Executing `%s' number %u\n", "GET(f)", crc->i); | 229 | crc->i); |
247 | #endif | 230 | #endif |
248 | GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); | 231 | GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); |
249 | GNUNET_DATASTORE_get_key (datastore, | 232 | GNUNET_DATASTORE_get_key (datastore, crc->offset++, &crc->key, |
250 | crc->offset++, | 233 | get_type (crc->i), 1, 1, TIMEOUT, &check_nothing, |
251 | &crc->key, | 234 | crc); |
252 | get_type (crc->i), | ||
253 | 1, 1, TIMEOUT, &check_nothing, crc); | ||
254 | break; | 235 | break; |
255 | case RP_DONE: | 236 | case RP_DONE: |
256 | GNUNET_assert (0 == crc->i); | 237 | GNUNET_assert (0 == crc->i); |
@@ -277,15 +258,14 @@ run_tests (void *cls, int success, const char *msg) | |||
277 | GNUNET_free (crc); | 258 | GNUNET_free (crc); |
278 | return; | 259 | return; |
279 | } | 260 | } |
280 | GNUNET_SCHEDULER_add_continuation (&run_continuation, | 261 | GNUNET_SCHEDULER_add_continuation (&run_continuation, crc, |
281 | crc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); | 262 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); |
282 | } | 263 | } |
283 | 264 | ||
284 | 265 | ||
285 | static void | 266 | static void |
286 | run (void *cls, | 267 | run (void *cls, char *const *args, const char *cfgfile, |
287 | char *const *args, | 268 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
288 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
289 | { | 269 | { |
290 | struct CpsRunContext *crc; | 270 | struct CpsRunContext *crc; |
291 | static GNUNET_HashCode zkey; | 271 | static GNUNET_HashCode zkey; |
@@ -296,10 +276,8 @@ run (void *cls, | |||
296 | now = GNUNET_TIME_absolute_get (); | 276 | now = GNUNET_TIME_absolute_get (); |
297 | datastore = GNUNET_DATASTORE_connect (cfg); | 277 | datastore = GNUNET_DATASTORE_connect (cfg); |
298 | if (NULL == | 278 | if (NULL == |
299 | GNUNET_DATASTORE_put (datastore, 0, | 279 | GNUNET_DATASTORE_put (datastore, 0, &zkey, 4, "TEST", |
300 | &zkey, 4, "TEST", | 280 | GNUNET_BLOCK_TYPE_TEST, 0, 0, 0, |
301 | GNUNET_BLOCK_TYPE_TEST, | ||
302 | 0, 0, 0, | ||
303 | GNUNET_TIME_relative_to_absolute | 281 | GNUNET_TIME_relative_to_absolute |
304 | (GNUNET_TIME_UNIT_SECONDS), 0, 1, | 282 | (GNUNET_TIME_UNIT_SECONDS), 0, 1, |
305 | GNUNET_TIME_UNIT_MINUTES, &run_tests, crc)) | 283 | GNUNET_TIME_UNIT_MINUTES, &run_tests, crc)) |
@@ -330,19 +308,19 @@ check () | |||
330 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 308 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
331 | GNUNET_GETOPT_OPTION_END | 309 | GNUNET_GETOPT_OPTION_END |
332 | }; | 310 | }; |
333 | GNUNET_snprintf (cfg_name, | 311 | GNUNET_snprintf (cfg_name, sizeof (cfg_name), |
334 | sizeof (cfg_name), | ||
335 | "test_datastore_api_data_%s.conf", plugin_name); | 312 | "test_datastore_api_data_%s.conf", plugin_name); |
336 | proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", | 313 | proc = |
337 | "gnunet-service-arm", | 314 | GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", |
315 | "gnunet-service-arm", | ||
338 | #if VERBOSE | 316 | #if VERBOSE |
339 | "-L", "DEBUG", | 317 | "-L", "DEBUG", |
340 | #endif | 318 | #endif |
341 | "-c", cfg_name, NULL); | 319 | "-c", cfg_name, NULL); |
342 | GNUNET_assert (NULL != proc); | 320 | GNUNET_assert (NULL != proc); |
343 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, | 321 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, |
344 | argv, "test-datastore-api-management", "nohelp", | 322 | "test-datastore-api-management", "nohelp", options, &run, |
345 | options, &run, NULL); | 323 | NULL); |
346 | sleep (1); /* give datastore chance to process 'DROP' request */ | 324 | sleep (1); /* give datastore chance to process 'DROP' request */ |
347 | if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) | 325 | if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) |
348 | { | 326 | { |
@@ -375,9 +353,8 @@ main (int argc, char *argv[]) | |||
375 | else | 353 | else |
376 | pos = (char *) plugin_name; | 354 | pos = (char *) plugin_name; |
377 | 355 | ||
378 | GNUNET_snprintf (dir_name, | 356 | GNUNET_snprintf (dir_name, sizeof (dir_name), "/tmp/test-gnunet-datastore-%s", |
379 | sizeof (dir_name), | 357 | plugin_name); |
380 | "/tmp/test-gnunet-datastore-%s", plugin_name); | ||
381 | GNUNET_DISK_directory_remove (dir_name); | 358 | GNUNET_DISK_directory_remove (dir_name); |
382 | GNUNET_log_setup ("test-datastore-api-management", | 359 | GNUNET_log_setup ("test-datastore-api-management", |
383 | #if VERBOSE | 360 | #if VERBOSE |