aboutsummaryrefslogtreecommitdiff
path: root/src/testing/testing_api_loop.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/testing_api_loop.c')
-rw-r--r--src/testing/testing_api_loop.c53
1 files changed, 41 insertions, 12 deletions
diff --git a/src/testing/testing_api_loop.c b/src/testing/testing_api_loop.c
index b21e01fcc..e0cb3fcda 100644
--- a/src/testing/testing_api_loop.c
+++ b/src/testing/testing_api_loop.c
@@ -46,7 +46,7 @@ struct GNUNET_TESTING_Interpreter
46 * Closure for @e rc. 46 * Closure for @e rc.
47 */ 47 */
48 void *rc_cls; 48 void *rc_cls;
49 49
50 /** 50 /**
51 * Commands the interpreter will run. 51 * Commands the interpreter will run.
52 */ 52 */
@@ -294,7 +294,7 @@ interpreter_run (void *cls)
294 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 294 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
295 "Running command END\n"); 295 "Running command END\n");
296 is->result = GNUNET_OK; 296 is->result = GNUNET_OK;
297 GNUNET_SCHEDULER_shutdown (); 297 finish_test (is);
298 return; 298 return;
299 } 299 }
300 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 300 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -304,17 +304,19 @@ interpreter_run (void *cls)
304 = cmd->last_req_time 304 = cmd->last_req_time
305 = GNUNET_TIME_absolute_get (); 305 = GNUNET_TIME_absolute_get ();
306 cmd->num_tries = 1; 306 cmd->num_tries = 1;
307 cmd->run (cmd->cls, 307 if (NULL != cmd->ac)
308 is);
309 if ( (NULL != cmd->finish) &&
310 (! cmd->asynchronous_finish) )
311 { 308 {
312 cmd->finish (cmd->cls, 309 cmd->ac->is = is;
313 &interpreter_next, 310 cmd->ac->cont = &interpreter_next;
314 is); 311 cmd->ac->cont_cls = is;
312 cmd->ac->finished = GNUNET_NO;
315 } 313 }
316 else 314 cmd->run (cmd->cls,
315 is);
316 if ( (cmd->asynchronous_finish) &&
317 (NULL != cmd->ac->cont) )
317 { 318 {
319 cmd->ac->cont = NULL;
318 interpreter_next (is); 320 interpreter_next (is);
319 } 321 }
320} 322}
@@ -380,12 +382,12 @@ struct MainParams
380 382
381 /** 383 /**
382 * Global timeout for the test. 384 * Global timeout for the test.
383 */ 385 */
384 struct GNUNET_TIME_Relative timeout; 386 struct GNUNET_TIME_Relative timeout;
385 387
386 /** 388 /**
387 * Set to #EXIT_FAILURE on error. 389 * Set to #EXIT_FAILURE on error.
388 */ 390 */
389 int rv; 391 int rv;
390}; 392};
391 393
@@ -444,4 +446,31 @@ GNUNET_TESTING_main (struct GNUNET_TESTING_Command *commands,
444} 446}
445 447
446 448
449void
450GNUNET_TESTING_async_fail (struct GNUNET_TESTING_AsyncContext *ac)
451{
452 GNUNET_assert (GNUNET_NO == ac->finished);
453 ac->finished = GNUNET_SYSERR;
454 GNUNET_TESTING_interpreter_fail (ac->is);
455 if (NULL != ac->cont)
456 {
457 ac->cont (ac->cont_cls);
458 ac->cont = NULL;
459 }
460}
461
462
463void
464GNUNET_TESTING_async_finish (struct GNUNET_TESTING_AsyncContext *ac)
465{
466 GNUNET_assert (GNUNET_NO == ac->finished);
467 ac->finished = GNUNET_OK;
468 if (NULL != ac->cont)
469 {
470 ac->cont (ac->cont_cls);
471 ac->cont = NULL;
472 }
473}
474
475
447/* end of testing_api_loop.c */ 476/* end of testing_api_loop.c */