[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-exchange] 01/07: fix issue with 'meta' not being ini
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-exchange] 01/07: fix issue with 'meta' not being initialized - by getting rid of it |
Date: |
Sat, 13 Oct 2018 19:45:59 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository exchange.
commit 85e22419c938d8aaeeba81a7a5a2f2a9ca112397
Author: Christian Grothoff <address@hidden>
AuthorDate: Sat Oct 13 18:08:51 2018 +0200
fix issue with 'meta' not being initialized - by getting rid of it
---
src/exchange-lib/testing_api_cmd_batch.c | 13 +++++++-
src/exchange-lib/testing_api_loop.c | 52 ++++++++++++++++++++++++++------
src/exchange-lib/testing_api_trait_cmd.c | 2 +-
src/include/taler_testing_lib.h | 18 +++++------
4 files changed, 64 insertions(+), 21 deletions(-)
diff --git a/src/exchange-lib/testing_api_cmd_batch.c
b/src/exchange-lib/testing_api_cmd_batch.c
index 738012b8..e4d11ae5 100644
--- a/src/exchange-lib/testing_api_cmd_batch.c
+++ b/src/exchange-lib/testing_api_cmd_batch.c
@@ -156,7 +156,6 @@ TALER_TESTING_cmd_batch (const char *label,
struct BatchState *bs;
unsigned int i;
- cmd.meta = GNUNET_YES;
bs = GNUNET_new (struct BatchState);
bs->batch_ip = -1;
@@ -179,3 +178,15 @@ TALER_TESTING_cmd_batch (const char *label,
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;
+}
diff --git a/src/exchange-lib/testing_api_loop.c
b/src/exchange-lib/testing_api_loop.c
index 8309d812..a7814136 100644
--- a/src/exchange-lib/testing_api_loop.c
+++ b/src/exchange-lib/testing_api_loop.c
@@ -66,7 +66,7 @@ TALER_TESTING_interpreter_lookup_command
label)) )
return cmd;
- if (GNUNET_YES == cmd->meta)
+ if (TALER_TESTING_cmd_is_batch (cmd))
{
#define BATCH_INDEX 1
struct TALER_TESTING_Command *batch;
@@ -173,17 +173,17 @@ TALER_TESTING_interpreter_next (struct
TALER_TESTING_Interpreter *is)
struct TALER_TESTING_Command *cmd = &is->commands[is->ip];
if (GNUNET_SYSERR == is->result)
- return; /* ignore, we already failed! */
- if (GNUNET_YES == cmd->meta)
+ return; /* ignore, we already failled! */
+ 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;
GNUNET_assert (GNUNET_OK == TALER_TESTING_get_trait_cmd
(cmd, CURRENT_BATCH_SUBCMD_INDEX, &sub_cmd));
- if (NULL == sub_cmd->label)
- is->ip++;
+ if (NULL == sub_cmd->label)
+ is->ip++;
}
else
is->ip++;
@@ -204,6 +204,8 @@ TALER_TESTING_interpreter_next (struct
TALER_TESTING_Interpreter *is)
/**
* Current command failed, clean up and fail the test case.
+ *
+ * @param is interpreter of the test
*/
void
TALER_TESTING_interpreter_fail
@@ -363,7 +365,7 @@ maint_child_death (void *cls)
struct GNUNET_OS_Process **processp;
char c[16];
- if (GNUNET_YES == cmd->meta)
+ if (TALER_TESTING_cmd_is_batch (cmd))
{
struct TALER_TESTING_Command *batch_cmd;
GNUNET_assert
@@ -465,6 +467,12 @@ TALER_TESTING_run2 (struct TALER_TESTING_Interpreter *is,
struct GNUNET_TIME_Relative timeout)
{
unsigned int i;
+
+ if (NULL != is->timeout_task)
+ {
+ GNUNET_SCHEDULER_cancel (is->timeout_task);
+ is->timeout_task = NULL;
+ }
/* get the number of commands */
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
* having scheduled the test interpreter.
*
- *
* @param is the interpreter state
* @param commands the list of command to execute
*/
@@ -643,6 +650,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,
* and responsible to run the "run" method.
*
@@ -676,6 +706,8 @@ main_wrapper_exchange_connect (void *cls)
return;
}
main_ctx->exchange_url = exchange_url;
+ is->timeout_task = GNUNET_SCHEDULER_add_shutdown (&do_abort,
+ main_ctx);
GNUNET_assert (NULL !=
(is->exchange = TALER_EXCHANGE_connect (is->ctx,
exchange_url,
@@ -732,8 +764,8 @@ TALER_TESTING_setup (TALER_TESTING_Main main_cb,
GNUNET_NO, GNUNET_NO);
GNUNET_assert (NULL != sigpipe);
shc_chld = GNUNET_SIGNAL_handler_install
- (GNUNET_SIGCHLD, &sighandler_child_death);
-
+ (GNUNET_SIGCHLD,
+ &sighandler_child_death);
is.ctx = GNUNET_CURL_init
(&GNUNET_CURL_gnunet_scheduler_reschedule,
&is.rc);
diff --git a/src/exchange-lib/testing_api_trait_cmd.c
b/src/exchange-lib/testing_api_trait_cmd.c
index 9f7c8d5c..8e796219 100644
--- a/src/exchange-lib/testing_api_trait_cmd.c
+++ b/src/exchange-lib/testing_api_trait_cmd.c
@@ -37,7 +37,7 @@
* @param cmd command to extract the command from.
* @param index always zero. Commands offering this
* 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.
* @param cmd_[out] where to write the wire details.
*
diff --git a/src/include/taler_testing_lib.h b/src/include/taler_testing_lib.h
index 97189a55..9d5b6438 100644
--- a/src/include/taler_testing_lib.h
+++ b/src/include/taler_testing_lib.h
@@ -314,17 +314,9 @@ struct TALER_TESTING_Command
const char *trait,
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.
*
@@ -1253,6 +1245,14 @@ TALER_TESTING_cmd_batch (const char *label,
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 ********* */
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [taler-exchange] branch master updated (c09c9009 -> 16b0c654), gnunet, 2018/10/13
- [GNUnet-SVN] [taler-exchange] 05/07: indentation fix, gnunet, 2018/10/13
- [GNUnet-SVN] [taler-exchange] 04/07: style fix: always put parens on macros, gnunet, 2018/10/13
- [GNUnet-SVN] [taler-exchange] 02/07: fix memory leaks, gnunet, 2018/10/13
- [GNUnet-SVN] [taler-exchange] 01/07: fix issue with 'meta' not being initialized - by getting rid of it,
gnunet <=
- [GNUnet-SVN] [taler-exchange] 03/07: wrong offset, last coin is #3, not #4, gnunet, 2018/10/13
- [GNUnet-SVN] [taler-exchange] 07/07: keep a most sigs around when serializing, gnunet, 2018/10/13
- [GNUnet-SVN] [taler-exchange] 06/07: intermediate patch towards implementing #5136, gnunet, 2018/10/13