aboutsummaryrefslogtreecommitdiff
path: root/src/testing/test_testing_plugin_testcmd.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/test_testing_plugin_testcmd.c')
-rw-r--r--src/testing/test_testing_plugin_testcmd.c116
1 files changed, 116 insertions, 0 deletions
diff --git a/src/testing/test_testing_plugin_testcmd.c b/src/testing/test_testing_plugin_testcmd.c
new file mode 100644
index 000000000..aeb0db5dc
--- /dev/null
+++ b/src/testing/test_testing_plugin_testcmd.c
@@ -0,0 +1,116 @@
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_testing_ng_lib.h"
30
31/**
32 * Generic logging shortcut
33 */
34#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
35
36unsigned int are_all_peers_started;
37
38static void
39all_peers_started ()
40{
41 are_all_peers_started = GNUNET_YES;
42 LOG (GNUNET_ERROR_TYPE_ERROR,
43 "setting are_all_peers_started: %d\n",
44 are_all_peers_started);
45}
46
47static void
48start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip,
49 char *node_ip,
50 char *n,
51 char *m,
52 char *local_m)
53{
54 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
55
56 LOG (GNUNET_ERROR_TYPE_ERROR,
57 "We got here 6!\n");
58
59 are_all_peers_started = GNUNET_NO;
60
61 struct GNUNET_TESTING_Command commands[] = {
62 GNUNET_TESTING_cmd_hello_world_birth ("hello-world-birth-0",
63 &now),
64 GNUNET_TESTING_cmd_hello_world ("hello-world-0","hello-world-birth-0",""),
65 GNUNET_TESTING_cmd_send_peer_ready ("send-peer-ready-1",
66 write_message),
67 GNUNET_TESTING_cmd_block_until_all_peers_started ("block-1",
68 &are_all_peers_started),
69 GNUNET_TESTING_cmd_local_test_finished ("local-test-finished-1",
70 write_message)
71 };
72
73 GNUNET_TESTING_run (NULL,
74 commands,
75 GNUNET_TIME_UNIT_FOREVER_REL);
76 LOG (GNUNET_ERROR_TYPE_ERROR,
77 "We got here 7!\n");
78
79}
80
81
82/**
83 * Entry point for the plugin.
84 *
85 * @param cls NULL
86 * @return the exported block API
87 */
88void *
89libgnunet_plugin_testcmd_init (void *cls)
90{
91 struct GNUNET_TESTING_PluginFunctions *api;
92
93 api = GNUNET_new (struct GNUNET_TESTING_PluginFunctions);
94 api->start_testcase = &start_testcase;
95 api->all_peers_started = &all_peers_started;
96 return api;
97}
98
99
100/**
101 * Exit point from the plugin.
102 *
103 * @param cls the return value from #libgnunet_plugin_block_test_init
104 * @return NULL
105 */
106void *
107libgnunet_plugin_testcmd_done (void *cls)
108{
109 struct GNUNET_TESTING_PluginFunctions *api = cls;
110
111 GNUNET_free (api);
112 return NULL;
113}
114
115
116/* end of plugin_testcmd.c */