aboutsummaryrefslogtreecommitdiff
path: root/src/transport/plugin_cmd_simple_send.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/plugin_cmd_simple_send.c')
-rw-r--r--src/transport/plugin_cmd_simple_send.c122
1 files changed, 122 insertions, 0 deletions
diff --git a/src/transport/plugin_cmd_simple_send.c b/src/transport/plugin_cmd_simple_send.c
new file mode 100644
index 000000000..ed3481c00
--- /dev/null
+++ b/src/transport/plugin_cmd_simple_send.c
@@ -0,0 +1,122 @@
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_testcmd.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_testbed_ng_service.h"
30
31/**
32 * Generic logging shortcut
33 */
34#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
35
36#define BASE_DIR "testdir"
37
38
39static void
40start_testcase (TESTBED_CMD_HELPER_write_cb write_message, char *router_ip,
41 char *node_ip,
42 char *m,
43 char *n)
44{
45 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
46 char *testdir;
47
48 testdir = GNUNET_malloc (strlen (basedir) + strlen (m) + strlen (n)
49 + 1);
50
51 strcpy (testdir, BASE_DIR);
52 strcat (testdir, m);
53 strcat (testdir, n);
54
55 struct GNUNET_TESTING_Command commands[] = {
56 GNUNET_TESTING_cmd_system_create ("system-create-1",
57 testdir),
58 GNUNET_TESTING_cmd_start_peer ("start-peer-1",
59 "system-create-1",
60 m,
61 n,
62 struct GNUNET_MQ_MessageHandler *handlers,
63 const char *cfgname),
64 GNUNET_TESTING_cmd_send_peer_ready ("send-peer-ready-1",
65 write_message),
66 GNUNET_TESTING_cmd_block_until_all_peers_started ("block-1",
67 &are_all_peers_started),
68 GNUNET_TESTING_cmd_connect_peers ("connect-peers-1",
69 "start-peer-1",
70 "this is useless"),
71 /*GNUNET_TESTING_cmd_send_simple ("send-simple-1",
72 char *m,
73 char *n,
74 uint32_t num,
75 const char *peer1_label,
76 const char *peer2_label),*/
77 GNUNET_TESTING_cmd_local_test_finished ("local-test-finished-1",
78 write_message)
79 };
80
81 GNUNET_TESTING_run (NULL,
82 commands,
83 GNUNET_TIME_UNIT_FOREVER_REL);
84
85}
86
87
88/**
89 * Entry point for the plugin.
90 *
91 * @param cls NULL
92 * @return the exported block API
93 */
94void *
95libgnunet_plugin_testcmd_init (void *cls)
96{
97 struct GNUNET_TESTING_PluginFunctions *api;
98
99 api = GNUNET_new (struct GNUNET_TESTING_PluginFunctions);
100 api->start_testcase = &start_testcase;
101 api->all_peers_started = &all_peers_started;
102 return api;
103}
104
105
106/**
107 * Exit point from the plugin.
108 *
109 * @param cls the return value from #libgnunet_plugin_block_test_init
110 * @return NULL
111 */
112void *
113libgnunet_plugin_testcmd_done (void *cls)
114{
115 struct GNUNET_TESTING_PluginFunctions *api = cls;
116
117 GNUNET_free (api);
118 return NULL;
119}
120
121
122/* end of plugin_testcmd.c */