aboutsummaryrefslogtreecommitdiff
path: root/src/lib/util/test_plugin.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/util/test_plugin.c')
-rw-r--r--src/lib/util/test_plugin.c88
1 files changed, 88 insertions, 0 deletions
diff --git a/src/lib/util/test_plugin.c b/src/lib/util/test_plugin.c
new file mode 100644
index 000000000..0831f3068
--- /dev/null
+++ b/src/lib/util/test_plugin.c
@@ -0,0 +1,88 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2009 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 util/test_plugin.c
22 * @brief testcase for plugin.c
23 */
24
25#include "platform.h"
26#include "gnunet_util_lib.h"
27
28
29static void
30test_cb (void *cls,
31 const char *libname,
32 void *lib_ret)
33{
34 const char *test_cls = cls;
35 char *ret;
36
37 GNUNET_assert (0 == strcmp (test_cls,
38 "test-closure"));
39 GNUNET_assert (0 == strcmp (lib_ret,
40 "Hello"));
41 ret = GNUNET_PLUGIN_unload (libname,
42 "out");
43 GNUNET_assert (NULL != ret);
44 GNUNET_assert (0 == strcmp (ret,
45 "World"));
46 free (ret);
47}
48
49
50int
51main (int argc, char *argv[])
52{
53 void *ret;
54
55 GNUNET_log_setup ("test-plugin",
56 "WARNING",
57 NULL);
58 GNUNET_log_skip (1,
59 GNUNET_NO);
60 ret = GNUNET_PLUGIN_load ("libgnunet_plugin_missing",
61 NULL);
62 GNUNET_log_skip (0, GNUNET_NO);
63 if (NULL != ret)
64 return 1;
65 ret = GNUNET_PLUGIN_load ("libgnunet_plugin_utiltest",
66 "in");
67 if (NULL == ret)
68 return 1;
69 if (0 != strcmp (ret,
70 "Hello"))
71 return 2;
72 ret = GNUNET_PLUGIN_unload ("libgnunet_plugin_utiltest",
73 "out");
74 if (NULL == ret)
75 return 3;
76 if (0 != strcmp (ret,
77 "World"))
78 return 4;
79 free (ret);
80 GNUNET_PLUGIN_load_all ("libgnunet_plugin_utiltes",
81 "in",
82 &test_cb,
83 "test-closure");
84 return 0;
85}
86
87
88/* end of test_plugin.c */