diff options
Diffstat (limited to 'src/transport/plugin_cmd_simple_send.c')
-rw-r--r-- | src/transport/plugin_cmd_simple_send.c | 188 |
1 files changed, 0 insertions, 188 deletions
diff --git a/src/transport/plugin_cmd_simple_send.c b/src/transport/plugin_cmd_simple_send.c deleted file mode 100644 index 62bb7544b..000000000 --- a/src/transport/plugin_cmd_simple_send.c +++ /dev/null | |||
@@ -1,188 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2013, 2014 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/plugin_cmd_simple_send.c | ||
23 | * @brief a plugin to provide the API for running test cases. | ||
24 | * @author t3sserakt | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_testing_ng_lib.h" | ||
28 | #include "gnunet_util_lib.h" | ||
29 | #include "gnunet_transport_application_service.h" | ||
30 | // #include "gnunet_transport_service.h" | ||
31 | #include "gnunet_testbed_ng_service.h" | ||
32 | #include "transport-testing2.h" | ||
33 | |||
34 | /** | ||
35 | * Generic logging shortcut | ||
36 | */ | ||
37 | #define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__) | ||
38 | |||
39 | #define BASE_DIR "testdir" | ||
40 | |||
41 | struct GNUNET_MQ_MessageHandler *handlers; | ||
42 | |||
43 | unsigned int are_all_peers_started; | ||
44 | |||
45 | static int | ||
46 | check_test (void *cls, | ||
47 | const struct GNUNET_TRANSPORT_TESTING_TestMessage *message) | ||
48 | { | ||
49 | return GNUNET_OK; | ||
50 | } | ||
51 | |||
52 | static void | ||
53 | handle_test (void *cls, | ||
54 | const struct GNUNET_TRANSPORT_TESTING_TestMessage *message) | ||
55 | { | ||
56 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
57 | "message received\n"); | ||
58 | } | ||
59 | |||
60 | static int | ||
61 | check_test2 (void *cls, | ||
62 | const struct GNUNET_TRANSPORT_TESTING_TestMessage *message) | ||
63 | { | ||
64 | return GNUNET_OK; | ||
65 | } | ||
66 | |||
67 | static void | ||
68 | handle_test2 (void *cls, | ||
69 | const struct GNUNET_TRANSPORT_TESTING_TestMessage *message) | ||
70 | { | ||
71 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
72 | "message received\n"); | ||
73 | } | ||
74 | |||
75 | static void | ||
76 | all_peers_started () | ||
77 | { | ||
78 | are_all_peers_started = GNUNET_YES; | ||
79 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
80 | "setting are_all_peers_started: %d\n", | ||
81 | are_all_peers_started); | ||
82 | } | ||
83 | |||
84 | static void | ||
85 | start_testcase (TESTBED_CMD_HELPER_write_cb write_message, char *router_ip, | ||
86 | char *node_ip, | ||
87 | char *m, | ||
88 | char *n) | ||
89 | { | ||
90 | char *testdir; | ||
91 | char *cfgname; | ||
92 | |||
93 | GNUNET_asprintf (&cfgname, | ||
94 | "%s%s.conf", | ||
95 | "test_transport_api2_tcp_peer", | ||
96 | n); | ||
97 | |||
98 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
99 | "cfgname: %s\n", | ||
100 | cfgname); | ||
101 | |||
102 | testdir = GNUNET_malloc (strlen (BASE_DIR) + strlen (m) + strlen (n) | ||
103 | + 1); | ||
104 | |||
105 | strcpy (testdir, BASE_DIR); | ||
106 | strcat (testdir, m); | ||
107 | strcat (testdir, n); | ||
108 | |||
109 | struct GNUNET_MQ_MessageHandler handlers[] = { | ||
110 | GNUNET_MQ_hd_var_size (test, | ||
111 | GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE, | ||
112 | struct GNUNET_TRANSPORT_TESTING_TestMessage, | ||
113 | NULL), | ||
114 | GNUNET_MQ_hd_var_size (test2, | ||
115 | GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE2, | ||
116 | struct GNUNET_TRANSPORT_TESTING_TestMessage, | ||
117 | NULL), | ||
118 | GNUNET_MQ_handler_end () | ||
119 | }; | ||
120 | |||
121 | struct GNUNET_TESTING_Command commands[] = { | ||
122 | GNUNET_TESTING_cmd_system_create ("system-create-1", | ||
123 | testdir), | ||
124 | GNUNET_TRANSPORT_cmd_start_peer ("start-peer-1", | ||
125 | "system-create-1", | ||
126 | m, | ||
127 | n, | ||
128 | handlers, | ||
129 | cfgname), | ||
130 | GNUNET_TESTING_cmd_send_peer_ready ("send-peer-ready-1", | ||
131 | write_message), | ||
132 | GNUNET_TESTING_cmd_block_until_all_peers_started ("block-1", | ||
133 | &are_all_peers_started), | ||
134 | GNUNET_TRANSPORT_cmd_connect_peers ("connect-peers-1", | ||
135 | "start-peer-1", | ||
136 | "this is useless"), | ||
137 | /*GNUNET_TESTING_cmd_send_simple ("send-simple-1", | ||
138 | char *m, | ||
139 | char *n, | ||
140 | uint32_t num, | ||
141 | const char *peer1_label, | ||
142 | const char *peer2_label),*/ | ||
143 | GNUNET_TESTING_cmd_local_test_finished ("local-test-finished-1", | ||
144 | write_message) | ||
145 | }; | ||
146 | |||
147 | GNUNET_TESTING_run (NULL, | ||
148 | commands, | ||
149 | GNUNET_TIME_UNIT_FOREVER_REL); | ||
150 | |||
151 | } | ||
152 | |||
153 | |||
154 | /** | ||
155 | * Entry point for the plugin. | ||
156 | * | ||
157 | * @param cls NULL | ||
158 | * @return the exported block API | ||
159 | */ | ||
160 | void * | ||
161 | libgnunet_plugin_cmd_simple_send_init (void *cls) | ||
162 | { | ||
163 | struct GNUNET_TESTING_PluginFunctions *api; | ||
164 | |||
165 | api = GNUNET_new (struct GNUNET_TESTING_PluginFunctions); | ||
166 | api->start_testcase = &start_testcase; | ||
167 | api->all_peers_started = &all_peers_started; | ||
168 | return api; | ||
169 | } | ||
170 | |||
171 | |||
172 | /** | ||
173 | * Exit point from the plugin. | ||
174 | * | ||
175 | * @param cls the return value from #libgnunet_plugin_block_test_init | ||
176 | * @return NULL | ||
177 | */ | ||
178 | void * | ||
179 | libgnunet_plugin_cmd_simple_send_done (void *cls) | ||
180 | { | ||
181 | struct GNUNET_TESTING_PluginFunctions *api = cls; | ||
182 | |||
183 | GNUNET_free (api); | ||
184 | return NULL; | ||
185 | } | ||
186 | |||
187 | |||
188 | /* end of plugin_cmd_simple_send.c */ | ||