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.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.c')
-rw-r--r-- | src/datastore/test_datastore_api.c | 68 |
1 files changed, 67 insertions, 1 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 | */ | ||
662 | static void | ||
663 | duc_dummy (void *cls, | ||
664 | int delta) | ||
665 | { | ||
666 | /* intentionally empty */ | ||
667 | } | ||
668 | |||
669 | |||
670 | /** | ||
671 | * check if plugin is actually working | ||
672 | */ | ||
673 | static int | ||
674 | test_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, |