diff options
Diffstat (limited to 'src/testing/testing_api_cmd_batch.c')
-rw-r--r-- | src/testing/testing_api_cmd_batch.c | 49 |
1 files changed, 35 insertions, 14 deletions
diff --git a/src/testing/testing_api_cmd_batch.c b/src/testing/testing_api_cmd_batch.c index e8f76ca37..5bb7b974e 100644 --- a/src/testing/testing_api_cmd_batch.c +++ b/src/testing/testing_api_cmd_batch.c @@ -38,6 +38,11 @@ struct BatchState struct TALER_TESTING_Command *batch; /** + * My command (the batch command). + */ + const struct TALER_TESTING_Command *cmd; + + /** * Internal command pointer. */ unsigned int batch_ip; @@ -58,6 +63,7 @@ batch_run (void *cls, { struct BatchState *bs = cls; + bs->cmd = cmd; if (NULL != bs->batch[bs->batch_ip].label) TALER_LOG_INFO ("Running batched command: %s\n", bs->batch[bs->batch_ip].label); @@ -97,8 +103,9 @@ batch_cleanup (void *cls, for (unsigned int i = 0; NULL != bs->batch[i].label; i++) - bs->batch[i].cleanup (bs->batch[i].cls, - &bs->batch[i]); + if (NULL != bs->batch[i].cleanup) + bs->batch[i].cleanup (bs->batch[i].cls, + &bs->batch[i]); GNUNET_free (bs->batch); GNUNET_free (bs); } @@ -121,7 +128,7 @@ batch_traits (void *cls, { struct BatchState *bs = cls; struct TALER_TESTING_Trait traits[] = { - TALER_TESTING_make_trait_batch_cmds (&bs->batch), + TALER_TESTING_make_trait_batch_cmds (bs->batch), TALER_TESTING_trait_end () }; @@ -149,9 +156,9 @@ TALER_TESTING_cmd_batch (const char *label, bs->batch = GNUNET_new_array (i + 1, struct TALER_TESTING_Command); - memcpy (bs->batch, - batch, - sizeof (struct TALER_TESTING_Command) * i); + GNUNET_memcpy (bs->batch, + batch, + sizeof (struct TALER_TESTING_Command) * i); { struct TALER_TESTING_Command cmd = { .cls = bs, @@ -166,19 +173,33 @@ TALER_TESTING_cmd_batch (const char *label, } -void -TALER_TESTING_cmd_batch_next (struct TALER_TESTING_Interpreter *is) +bool +TALER_TESTING_cmd_batch_next (struct TALER_TESTING_Interpreter *is, + void *cls) { - struct BatchState *bs = is->commands[is->ip].cls; + struct BatchState *bs = cls; + struct TALER_TESTING_Command *bcmd = &bs->batch[bs->batch_ip]; - if (NULL == bs->batch[bs->batch_ip].label) + if (NULL == bcmd->label) { - is->commands[is->ip].finish_time = GNUNET_TIME_absolute_get (); - is->ip++; - return; + /* This batch is done */ + return true; + } + if (TALER_TESTING_cmd_is_batch (bcmd)) + { + if (TALER_TESTING_cmd_batch_next (is, + bcmd->cls)) + { + /* sub-batch is done */ + bcmd->finish_time = GNUNET_TIME_absolute_get (); + bs->batch_ip++; + return false; + } } - bs->batch[bs->batch_ip].finish_time = GNUNET_TIME_absolute_get (); + /* Simple command is done */ + bcmd->finish_time = GNUNET_TIME_absolute_get (); bs->batch_ip++; + return false; } |