diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-07-20 22:37:09 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-07-20 22:37:09 +0000 |
commit | ae9918852bed2d822c12e110d6b754520e601388 (patch) | |
tree | d7226f4d590fb9d456231469c075c11b41ce0cb3 /src/datastore/test_datastore_api_management.c | |
parent | 90c70e8315c4a366996da379f839dc84d21d5f38 (diff) | |
download | gnunet-ae9918852bed2d822c12e110d6b754520e601388.tar.gz gnunet-ae9918852bed2d822c12e110d6b754520e601388.zip |
-skip mysql tests properly if mysql is not configured correctly
Diffstat (limited to 'src/datastore/test_datastore_api_management.c')
-rw-r--r-- | src/datastore/test_datastore_api_management.c | 54 |
1 files changed, 52 insertions, 2 deletions
diff --git a/src/datastore/test_datastore_api_management.c b/src/datastore/test_datastore_api_management.c index 954e61bec..5e536d6c5 100644 --- a/src/datastore/test_datastore_api_management.c +++ b/src/datastore/test_datastore_api_management.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include "gnunet_util_lib.h" | 26 | #include "gnunet_util_lib.h" |
27 | #include "gnunet_protocols.h" | 27 | #include "gnunet_protocols.h" |
28 | #include "gnunet_datastore_service.h" | 28 | #include "gnunet_datastore_service.h" |
29 | #include "gnunet_datastore_plugin.h" | ||
29 | #include "gnunet_testing_lib.h" | 30 | #include "gnunet_testing_lib.h" |
30 | 31 | ||
31 | 32 | ||
@@ -296,14 +297,63 @@ run (void *cls, | |||
296 | } | 297 | } |
297 | 298 | ||
298 | 299 | ||
300 | /** | ||
301 | * check if plugin is actually working | ||
302 | */ | ||
303 | static int | ||
304 | test_plugin (const char *cfg_name) | ||
305 | { | ||
306 | char libname[128]; | ||
307 | struct GNUNET_CONFIGURATION_Handle *cfg; | ||
308 | struct GNUNET_DATASTORE_PluginFunctions *api; | ||
309 | struct GNUNET_DATASTORE_PluginEnvironment env; | ||
310 | |||
311 | cfg = GNUNET_CONFIGURATION_create (); | ||
312 | if (GNUNET_OK != | ||
313 | GNUNET_CONFIGURATION_load (cfg, | ||
314 | cfg_name)) | ||
315 | { | ||
316 | GNUNET_CONFIGURATION_destroy (cfg); | ||
317 | fprintf (stderr, | ||
318 | "Failed to load configuration %s\n", | ||
319 | cfg_name); | ||
320 | return 1; | ||
321 | } | ||
322 | memset (&env, 0, sizeof (env)); | ||
323 | env.cfg = cfg; | ||
324 | GNUNET_snprintf (libname, | ||
325 | sizeof (libname), | ||
326 | "libgnunet_plugin_datastore_%s", | ||
327 | plugin_name); | ||
328 | api = GNUNET_PLUGIN_load (libname, &env); | ||
329 | if (NULL == api) | ||
330 | { | ||
331 | GNUNET_CONFIGURATION_destroy (cfg); | ||
332 | fprintf (stderr, | ||
333 | "Failed to load plugin `%s'\n", | ||
334 | libname); | ||
335 | return 77; | ||
336 | } | ||
337 | GNUNET_PLUGIN_unload (libname, api); | ||
338 | GNUNET_CONFIGURATION_destroy (cfg); | ||
339 | return 0; | ||
340 | } | ||
341 | |||
342 | |||
299 | int | 343 | int |
300 | main (int argc, char *argv[]) | 344 | main (int argc, char *argv[]) |
301 | { | 345 | { |
302 | char cfg_name[128]; | 346 | char cfg_name[128]; |
347 | int ret; | ||
303 | 348 | ||
304 | plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); | 349 | plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); |
305 | GNUNET_snprintf (cfg_name, sizeof (cfg_name), | 350 | GNUNET_snprintf (cfg_name, |
306 | "test_datastore_api_data_%s.conf", plugin_name); | 351 | sizeof (cfg_name), |
352 | "test_datastore_api_data_%s.conf", | ||
353 | plugin_name); | ||
354 | ret = test_plugin (cfg_name); | ||
355 | if (0 != ret) | ||
356 | return ret; | ||
307 | if (0 != | 357 | if (0 != |
308 | GNUNET_TESTING_peer_run ("test-gnunet-datastore-management", | 358 | GNUNET_TESTING_peer_run ("test-gnunet-datastore-management", |
309 | cfg_name, | 359 | cfg_name, |