2 This file is part of GNUnet.
3 Copyright (C) 2019 GNUnet e.V.
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
18 SPDX-License-Identifier: AGPL3.0-or-later
21 * @file namestore/test_common.c
22 * @brief common functions for testcase setup
26 * test if we can load the plugin @a name.
29 TNC_test_plugin (const char *cfg_name)
33 struct GNUNET_NAMESTORE_PluginFunctions *db;
34 struct GNUNET_CONFIGURATION_Handle *cfg;
36 cfg = GNUNET_CONFIGURATION_create ();
38 GNUNET_CONFIGURATION_load (cfg,
42 GNUNET_CONFIGURATION_destroy (cfg);
46 GNUNET_CONFIGURATION_get_value_string (cfg,
51 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
52 "No database backend configured\n");
53 GNUNET_CONFIGURATION_destroy (cfg);
56 GNUNET_asprintf (&db_lib_name,
57 "libgnunet_plugin_namestore_%s",
59 db = GNUNET_PLUGIN_load (db_lib_name,
63 GNUNET_PLUGIN_unload (db_lib_name,
65 GNUNET_free (db_lib_name);
66 GNUNET_CONFIGURATION_destroy (cfg);
74 * General setup logic for starting the tests. Obtains the @a
75 * plugin_name and initializes the @a cfg_name.
77 #define SETUP_CFG(plugin_name,cfg_name) do { \
78 plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); \
79 GNUNET_asprintf (&cfg_name, \
80 "test_namestore_api_%s.conf", \
82 if (! TNC_test_plugin (cfg_name)) \
84 GNUNET_free (cfg_name); \
87 GNUNET_DISK_purge_cfg_dir (cfg_name, \
88 "GNUNET_TEST_HOME"); \