gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-merchant] branch master updated (bbd91d3 -> bf9076a)


From: gnunet
Subject: [GNUnet-SVN] [taler-merchant] branch master updated (bbd91d3 -> bf9076a)
Date: Tue, 08 May 2018 23:52:53 +0200

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

marcello pushed a change to branch master
in repository merchant.

    from bbd91d3  Make test configs more autocomplete.
     new b03b86f  Paygen: getting rid of GNUNET_PROGRAM_run.
     new 8c46f3b  remove dead code.
     new c1d3421  launching the exchange.
     new bf9076a  terminate bank and merchant when done.

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../taler-merchant-generate-payments_new.c         | 154 +++++++++++----------
 1 file changed, 83 insertions(+), 71 deletions(-)

diff --git a/src/merchant-tools/taler-merchant-generate-payments_new.c 
b/src/merchant-tools/taler-merchant-generate-payments_new.c
index 30ac366..67a1a48 100644
--- a/src/merchant-tools/taler-merchant-generate-payments_new.c
+++ b/src/merchant-tools/taler-merchant-generate-payments_new.c
@@ -38,10 +38,15 @@
 #include <taler/taler_error_codes.h>
 #include "taler_merchant_testing_lib.h"
 
+#define MISSING_MERCHANT_URL 2
+#define FAILED_TO_LAUNCH_MERCHANT 3
+#define MISSING_BANK_URL 4
+#define FAILED_TO_LAUNCH_BANK 5
+
 /**
  * Exit code.
  */
-unsigned int result = 1;
+unsigned int result;
 
 /**
  * Merchant process.
@@ -69,6 +74,11 @@ unsigned int tracks_number;
 static char *bank_url;
 
 /**
+ * Log file.
+ */
+static char *logfile;
+
+/**
  * Merchant base URL.
  */
 static char *merchant_url;
@@ -77,83 +87,29 @@ static char *merchant_url;
  * Actual commands collection.
  */
 static void
-run_commands (void *cls,
-              struct TALER_TESTING_Interpreter *is)
+run (void *cls,
+     struct TALER_TESTING_Interpreter *is)
 {
-  /*struct TALER_TESTING_Command commands[] = {
+  struct TALER_TESTING_Command commands[] = {
     TALER_TESTING_cmd_end ()
   };
 
-  TALER_TESTING_run (is, commands);*/
-  TALER_LOG_INFO ("End-of-work\n");
+  TALER_TESTING_run (is, commands);
 }
 
 /**
- * Main function that will be run by the scheduler,
- * mainly needed to get the configuration filename to use.
+ * Send SIGTERM and wait for process termination.
  *
- * @param cls closure
- * @param args remaining command-line arguments
- * @param cfgfile name of the configuration file
- *        used (for saving, can be NULL!)
- * @param config configuration
+ * @param process process to terminate.
  */
-static void
-run (void *cls,
-     char *const *args,
-     const char *cfgfile,
-     const struct GNUNET_CONFIGURATION_Handle *config)
+void
+terminate_process (struct GNUNET_OS_Process *process)
 {
-  TALER_LOG_DEBUG ("Using configuration file: %s\n", cfgfile);
-
-  if (NULL == merchant_url)
-  {
-    TALER_LOG_ERROR ("Option -m is mandatory!\n");
-    result = 2;
-    return;
-  }
-
-  if (NULL == (merchantd = TALER_TESTING_run_merchant
-    (cfgfile, merchant_url)))
-  {
-    TALER_LOG_ERROR ("Failed to launch the merchant\n");
-    result = 3;
-    return;
-  }
-
-  result = 0;
-
-  if (NULL == bank_url)
-  {
-    TALER_LOG_ERROR ("Option -b is mandatory!\n");
-    result = 5;
-    return;
-  }
-  if (NULL == (bankd = TALER_TESTING_run_bank (cfgfile,
-                                               bank_url)))
-  {
-    TALER_LOG_ERROR ("Failed to run the bank\n");
-    result = 4;
-    GNUNET_OS_process_kill (merchantd, SIGTERM);
-    GNUNET_OS_process_wait (merchantd);
-    GNUNET_OS_process_destroy (merchantd);
-    return;
-  }
-
-  /* Blocks.. */
-  result = TALER_TESTING_setup_with_exchange (&run_commands,
-                                              NULL,
-                                              cfgfile);
-
-  GNUNET_OS_process_kill (merchantd, SIGTERM);
-  GNUNET_OS_process_wait (merchantd);
-  GNUNET_OS_process_destroy (merchantd);
-  GNUNET_OS_process_kill (bankd, SIGTERM);
-  GNUNET_OS_process_wait (bankd);
-  GNUNET_OS_process_destroy (bankd);
+  GNUNET_OS_process_kill (process, SIGTERM);
+  GNUNET_OS_process_wait (process);
+  GNUNET_OS_process_destroy (process);
 }
 
-
 /**
  * The main function of the serve tool
  *
@@ -166,6 +122,11 @@ main (int argc,
       char *const *argv)
 {
 
+  const char *default_config_file;
+
+  default_config_file = GNUNET_OS_project_data_get
+    ()->user_config_file;
+
   struct GNUNET_GETOPT_CommandLineOption options[] = {
 
     GNUNET_GETOPT_option_uint
@@ -203,12 +164,63 @@ main (int argc,
        "bank base url, mandatory",
        &bank_url),
 
+    GNUNET_GETOPT_option_string
+      ('l',
+       "logfile",
+       "LF",
+       "will log to file LF",
+       &logfile),
+
     GNUNET_GETOPT_OPTION_END
   };
 
-  GNUNET_PROGRAM_run (argc, argv,
-                      "taler-merchant-generate-payments-new",
-                      "Populate the database with payments",
-                      options, &run, NULL);
-  return result;
+  GNUNET_assert (GNUNET_SYSERR != GNUNET_GETOPT_run
+    ("taler-merchant-generate-payments-new",
+     options,
+     argc,
+     argv));
+
+  GNUNET_log_setup ("taler-merchant-generate-payments-new",
+                    "INFO",
+                    logfile);
+
+  if (NULL == merchant_url)
+  {
+    TALER_LOG_ERROR ("Option -m is mandatory!\n");
+    return MISSING_MERCHANT_URL;
+  }
+
+  if (NULL == (merchantd = TALER_TESTING_run_merchant
+    (default_config_file, merchant_url)))
+  {
+    TALER_LOG_ERROR ("Failed to launch the merchant\n");
+    terminate_process (merchantd);
+    return FAILED_TO_LAUNCH_MERCHANT;
+  }
+
+  if (NULL == bank_url)
+  {
+    TALER_LOG_ERROR ("Option -b is mandatory!\n");
+    return MISSING_BANK_URL;
+  }
+
+  if (NULL == (bankd = TALER_TESTING_run_bank
+    (default_config_file,
+     bank_url)))
+  {
+    TALER_LOG_ERROR ("Failed to run the bank\n");
+    terminate_process (bankd);
+    terminate_process (merchantd);
+    return FAILED_TO_LAUNCH_BANK;
+  }
+
+  result = TALER_TESTING_setup_with_exchange
+    (run,
+     NULL,
+     default_config_file);
+
+  terminate_process (bankd);
+  terminate_process (merchantd);
+
+  return (GNUNET_OK == result) ? 0 : result;
 }

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



reply via email to

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