diff options
| author | Christian Grothoff <christian@grothoff.org> | 2018-08-09 10:33:21 +0200 | 
|---|---|---|
| committer | Christian Grothoff <christian@grothoff.org> | 2018-08-09 10:33:21 +0200 | 
| commit | f17ad4de768e297879a6ace43f7be723ddff6b6f (patch) | |
| tree | 906297edbe737f96028187d444f4d261257a4f91 /src/exchange-lib | |
| parent | 4693708b8c53471f7bc5e956dff8158615c46deb (diff) | |
in parallel tests, only launch one exchange -- still broken: code attempts to launch multiple fakebanks
Diffstat (limited to 'src/exchange-lib')
| -rw-r--r-- | src/exchange-lib/testing_api_helpers.c | 74 | ||||
| -rw-r--r-- | src/exchange-lib/testing_api_loop.c | 7 | 
2 files changed, 48 insertions, 33 deletions
| diff --git a/src/exchange-lib/testing_api_helpers.c b/src/exchange-lib/testing_api_helpers.c index d0efae39..bcdb4430 100644 --- a/src/exchange-lib/testing_api_helpers.c +++ b/src/exchange-lib/testing_api_helpers.c @@ -338,6 +338,47 @@ TALER_TESTING_find_pk (const struct TALER_EXCHANGE_Keys *keys,  /** + * Wait for the exchange to have started. Waits for at + * most 10s, after that returns 77 to indicate an error. + * + * @param base_url what URL should we expect the exchange + *        to be running at + * @return 0 on success + */ +int +TALER_TESTING_wait_exchange_ready (const char *base_url) +{ +  char *wget_cmd; +  unsigned int iter; + +  GNUNET_asprintf (&wget_cmd, +                   "wget -q -t 1 -T 1 %skeys" +                   " -o /dev/null -O /dev/null", +                   base_url); // make sure ends with '/' +  /* give child time to start and bind against the socket */ +  fprintf (stderr, +           "Waiting for `taler-exchange-httpd' to be ready\n"); +  iter = 0; +  do +    { +      if (10 == iter) +      { +	fprintf (stderr, +		 "Failed to launch `taler-exchange-httpd' (or `wget')\n"); +        GNUNET_free (wget_cmd); +	return 77; +      } +      fprintf (stderr, ".\n"); +      sleep (1); +      iter++; +    } +  while (0 != system (wget_cmd)); +  GNUNET_free (wget_cmd); +  return 0; +} + + +/**   * Initialize scheduler loop and curl context for the testcase   * including starting and stopping the exchange using the given   * configuration file. @@ -356,12 +397,10 @@ TALER_TESTING_setup_with_exchange (TALER_TESTING_Main main_cb,                                     const char *config_filename)  {    int result; -  unsigned int iter;    struct GNUNET_OS_Process *exchanged;    struct GNUNET_CONFIGURATION_Handle *cfg;    unsigned long long port;    char *serve; -  char *wget_cmd;    char *base_url;    cfg = GNUNET_CONFIGURATION_create (); @@ -397,7 +436,7 @@ TALER_TESTING_setup_with_exchange (TALER_TESTING_Main main_cb,        GNUNET_CONFIGURATION_destroy (cfg);        return GNUNET_NO;      } -   +      if (GNUNET_OK !=          GNUNET_NETWORK_test_port_free (IPPROTO_TCP,    				     (uint16_t) port)) @@ -431,33 +470,8 @@ TALER_TESTING_setup_with_exchange (TALER_TESTING_Main main_cb,    }    GNUNET_CONFIGURATION_destroy (cfg); -  GNUNET_asprintf (&wget_cmd, -                   "wget -q -t 1 -T 1 %skeys" -                   " -o /dev/null -O /dev/null", -                   base_url); // make sure ends with '/' - -  /* give child time to start and bind against the socket */ -  fprintf (stderr, -           "Waiting for `taler-exchange-httpd' to be ready\n"); -  iter = 0; -  do -    { -      if (10 == iter) -      { -	fprintf (stderr, -		 "Failed to launch `taler-exchange-httpd'" -                 " (or `wget')\n"); -	GNUNET_OS_process_kill (exchanged, -				SIGTERM); -	GNUNET_OS_process_wait (exchanged); -	GNUNET_OS_process_destroy (exchanged); -	return 77; -      } -      fprintf (stderr, ".\n"); -      sleep (1); -      iter++; -    } -  while (0 != system (wget_cmd)); +  if (0 != TALER_TESTING_wait_exchange_ready (base_url)) +    return 77;    /* NOTE: this blocks.  */    result = TALER_TESTING_setup (main_cb, diff --git a/src/exchange-lib/testing_api_loop.c b/src/exchange-lib/testing_api_loop.c index 54323d6b..29cafe94 100644 --- a/src/exchange-lib/testing_api_loop.c +++ b/src/exchange-lib/testing_api_loop.c @@ -78,7 +78,7 @@ TALER_TESTING_interpreter_lookup_command        for (unsigned int i=0;             NULL != (cmd = &batch[i])->label; -           i++)  +           i++)        {          if ( (NULL != cmd->label) &&              (0 == strcmp (cmd->label, @@ -181,7 +181,7 @@ TALER_TESTING_interpreter_next (struct TALER_TESTING_Interpreter *is)      GNUNET_assert (GNUNET_OK == TALER_TESTING_get_trait_cmd        (cmd, CURRENT_BATCH_SUBCMD_INDEX, &sub_cmd)); -       +        if (NULL == sub_cmd->label)          is->ip++;    } @@ -520,7 +520,7 @@ sighandler_child_death ()   * @param keys the exchange's keys.   * @param compat protocol compatibility information.   */ -void +static void  cert_cb (void *cls,           const struct TALER_EXCHANGE_Keys *keys,  	 enum TALER_EXCHANGE_VersionCompatibility compat) @@ -562,6 +562,7 @@ cert_cb (void *cls,                              main_ctx->is);  } +  /**   * Initialize scheduler loop and curl context for the testcase,   * and responsible to run the "run" method. | 
