summaryrefslogtreecommitdiff
path: root/src/exchange-lib/testing_api_helpers.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2018-08-09 10:33:21 +0200
committerChristian Grothoff <christian@grothoff.org>2018-08-09 10:33:21 +0200
commitf17ad4de768e297879a6ace43f7be723ddff6b6f (patch)
tree906297edbe737f96028187d444f4d261257a4f91 /src/exchange-lib/testing_api_helpers.c
parent4693708b8c53471f7bc5e956dff8158615c46deb (diff)
downloadexchange-f17ad4de768e297879a6ace43f7be723ddff6b6f.tar.gz
exchange-f17ad4de768e297879a6ace43f7be723ddff6b6f.tar.bz2
exchange-f17ad4de768e297879a6ace43f7be723ddff6b6f.zip
in parallel tests, only launch one exchange -- still broken: code attempts to launch multiple fakebanks
Diffstat (limited to 'src/exchange-lib/testing_api_helpers.c')
-rw-r--r--src/exchange-lib/testing_api_helpers.c74
1 files changed, 44 insertions, 30 deletions
diff --git a/src/exchange-lib/testing_api_helpers.c b/src/exchange-lib/testing_api_helpers.c
index d0efae390..bcdb44305 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,