diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-04-26 18:19:15 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-04-26 18:19:15 +0000 |
commit | 27ed8fcbc85a361864948edb517d47804c2b5a56 (patch) | |
tree | 01626713ea5b2ead4691f13eb66a1574b1c0c7fd /src/datastore/test_datastore_api_management.c | |
parent | b6c71d97d2a4bb3cb0e0e0ac1cd2a4e145748cc6 (diff) | |
download | gnunet-27ed8fcbc85a361864948edb517d47804c2b5a56.tar.gz gnunet-27ed8fcbc85a361864948edb517d47804c2b5a56.zip |
datastore and fs fixes from Easter
Diffstat (limited to 'src/datastore/test_datastore_api_management.c')
-rw-r--r-- | src/datastore/test_datastore_api_management.c | 68 |
1 files changed, 28 insertions, 40 deletions
diff --git a/src/datastore/test_datastore_api_management.c b/src/datastore/test_datastore_api_management.c index 5dfb5cea7..41aa7ae3e 100644 --- a/src/datastore/test_datastore_api_management.c +++ b/src/datastore/test_datastore_api_management.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | (C) 2004, 2005, 2006, 2007, 2009 Christian Grothoff (and other contributing authors) | 3 | (C) 2004, 2005, 2006, 2007, 2009, 2011 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -97,9 +97,9 @@ get_expiration (int i) | |||
97 | 97 | ||
98 | enum RunPhase | 98 | enum RunPhase |
99 | { | 99 | { |
100 | RP_DONE = 0, | ||
101 | RP_PUT, | 100 | RP_PUT, |
102 | RP_GET, | 101 | RP_GET, |
102 | RP_DONE, | ||
103 | RP_GET_FAIL | 103 | RP_GET_FAIL |
104 | }; | 104 | }; |
105 | 105 | ||
@@ -112,6 +112,7 @@ struct CpsRunContext | |||
112 | const struct GNUNET_CONFIGURATION_Handle *cfg; | 112 | const struct GNUNET_CONFIGURATION_Handle *cfg; |
113 | void *data; | 113 | void *data; |
114 | enum RunPhase phase; | 114 | enum RunPhase phase; |
115 | uint64_t offset; | ||
115 | }; | 116 | }; |
116 | 117 | ||
117 | 118 | ||
@@ -146,42 +147,26 @@ check_value (void *cls, | |||
146 | enum GNUNET_BLOCK_Type type, | 147 | enum GNUNET_BLOCK_Type type, |
147 | uint32_t priority, | 148 | uint32_t priority, |
148 | uint32_t anonymity, | 149 | uint32_t anonymity, |
149 | struct GNUNET_TIME_Absolute | 150 | struct GNUNET_TIME_Absolute expiration, |
150 | expiration, uint64_t uid) | 151 | uint64_t uid) |
151 | { | 152 | { |
152 | struct CpsRunContext *crc = cls; | 153 | struct CpsRunContext *crc = cls; |
153 | int i; | 154 | int i; |
154 | 155 | ||
155 | if (key == NULL) | ||
156 | { | ||
157 | crc->i--; | ||
158 | if (crc->found == GNUNET_YES) | ||
159 | { | ||
160 | crc->phase = RP_GET; | ||
161 | crc->found = GNUNET_NO; | ||
162 | } | ||
163 | else | ||
164 | { | ||
165 | fprintf (stderr, | ||
166 | "First not found was %u\n", crc->i); | ||
167 | crc->phase = RP_GET_FAIL; | ||
168 | } | ||
169 | if (0 == crc->i) | ||
170 | crc->phase = RP_DONE; | ||
171 | GNUNET_SCHEDULER_add_continuation (&run_continuation, | ||
172 | crc, | ||
173 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); | ||
174 | return; | ||
175 | } | ||
176 | i = crc->i; | 156 | i = crc->i; |
177 | crc->found = GNUNET_YES; | ||
178 | GNUNET_assert (size == get_size (i)); | 157 | GNUNET_assert (size == get_size (i)); |
179 | GNUNET_assert (0 == memcmp (data, get_data(i), size)); | 158 | GNUNET_assert (0 == memcmp (data, get_data(i), size)); |
180 | GNUNET_assert (type == get_type (i)); | 159 | GNUNET_assert (type == get_type (i)); |
181 | GNUNET_assert (priority == get_priority (i)); | 160 | GNUNET_assert (priority == get_priority (i)); |
182 | GNUNET_assert (anonymity == get_anonymity(i)); | 161 | GNUNET_assert (anonymity == get_anonymity(i)); |
183 | GNUNET_assert (expiration.abs_value == get_expiration(i).abs_value); | 162 | GNUNET_assert (expiration.abs_value == get_expiration(i).abs_value); |
184 | GNUNET_DATASTORE_iterate_get_next (datastore); | 163 | crc->offset++; |
164 | crc->i--; | ||
165 | if (crc->i == 0) | ||
166 | crc->phase = RP_DONE; | ||
167 | GNUNET_SCHEDULER_add_continuation (&run_continuation, | ||
168 | crc, | ||
169 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); | ||
185 | } | 170 | } |
186 | 171 | ||
187 | 172 | ||
@@ -241,7 +226,7 @@ run_continuation (void *cls, | |||
241 | { | 226 | { |
242 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 227 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
243 | "Sleeping to give datastore time to clean up\n"); | 228 | "Sleeping to give datastore time to clean up\n"); |
244 | sleep (5); | 229 | sleep (1); |
245 | crc->phase = RP_GET; | 230 | crc->phase = RP_GET; |
246 | crc->i--; | 231 | crc->i--; |
247 | } | 232 | } |
@@ -254,12 +239,13 @@ run_continuation (void *cls, | |||
254 | crc->i); | 239 | crc->i); |
255 | #endif | 240 | #endif |
256 | GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); | 241 | GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); |
257 | GNUNET_DATASTORE_iterate_key (datastore, | 242 | GNUNET_DATASTORE_get_key (datastore, |
258 | &crc->key, | 243 | crc->offset++, |
259 | get_type (crc->i), | 244 | &crc->key, |
260 | 1, 1, TIMEOUT, | 245 | get_type (crc->i), |
261 | &check_value, | 246 | 1, 1, TIMEOUT, |
262 | crc); | 247 | &check_value, |
248 | crc); | ||
263 | break; | 249 | break; |
264 | case RP_GET_FAIL: | 250 | case RP_GET_FAIL: |
265 | #if VERBOSE | 251 | #if VERBOSE |
@@ -269,12 +255,13 @@ run_continuation (void *cls, | |||
269 | crc->i); | 255 | crc->i); |
270 | #endif | 256 | #endif |
271 | GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); | 257 | GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); |
272 | GNUNET_DATASTORE_iterate_key (datastore, | 258 | GNUNET_DATASTORE_get_key (datastore, |
273 | &crc->key, | 259 | crc->offset++, |
274 | get_type (crc->i), | 260 | &crc->key, |
275 | 1, 1, TIMEOUT, | 261 | get_type (crc->i), |
276 | &check_nothing, | 262 | 1, 1, TIMEOUT, |
277 | crc); | 263 | &check_nothing, |
264 | crc); | ||
278 | break; | 265 | break; |
279 | case RP_DONE: | 266 | case RP_DONE: |
280 | GNUNET_assert (0 == crc->i); | 267 | GNUNET_assert (0 == crc->i); |
@@ -372,6 +359,7 @@ check () | |||
372 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, | 359 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, |
373 | argv, "test-datastore-api", "nohelp", | 360 | argv, "test-datastore-api", "nohelp", |
374 | options, &run, NULL); | 361 | options, &run, NULL); |
362 | sleep (1); /* give datastore chance to process 'DROP' request */ | ||
375 | if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) | 363 | if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) |
376 | { | 364 | { |
377 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); | 365 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); |