diff options
Diffstat (limited to 'src/namestore/test_common.c')
-rw-r--r-- | src/namestore/test_common.c | 80 |
1 files changed, 0 insertions, 80 deletions
diff --git a/src/namestore/test_common.c b/src/namestore/test_common.c deleted file mode 100644 index 58afb0a32..000000000 --- a/src/namestore/test_common.c +++ /dev/null | |||
@@ -1,80 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2019 GNUnet e.V. | ||
4 | |||
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. | ||
9 | |||
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. | ||
14 | |||
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/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | /** | ||
21 | * @file namestore/test_common.c | ||
22 | * @brief common functions for testcase setup | ||
23 | */ | ||
24 | |||
25 | /** | ||
26 | * test if we can load the plugin @a name. | ||
27 | */ | ||
28 | static int | ||
29 | TNC_test_plugin (const char *cfg_name) | ||
30 | { | ||
31 | char *database; | ||
32 | char *db_lib_name; | ||
33 | struct GNUNET_NAMESTORE_PluginFunctions *db; | ||
34 | struct GNUNET_CONFIGURATION_Handle *cfg; | ||
35 | |||
36 | cfg = GNUNET_CONFIGURATION_create (); | ||
37 | if (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg, cfg_name)) | ||
38 | { | ||
39 | GNUNET_break (0); | ||
40 | GNUNET_CONFIGURATION_destroy (cfg); | ||
41 | return GNUNET_SYSERR; | ||
42 | } | ||
43 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, | ||
44 | "namestore", | ||
45 | "database", | ||
46 | &database)) | ||
47 | { | ||
48 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No database backend configured\n"); | ||
49 | GNUNET_CONFIGURATION_destroy (cfg); | ||
50 | return GNUNET_SYSERR; | ||
51 | } | ||
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); | ||
55 | if (NULL != db) | ||
56 | GNUNET_break (NULL == GNUNET_PLUGIN_unload (db_lib_name, db)); | ||
57 | GNUNET_free (db_lib_name); | ||
58 | GNUNET_CONFIGURATION_destroy (cfg); | ||
59 | if (NULL == db) | ||
60 | return GNUNET_NO; | ||
61 | return GNUNET_YES; | ||
62 | } | ||
63 | |||
64 | |||
65 | /** | ||
66 | * General setup logic for starting the tests. Obtains the @a | ||
67 | * plugin_name and initializes the @a cfg_name. | ||
68 | */ | ||
69 | #define SETUP_CFG(plugin_name, cfg_name) \ | ||
70 | do \ | ||
71 | { \ | ||
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)) \ | ||
75 | { \ | ||
76 | GNUNET_free (cfg_name); \ | ||
77 | return 77; \ | ||
78 | } \ | ||
79 | GNUNET_DISK_purge_cfg_dir (cfg_name, "GNUNET_TEST_HOME"); \ | ||
80 | } while (0) | ||