aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-06-04 11:46:19 +0200
committerChristian Grothoff <christian@grothoff.org>2019-06-04 11:46:19 +0200
commitce4a47a9937aa30075b8cc8624bdb1332cd69a2d (patch)
treea0b69787d854beea71cd4e9a770952e18261e55a
parent6b9490cdf1a39464d512a54738f08a9caba18104 (diff)
downloadgnunet-ce4a47a9937aa30075b8cc8624bdb1332cd69a2d.tar.gz
gnunet-ce4a47a9937aa30075b8cc8624bdb1332cd69a2d.zip
fix leak
-rw-r--r--src/namestore/test_common.c55
1 files changed, 23 insertions, 32 deletions
diff --git a/src/namestore/test_common.c b/src/namestore/test_common.c
index 0dc6f9277..6d9761701 100644
--- a/src/namestore/test_common.c
+++ b/src/namestore/test_common.c
@@ -11,7 +11,7 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 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/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
@@ -32,36 +32,28 @@ TNC_test_plugin (const char *cfg_name)
32 char *db_lib_name; 32 char *db_lib_name;
33 struct GNUNET_NAMESTORE_PluginFunctions *db; 33 struct GNUNET_NAMESTORE_PluginFunctions *db;
34 struct GNUNET_CONFIGURATION_Handle *cfg; 34 struct GNUNET_CONFIGURATION_Handle *cfg;
35 35
36 cfg = GNUNET_CONFIGURATION_create (); 36 cfg = GNUNET_CONFIGURATION_create ();
37 if (GNUNET_OK != 37 if (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg, cfg_name))
38 GNUNET_CONFIGURATION_load (cfg,
39 cfg_name))
40 { 38 {
41 GNUNET_break (0); 39 GNUNET_break (0);
42 GNUNET_CONFIGURATION_destroy (cfg); 40 GNUNET_CONFIGURATION_destroy (cfg);
43 return GNUNET_SYSERR; 41 return GNUNET_SYSERR;
44 } 42 }
45 if (GNUNET_OK != 43 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg,
46 GNUNET_CONFIGURATION_get_value_string (cfg, 44 "namestore",
47 "namestore", 45 "database",
48 "database", 46 &database))
49 &database))
50 { 47 {
51 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 48 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No database backend configured\n");
52 "No database backend configured\n");
53 GNUNET_CONFIGURATION_destroy (cfg); 49 GNUNET_CONFIGURATION_destroy (cfg);
54 return GNUNET_SYSERR; 50 return GNUNET_SYSERR;
55 } 51 }
56 GNUNET_asprintf (&db_lib_name, 52 GNUNET_asprintf (&db_lib_name, "libgnunet_plugin_namestore_%s", database);
57 "libgnunet_plugin_namestore_%s", 53 GNUNET_free (database);
58 database); 54 db = GNUNET_PLUGIN_load (db_lib_name, (void *) cfg);
59 db = GNUNET_PLUGIN_load (db_lib_name,
60 (void *) cfg);
61 if (NULL != db) 55 if (NULL != db)
62 GNUNET_break (NULL == 56 GNUNET_break (NULL == GNUNET_PLUGIN_unload (db_lib_name, db));
63 GNUNET_PLUGIN_unload (db_lib_name,
64 db));
65 GNUNET_free (db_lib_name); 57 GNUNET_free (db_lib_name);
66 GNUNET_CONFIGURATION_destroy (cfg); 58 GNUNET_CONFIGURATION_destroy (cfg);
67 if (NULL == db) 59 if (NULL == db)
@@ -74,16 +66,15 @@ TNC_test_plugin (const char *cfg_name)
74 * General setup logic for starting the tests. Obtains the @a 66 * General setup logic for starting the tests. Obtains the @a
75 * plugin_name and initializes the @a cfg_name. 67 * plugin_name and initializes the @a cfg_name.
76 */ 68 */
77#define SETUP_CFG(plugin_name,cfg_name) do { \ 69#define SETUP_CFG(plugin_name, cfg_name) \
78 plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); \ 70 do \
79 GNUNET_asprintf (&cfg_name, \ 71 { \
80 "test_namestore_api_%s.conf", \ 72 plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); \
81 plugin_name); \ 73 GNUNET_asprintf (&cfg_name, "test_namestore_api_%s.conf", plugin_name); \
82 if (! TNC_test_plugin (cfg_name)) \ 74 if (! TNC_test_plugin (cfg_name)) \
83 { \ 75 { \
84 GNUNET_free (cfg_name); \ 76 GNUNET_free (cfg_name); \
85 return 77; \ 77 return 77; \
86 } \ 78 } \
87 GNUNET_DISK_purge_cfg_dir (cfg_name, \ 79 GNUNET_DISK_purge_cfg_dir (cfg_name, "GNUNET_TEST_HOME"); \
88 "GNUNET_TEST_HOME"); \
89 } while (0) 80 } while (0)