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 ();
37 if (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg, cfg_name))
40 GNUNET_CONFIGURATION_destroy (cfg);
43 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg,
48 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No database backend configured\n");
49 GNUNET_CONFIGURATION_destroy (cfg);
52 GNUNET_asprintf (&db_lib_name, "libgnunet_plugin_namestore_%s", database);
53 GNUNET_free (database);
54 db = GNUNET_PLUGIN_load (db_lib_name, (void *) cfg);
56 GNUNET_break (NULL == GNUNET_PLUGIN_unload (db_lib_name, db));
57 GNUNET_free (db_lib_name);
58 GNUNET_CONFIGURATION_destroy (cfg);
66 * General setup logic for starting the tests. Obtains the @a
67 * plugin_name and initializes the @a cfg_name.
69 #define SETUP_CFG(plugin_name, cfg_name) \
72 plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); \
73 GNUNET_asprintf (&cfg_name, "test_namestore_api_%s.conf", plugin_name); \
74 if (! TNC_test_plugin (cfg_name)) \
76 GNUNET_free (cfg_name); \
79 GNUNET_DISK_purge_cfg_dir (cfg_name, "GNUNET_TEST_HOME"); \