[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-twister] 24/34: add testing-lib command to modify re
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-twister] 24/34: add testing-lib command to modify responses. |
Date: |
Sat, 17 Mar 2018 01:58:15 +0100 |
This is an automated email from the git hooks/post-receive script.
marcello pushed a commit to branch master
in repository twister.
commit ed4f74e6d159419637ca71910c4c9f3674f1656b
Author: Marcello Stanisci <address@hidden>
AuthorDate: Fri Mar 9 21:00:51 2018 +0100
add testing-lib command to modify responses.
---
src/include/taler_twister_testing_lib.h | 16 ++++
src/twister/testing_api_cmd_exec_client.c | 140 +++++++++++++++++++++++++++++-
2 files changed, 155 insertions(+), 1 deletion(-)
diff --git a/src/include/taler_twister_testing_lib.h
b/src/include/taler_twister_testing_lib.h
index b91f906..e0fa0ca 100644
--- a/src/include/taler_twister_testing_lib.h
+++ b/src/include/taler_twister_testing_lib.h
@@ -64,4 +64,20 @@ TALER_TESTING_cmd_delete_object (const char *label,
const char *config_filename,
const char *path);
+
+/**
+ * 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_modify_object (const char *label,
+ const char *config_filename,
+ const char *path,
+ const char *value);
#endif
diff --git a/src/twister/testing_api_cmd_exec_client.c
b/src/twister/testing_api_cmd_exec_client.c
index 5429a15..2e18afc 100644
--- a/src/twister/testing_api_cmd_exec_client.c
+++ b/src/twister/testing_api_cmd_exec_client.c
@@ -29,6 +29,28 @@
#include <taler/taler_testing_lib.h>
#include "taler_twister_testing_lib.h"
+struct ModifyObjectState
+{
+ /**
+ * Process handle for the twister CLI client.
+ */
+ struct GNUNET_OS_Process *proc;
+
+ /**
+ * Object-like notation to the object to delete.
+ */
+ const char *path;
+
+ const char *value;
+
+ /**
+ * Config file name to pass to the CLI client.
+ */
+ const char *config_filename;
+
+};
+
+
struct DeleteObjectState
{
/**
@@ -239,7 +261,6 @@ delete_object_traits (void *cls,
index);
}
-
/**
* FIXME: document.
*/
@@ -267,6 +288,89 @@ delete_object_run (void *cls,
TALER_TESTING_wait_for_sigchld (is);
}
+/**
+ * TODO.
+ */
+static void
+modify_object_cleanup
+ (void *cls,
+ const struct TALER_TESTING_Command *cmd)
+{
+ struct ModifyObjectState *mos = cls;
+
+ if (NULL != mos->proc)
+ {
+ GNUNET_break (0 == GNUNET_OS_process_kill (mos->proc,
+ SIGKILL));
+ GNUNET_OS_process_wait (mos->proc);
+ GNUNET_OS_process_destroy (mos->proc);
+ mos->proc = NULL;
+ }
+ GNUNET_free (mos);
+}
+
+
+/**
+ * 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
+modify_object_traits (void *cls,
+ void **ret,
+ const char *trait,
+ unsigned int index)
+{
+
+ struct ModifyObjectState *mos = cls;
+ struct TALER_TESTING_Trait traits[] = {
+ TALER_TESTING_make_trait_process (0, &mos->proc),
+ TALER_TESTING_trait_end ()
+ };
+
+ return TALER_TESTING_get_trait (traits,
+ ret,
+ trait,
+ index);
+}
+
+
+/**
+ * FIXME: document.
+ */
+static void
+modify_object_run (void *cls,
+ const struct TALER_TESTING_Command *cmd,
+ struct TALER_TESTING_Interpreter *is)
+{
+ struct ModifyObjectState *mos = cls;
+
+ mos->proc = GNUNET_OS_start_process (GNUNET_NO,
+ GNUNET_OS_INHERIT_STD_ALL,
+ NULL, NULL, NULL,
+ "taler-twister",
+ "taler-twister",
+ "-c", mos->config_filename,
+ "--deleteobject", mos->path,
+ "--value", mos->value,
+ NULL);
+ if (NULL == mos->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.
@@ -298,3 +402,37 @@ TALER_TESTING_cmd_delete_object (const char *label,
return cmd;
}
+
+
+/**
+ * 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_modify_object (const char *label,
+ const char *config_filename,
+ const char *path,
+ const char *value)
+{
+ struct ModifyObjectState *mos;
+ struct TALER_TESTING_Command cmd;
+
+ mos = GNUNET_new (struct ModifyObjectState);
+ mos->path = path;
+ mos->value = value;
+ mos->config_filename = config_filename;
+
+ cmd.label = label;
+ cmd.run = &modify_object_run;
+ cmd.cleanup = &modify_object_cleanup;
+ cmd.traits = &modify_object_traits;
+ cmd.cls = mos;
+
+ return cmd;
+}
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [taler-twister] 12/34: test command to empty objects., (continued)
- [GNUnet-SVN] [taler-twister] 12/34: test command to empty objects., gnunet, 2018/03/16
- [GNUnet-SVN] [taler-twister] 16/34: fix proxied response headers., gnunet, 2018/03/16
- [GNUnet-SVN] [taler-twister] 17/34: moving object-killer into helper function., gnunet, 2018/03/16
- [GNUnet-SVN] [taler-twister] 18/34: avoid duplicating tokenized string., gnunet, 2018/03/16
- [GNUnet-SVN] [taler-twister] 02/34: parse proxied response., gnunet, 2018/03/16
- [GNUnet-SVN] [taler-twister] 27/34: fix last path token detection., gnunet, 2018/03/16
- [GNUnet-SVN] [taler-twister] 28/34: new-line, gnunet, 2018/03/16
- [GNUnet-SVN] [taler-twister] 33/34: rely again on RNG., gnunet, 2018/03/16
- [GNUnet-SVN] [taler-twister] 25/34: make mods cumulative, gnunet, 2018/03/16
- [GNUnet-SVN] [taler-twister] 20/34: option name., gnunet, 2018/03/16
- [GNUnet-SVN] [taler-twister] 24/34: add testing-lib command to modify responses.,
gnunet <=
- [GNUnet-SVN] [taler-twister] 31/34: implement upload data malformation., gnunet, 2018/03/16
- [GNUnet-SVN] [taler-twister] 34/34: leading slash when constructing twister url., gnunet, 2018/03/16
- [GNUnet-SVN] [taler-twister] 19/34: renaming operation., gnunet, 2018/03/16
- [GNUnet-SVN] [taler-twister] 26/34: remove number conversion, for now., gnunet, 2018/03/16
- [GNUnet-SVN] [taler-twister] 32/34: fix headers preparation for malformed uploads., gnunet, 2018/03/16
- [GNUnet-SVN] [taler-twister] 22/34: object walker as separate function., gnunet, 2018/03/16
- [GNUnet-SVN] [taler-twister] 21/34: dup'ing path string., gnunet, 2018/03/16
- [GNUnet-SVN] [taler-twister] 23/34: add command to modify responses., gnunet, 2018/03/16
- [GNUnet-SVN] [taler-twister] 29/34: adding command for randomly truncating responses., gnunet, 2018/03/16