fix issue with 'meta' not being initialized - by getting rid of it

This commit is contained in:
Christian Grothoff 2018-10-13 18:08:51 +02:00
parent c09c900922
commit 85e22419c9
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
4 changed files with 64 additions and 21 deletions

View File

@ -156,7 +156,6 @@ TALER_TESTING_cmd_batch (const char *label,
struct BatchState *bs; struct BatchState *bs;
unsigned int i; unsigned int i;
cmd.meta = GNUNET_YES;
bs = GNUNET_new (struct BatchState); bs = GNUNET_new (struct BatchState);
bs->batch_ip = -1; bs->batch_ip = -1;
@ -179,3 +178,15 @@ TALER_TESTING_cmd_batch (const char *label,
return cmd; return cmd;
} }
/**
* Test if this command is a batch command.
*
* @return false if not, true if it is a batch command
*/
int
TALER_TESTING_cmd_is_batch (const struct TALER_TESTING_Command *cmd)
{
return cmd->run == &batch_run;
}

View File

@ -66,7 +66,7 @@ TALER_TESTING_interpreter_lookup_command
label)) ) label)) )
return cmd; return cmd;
if (GNUNET_YES == cmd->meta) if (TALER_TESTING_cmd_is_batch (cmd))
{ {
#define BATCH_INDEX 1 #define BATCH_INDEX 1
struct TALER_TESTING_Command *batch; struct TALER_TESTING_Command *batch;
@ -173,10 +173,10 @@ TALER_TESTING_interpreter_next (struct TALER_TESTING_Interpreter *is)
struct TALER_TESTING_Command *cmd = &is->commands[is->ip]; struct TALER_TESTING_Command *cmd = &is->commands[is->ip];
if (GNUNET_SYSERR == is->result) if (GNUNET_SYSERR == is->result)
return; /* ignore, we already failed! */ return; /* ignore, we already failled! */
if (GNUNET_YES == cmd->meta) if (TALER_TESTING_cmd_is_batch (cmd))
{ {
#define CURRENT_BATCH_SUBCMD_INDEX 0 #define CURRENT_BATCH_SUBCMD_INDEX 0
struct TALER_TESTING_Command *sub_cmd; struct TALER_TESTING_Command *sub_cmd;
GNUNET_assert (GNUNET_OK == TALER_TESTING_get_trait_cmd GNUNET_assert (GNUNET_OK == TALER_TESTING_get_trait_cmd
@ -204,6 +204,8 @@ TALER_TESTING_interpreter_next (struct TALER_TESTING_Interpreter *is)
/** /**
* Current command failed, clean up and fail the test case. * Current command failed, clean up and fail the test case.
*
* @param is interpreter of the test
*/ */
void void
TALER_TESTING_interpreter_fail TALER_TESTING_interpreter_fail
@ -363,7 +365,7 @@ maint_child_death (void *cls)
struct GNUNET_OS_Process **processp; struct GNUNET_OS_Process **processp;
char c[16]; char c[16];
if (GNUNET_YES == cmd->meta) if (TALER_TESTING_cmd_is_batch (cmd))
{ {
struct TALER_TESTING_Command *batch_cmd; struct TALER_TESTING_Command *batch_cmd;
GNUNET_assert GNUNET_assert
@ -465,6 +467,12 @@ TALER_TESTING_run2 (struct TALER_TESTING_Interpreter *is,
struct GNUNET_TIME_Relative timeout) struct GNUNET_TIME_Relative timeout)
{ {
unsigned int i; unsigned int i;
if (NULL != is->timeout_task)
{
GNUNET_SCHEDULER_cancel (is->timeout_task);
is->timeout_task = NULL;
}
/* get the number of commands */ /* get the number of commands */
for (i=0;NULL != commands[i].label;i++) ; for (i=0;NULL != commands[i].label;i++) ;
@ -488,7 +496,6 @@ TALER_TESTING_run2 (struct TALER_TESTING_Interpreter *is,
* defined into the "run" method that returns after * defined into the "run" method that returns after
* having scheduled the test interpreter. * having scheduled the test interpreter.
* *
*
* @param is the interpreter state * @param is the interpreter state
* @param commands the list of command to execute * @param commands the list of command to execute
*/ */
@ -642,6 +649,29 @@ main_wrapper_exchange_agnostic (void *cls)
} }
/**
* Function run when the test is aborted before we launch the actual
* interpreter. Cleans up our state.
*
* @param cls the main context
*/
static void
do_abort (void *cls)
{
struct MainContext *main_ctx = cls;
struct TALER_TESTING_Interpreter *is = main_ctx->is;
is->timeout_task = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Executing abort prior to interpreter launch\n");
if (NULL != is->exchange)
{
TALER_EXCHANGE_disconnect (is->exchange);
is->exchange = NULL;
}
}
/** /**
* Initialize scheduler loop and curl context for the testcase, * Initialize scheduler loop and curl context for the testcase,
* and responsible to run the "run" method. * and responsible to run the "run" method.
@ -676,6 +706,8 @@ main_wrapper_exchange_connect (void *cls)
return; return;
} }
main_ctx->exchange_url = exchange_url; main_ctx->exchange_url = exchange_url;
is->timeout_task = GNUNET_SCHEDULER_add_shutdown (&do_abort,
main_ctx);
GNUNET_assert (NULL != GNUNET_assert (NULL !=
(is->exchange = TALER_EXCHANGE_connect (is->ctx, (is->exchange = TALER_EXCHANGE_connect (is->ctx,
exchange_url, exchange_url,
@ -732,8 +764,8 @@ TALER_TESTING_setup (TALER_TESTING_Main main_cb,
GNUNET_NO, GNUNET_NO); GNUNET_NO, GNUNET_NO);
GNUNET_assert (NULL != sigpipe); GNUNET_assert (NULL != sigpipe);
shc_chld = GNUNET_SIGNAL_handler_install shc_chld = GNUNET_SIGNAL_handler_install
(GNUNET_SIGCHLD, &sighandler_child_death); (GNUNET_SIGCHLD,
&sighandler_child_death);
is.ctx = GNUNET_CURL_init is.ctx = GNUNET_CURL_init
(&GNUNET_CURL_gnunet_scheduler_reschedule, (&GNUNET_CURL_gnunet_scheduler_reschedule,
&is.rc); &is.rc);

View File

@ -37,7 +37,7 @@
* @param cmd command to extract the command from. * @param cmd command to extract the command from.
* @param index always zero. Commands offering this * @param index always zero. Commands offering this
* kind of traits do not need this index. For * kind of traits do not need this index. For
* example, a "meta" CMD returns always the * example, a "batch" CMD returns always the
* CMD currently being executed. * CMD currently being executed.
* @param cmd_[out] where to write the wire details. * @param cmd_[out] where to write the wire details.
* *

View File

@ -314,17 +314,9 @@ struct TALER_TESTING_Command
const char *trait, const char *trait,
unsigned int index); unsigned int index);
/**
* Has GNUNET_YES if the command is a "meta" one. Meta
* commands are those that takes arrays of commands and
* execute them. Are used to group testing commands in
* order to improve readability of test cases.
*/
unsigned int meta;
}; };
/** /**
* Lookup command by label. * Lookup command by label.
* *
@ -1253,6 +1245,14 @@ TALER_TESTING_cmd_batch (const char *label,
struct TALER_TESTING_Command *batch); struct TALER_TESTING_Command *batch);
/**
* Test if this command is a batch command.
*
* @return false if not, true if it is a batch command
*/
int
TALER_TESTING_cmd_is_batch (const struct TALER_TESTING_Command *cmd);
/* *** Generic trait logic for implementing traits ********* */ /* *** Generic trait logic for implementing traits ********* */