gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-twister] 08/11: export "flippers" to the internal AP


From: gnunet
Subject: [GNUnet-SVN] [taler-twister] 08/11: export "flippers" to the internal API.
Date: Wed, 16 May 2018 10:42:03 +0200

This is an automated email from the git hooks/post-receive script.

marcello pushed a commit to branch master
in repository twister.

commit fe0013a8551a788d8999f5e88c923d9ee3ebc2fb
Author: Marcello Stanisci <address@hidden>
AuthorDate: Tue May 15 13:27:34 2018 +0200

    export "flippers" to the internal API.
---
 src/include/taler_twister_service.h       | 19 ++++++++-
 src/include/taler_twister_testing_lib.h   |  7 +++-
 src/twister/taler-twister.c               |  4 +-
 src/twister/testing_api_cmd_exec_client.c | 69 +++++++++++++++++++++++++++++--
 src/twister/twister_api.c                 | 29 ++++++++++++-
 5 files changed, 119 insertions(+), 9 deletions(-)

diff --git a/src/include/taler_twister_service.h 
b/src/include/taler_twister_service.h
index 7adf40e..ae16847 100644
--- a/src/include/taler_twister_service.h
+++ b/src/include/taler_twister_service.h
@@ -107,12 +107,29 @@ TALER_TWISTER_modify_path (struct TALER_TWISTER_Handle *h,
  * @return operation handle (to possibly abort)
  */
 struct TALER_TWISTER_Operation *
-TALER_TWISTER_flip_path
+TALER_TWISTER_flip_download
   (struct TALER_TWISTER_Handle *h,
    const char *path,
    GNUNET_SCHEDULER_TaskCallback cb,
    void *cb_cls);
 
+/**
+ * Randomly flip a character into the JSON string
+ * object pointed to by @a path.
+ *
+ * @param h twister instance to control
+ * @param path object-like notation to point the string
+ *        object where we seek a character to flip.
+ * @param cb function to call once twister is ready
+ * @param cb_cls closure for @a cb
+ * @return operation handle (to possibly abort)
+ */
+struct TALER_TWISTER_Operation *
+TALER_TWISTER_flip_upload
+  (struct TALER_TWISTER_Handle *h,
+   const char *path,
+   GNUNET_SCHEDULER_TaskCallback cb,
+   void *cb_cls);
 
 /**
  * Change the next response code to @a new_rc.
diff --git a/src/include/taler_twister_testing_lib.h 
b/src/include/taler_twister_testing_lib.h
index d7417b8..9f3d7e5 100644
--- a/src/include/taler_twister_testing_lib.h
+++ b/src/include/taler_twister_testing_lib.h
@@ -119,7 +119,12 @@ TALER_TESTING_cmd_malform_request (const char *label,
  * @return the command
  */
 struct TALER_TESTING_Command
-TALER_TESTING_cmd_flip_object (const char *label,
+TALER_TESTING_cmd_flip_upload (const char *label,
                                const char *config_filename,
                                const char *path);
+
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_flip_download (const char *label,
+                                 const char *config_filename,
+                                 const char *path);
 #endif
diff --git a/src/twister/taler-twister.c b/src/twister/taler-twister.c
index 891a6dd..6806f74 100644
--- a/src/twister/taler-twister.c
+++ b/src/twister/taler-twister.c
@@ -181,7 +181,7 @@ run (void *cls,
     num_ops++;
 
   if ( (NULL != flip_path_ul) &&
-       (NULL != TALER_TWISTER_flip_path
+       (NULL != TALER_TWISTER_flip_upload
          (tth,
           flip_path_ul,
           &handle_acknowledgement,
@@ -189,7 +189,7 @@ run (void *cls,
     num_ops++;
 
   if ( (NULL != flip_path_dl) &&
-       (NULL != TALER_TWISTER_flip_path
+       (NULL != TALER_TWISTER_flip_download
          (tth,
           flip_path_dl,
           &handle_acknowledgement,
diff --git a/src/twister/testing_api_cmd_exec_client.c 
b/src/twister/testing_api_cmd_exec_client.c
index 1e5b480..8f651a5 100644
--- a/src/twister/testing_api_cmd_exec_client.c
+++ b/src/twister/testing_api_cmd_exec_client.c
@@ -507,7 +507,7 @@ flip_object_traits (void *cls,
  * FIXME: document.
  */
 static void
-flip_object_run (void *cls,
+flip_upload_run (void *cls,
                  const struct TALER_TESTING_Command *cmd,
                  struct TALER_TESTING_Interpreter *is)
 {
@@ -519,7 +519,36 @@ flip_object_run (void *cls,
                                        "taler-twister",
                                        "taler-twister",
                                        "-c", fos->config_filename,
-                                       "--flip", fos->path,
+                                       "--flip-ul", fos->path,
+                                       NULL);
+  if (NULL == fos->proc)
+  {
+    GNUNET_break (0);
+    TALER_TESTING_interpreter_fail (is);
+    return;
+  }
+  TALER_TESTING_wait_for_sigchld (is);
+}
+
+
+
+/**
+ * FIXME: document.
+ */
+static void
+flip_download_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-dl", fos->path,
                                        NULL);
   if (NULL == fos->proc)
   {
@@ -541,7 +570,7 @@ flip_object_run (void *cls,
  * @return the command
  */
 struct TALER_TESTING_Command
-TALER_TESTING_cmd_flip_object (const char *label,
+TALER_TESTING_cmd_flip_upload (const char *label,
                                const char *config_filename,
                                const char *path)
 {
@@ -553,7 +582,39 @@ TALER_TESTING_cmd_flip_object (const char *label,
   dos->config_filename = config_filename;
 
   cmd.label = label;
-  cmd.run = &flip_object_run;
+  cmd.run = &flip_upload_run;
+  cmd.cleanup = &flip_object_cleanup;
+  cmd.traits = &flip_object_traits;
+  cmd.cls = dos;
+
+  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_flip_download (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_download_run;
   cmd.cleanup = &flip_object_cleanup;
   cmd.traits = &flip_object_traits;
   cmd.cls = dos;
diff --git a/src/twister/twister_api.c b/src/twister/twister_api.c
index 16bd71c..c59e37a 100644
--- a/src/twister/twister_api.c
+++ b/src/twister/twister_api.c
@@ -287,7 +287,7 @@ TALER_TWISTER_malform
  * @return operation handle (to possibly abort)
  */
 struct TALER_TWISTER_Operation *
-TALER_TWISTER_flip_path
+TALER_TWISTER_flip_download
   (struct TALER_TWISTER_Handle *h,
    const char *path,
    GNUNET_SCHEDULER_TaskCallback cb,
@@ -314,6 +314,33 @@ TALER_TWISTER_flip_path
   return op;
 }
 
+struct TALER_TWISTER_Operation *
+TALER_TWISTER_flip_upload
+  (struct TALER_TWISTER_Handle *h,
+   const char *path,
+   GNUNET_SCHEDULER_TaskCallback cb,
+   void *cb_cls)
+{
+  struct TALER_TWISTER_Operation *op;
+  struct GNUNET_MQ_Envelope *env;
+  struct TWISTER_FlipPath *src; //FIXME 'src' right name?
+
+  op = GNUNET_new (struct TALER_TWISTER_Operation);
+  op->h = h;
+  op->cb = cb;
+  op->cb_cls = cb_cls;
+  GNUNET_CONTAINER_DLL_insert_tail (h->op_head,
+                                    h->op_tail,
+                                    op);
+  /* Prepare *env*elope. */
+  env = GNUNET_MQ_msg
+    (src, TWISTER_MESSAGE_TYPE_FLIP_PATH_UL);
+  /* Put data into the envelope. */
+  strcpy (src->path, path);
+  /* Send message. */
+  GNUNET_MQ_send (h->mq, env);
+  return op;
+}
 
 /**
  * Delete the object pointed to by @a path.

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]