diff options
Diffstat (limited to 'src/testbed/gnunet-cmd.c')
-rw-r--r-- | src/testbed/gnunet-cmd.c | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/src/testbed/gnunet-cmd.c b/src/testbed/gnunet-cmd.c new file mode 100644 index 000000000..477c3c454 --- /dev/null +++ b/src/testbed/gnunet-cmd.c | |||
@@ -0,0 +1,93 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2008--2013, 2016 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 | /** | ||
22 | * @file testbed/gnunet-cmd.c | ||
23 | * | ||
24 | * @brief Binary to start testcase plugins | ||
25 | * | ||
26 | * @author t3sserakt | ||
27 | */ | ||
28 | |||
29 | #include "platform.h" | ||
30 | #include "gnunet_util_lib.h" | ||
31 | #include "gnunet_testing_lib.h" | ||
32 | #include "gnunet_testing_plugin.h" | ||
33 | |||
34 | /** | ||
35 | * Generic logging shortcut | ||
36 | */ | ||
37 | #define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__) | ||
38 | |||
39 | |||
40 | /** | ||
41 | * Handle for a plugin. | ||
42 | */ | ||
43 | struct Plugin | ||
44 | { | ||
45 | /** | ||
46 | * Name of the shared library. | ||
47 | */ | ||
48 | char *library_name; | ||
49 | |||
50 | /** | ||
51 | * Plugin API. | ||
52 | */ | ||
53 | struct GNUNET_TESTING_PluginFunctions *api; | ||
54 | }; | ||
55 | |||
56 | |||
57 | /** | ||
58 | * Main function to run the test cases. | ||
59 | * | ||
60 | * @param cls not used. | ||
61 | * | ||
62 | */ | ||
63 | static void | ||
64 | run (void *cls) | ||
65 | { | ||
66 | struct Plugin *plugin; | ||
67 | |||
68 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "gnunet-cmd", | ||
69 | "running plugin.\n"); | ||
70 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
71 | "running plugin.\n"); | ||
72 | plugin = GNUNET_new (struct Plugin); | ||
73 | plugin->api = GNUNET_PLUGIN_load ("libgnunet_plugin_testcmd", | ||
74 | NULL); | ||
75 | plugin->library_name = GNUNET_strdup ("libgnunet_plugin_testcmd"); | ||
76 | plugin->api->start_testcase (); | ||
77 | } | ||
78 | |||
79 | |||
80 | int | ||
81 | main (int argc, char *const *argv) | ||
82 | { | ||
83 | int rv = 0; | ||
84 | |||
85 | GNUNET_log_setup ("gnunet-cmd", | ||
86 | "DEBUG", | ||
87 | NULL); | ||
88 | |||
89 | GNUNET_SCHEDULER_run (&run, | ||
90 | NULL); | ||
91 | |||
92 | return rv; | ||
93 | } | ||