aboutsummaryrefslogtreecommitdiff
path: root/src/bank-lib/testing_api_helpers.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bank-lib/testing_api_helpers.c')
-rw-r--r--src/bank-lib/testing_api_helpers.c50
1 files changed, 37 insertions, 13 deletions
diff --git a/src/bank-lib/testing_api_helpers.c b/src/bank-lib/testing_api_helpers.c
index 411391e5a..e2a980ec8 100644
--- a/src/bank-lib/testing_api_helpers.c
+++ b/src/bank-lib/testing_api_helpers.c
@@ -28,8 +28,15 @@
28#include "taler_testing_bank_lib.h" 28#include "taler_testing_bank_lib.h"
29#include "taler_fakebank_lib.h" 29#include "taler_fakebank_lib.h"
30 30
31/* Keep each bank account credentials at index: 31
32 * bank account number - 1 */ 32#define BANK_FAIL() \
33 do {GNUNET_break (0); return NULL; } while (0)
34
35
36/**
37 * Keep each bank account credentials at index:
38 * bank account number - 1
39 */
33struct TALER_BANK_AuthenticationData AUTHS[] = { 40struct TALER_BANK_AuthenticationData AUTHS[] = {
34 41
35 /* Bank credentials */ 42 /* Bank credentials */
@@ -97,7 +104,7 @@ TALER_TESTING_has_in_name (const char *prog_name,
97 size_t name_pos; 104 size_t name_pos;
98 size_t pos; 105 size_t pos;
99 106
100 if (!prog_name || !marker) 107 if (! prog_name || ! marker)
101 return GNUNET_NO; 108 return GNUNET_NO;
102 109
103 pos = 0; 110 pos = 0;
@@ -110,7 +117,7 @@ TALER_TESTING_has_in_name (const char *prog_name,
110 } 117 }
111 if (name_pos == pos) 118 if (name_pos == pos)
112 return GNUNET_YES; 119 return GNUNET_YES;
113 return strstr(prog_name + name_pos, marker) != NULL; 120 return strstr (prog_name + name_pos, marker) != NULL;
114} 121}
115 122
116/** 123/**
@@ -137,7 +144,6 @@ TALER_TESTING_run_bank (const char *config_filename,
137 char *serve_arg; 144 char *serve_arg;
138 struct GNUNET_CONFIGURATION_Handle *cfg; 145 struct GNUNET_CONFIGURATION_Handle *cfg;
139 146
140
141 cfg = GNUNET_CONFIGURATION_create (); 147 cfg = GNUNET_CONFIGURATION_create ();
142 if (GNUNET_OK != 148 if (GNUNET_OK !=
143 GNUNET_CONFIGURATION_load (cfg, 149 GNUNET_CONFIGURATION_load (cfg,
@@ -173,13 +179,15 @@ TALER_TESTING_run_bank (const char *config_filename,
173 "serve"); 179 "serve");
174 GNUNET_break (0); 180 GNUNET_break (0);
175 GNUNET_CONFIGURATION_destroy (cfg); 181 GNUNET_CONFIGURATION_destroy (cfg);
182 GNUNET_free (database);
176 exit (77); 183 exit (77);
177 } 184 }
185 GNUNET_CONFIGURATION_destroy (cfg);
178 186
179 serve_arg = "serve-http"; 187 serve_arg = "serve-http";
180 if (0 != strcmp ("http", serve_cfg)) 188 if (0 != strcmp ("http", serve_cfg))
181 serve_arg = "serve-uwsgi"; 189 serve_arg = "serve-uwsgi";
182 190 GNUNET_free (serve_cfg);
183 bank_proc = GNUNET_OS_start_process 191 bank_proc = GNUNET_OS_start_process
184 (GNUNET_NO, 192 (GNUNET_NO,
185 GNUNET_OS_INHERIT_STD_ALL, 193 GNUNET_OS_INHERIT_STD_ALL,
@@ -189,8 +197,11 @@ TALER_TESTING_run_bank (const char *config_filename,
189 "-c", config_filename, 197 "-c", config_filename,
190 "--with-db", database, 198 "--with-db", database,
191 serve_arg, NULL); 199 serve_arg, NULL);
200 GNUNET_free (database);
192 if (NULL == bank_proc) 201 if (NULL == bank_proc)
202 {
193 BANK_FAIL (); 203 BANK_FAIL ();
204 }
194 205
195 GNUNET_asprintf (&wget_cmd, 206 GNUNET_asprintf (&wget_cmd,
196 "wget -q -t 1 -T 1 %s" 207 "wget -q -t 1 -T 1 %s"
@@ -212,6 +223,7 @@ TALER_TESTING_run_bank (const char *config_filename,
212 SIGTERM); 223 SIGTERM);
213 GNUNET_OS_process_wait (bank_proc); 224 GNUNET_OS_process_wait (bank_proc);
214 GNUNET_OS_process_destroy (bank_proc); 225 GNUNET_OS_process_destroy (bank_proc);
226 GNUNET_free (wget_cmd);
215 BANK_FAIL (); 227 BANK_FAIL ();
216 } 228 }
217 fprintf (stderr, "."); 229 fprintf (stderr, ".");
@@ -219,6 +231,7 @@ TALER_TESTING_run_bank (const char *config_filename,
219 iter++; 231 iter++;
220 } 232 }
221 while (0 != system (wget_cmd)); 233 while (0 != system (wget_cmd));
234 GNUNET_free (wget_cmd);
222 fprintf (stderr, "\n"); 235 fprintf (stderr, "\n");
223 236
224 return bank_proc; 237 return bank_proc;
@@ -248,12 +261,17 @@ TALER_TESTING_prepare_bank (const char *config_filename)
248 261
249 cfg = GNUNET_CONFIGURATION_create (); 262 cfg = GNUNET_CONFIGURATION_create ();
250 263
251 if (GNUNET_OK != GNUNET_CONFIGURATION_load 264 if (GNUNET_OK !=
252 (cfg, config_filename)) 265 GNUNET_CONFIGURATION_load (cfg, config_filename))
266 {
267 GNUNET_CONFIGURATION_destroy (cfg);
253 BANK_FAIL (); 268 BANK_FAIL ();
254 269 }
255 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string 270 if (GNUNET_OK !=
256 (cfg, "bank", "DATABASE", &database)) 271 GNUNET_CONFIGURATION_get_value_string (cfg,
272 "bank",
273 "DATABASE",
274 &database))
257 { 275 {
258 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, 276 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
259 "bank", 277 "bank",
@@ -262,13 +280,17 @@ TALER_TESTING_prepare_bank (const char *config_filename)
262 BANK_FAIL (); 280 BANK_FAIL ();
263 } 281 }
264 282
265 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number 283 if (GNUNET_OK !=
266 (cfg, "bank", "HTTP_PORT", &port)) 284 GNUNET_CONFIGURATION_get_value_number (cfg,
285 "bank",
286 "HTTP_PORT",
287 &port))
267 { 288 {
268 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, 289 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
269 "bank", 290 "bank",
270 "HTTP_PORT"); 291 "HTTP_PORT");
271 GNUNET_CONFIGURATION_destroy (cfg); 292 GNUNET_CONFIGURATION_destroy (cfg);
293 GNUNET_free (database);
272 BANK_FAIL (); 294 BANK_FAIL ();
273 } 295 }
274 GNUNET_CONFIGURATION_destroy (cfg); 296 GNUNET_CONFIGURATION_destroy (cfg);
@@ -298,8 +320,10 @@ TALER_TESTING_prepare_bank (const char *config_filename)
298 { 320 {
299 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 321 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
300 "Failed to flush the bank db.\n"); 322 "Failed to flush the bank db.\n");
323 GNUNET_free (database);
301 BANK_FAIL (); 324 BANK_FAIL ();
302 } 325 }
326 GNUNET_free (database);
303 327
304 if (GNUNET_SYSERR == 328 if (GNUNET_SYSERR ==
305 GNUNET_OS_process_wait_status (dbreset_proc, 329 GNUNET_OS_process_wait_status (dbreset_proc,