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.c64
1 files changed, 20 insertions, 44 deletions
diff --git a/src/testing/testing_api_cmd_batch.c b/src/testing/testing_api_cmd_batch.c
index e39489616..080a4880d 100644
--- a/src/testing/testing_api_cmd_batch.c
+++ b/src/testing/testing_api_cmd_batch.c
@@ -119,16 +119,15 @@ batch_traits (void *cls,
const char *trait,
unsigned int index)
{
+ struct BatchState *bs = cls;
+ // FIXME: these constants should be more global!
#define CURRENT_CMD_INDEX 0
#define BATCH_INDEX 1
-
- struct BatchState *bs = cls;
-
struct GNUNET_TESTING_Trait traits[] = {
- GNUNET_TESTING_make_trait_cmd
- (CURRENT_CMD_INDEX, &bs->batch[bs->batch_ip]),
- GNUNET_TESTING_make_trait_cmd
- (BATCH_INDEX, bs->batch),
+ GNUNET_TESTING_make_trait_cmd (CURRENT_CMD_INDEX,
+ &bs->batch[bs->batch_ip]),
+ GNUNET_TESTING_make_trait_cmd (BATCH_INDEX,
+ bs->batch),
GNUNET_TESTING_trait_end ()
};
@@ -185,68 +184,45 @@ GNUNET_TESTING_cmd_batch (const char *label,
}
-/**
- * Advance internal pointer to next command.
- *
- * @param is interpreter state.
- */
-void
-GNUNET_TESTING_cmd_batch_next (struct GNUNET_TESTING_Interpreter *is)
+bool
+GNUNET_TESTING_cmd_batch_next_ (void *cls)
{
- struct BatchState *bs = is->commands[is->ip].cls;
+ struct BatchState *bs = cls;
if (NULL == bs->batch[bs->batch_ip].label)
- {
- is->commands[is->ip].finish_time = GNUNET_TIME_absolute_get ();
- is->ip++;
- return;
- }
- bs->batch[bs->batch_ip].finish_time = GNUNET_TIME_absolute_get ();
+ return false;
+ bs->batch[bs->batch_ip].finish_time
+ = GNUNET_TIME_absolute_get ();
bs->batch_ip++;
+ return true;
}
-/**
- * Test if this command is a batch command.
- *
- * @return false if not, true if it is a batch command
- */
-int
-GNUNET_TESTING_cmd_is_batch (const struct GNUNET_TESTING_Command *cmd)
+bool
+GNUNET_TESTING_cmd_is_batch_ (const struct GNUNET_TESTING_Command *cmd)
{
return cmd->run == &batch_run;
}
-/**
- * Obtain what command the batch is at.
- *
- * @return cmd current batch command
- */
struct GNUNET_TESTING_Command *
-GNUNET_TESTING_cmd_batch_get_current (const struct GNUNET_TESTING_Command *cmd)
+GNUNET_TESTING_cmd_batch_get_current_ (const struct GNUNET_TESTING_Command *cmd)
{
struct BatchState *bs = cmd->cls;
- GNUNET_assert (cmd->run == &batch_run);
+ GNUNET_assert (GNUNET_TESTING_cmd_is_batch_ (cmd));
return &bs->batch[bs->batch_ip];
}
-/**
- * Set what command the batch should be at.
- *
- * @param cmd current batch command
- * @param new_ip where to move the IP
- */
void
-GNUNET_TESTING_cmd_batch_set_current (const struct GNUNET_TESTING_Command *cmd,
- unsigned int new_ip)
+GNUNET_TESTING_cmd_batch_set_current_ (const struct GNUNET_TESTING_Command *cmd,
+ unsigned int new_ip)
{
struct BatchState *bs = cmd->cls;
/* sanity checks */
- GNUNET_assert (cmd->run == &batch_run);
+ GNUNET_assert (GNUNET_TESTING_cmd_is_batch_ (cmd));
for (unsigned int i = 0; i < new_ip; i++)
GNUNET_assert (NULL != bs->batch[i].label);
/* actual logic */