aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-07-20 22:37:09 +0000
committerChristian Grothoff <christian@grothoff.org>2016-07-20 22:37:09 +0000
commitae9918852bed2d822c12e110d6b754520e601388 (patch)
treed7226f4d590fb9d456231469c075c11b41ce0cb3 /src
parent90c70e8315c4a366996da379f839dc84d21d5f38 (diff)
downloadgnunet-ae9918852bed2d822c12e110d6b754520e601388.tar.gz
gnunet-ae9918852bed2d822c12e110d6b754520e601388.zip
-skip mysql tests properly if mysql is not configured correctly
Diffstat (limited to 'src')
-rw-r--r--src/datastore/test_datastore_api.c68
-rw-r--r--src/datastore/test_datastore_api_management.c54
2 files changed, 119 insertions, 3 deletions
diff --git a/src/datastore/test_datastore_api.c b/src/datastore/test_datastore_api.c
index 43f6e9fa6..9f89d4087 100644
--- a/src/datastore/test_datastore_api.c
+++ b/src/datastore/test_datastore_api.c
@@ -30,6 +30,7 @@
30#include "gnunet_util_lib.h" 30#include "gnunet_util_lib.h"
31#include "gnunet_protocols.h" 31#include "gnunet_protocols.h"
32#include "gnunet_datastore_service.h" 32#include "gnunet_datastore_service.h"
33#include "gnunet_datastore_plugin.h"
33#include "gnunet_testing_lib.h" 34#include "gnunet_testing_lib.h"
34 35
35 36
@@ -651,6 +652,66 @@ run (void *cls,
651 652
652 653
653/** 654/**
655 * Function invoked to notify service of disk utilization
656 * changes.
657 *
658 * @param cls closure
659 * @param delta change in disk utilization,
660 * 0 for "reset to empty"
661 */
662static void
663duc_dummy (void *cls,
664 int delta)
665{
666 /* intentionally empty */
667}
668
669
670/**
671 * check if plugin is actually working
672 */
673static int
674test_plugin (const char *cfg_name)
675{
676 char libname[128];
677 struct GNUNET_CONFIGURATION_Handle *cfg;
678 struct GNUNET_DATASTORE_PluginFunctions *api;
679 struct GNUNET_DATASTORE_PluginEnvironment env;
680
681 cfg = GNUNET_CONFIGURATION_create ();
682 if (GNUNET_OK !=
683 GNUNET_CONFIGURATION_load (cfg,
684 cfg_name))
685 {
686 GNUNET_CONFIGURATION_destroy (cfg);
687 fprintf (stderr,
688 "Failed to load configuration %s\n",
689 cfg_name);
690 return 1;
691 }
692 memset (&env, 0, sizeof (env));
693 env.cfg = cfg;
694 env.duc = &duc_dummy;
695 GNUNET_snprintf (libname,
696 sizeof (libname),
697 "libgnunet_plugin_datastore_%s",
698 plugin_name);
699 api = GNUNET_PLUGIN_load (libname, &env);
700 if (NULL == api)
701 {
702 GNUNET_CONFIGURATION_destroy (cfg);
703 fprintf (stderr,
704 "Failed to load plugin `%s'\n",
705 libname);
706 return 77;
707 }
708 GNUNET_PLUGIN_unload (libname, api);
709 GNUNET_CONFIGURATION_destroy (cfg);
710 return 0;
711}
712
713
714/**
654 * Entry point into the test. Determines which configuration / plugin 715 * Entry point into the test. Determines which configuration / plugin
655 * we are running with based on the name of the binary and starts 716 * we are running with based on the name of the binary and starts
656 * the peer. 717 * the peer.
@@ -664,12 +725,17 @@ main (int argc,
664 char *argv[]) 725 char *argv[])
665{ 726{
666 char cfg_name[128]; 727 char cfg_name[128];
667 728 int ret;
729
668 plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); 730 plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]);
669 GNUNET_snprintf (cfg_name, 731 GNUNET_snprintf (cfg_name,
670 sizeof (cfg_name), 732 sizeof (cfg_name),
671 "test_datastore_api_data_%s.conf", 733 "test_datastore_api_data_%s.conf",
672 plugin_name); 734 plugin_name);
735 ret = test_plugin (cfg_name);
736 if (0 != ret)
737 return ret;
738 /* run actual test */
673 if (0 != 739 if (0 !=
674 GNUNET_TESTING_peer_run ("test-gnunet-datastore", 740 GNUNET_TESTING_peer_run ("test-gnunet-datastore",
675 cfg_name, 741 cfg_name,
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 */
303static int
304test_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
299int 343int
300main (int argc, char *argv[]) 344main (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,