diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2013-01-24 17:01:06 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2013-01-24 17:01:06 +0000 |
commit | 739e84766c1af20fd0f117178adf5541a665253f (patch) | |
tree | f3dabf33446e9d158b3bb393ab5fc3635260bbe6 /src/testbed/test_testbed_api_operations.c | |
parent | f4ab6f4d8addaa93b2dd18af393ac5b699013a9b (diff) | |
download | gnunet-739e84766c1af20fd0f117178adf5541a665253f.tar.gz gnunet-739e84766c1af20fd0f117178adf5541a665253f.zip |
test harder
Diffstat (limited to 'src/testbed/test_testbed_api_operations.c')
-rw-r--r-- | src/testbed/test_testbed_api_operations.c | 137 |
1 files changed, 127 insertions, 10 deletions
diff --git a/src/testbed/test_testbed_api_operations.c b/src/testbed/test_testbed_api_operations.c index cccaac4d0..2320c4d1b 100644 --- a/src/testbed/test_testbed_api_operations.c +++ b/src/testbed/test_testbed_api_operations.c | |||
@@ -37,12 +37,12 @@ | |||
37 | /** | 37 | /** |
38 | * Queue A. Initially the max active is set to 2 and then reduced to 0 - this | 38 | * Queue A. Initially the max active is set to 2 and then reduced to 0 - this |
39 | * should block op2 even after op1 has finished. Later the max active is set to | 39 | * should block op2 even after op1 has finished. Later the max active is set to |
40 | * 1 and this should start op2 | 40 | * 2 and this should start op2 |
41 | */ | 41 | */ |
42 | struct OperationQueue *q1; | 42 | struct OperationQueue *q1; |
43 | 43 | ||
44 | /** | 44 | /** |
45 | * Queue B. Max active set to 1 | 45 | * Queue B. Max active set to 2 is not changed throughout the test |
46 | */ | 46 | */ |
47 | struct OperationQueue *q2; | 47 | struct OperationQueue *q2; |
48 | 48 | ||
@@ -57,12 +57,39 @@ struct GNUNET_TESTBED_Operation *op1; | |||
57 | struct GNUNET_TESTBED_Operation *op2; | 57 | struct GNUNET_TESTBED_Operation *op2; |
58 | 58 | ||
59 | /** | 59 | /** |
60 | * This operation should go into both queues and should be started after op2 has | 60 | * This operation should go into both queues and should consume 2 units of |
61 | * been released. | 61 | * resources on both queues. Since op2 needs a resource from both queues and is |
62 | * queues before this operation, it will be blocked until op2 is released even | ||
63 | * though q1 has | ||
62 | */ | 64 | */ |
63 | struct GNUNET_TESTBED_Operation *op3; | 65 | struct GNUNET_TESTBED_Operation *op3; |
64 | 66 | ||
65 | /** | 67 | /** |
68 | * Just like op3, this operation also consumes 2 units of resources on both | ||
69 | * queues. Since this is queued after op3 and both queues are at max active | ||
70 | * 2. This will be blocked until op3 is done. | ||
71 | */ | ||
72 | struct GNUNET_TESTBED_Operation *op4; | ||
73 | |||
74 | /** | ||
75 | * This operation is started after op4 is released and should consume only 1 | ||
76 | * resource on queue q1. It should be started along with op6 and op7 | ||
77 | */ | ||
78 | struct GNUNET_TESTBED_Operation *op5; | ||
79 | |||
80 | /** | ||
81 | * This operation is started after op4 is released and should consume only 1 | ||
82 | * resource on q2. It should be started along with op5 and op7 | ||
83 | */ | ||
84 | struct GNUNET_TESTBED_Operation *op6; | ||
85 | |||
86 | /** | ||
87 | * This operation is started after op4 is released and should consume 1 resource | ||
88 | * on both queues q1 and q1. It should be started along with op5 and op6 | ||
89 | */ | ||
90 | struct GNUNET_TESTBED_Operation *op7; | ||
91 | |||
92 | /** | ||
66 | * The delay task identifier | 93 | * The delay task identifier |
67 | */ | 94 | */ |
68 | GNUNET_SCHEDULER_TaskIdentifier step_task; | 95 | GNUNET_SCHEDULER_TaskIdentifier step_task; |
@@ -112,7 +139,37 @@ enum Test | |||
112 | /** | 139 | /** |
113 | * op3 has finished | 140 | * op3 has finished |
114 | */ | 141 | */ |
115 | TEST_OP3_RELEASED | 142 | TEST_OP3_RELEASED, |
143 | |||
144 | /** | ||
145 | * op4 has started | ||
146 | */ | ||
147 | TEST_OP4_STARTED, | ||
148 | |||
149 | /** | ||
150 | * op4 has released | ||
151 | */ | ||
152 | TEST_OP4_RELEASED, | ||
153 | |||
154 | /** | ||
155 | * op5, op6, op7 started | ||
156 | */ | ||
157 | TEST_OP5_6_7_STARTED, | ||
158 | |||
159 | /** | ||
160 | * op5 has released | ||
161 | */ | ||
162 | TEST_OP5_RELEASED, | ||
163 | |||
164 | /** | ||
165 | * op6 has released | ||
166 | */ | ||
167 | TEST_OP6_RELEASED, | ||
168 | |||
169 | /** | ||
170 | * op7 has released | ||
171 | */ | ||
172 | TEST_OP7_RELEASED | ||
116 | }; | 173 | }; |
117 | 174 | ||
118 | /** | 175 | /** |
@@ -159,14 +216,18 @@ step (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
159 | case TEST_OP1_STARTED: | 216 | case TEST_OP1_STARTED: |
160 | GNUNET_TESTBED_operation_release_ (op1); | 217 | GNUNET_TESTBED_operation_release_ (op1); |
161 | GNUNET_TESTBED_operation_queue_reset_max_active_ (q1, 0); | 218 | GNUNET_TESTBED_operation_queue_reset_max_active_ (q1, 0); |
162 | op3 = GNUNET_TESTBED_operation_create_ (&op3, &start_cb, &release_cb); | 219 | op3 = GNUNET_TESTBED_operation_create_ (&op3, &start_cb, &release_cb); |
163 | GNUNET_TESTBED_operation_queue_insert_ (q1, op3); | 220 | GNUNET_TESTBED_operation_queue_insert2_ (q1, op3, 2); |
164 | GNUNET_TESTBED_operation_queue_insert_ (q2, op3); | 221 | GNUNET_TESTBED_operation_queue_insert2_ (q2, op3, 2); |
165 | GNUNET_TESTBED_operation_begin_wait_ (op3); | 222 | GNUNET_TESTBED_operation_begin_wait_ (op3); |
223 | op4 = GNUNET_TESTBED_operation_create_ (&op4, &start_cb, &release_cb); | ||
224 | GNUNET_TESTBED_operation_queue_insert2_ (q1, op4, 2); | ||
225 | GNUNET_TESTBED_operation_queue_insert2_ (q2, op4, 2); | ||
226 | GNUNET_TESTBED_operation_begin_wait_ (op4); | ||
166 | break; | 227 | break; |
167 | case TEST_OP1_RELEASED: | 228 | case TEST_OP1_RELEASED: |
168 | result = TEST_PAUSE; | 229 | result = TEST_PAUSE; |
169 | GNUNET_TESTBED_operation_queue_reset_max_active_ (q1, 1); | 230 | GNUNET_TESTBED_operation_queue_reset_max_active_ (q1, 2); |
170 | break; | 231 | break; |
171 | case TEST_OP2_STARTED: | 232 | case TEST_OP2_STARTED: |
172 | GNUNET_TESTBED_operation_release_ (op2); | 233 | GNUNET_TESTBED_operation_release_ (op2); |
@@ -174,6 +235,9 @@ step (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
174 | case TEST_OP3_STARTED: | 235 | case TEST_OP3_STARTED: |
175 | GNUNET_TESTBED_operation_release_ (op3); | 236 | GNUNET_TESTBED_operation_release_ (op3); |
176 | break; | 237 | break; |
238 | case TEST_OP4_STARTED: | ||
239 | GNUNET_TESTBED_operation_release_ (op4); | ||
240 | break; | ||
177 | default: | 241 | default: |
178 | GNUNET_assert (0); | 242 | GNUNET_assert (0); |
179 | } | 243 | } |
@@ -208,6 +272,26 @@ start_cb (void *cls) | |||
208 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == step_task); | 272 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == step_task); |
209 | step_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &step, NULL); | 273 | step_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &step, NULL); |
210 | break; | 274 | break; |
275 | case TEST_OP3_RELEASED: | ||
276 | GNUNET_assert (&op4 == cls); | ||
277 | result = TEST_OP4_STARTED; | ||
278 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == step_task); | ||
279 | step_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &step, | ||
280 | NULL); | ||
281 | break; | ||
282 | case TEST_OP4_RELEASED: | ||
283 | { | ||
284 | static int nops; | ||
285 | |||
286 | nops++; | ||
287 | if (nops == 3) | ||
288 | { | ||
289 | result = TEST_OP5_6_7_STARTED; | ||
290 | GNUNET_TESTBED_operation_release_ (op5); | ||
291 | op5 = NULL; | ||
292 | } | ||
293 | } | ||
294 | break; | ||
211 | default: | 295 | default: |
212 | GNUNET_assert (0); | 296 | GNUNET_assert (0); |
213 | } | 297 | } |
@@ -244,8 +328,40 @@ release_cb (void *cls) | |||
244 | case TEST_OP3_STARTED: | 328 | case TEST_OP3_STARTED: |
245 | GNUNET_assert (&op3 == cls); | 329 | GNUNET_assert (&op3 == cls); |
246 | result = TEST_OP3_RELEASED; | 330 | result = TEST_OP3_RELEASED; |
331 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == step_task); | ||
332 | break; | ||
333 | case TEST_OP4_STARTED: | ||
334 | GNUNET_assert (&op4 == cls); | ||
335 | result = TEST_OP4_RELEASED; | ||
336 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == step_task); | ||
337 | op5 = GNUNET_TESTBED_operation_create_ (&op5, &start_cb, &release_cb); | ||
338 | GNUNET_TESTBED_operation_queue_insert2_ (q1, op5, 1); | ||
339 | GNUNET_TESTBED_operation_begin_wait_ (op5); | ||
340 | op6 = GNUNET_TESTBED_operation_create_ (&op6, &start_cb, &release_cb); | ||
341 | GNUNET_TESTBED_operation_queue_insert2_ (q2, op6, 1); | ||
342 | GNUNET_TESTBED_operation_begin_wait_ (op6); | ||
343 | op7 = GNUNET_TESTBED_operation_create_ (&op7, &start_cb, &release_cb); | ||
344 | GNUNET_TESTBED_operation_queue_insert2_ (q1, op7, 1); | ||
345 | GNUNET_TESTBED_operation_queue_insert2_ (q2, op7, 1); | ||
346 | GNUNET_TESTBED_operation_begin_wait_ (op7); | ||
347 | break; | ||
348 | case TEST_OP5_6_7_STARTED: | ||
349 | result = TEST_OP5_RELEASED; | ||
350 | op5 = NULL; | ||
351 | GNUNET_TESTBED_operation_release_ (op6); | ||
352 | break; | ||
353 | case TEST_OP5_RELEASED: | ||
354 | op6 = NULL; | ||
355 | result = TEST_OP6_RELEASED; | ||
356 | GNUNET_TESTBED_operation_release_ (op7); | ||
357 | break; | ||
358 | case TEST_OP6_RELEASED: | ||
359 | result = TEST_OP7_RELEASED; | ||
360 | op7 = NULL; | ||
247 | GNUNET_TESTBED_operation_queue_destroy_ (q1); | 361 | GNUNET_TESTBED_operation_queue_destroy_ (q1); |
248 | GNUNET_TESTBED_operation_queue_destroy_ (q2); | 362 | GNUNET_TESTBED_operation_queue_destroy_ (q2); |
363 | q1 = NULL; | ||
364 | q2 = NULL; | ||
249 | break; | 365 | break; |
250 | default: | 366 | default: |
251 | GNUNET_assert (0); | 367 | GNUNET_assert (0); |
@@ -281,6 +397,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
281 | result = TEST_INIT; | 397 | result = TEST_INIT; |
282 | } | 398 | } |
283 | 399 | ||
400 | |||
284 | /** | 401 | /** |
285 | * Main function | 402 | * Main function |
286 | */ | 403 | */ |
@@ -297,7 +414,7 @@ main (int argc, char **argv) | |||
297 | GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2, | 414 | GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2, |
298 | "test_testbed_api_operations", "nohelp", options, | 415 | "test_testbed_api_operations", "nohelp", options, |
299 | &run, NULL); | 416 | &run, NULL); |
300 | if ((GNUNET_OK != ret) || (TEST_OP3_RELEASED != result)) | 417 | if ((GNUNET_OK != ret) || (TEST_OP7_RELEASED != result)) |
301 | return 1; | 418 | return 1; |
302 | op1 = NULL; | 419 | op1 = NULL; |
303 | op2 = NULL; | 420 | op2 = NULL; |