[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-twister] branch master updated: add string-object fl
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-twister] branch master updated: add string-object flipper testing command. |
Date: |
Thu, 22 Mar 2018 17:12:10 +0100 |
This is an automated email from the git hooks/post-receive script.
marcello pushed a commit to branch master
in repository twister.
The following commit(s) were added to refs/heads/master by this push:
new 3bceec0 add string-object flipper testing command.
3bceec0 is described below
commit 3bceec019b0bb732b6414c9e11fb60839f49b21b
Author: Marcello Stanisci <address@hidden>
AuthorDate: Thu Mar 22 17:11:46 2018 +0100
add string-object flipper testing command.
---
src/include/taler_twister_testing_lib.h | 14 +++
src/twister/taler-twister-service.c | 8 +-
src/twister/testing_api_cmd_exec_client.c | 136 +++++++++++++++++++++++++++++-
3 files changed, 152 insertions(+), 6 deletions(-)
diff --git a/src/include/taler_twister_testing_lib.h
b/src/include/taler_twister_testing_lib.h
index 2dde7f5..d7417b8 100644
--- a/src/include/taler_twister_testing_lib.h
+++ b/src/include/taler_twister_testing_lib.h
@@ -108,4 +108,18 @@ struct TALER_TESTING_Command
TALER_TESTING_cmd_malform_request (const char *label,
const char *config_filename);
+/**
+ * This command deletes the JSON object pointed by @a path.
+ *
+ * @param label command label
+ * @param config_filename configuration filename.
+ * @param path object-like path notation to point the object
+ * to delete.
+ *
+ * @return the command
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_flip_object (const char *label,
+ const char *config_filename,
+ const char *path);
#endif
diff --git a/src/twister/taler-twister-service.c
b/src/twister/taler-twister-service.c
index d3687e2..f683a16 100644
--- a/src/twister/taler-twister-service.c
+++ b/src/twister/taler-twister-service.c
@@ -1061,6 +1061,10 @@ flip_object (struct MHD_Connection *con,
/* flip the LSB. */
current_value_flip[index] ^= 1;
+
+ TALER_LOG_INFO ("Flipping %s to %s\n",
+ current_value,
+ current_value_flip);
if (0 == json_string_set
(child,
(const char *) current_value_flip))
@@ -1068,10 +1072,6 @@ flip_object (struct MHD_Connection *con,
if (-1 == ret_flip)
TALER_LOG_WARNING ("Could not flip '%s'\n", target);
- else
- TALER_LOG_INFO ("Flipped to %s, from %s\n",
- current_value_flip,
- current_value);
flip_path[0] = '\0';
GNUNET_free (target);
diff --git a/src/twister/testing_api_cmd_exec_client.c
b/src/twister/testing_api_cmd_exec_client.c
index 6c4f3be..1e5b480 100644
--- a/src/twister/testing_api_cmd_exec_client.c
+++ b/src/twister/testing_api_cmd_exec_client.c
@@ -51,6 +51,24 @@ struct ModifyObjectState
};
+struct FlipObjectState
+{
+ /**
+ * Process handle for the twister CLI client.
+ */
+ struct GNUNET_OS_Process *proc;
+
+ /**
+ * Object-like notation to the object to delete.
+ */
+ const char *path;
+
+ /**
+ * Config file name to pass to the CLI client.
+ */
+ const char *config_filename;
+};
+
struct DeleteObjectState
{
/**
@@ -396,8 +414,6 @@ modify_object_run (void *cls,
TALER_TESTING_wait_for_sigchld (is);
}
-
-
/**
* This command deletes the JSON object pointed by @a path.
*
@@ -430,6 +446,122 @@ TALER_TESTING_cmd_delete_object (const char *label,
}
+//////
+
+/**
+ * Clean up after the command. Run during forced termination
+ * (CTRL-C) or test failure or test success.
+ *
+ * @param cls closure
+ */
+static void
+flip_object_cleanup
+ (void *cls,
+ const struct TALER_TESTING_Command *cmd)
+{
+ struct FlipObjectState *fos = cls;
+
+ if (NULL != fos->proc)
+ {
+ GNUNET_break (0 == GNUNET_OS_process_kill (fos->proc,
+ SIGKILL));
+ GNUNET_OS_process_wait (fos->proc);
+ GNUNET_OS_process_destroy (fos->proc);
+ fos->proc = NULL;
+ }
+ GNUNET_free (fos);
+}
+
+/**
+ * Extract information from a command that is useful for other
+ * commands.
+ *
+ * @param cls closure
+ * @param ret[out] result (could be anything)
+ * @param trait name of the trait
+ * @param selector more detailed information about which object
+ * to return in case there were multiple generated
+ * by the command
+ * @return #GNUNET_OK on success
+ */
+static int
+flip_object_traits (void *cls,
+ void **ret,
+ const char *trait,
+ unsigned int index)
+{
+
+ struct FlipObjectState *fos = cls;
+ struct TALER_TESTING_Trait traits[] = {
+ TALER_TESTING_make_trait_process (0, &fos->proc),
+ TALER_TESTING_trait_end ()
+ };
+
+ return TALER_TESTING_get_trait (traits,
+ ret,
+ trait,
+ index);
+}
+
+/**
+ * FIXME: document.
+ */
+static void
+flip_object_run (void *cls,
+ const struct TALER_TESTING_Command *cmd,
+ struct TALER_TESTING_Interpreter *is)
+{
+ struct FlipObjectState *fos = cls;
+
+ fos->proc = GNUNET_OS_start_process (GNUNET_NO,
+ GNUNET_OS_INHERIT_STD_ALL,
+ NULL, NULL, NULL,
+ "taler-twister",
+ "taler-twister",
+ "-c", fos->config_filename,
+ "--flip", fos->path,
+ NULL);
+ if (NULL == fos->proc)
+ {
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (is);
+ return;
+ }
+ TALER_TESTING_wait_for_sigchld (is);
+}
+
+/**
+ * This command deletes the JSON object pointed by @a path.
+ *
+ * @param label command label
+ * @param config_filename configuration filename.
+ * @param path object-like path notation to point the object
+ * to delete.
+ *
+ * @return the command
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_flip_object (const char *label,
+ const char *config_filename,
+ const char *path)
+{
+ struct FlipObjectState *dos;
+ struct TALER_TESTING_Command cmd;
+
+ dos = GNUNET_new (struct FlipObjectState);
+ dos->path = path;
+ dos->config_filename = config_filename;
+
+ cmd.label = label;
+ cmd.run = &flip_object_run;
+ cmd.cleanup = &flip_object_cleanup;
+ cmd.traits = &flip_object_traits;
+ cmd.cls = dos;
+
+ return cmd;
+}
+
+
/**
* TODO.
*/
--
To stop receiving notification emails like this one, please contact
address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] [taler-twister] branch master updated: add string-object flipper testing command.,
gnunet <=