diff options
author | Marcello Stanisci <stanisci.m@gmail.com> | 2018-05-04 13:06:23 +0200 |
---|---|---|
committer | Marcello Stanisci <stanisci.m@gmail.com> | 2018-05-04 13:06:23 +0200 |
commit | a761baab49178ed04ca55baa8eeff3e1554153e8 (patch) | |
tree | 84731df88fa997c2d52839595b2b79a821be4f44 /src | |
parent | 7d2fbc47968fbcf5cc654bfa4c218f8acb474e47 (diff) | |
download | exchange-a761baab49178ed04ca55baa8eeff3e1554153e8.tar.xz |
Test cases.
Only check if PORT is available if exchange
serves via http. Also get the base URL from
the config -- fixes those situations where it
is not possible to construct it as localhost:<port>.
Diffstat (limited to 'src')
-rw-r--r-- | src/exchange-lib/testing_api_helpers.c | 69 |
1 files changed, 52 insertions, 17 deletions
diff --git a/src/exchange-lib/testing_api_helpers.c b/src/exchange-lib/testing_api_helpers.c index 31f28d024..c18277291 100644 --- a/src/exchange-lib/testing_api_helpers.c +++ b/src/exchange-lib/testing_api_helpers.c @@ -355,39 +355,57 @@ TALER_TESTING_setup_with_exchange (TALER_TESTING_Main main_cb, 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 (); if (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg, config_filename)) return GNUNET_NO; + if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_number (cfg, + GNUNET_CONFIGURATION_get_value_string (cfg, "exchange", - "PORT", - &port)) + "SERVE", + &serve)) { GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "exchange", - "PORT"); + "SERVE"); GNUNET_CONFIGURATION_destroy (cfg); return GNUNET_NO; } - GNUNET_CONFIGURATION_destroy (cfg); - if (GNUNET_OK != - GNUNET_NETWORK_test_port_free (IPPROTO_TCP, - (uint16_t) port)) + if (0 == strcmp ("http", serve)) { - fprintf (stderr, - "Required port %llu not available, skipping.\n", - port); - return GNUNET_NO; + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_number (cfg, + "exchange", + "PORT", + &port)) + { + GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, + "exchange", + "PORT"); + GNUNET_CONFIGURATION_destroy (cfg); + return GNUNET_NO; + } + + GNUNET_CONFIGURATION_destroy (cfg); + if (GNUNET_OK != + GNUNET_NETWORK_test_port_free (IPPROTO_TCP, + (uint16_t) port)) + { + fprintf (stderr, + "Required port %llu not available, skipping.\n", + port); + return GNUNET_NO; + } } - exchanged = GNUNET_OS_start_process (GNUNET_NO, GNUNET_OS_INHERIT_STD_ALL, NULL, NULL, NULL, @@ -396,6 +414,25 @@ TALER_TESTING_setup_with_exchange (TALER_TESTING_Main main_cb, "-c", config_filename, "-i", NULL); + + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_string (cfg, + "exchange", + "BASE_URL", + &base_url)) + { + GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, + "exchange", + "BASE_URL"); + GNUNET_CONFIGURATION_destroy (cfg); + return GNUNET_NO; + } + + 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"); @@ -417,9 +454,7 @@ TALER_TESTING_setup_with_exchange (TALER_TESTING_Main main_cb, sleep (1); iter++; } - while (0 != system - ("wget -q -t 1 -T 1 http://127.0.0.1:8081/keys" - " -o /dev/null -O /dev/null")); + while (0 != system (wget_cmd)); result = TALER_TESTING_setup (main_cb, main_cb_cls, |