summaryrefslogtreecommitdiff
path: root/src/testing/testing_api_cmd_batch.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/testing_api_cmd_batch.c')
-rw-r--r--src/testing/testing_api_cmd_batch.c84
1 files changed, 10 insertions, 74 deletions
diff --git a/src/testing/testing_api_cmd_batch.c b/src/testing/testing_api_cmd_batch.c
index 2e880e8df..e8f76ca37 100644
--- a/src/testing/testing_api_cmd_batch.c
+++ b/src/testing/testing_api_cmd_batch.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2014-2018 Taler Systems SA
+ Copyright (C) 2014-2021 Taler Systems SA
TALER is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -113,22 +113,15 @@ batch_cleanup (void *cls,
* @param index index number of the object to offer.
* @return #GNUNET_OK on success.
*/
-static int
+static enum GNUNET_GenericReturnValue
batch_traits (void *cls,
const void **ret,
const char *trait,
unsigned int index)
{
-#define CURRENT_CMD_INDEX 0
-#define BATCH_INDEX 1
-
struct BatchState *bs = cls;
-
struct TALER_TESTING_Trait traits[] = {
- TALER_TESTING_make_trait_cmd
- (CURRENT_CMD_INDEX, &bs->batch[bs->batch_ip]),
- TALER_TESTING_make_trait_cmd
- (BATCH_INDEX, bs->batch),
+ TALER_TESTING_make_trait_batch_cmds (&bs->batch),
TALER_TESTING_trait_end ()
};
@@ -140,18 +133,6 @@ batch_traits (void *cls,
}
-/**
- * Create a "batch" command. Such command takes a
- * end_CMD-terminated array of CMDs and executed them.
- * Once it hits the end CMD, it passes the control
- * to the next top-level CMD, regardless of it being
- * another batch or ordinary CMD.
- *
- * @param label the command label.
- * @param batch array of CMDs to execute.
- *
- * @return the command.
- */
struct TALER_TESTING_Command
TALER_TESTING_cmd_batch (const char *label,
struct TALER_TESTING_Command *batch)
@@ -185,68 +166,29 @@ TALER_TESTING_cmd_batch (const char *label,
}
-/**
- * Advance internal pointer to next command.
- *
- * @param is interpreter state.
- * @param cmd batch to advance
- */
void
-TALER_TESTING_cmd_batch_next (struct TALER_TESTING_Interpreter *is,
- struct TALER_TESTING_Command *par,
- struct TALER_TESTING_Command *cmd)
+TALER_TESTING_cmd_batch_next (struct TALER_TESTING_Interpreter *is)
{
- struct BatchState *bs = cmd->cls;
- struct TALER_TESTING_Command *chld;
+ struct BatchState *bs = is->commands[is->ip].cls;
if (NULL == bs->batch[bs->batch_ip].label)
{
- if (NULL == par)
- {
- is->commands[is->ip].finish_time = GNUNET_TIME_absolute_get ();
- is->ip++;
- }
- else
- {
- struct BatchState *ps = par->cls;
-
- cmd->finish_time = GNUNET_TIME_absolute_get ();
- ps->batch_ip++;
- }
+ is->commands[is->ip].finish_time = GNUNET_TIME_absolute_get ();
+ is->ip++;
return;
}
- chld = &bs->batch[bs->batch_ip];
- if (TALER_TESTING_cmd_is_batch (chld))
- {
- TALER_TESTING_cmd_batch_next (is,
- cmd,
- chld);
- }
- else
- {
- bs->batch[bs->batch_ip].finish_time = GNUNET_TIME_absolute_get ();
- bs->batch_ip++;
- }
+ bs->batch[bs->batch_ip].finish_time = GNUNET_TIME_absolute_get ();
+ bs->batch_ip++;
}
-/**
- * Test if this command is a batch command.
- *
- * @return false if not, true if it is a batch command
- */
-int
+bool
TALER_TESTING_cmd_is_batch (const struct TALER_TESTING_Command *cmd)
{
return cmd->run == &batch_run;
}
-/**
- * Obtain what command the batch is at.
- *
- * @return cmd current batch command
- */
struct TALER_TESTING_Command *
TALER_TESTING_cmd_batch_get_current (const struct TALER_TESTING_Command *cmd)
{
@@ -257,12 +199,6 @@ TALER_TESTING_cmd_batch_get_current (const struct TALER_TESTING_Command *cmd)
}
-/**
- * Set what command the batch should be at.
- *
- * @param cmd current batch command
- * @param new_ip where to move the IP
- */
void
TALER_TESTING_cmd_batch_set_current (const struct TALER_TESTING_Command *cmd,
unsigned int new_ip)