diff options
author | t3sserakt <t3ss@posteo.de> | 2021-08-17 19:57:12 +0200 |
---|---|---|
committer | t3sserakt <t3ss@posteo.de> | 2021-08-17 19:57:12 +0200 |
commit | 32a8c505c1fa27bb43c4e7c8d288566d51417f56 (patch) | |
tree | 0328fe50b6a099b5020fe6d1e01cbd6b96ecd18a | |
parent | 1e063cd73452396778cf00127346b9b08a922317 (diff) | |
download | gnunet-32a8c505c1fa27bb43c4e7c8d288566d51417f56.tar.gz gnunet-32a8c505c1fa27bb43c4e7c8d288566d51417f56.zip |
- moved test code from testbed to testing
24 files changed, 809 insertions, 404 deletions
diff --git a/po/POTFILES.in b/po/POTFILES.in index 8ed952089..6675d0d25 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in | |||
@@ -396,7 +396,6 @@ src/template/gnunet-template.c | |||
396 | src/testbed-logger/gnunet-service-testbed-logger.c | 396 | src/testbed-logger/gnunet-service-testbed-logger.c |
397 | src/testbed-logger/testbed_logger_api.c | 397 | src/testbed-logger/testbed_logger_api.c |
398 | src/testbed/generate-underlay-topology.c | 398 | src/testbed/generate-underlay-topology.c |
399 | src/testbed/gnunet-cmds-helper.c | ||
400 | src/testbed/gnunet-daemon-latency-logger.c | 399 | src/testbed/gnunet-daemon-latency-logger.c |
401 | src/testbed/gnunet-daemon-testbed-blacklist.c | 400 | src/testbed/gnunet-daemon-testbed-blacklist.c |
402 | src/testbed/gnunet-daemon-testbed-underlay.c | 401 | src/testbed/gnunet-daemon-testbed-underlay.c |
@@ -414,16 +413,9 @@ src/testbed/gnunet-service-testbed_peers.c | |||
414 | src/testbed/gnunet-testbed-profiler.c | 413 | src/testbed/gnunet-testbed-profiler.c |
415 | src/testbed/gnunet_mpi_test.c | 414 | src/testbed/gnunet_mpi_test.c |
416 | src/testbed/gnunet_testbed_mpi_spawn.c | 415 | src/testbed/gnunet_testbed_mpi_spawn.c |
417 | src/testbed/plugin_testcmd.c | ||
418 | src/testbed/testbed_api.c | 416 | src/testbed/testbed_api.c |
419 | src/testbed/testbed_api_barriers.c | 417 | src/testbed/testbed_api_barriers.c |
420 | src/testbed/testbed_api_cmd_block_until_all_peers_started.c | ||
421 | src/testbed/testbed_api_cmd_local_test_finished.c | ||
422 | src/testbed/testbed_api_cmd_netjail_start.c | ||
423 | src/testbed/testbed_api_cmd_netjail_start_testbed.c | 418 | src/testbed/testbed_api_cmd_netjail_start_testbed.c |
424 | src/testbed/testbed_api_cmd_netjail_stop.c | ||
425 | src/testbed/testbed_api_cmd_netjail_stop_testbed.c | ||
426 | src/testbed/testbed_api_cmd_send_peer_ready.c | ||
427 | src/testbed/testbed_api_hosts.c | 419 | src/testbed/testbed_api_hosts.c |
428 | src/testbed/testbed_api_operations.c | 420 | src/testbed/testbed_api_operations.c |
429 | src/testbed/testbed_api_peers.c | 421 | src/testbed/testbed_api_peers.c |
@@ -434,12 +426,19 @@ src/testbed/testbed_api_test.c | |||
434 | src/testbed/testbed_api_testbed.c | 426 | src/testbed/testbed_api_testbed.c |
435 | src/testbed/testbed_api_topology.c | 427 | src/testbed/testbed_api_topology.c |
436 | src/testbed/testbed_api_underlay.c | 428 | src/testbed/testbed_api_underlay.c |
429 | src/testing/gnunet-cmds-helper.c | ||
437 | src/testing/gnunet-testing.c | 430 | src/testing/gnunet-testing.c |
438 | src/testing/list-keys.c | 431 | src/testing/list-keys.c |
439 | src/testing/testing.c | 432 | src/testing/testing.c |
440 | src/testing/testing_api_cmd_batch.c | 433 | src/testing/testing_api_cmd_batch.c |
434 | src/testing/testing_api_cmd_block_until_all_peers_started.c | ||
441 | src/testing/testing_api_cmd_hello_world.c | 435 | src/testing/testing_api_cmd_hello_world.c |
442 | src/testing/testing_api_cmd_hello_world_birth.c | 436 | src/testing/testing_api_cmd_hello_world_birth.c |
437 | src/testing/testing_api_cmd_local_test_finished.c | ||
438 | src/testing/testing_api_cmd_netjail_start.c | ||
439 | src/testing/testing_api_cmd_netjail_start_testbed.c | ||
440 | src/testing/testing_api_cmd_netjail_stop.c | ||
441 | src/testing/testing_api_cmd_netjail_stop_testbed.c | ||
443 | src/testing/testing_api_cmd_send_peer_ready.c | 442 | src/testing/testing_api_cmd_send_peer_ready.c |
444 | src/testing/testing_api_cmd_system_create.c | 443 | src/testing/testing_api_cmd_system_create.c |
445 | src/testing/testing_api_loop.c | 444 | src/testing/testing_api_loop.c |
@@ -466,7 +465,6 @@ src/transport/gnunet-transport-profiler.c | |||
466 | src/transport/gnunet-transport-wlan-receiver.c | 465 | src/transport/gnunet-transport-wlan-receiver.c |
467 | src/transport/gnunet-transport-wlan-sender.c | 466 | src/transport/gnunet-transport-wlan-sender.c |
468 | src/transport/gnunet-transport.c | 467 | src/transport/gnunet-transport.c |
469 | src/transport/plugin_cmd_simple_send.c | ||
470 | src/transport/plugin_transport_http_client.c | 468 | src/transport/plugin_transport_http_client.c |
471 | src/transport/plugin_transport_http_common.c | 469 | src/transport/plugin_transport_http_common.c |
472 | src/transport/plugin_transport_http_server.c | 470 | src/transport/plugin_transport_http_server.c |
diff --git a/src/include/Makefile.am b/src/include/Makefile.am index 16ff25350..9c22b5977 100644 --- a/src/include/Makefile.am +++ b/src/include/Makefile.am | |||
@@ -115,7 +115,6 @@ gnunetinclude_HEADERS = \ | |||
115 | gnunet_strings_lib.h \ | 115 | gnunet_strings_lib.h \ |
116 | gnunet_testbed_service.h \ | 116 | gnunet_testbed_service.h \ |
117 | gnunet_testbed_logger_service.h \ | 117 | gnunet_testbed_logger_service.h \ |
118 | gnunet_testbed_ng_service.h \ | ||
119 | gnunet_testing_lib.h \ | 118 | gnunet_testing_lib.h \ |
120 | gnunet_testing_plugin.h \ | 119 | gnunet_testing_plugin.h \ |
121 | gnunet_testing_ng_lib.h \ | 120 | gnunet_testing_ng_lib.h \ |
diff --git a/src/include/gnunet_testbed_ng_service.h b/src/include/gnunet_testbed_ng_service.h deleted file mode 100644 index 5979cd85a..000000000 --- a/src/include/gnunet_testbed_ng_service.h +++ /dev/null | |||
@@ -1,110 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2021 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 | * @author t3sserakt | ||
23 | * | ||
24 | * @file | ||
25 | * API for writing tests and creating large-scale emulation testbeds for GNUnet with command pattern. | ||
26 | * | ||
27 | * @defgroup testbed Testbed service | ||
28 | * Writing tests and creating large-scale emulation testbeds for GNUnet with command pattern. | ||
29 | * | ||
30 | * @see [Documentation](https://docs.gnunet.org/handbook/gnunet.html#TESTBED-NG-Subsystem) | ||
31 | * | ||
32 | * @{ | ||
33 | */ | ||
34 | |||
35 | #ifndef GNUNET_TESTBED_NG_SERVICE_H | ||
36 | #define GNUNET_TESTBED_NG_SERVICE_H | ||
37 | |||
38 | #include "gnunet_util_lib.h" | ||
39 | #include "gnunet_testing_ng_lib.h" | ||
40 | |||
41 | |||
42 | /** | ||
43 | * Create command. | ||
44 | * | ||
45 | * @param label name for command. | ||
46 | * @param binaryname to start. | ||
47 | * @return command. | ||
48 | */ | ||
49 | struct GNUNET_TESTING_Command | ||
50 | GNUNET_TESTING_cmd_netjail_start (const char *label, | ||
51 | char *local_m, | ||
52 | char *global_n); | ||
53 | |||
54 | |||
55 | /** | ||
56 | * Create command. | ||
57 | * | ||
58 | * @param label name for command. | ||
59 | * @param binaryname to exec. | ||
60 | * @return command. | ||
61 | */ | ||
62 | struct GNUNET_TESTING_Command | ||
63 | GNUNET_TESTING_cmd_netjail_start_testing_system (const char *label, | ||
64 | char *local_m, | ||
65 | char *global_n, | ||
66 | char *plugin_name, | ||
67 | unsigned int *rv); | ||
68 | |||
69 | |||
70 | /** | ||
71 | * Create command. | ||
72 | * | ||
73 | * @param label name for command. | ||
74 | * @param binaryname to stop. | ||
75 | * @return command. | ||
76 | */ | ||
77 | struct GNUNET_TESTING_Command | ||
78 | GNUNET_TESTING_cmd_netjail_stop (const char *label, | ||
79 | char *local_m, | ||
80 | char *global_n); | ||
81 | |||
82 | |||
83 | struct GNUNET_TESTING_Command | ||
84 | GNUNET_TESTING_cmd_stop_testing_system (const char *label, | ||
85 | const char *helper_start_label, | ||
86 | char *local_m, | ||
87 | char *global_n); | ||
88 | |||
89 | |||
90 | int | ||
91 | GNUNET_TESTING_get_trait_helper_handles (const struct | ||
92 | GNUNET_TESTING_Command *cmd, | ||
93 | struct GNUNET_HELPER_Handle ***helper); | ||
94 | |||
95 | |||
96 | struct GNUNET_TESTING_Command | ||
97 | GNUNET_TESTING_cmd_block_until_all_peers_started (const char *label, | ||
98 | unsigned int * | ||
99 | all_peers_started); | ||
100 | |||
101 | struct GNUNET_TESTING_Command | ||
102 | GNUNET_TESTING_cmd_send_peer_ready (const char *label, | ||
103 | TESTING_CMD_HELPER_write_cb write_message); | ||
104 | |||
105 | struct GNUNET_TESTING_Command | ||
106 | GNUNET_TESTING_cmd_local_test_finished (const char *label, | ||
107 | TESTING_CMD_HELPER_write_cb | ||
108 | write_message); | ||
109 | |||
110 | #endif | ||
diff --git a/src/include/gnunet_testing_ng_lib.h b/src/include/gnunet_testing_ng_lib.h index aad7ddec2..035d1bcad 100644 --- a/src/include/gnunet_testing_ng_lib.h +++ b/src/include/gnunet_testing_ng_lib.h | |||
@@ -842,4 +842,72 @@ struct GNUNET_TESTING_Command | |||
842 | GNUNET_TESTING_cmd_system_create (const char *label, | 842 | GNUNET_TESTING_cmd_system_create (const char *label, |
843 | const char *testdir); | 843 | const char *testdir); |
844 | 844 | ||
845 | |||
846 | /** | ||
847 | * Create command. | ||
848 | * | ||
849 | * @param label name for command. | ||
850 | * @param binaryname to start. | ||
851 | * @return command. | ||
852 | */ | ||
853 | struct GNUNET_TESTING_Command | ||
854 | GNUNET_TESTING_cmd_netjail_start (const char *label, | ||
855 | char *local_m, | ||
856 | char *global_n); | ||
857 | |||
858 | |||
859 | /** | ||
860 | * Create command. | ||
861 | * | ||
862 | * @param label name for command. | ||
863 | * @param binaryname to exec. | ||
864 | * @return command. | ||
865 | */ | ||
866 | struct GNUNET_TESTING_Command | ||
867 | GNUNET_TESTING_cmd_netjail_start_testing_system (const char *label, | ||
868 | char *local_m, | ||
869 | char *global_n, | ||
870 | char *plugin_name, | ||
871 | unsigned int *rv); | ||
872 | |||
873 | |||
874 | /** | ||
875 | * Create command. | ||
876 | * | ||
877 | * @param label name for command. | ||
878 | * @param binaryname to stop. | ||
879 | * @return command. | ||
880 | */ | ||
881 | struct GNUNET_TESTING_Command | ||
882 | GNUNET_TESTING_cmd_netjail_stop (const char *label, | ||
883 | char *local_m, | ||
884 | char *global_n); | ||
885 | |||
886 | |||
887 | struct GNUNET_TESTING_Command | ||
888 | GNUNET_TESTING_cmd_stop_testing_system (const char *label, | ||
889 | const char *helper_start_label, | ||
890 | char *local_m, | ||
891 | char *global_n); | ||
892 | |||
893 | |||
894 | int | ||
895 | GNUNET_TESTING_get_trait_helper_handles (const struct | ||
896 | GNUNET_TESTING_Command *cmd, | ||
897 | struct GNUNET_HELPER_Handle ***helper); | ||
898 | |||
899 | |||
900 | struct GNUNET_TESTING_Command | ||
901 | GNUNET_TESTING_cmd_block_until_all_peers_started (const char *label, | ||
902 | unsigned int * | ||
903 | all_peers_started); | ||
904 | |||
905 | struct GNUNET_TESTING_Command | ||
906 | GNUNET_TESTING_cmd_send_peer_ready (const char *label, | ||
907 | TESTING_CMD_HELPER_write_cb write_message); | ||
908 | |||
909 | struct GNUNET_TESTING_Command | ||
910 | GNUNET_TESTING_cmd_local_test_finished (const char *label, | ||
911 | TESTING_CMD_HELPER_write_cb | ||
912 | write_message); | ||
845 | #endif | 913 | #endif |
diff --git a/src/testbed/Makefile.am b/src/testbed/Makefile.am index 5a221cd69..d1f43f0f6 100644 --- a/src/testbed/Makefile.am +++ b/src/testbed/Makefile.am | |||
@@ -23,7 +23,6 @@ if HAVE_SQLITE | |||
23 | endif | 23 | endif |
24 | 24 | ||
25 | libexec_PROGRAMS = \ | 25 | libexec_PROGRAMS = \ |
26 | gnunet-cmds-helper \ | ||
27 | gnunet-service-testbed \ | 26 | gnunet-service-testbed \ |
28 | gnunet-helper-testbed \ | 27 | gnunet-helper-testbed \ |
29 | gnunet-daemon-testbed-blacklist \ | 28 | gnunet-daemon-testbed-blacklist \ |
@@ -36,21 +35,6 @@ bin_PROGRAMS = \ | |||
36 | noinst_PROGRAMS = \ | 35 | noinst_PROGRAMS = \ |
37 | $(generate_underlay) | 36 | $(generate_underlay) |
38 | 37 | ||
39 | plugin_LTLIBRARIES = \ | ||
40 | libgnunet_plugin_testcmd.la | ||
41 | |||
42 | libgnunet_plugin_testcmd_la_SOURCES = \ | ||
43 | plugin_testcmd.c | ||
44 | libgnunet_plugin_testcmd_la_LIBADD = \ | ||
45 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
46 | $(top_builddir)/src/arm/libgnunetarm.la \ | ||
47 | $(top_builddir)/src/testing/libgnunettesting.la \ | ||
48 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | ||
49 | libgnunettestbed.la \ | ||
50 | $(LTLIBINTL) | ||
51 | libgnunet_plugin_testcmd_la_LDFLAGS = \ | ||
52 | $(GN_PLUGIN_LDFLAGS) | ||
53 | |||
54 | gnunet_service_testbed_SOURCES = \ | 38 | gnunet_service_testbed_SOURCES = \ |
55 | gnunet-service-testbed.c gnunet-service-testbed.h \ | 39 | gnunet-service-testbed.c gnunet-service-testbed.h \ |
56 | gnunet-service-testbed_links.c gnunet-service-testbed_links.h \ | 40 | gnunet-service-testbed_links.c gnunet-service-testbed_links.h \ |
@@ -89,15 +73,6 @@ gnunet_helper_testbed_LDADD = $(XLIB) \ | |||
89 | libgnunettestbed.la \ | 73 | libgnunettestbed.la \ |
90 | $(LTLIBINTL) $(Z_LIBS) | 74 | $(LTLIBINTL) $(Z_LIBS) |
91 | 75 | ||
92 | gnunet_cmds_helper_SOURCES = \ | ||
93 | gnunet-cmds-helper.c | ||
94 | gnunet_cmds_helper_LDADD = $(XLIB) \ | ||
95 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
96 | $(top_builddir)/src/testing/libgnunettesting.la \ | ||
97 | $(top_builddir)/src/transport/libgnunettransporttesting2.la \ | ||
98 | libgnunettestbed.la \ | ||
99 | $(LTLIBINTL) $(Z_LIBS) | ||
100 | |||
101 | gnunet_daemon_testbed_blacklist_SOURCES = gnunet-daemon-testbed-blacklist.c | 76 | gnunet_daemon_testbed_blacklist_SOURCES = gnunet-daemon-testbed-blacklist.c |
102 | gnunet_daemon_testbed_blacklist_LDADD = $(XLIB) \ | 77 | gnunet_daemon_testbed_blacklist_LDADD = $(XLIB) \ |
103 | $(top_builddir)/src/transport/libgnunettransport.la \ | 78 | $(top_builddir)/src/transport/libgnunettransport.la \ |
@@ -120,13 +95,6 @@ lib_LTLIBRARIES = \ | |||
120 | libgnunettestbed.la | 95 | libgnunettestbed.la |
121 | 96 | ||
122 | libgnunettestbed_la_SOURCES = \ | 97 | libgnunettestbed_la_SOURCES = \ |
123 | testbed_api_cmd_local_test_finished.c \ | ||
124 | testbed_api_cmd_send_peer_ready.c \ | ||
125 | testbed_api_cmd_block_until_all_peers_started.c \ | ||
126 | testbed_api_cmd_netjail_start.c \ | ||
127 | testbed_api_cmd_netjail_start_testbed.c \ | ||
128 | testbed_api_cmd_netjail_stop_testbed.c \ | ||
129 | testbed_api_cmd_netjail_stop.c \ | ||
130 | testbed_api.c testbed_api.h testbed.h \ | 98 | testbed_api.c testbed_api.h testbed.h \ |
131 | testbed_api_hosts.c testbed_api_hosts.h testbed_helper.h \ | 99 | testbed_api_hosts.c testbed_api_hosts.h testbed_helper.h \ |
132 | testbed_api_operations.c testbed_api_operations.h \ | 100 | testbed_api_operations.c testbed_api_operations.h \ |
@@ -165,7 +133,6 @@ generate_underlay_topology_LDADD = $(XLIB) \ | |||
165 | $(LTLIBINTL) -lsqlite3 | 133 | $(LTLIBINTL) -lsqlite3 |
166 | 134 | ||
167 | check_PROGRAMS = \ | 135 | check_PROGRAMS = \ |
168 | test_testbed_api_cmd_netjail \ | ||
169 | test_testbed_api_hosts \ | 136 | test_testbed_api_hosts \ |
170 | test_gnunet_helper_testbed \ | 137 | test_gnunet_helper_testbed \ |
171 | test_testbed_api_controllerlink \ | 138 | test_testbed_api_controllerlink \ |
@@ -200,7 +167,6 @@ check_PROGRAMS = \ | |||
200 | if ENABLE_TEST_RUN | 167 | if ENABLE_TEST_RUN |
201 | AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME; | 168 | AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME; |
202 | TESTS = \ | 169 | TESTS = \ |
203 | test_testbed_api_cmd_netjail \ | ||
204 | test_testbed_api \ | 170 | test_testbed_api \ |
205 | test_testbed_api_sd \ | 171 | test_testbed_api_sd \ |
206 | test_testbed_api_operations \ | 172 | test_testbed_api_operations \ |
@@ -231,13 +197,6 @@ if ENABLE_TEST_RUN | |||
231 | $(underlay_testcases) | 197 | $(underlay_testcases) |
232 | endif | 198 | endif |
233 | 199 | ||
234 | test_testbed_api_cmd_netjail_SOURCES = \ | ||
235 | test_testbed_api_cmd_netjail.c | ||
236 | test_testbed_api_cmd_netjail_LDADD = \ | ||
237 | $(top_builddir)/src/testing/libgnunettesting.la \ | ||
238 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
239 | libgnunettestbed.la | ||
240 | |||
241 | test_testbed_api_SOURCES = \ | 200 | test_testbed_api_SOURCES = \ |
242 | test_testbed_api.c | 201 | test_testbed_api.c |
243 | test_testbed_api_LDADD = \ | 202 | test_testbed_api_LDADD = \ |
diff --git a/src/testbed/testbed_api.h b/src/testbed/testbed_api.h index 9a54ca36c..d4ef832ad 100644 --- a/src/testbed/testbed_api.h +++ b/src/testbed/testbed_api.h | |||
@@ -37,11 +37,6 @@ | |||
37 | */ | 37 | */ |
38 | #define HELPER_TESTBED_BINARY "gnunet-helper-testbed" | 38 | #define HELPER_TESTBED_BINARY "gnunet-helper-testbed" |
39 | 39 | ||
40 | /** | ||
41 | * Cmds Helper binary name | ||
42 | */ | ||
43 | #define HELPER_CMDS_BINARY "gnunet-cmds-helper" | ||
44 | |||
45 | 40 | ||
46 | /** | 41 | /** |
47 | * Enumeration of operations | 42 | * Enumeration of operations |
@@ -185,6 +180,7 @@ struct OperationContext | |||
185 | typedef void | 180 | typedef void |
186 | (*TESTBED_opcq_empty_cb) (void *cls); | 181 | (*TESTBED_opcq_empty_cb) (void *cls); |
187 | 182 | ||
183 | |||
188 | /** | 184 | /** |
189 | * Handle to interact with a GNUnet testbed controller. Each | 185 | * Handle to interact with a GNUnet testbed controller. Each |
190 | * controller has at least one master handle which is created when the | 186 | * controller has at least one master handle which is created when the |
diff --git a/src/testbed/testbed_api_cmd_send_peer_ready.c b/src/testbed/testbed_api_cmd_send_peer_ready.c deleted file mode 100644 index 987f0853e..000000000 --- a/src/testbed/testbed_api_cmd_send_peer_ready.c +++ /dev/null | |||
@@ -1,103 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2021 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 testing_api_cmd_send_peer_ready.c | ||
23 | * @brief cmd to send a helper message if peer is ready. | ||
24 | * @author t3sserakt | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_util_lib.h" | ||
28 | #include "gnunet_testing_ng_lib.h" | ||
29 | #include "testbed_helper.h" | ||
30 | |||
31 | |||
32 | struct SendPeerReadyState | ||
33 | { | ||
34 | TESTING_CMD_HELPER_write_cb write_message; | ||
35 | |||
36 | struct GNUNET_CMDS_PEER_STARTED *reply; | ||
37 | }; | ||
38 | |||
39 | |||
40 | static int | ||
41 | send_peer_ready_traits (void *cls, | ||
42 | const void **ret, | ||
43 | const char *trait, | ||
44 | unsigned int index) | ||
45 | { | ||
46 | return GNUNET_OK; | ||
47 | } | ||
48 | |||
49 | |||
50 | static void | ||
51 | send_peer_ready_cleanup (void *cls, | ||
52 | const struct GNUNET_TESTING_Command *cmd) | ||
53 | { | ||
54 | struct SendPeerReadyState *sprs = cls; | ||
55 | |||
56 | GNUNET_free (sprs->reply); | ||
57 | GNUNET_free (sprs); | ||
58 | } | ||
59 | |||
60 | |||
61 | static void | ||
62 | send_peer_ready_run (void *cls, | ||
63 | const struct GNUNET_TESTING_Command *cmd, | ||
64 | struct GNUNET_TESTING_Interpreter *is) | ||
65 | { | ||
66 | struct SendPeerReadyState *sprs = cls; | ||
67 | struct GNUNET_CMDS_PEER_STARTED *reply; | ||
68 | size_t msg_length; | ||
69 | |||
70 | msg_length = sizeof(struct GNUNET_CMDS_PEER_STARTED); | ||
71 | reply = GNUNET_new (struct GNUNET_CMDS_PEER_STARTED); | ||
72 | reply->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_PEER_STARTED); | ||
73 | reply->header.size = htons ((uint16_t) msg_length); | ||
74 | sprs->reply = reply; | ||
75 | sprs->write_message ((struct GNUNET_MessageHeader *) reply, msg_length); | ||
76 | } | ||
77 | |||
78 | |||
79 | /** | ||
80 | * Create command. | ||
81 | * | ||
82 | * @param label name for command. | ||
83 | * @return command. | ||
84 | */ | ||
85 | struct GNUNET_TESTING_Command | ||
86 | GNUNET_TESTING_cmd_send_peer_ready (const char *label, | ||
87 | TESTING_CMD_HELPER_write_cb write_message) | ||
88 | { | ||
89 | struct SendPeerReadyState *sprs; | ||
90 | |||
91 | sprs = GNUNET_new (struct SendPeerReadyState); | ||
92 | sprs->write_message = write_message; | ||
93 | |||
94 | struct GNUNET_TESTING_Command cmd = { | ||
95 | .cls = sprs, | ||
96 | .label = label, | ||
97 | .run = &send_peer_ready_run, | ||
98 | .cleanup = &send_peer_ready_cleanup, | ||
99 | .traits = &send_peer_ready_traits | ||
100 | }; | ||
101 | |||
102 | return cmd; | ||
103 | } | ||
diff --git a/src/testbed/testbed_api_hosts.c b/src/testbed/testbed_api_hosts.c index d0a460fe6..1a8d9976d 100644 --- a/src/testbed/testbed_api_hosts.c +++ b/src/testbed/testbed_api_hosts.c | |||
@@ -964,10 +964,22 @@ gen_rsh_suffix_args (const char *const *append_args) | |||
964 | } | 964 | } |
965 | 965 | ||
966 | 966 | ||
967 | void | 967 | /** |
968 | GNUNET_TESTBED_extract_cfg (struct GNUNET_TESTBED_Host *host, const struct | 968 | * Functions with this signature are called whenever a |
969 | GNUNET_MessageHeader *message) | 969 | * complete message is received by the tokenizer. |
970 | * | ||
971 | * Do not call GNUNET_SERVER_mst_destroy in callback | ||
972 | * | ||
973 | * @param cls closure | ||
974 | * @param client identification of the client | ||
975 | * @param message the actual message | ||
976 | * | ||
977 | * @return #GNUNET_OK on success, #GNUNET_SYSERR to stop further processing | ||
978 | */ | ||
979 | static int | ||
980 | helper_mst (void *cls, const struct GNUNET_MessageHeader *message) | ||
970 | { | 981 | { |
982 | struct GNUNET_TESTBED_ControllerProc *cp = cls; | ||
971 | const struct GNUNET_TESTBED_HelperReply *msg; | 983 | const struct GNUNET_TESTBED_HelperReply *msg; |
972 | const char *hostname; | 984 | const char *hostname; |
973 | char *config; | 985 | char *config; |
@@ -989,43 +1001,22 @@ GNUNET_TESTBED_extract_cfg (struct GNUNET_TESTBED_Host *host, const struct | |||
989 | xconfig_size)); | 1001 | xconfig_size)); |
990 | /* Replace the configuration template present in the host with the | 1002 | /* Replace the configuration template present in the host with the |
991 | controller's running configuration */ | 1003 | controller's running configuration */ |
992 | GNUNET_CONFIGURATION_destroy (host->cfg); | 1004 | GNUNET_CONFIGURATION_destroy (cp->host->cfg); |
993 | host->cfg = GNUNET_CONFIGURATION_create (); | 1005 | cp->host->cfg = GNUNET_CONFIGURATION_create (); |
994 | GNUNET_assert (GNUNET_CONFIGURATION_deserialize (host->cfg, | 1006 | GNUNET_assert (GNUNET_CONFIGURATION_deserialize (cp->host->cfg, |
995 | config, | 1007 | config, |
996 | config_size, | 1008 | config_size, |
997 | NULL)); | 1009 | NULL)); |
998 | GNUNET_free (config); | 1010 | GNUNET_free (config); |
999 | if (NULL == (hostname = GNUNET_TESTBED_host_get_hostname (host))) | 1011 | if (NULL == (hostname = GNUNET_TESTBED_host_get_hostname (cp->host))) |
1000 | hostname = "localhost"; | 1012 | hostname = "localhost"; |
1001 | /* Change the hostname so that we can connect to it */ | 1013 | /* Change the hostname so that we can connect to it */ |
1002 | GNUNET_CONFIGURATION_set_value_string (host->cfg, | 1014 | GNUNET_CONFIGURATION_set_value_string (cp->host->cfg, |
1003 | "testbed", | 1015 | "testbed", |
1004 | "hostname", | 1016 | "hostname", |
1005 | hostname); | 1017 | hostname); |
1006 | host->locked = GNUNET_NO; | 1018 | cp->host->locked = GNUNET_NO; |
1007 | } | 1019 | cp->host->controller_started = GNUNET_YES; |
1008 | |||
1009 | /** | ||
1010 | * Functions with this signature are called whenever a | ||
1011 | * complete message is received by the tokenizer. | ||
1012 | * | ||
1013 | * Do not call GNUNET_SERVER_mst_destroy in callback | ||
1014 | * | ||
1015 | * @param cls closure | ||
1016 | * @param client identification of the client | ||
1017 | * @param message the actual message | ||
1018 | * | ||
1019 | * @return #GNUNET_OK on success, #GNUNET_SYSERR to stop further processing | ||
1020 | */ | ||
1021 | static int | ||
1022 | helper_mst (void *cls, const struct GNUNET_MessageHeader *message) | ||
1023 | { | ||
1024 | struct GNUNET_TESTBED_ControllerProc *cp = cls; | ||
1025 | struct GNUNET_TESTBED_Host *host = cp->host; | ||
1026 | |||
1027 | GNUNET_TESTBED_extract_cfg (host, message); | ||
1028 | |||
1029 | cp->cb (cp->cls, cp->host->cfg, GNUNET_OK); | 1020 | cp->cb (cp->cls, cp->host->cfg, GNUNET_OK); |
1030 | return GNUNET_OK; | 1021 | return GNUNET_OK; |
1031 | } | 1022 | } |
diff --git a/src/testbed/testbed_helper.h b/src/testbed/testbed_helper.h index af90ce85d..817ad559d 100644 --- a/src/testbed/testbed_helper.h +++ b/src/testbed/testbed_helper.h | |||
@@ -84,60 +84,6 @@ struct GNUNET_TESTBED_HelperReply | |||
84 | * un-compressed */ | 84 | * un-compressed */ |
85 | }; | 85 | }; |
86 | 86 | ||
87 | /** | ||
88 | * Initialization message for gnunet-cmds-testbed to start cmd binary. | ||
89 | */ | ||
90 | struct GNUNET_CMDS_HelperInit | ||
91 | { | ||
92 | /** | ||
93 | * Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_INIT | ||
94 | */ | ||
95 | struct GNUNET_MessageHeader header; | ||
96 | |||
97 | /** | ||
98 | * | ||
99 | */ | ||
100 | uint16_t plugin_name_size GNUNET_PACKED; | ||
101 | |||
102 | /* Followed by plugin name of the plugin running the test case. This is not NULL | ||
103 | * terminated */ | ||
104 | }; | ||
105 | |||
106 | /** | ||
107 | * Reply message from cmds helper process | ||
108 | */ | ||
109 | struct GNUNET_CMDS_HelperReply | ||
110 | { | ||
111 | /** | ||
112 | * Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_REPLY | ||
113 | */ | ||
114 | struct GNUNET_MessageHeader header; | ||
115 | }; | ||
116 | |||
117 | struct GNUNET_CMDS_PEER_STARTED | ||
118 | { | ||
119 | /** | ||
120 | * Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_PEER_STARTED | ||
121 | */ | ||
122 | struct GNUNET_MessageHeader header; | ||
123 | }; | ||
124 | |||
125 | struct GNUNET_CMDS_ALL_PEERS_STARTED | ||
126 | { | ||
127 | /** | ||
128 | * Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_PEERS_STARTED | ||
129 | */ | ||
130 | struct GNUNET_MessageHeader header; | ||
131 | }; | ||
132 | |||
133 | struct GNUNET_CMDS_LOCAL_FINISHED | ||
134 | { | ||
135 | /** | ||
136 | * Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED | ||
137 | */ | ||
138 | struct GNUNET_MessageHeader header; | ||
139 | }; | ||
140 | |||
141 | GNUNET_NETWORK_STRUCT_END | 87 | GNUNET_NETWORK_STRUCT_END |
142 | #endif | 88 | #endif |
143 | /* end of testbed_helper.h */ | 89 | /* end of testbed_helper.h */ |
diff --git a/src/testing/Makefile.am b/src/testing/Makefile.am index 8b28e6e23..15469a310 100644 --- a/src/testing/Makefile.am +++ b/src/testing/Makefile.am | |||
@@ -11,10 +11,43 @@ pkgcfgdir= $(pkgdatadir)/config.d/ | |||
11 | dist_pkgcfg_DATA = \ | 11 | dist_pkgcfg_DATA = \ |
12 | testing.conf | 12 | testing.conf |
13 | 13 | ||
14 | libexec_PROGRAMS = \ | ||
15 | gnunet-cmds-helper | ||
16 | |||
17 | plugindir = $(libdir)/gnunet | ||
18 | |||
19 | plugin_LTLIBRARIES = \ | ||
20 | libgnunet_test_testing_plugin_testcmd.la | ||
21 | |||
14 | lib_LTLIBRARIES = \ | 22 | lib_LTLIBRARIES = \ |
15 | libgnunettesting.la | 23 | libgnunettesting.la |
16 | 24 | ||
25 | gnunet_cmds_helper_SOURCES = \ | ||
26 | gnunet-cmds-helper.c | ||
27 | gnunet_cmds_helper_LDADD = $(XLIB) \ | ||
28 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
29 | libgnunettesting.la \ | ||
30 | $(LTLIBINTL) $(Z_LIBS) | ||
31 | |||
32 | libgnunet_test_testing_plugin_testcmd_la_SOURCES = \ | ||
33 | test_testing_plugin_testcmd.c | ||
34 | libgnunet_test_testing_plugin_testcmd_la_LIBADD = \ | ||
35 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
36 | $(top_builddir)/src/arm/libgnunetarm.la \ | ||
37 | libgnunettesting.la \ | ||
38 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | ||
39 | $(LTLIBINTL) | ||
40 | libgnunet_test_testing_plugin_testcmd_la_LDFLAGS = \ | ||
41 | $(GN_PLUGIN_LDFLAGS) | ||
42 | |||
17 | libgnunettesting_la_SOURCES = \ | 43 | libgnunettesting_la_SOURCES = \ |
44 | testing_api_cmd_local_test_finished.c \ | ||
45 | testing_api_cmd_send_peer_ready.c \ | ||
46 | testing_api_cmd_block_until_all_peers_started.c \ | ||
47 | testing_api_cmd_netjail_start.c \ | ||
48 | testing_api_cmd_netjail_start_testsystem.c \ | ||
49 | testing_api_cmd_netjail_stop_testsystem.c \ | ||
50 | testing_api_cmd_netjail_stop.c \ | ||
18 | testing.c testing.h \ | 51 | testing.c testing.h \ |
19 | testing_api_cmd_system_create.c \ | 52 | testing_api_cmd_system_create.c \ |
20 | testing_api_cmd_batch.c \ | 53 | testing_api_cmd_batch.c \ |
@@ -56,6 +89,7 @@ list_keys_LDADD = \ | |||
56 | 89 | ||
57 | 90 | ||
58 | check_PROGRAMS = \ | 91 | check_PROGRAMS = \ |
92 | test_testing_api_cmd_netjail \ | ||
59 | test_testing_hello_world \ | 93 | test_testing_hello_world \ |
60 | test_testing_portreservation \ | 94 | test_testing_portreservation \ |
61 | test_testing_servicestartup \ | 95 | test_testing_servicestartup \ |
@@ -66,6 +100,7 @@ check_PROGRAMS = \ | |||
66 | if ENABLE_TEST_RUN | 100 | if ENABLE_TEST_RUN |
67 | AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME; | 101 | AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME; |
68 | TESTS = \ | 102 | TESTS = \ |
103 | test_testing_api_cmd_netjail \ | ||
69 | test_testing_hello_world \ | 104 | test_testing_hello_world \ |
70 | test_testing_portreservation \ | 105 | test_testing_portreservation \ |
71 | test_testing_peerstartup \ | 106 | test_testing_peerstartup \ |
@@ -73,6 +108,12 @@ TESTS = \ | |||
73 | test_testing_servicestartup | 108 | test_testing_servicestartup |
74 | endif | 109 | endif |
75 | 110 | ||
111 | test_testing_api_cmd_netjail_SOURCES = \ | ||
112 | test_testing_api_cmd_netjail.c | ||
113 | test_testing_api_cmd_netjail_LDADD = \ | ||
114 | libgnunettesting.la \ | ||
115 | $(top_builddir)/src/util/libgnunetutil.la | ||
116 | |||
76 | test_testing_hello_world_SOURCES = \ | 117 | test_testing_hello_world_SOURCES = \ |
77 | test_testing_hello_world.c | 118 | test_testing_hello_world.c |
78 | test_testing_hello_world_LDADD = \ | 119 | test_testing_hello_world_LDADD = \ |
diff --git a/src/testbed/gnunet-cmds-helper.c b/src/testing/gnunet-cmds-helper.c index 4bc0656de..d9fcf3541 100644 --- a/src/testbed/gnunet-cmds-helper.c +++ b/src/testing/gnunet-cmds-helper.c | |||
@@ -39,9 +39,8 @@ | |||
39 | #include "platform.h" | 39 | #include "platform.h" |
40 | #include "gnunet_util_lib.h" | 40 | #include "gnunet_util_lib.h" |
41 | #include "gnunet_testing_lib.h" | 41 | #include "gnunet_testing_lib.h" |
42 | #include "gnunet_testbed_service.h" | 42 | #include "gnunet_testing_ng_lib.h" |
43 | #include "testbed_helper.h" | 43 | #include "testing_cmds.h" |
44 | #include "testbed_api.h" | ||
45 | #include "gnunet_testing_plugin.h" | 44 | #include "gnunet_testing_plugin.h" |
46 | #include <zlib.h> | 45 | #include <zlib.h> |
47 | 46 | ||
@@ -124,7 +123,7 @@ struct Plugin *plugin; | |||
124 | 123 | ||
125 | /** | 124 | /** |
126 | * The process handle to the testbed service | 125 | * The process handle to the testbed service |
127 | 126 | ||
128 | static struct GNUNET_OS_Process *cmd_binary_process;*/ | 127 | static struct GNUNET_OS_Process *cmd_binary_process;*/ |
129 | 128 | ||
130 | /** | 129 | /** |
@@ -284,7 +283,7 @@ child_death_task (void *cls) | |||
284 | 283 | ||
285 | pr = GNUNET_DISK_pipe_handle (sigpipe, GNUNET_DISK_PIPE_END_READ); | 284 | pr = GNUNET_DISK_pipe_handle (sigpipe, GNUNET_DISK_PIPE_END_READ); |
286 | child_death_task_id = NULL; | 285 | child_death_task_id = NULL; |
287 | // consume the signal | 286 | // consume the signal |
288 | GNUNET_break (0 < GNUNET_DISK_file_read (pr, &c, sizeof(c))); | 287 | GNUNET_break (0 < GNUNET_DISK_file_read (pr, &c, sizeof(c))); |
289 | LOG_DEBUG ("Got SIGCHLD\n"); | 288 | LOG_DEBUG ("Got SIGCHLD\n"); |
290 | 289 | ||
@@ -411,7 +410,7 @@ tokenizer_cb (void *cls, const struct GNUNET_MessageHeader *message) | |||
411 | plugin = GNUNET_new (struct Plugin); | 410 | plugin = GNUNET_new (struct Plugin); |
412 | plugin->api = GNUNET_PLUGIN_load (plugin_name, | 411 | plugin->api = GNUNET_PLUGIN_load (plugin_name, |
413 | NULL); | 412 | NULL); |
414 | plugin->library_name = GNUNET_strdup (basename(plugin_name)); | 413 | plugin->library_name = GNUNET_strdup (basename (plugin_name)); |
415 | 414 | ||
416 | plugin->global_n = ni->global_n; | 415 | plugin->global_n = ni->global_n; |
417 | plugin->local_m = ni->local_m; | 416 | plugin->local_m = ni->local_m; |
diff --git a/src/testbed/test_testbed_api_cmd_netjail.c b/src/testing/test_testing_api_cmd_netjail.c index 85da39f0e..543642109 100644 --- a/src/testbed/test_testbed_api_cmd_netjail.c +++ b/src/testing/test_testing_api_cmd_netjail.c | |||
@@ -25,7 +25,6 @@ | |||
25 | */ | 25 | */ |
26 | #include "platform.h" | 26 | #include "platform.h" |
27 | #include "gnunet_testing_ng_lib.h" | 27 | #include "gnunet_testing_ng_lib.h" |
28 | #include "gnunet_testbed_ng_service.h" | ||
29 | #include "gnunet_util_lib.h" | 28 | #include "gnunet_util_lib.h" |
30 | 29 | ||
31 | 30 | ||
diff --git a/src/testbed/plugin_testcmd.c b/src/testing/test_testing_plugin_testcmd.c index b74b67240..aeb0db5dc 100644 --- a/src/testbed/plugin_testcmd.c +++ b/src/testing/test_testing_plugin_testcmd.c | |||
@@ -26,7 +26,7 @@ | |||
26 | #include "platform.h" | 26 | #include "platform.h" |
27 | #include "gnunet_testing_ng_lib.h" | 27 | #include "gnunet_testing_ng_lib.h" |
28 | #include "gnunet_util_lib.h" | 28 | #include "gnunet_util_lib.h" |
29 | #include "gnunet_testbed_ng_service.h" | 29 | #include "gnunet_testing_ng_lib.h" |
30 | 30 | ||
31 | /** | 31 | /** |
32 | * Generic logging shortcut | 32 | * Generic logging shortcut |
diff --git a/src/testbed/testbed_api_cmd_block_until_all_peers_started.c b/src/testing/testing_api_cmd_block_until_all_peers_started.c index 8659fbb46..8659fbb46 100644 --- a/src/testbed/testbed_api_cmd_block_until_all_peers_started.c +++ b/src/testing/testing_api_cmd_block_until_all_peers_started.c | |||
diff --git a/src/testbed/testbed_api_cmd_local_test_finished.c b/src/testing/testing_api_cmd_local_test_finished.c index c02546945..5b74d4e04 100644 --- a/src/testbed/testbed_api_cmd_local_test_finished.c +++ b/src/testing/testing_api_cmd_local_test_finished.c | |||
@@ -26,7 +26,7 @@ | |||
26 | #include "platform.h" | 26 | #include "platform.h" |
27 | #include "gnunet_util_lib.h" | 27 | #include "gnunet_util_lib.h" |
28 | #include "gnunet_testing_ng_lib.h" | 28 | #include "gnunet_testing_ng_lib.h" |
29 | #include "testbed_helper.h" | 29 | #include "testing_cmds.h" |
30 | 30 | ||
31 | /** | 31 | /** |
32 | * Generic logging shortcut | 32 | * Generic logging shortcut |
diff --git a/src/testbed/testbed_api_cmd_netjail_start.c b/src/testing/testing_api_cmd_netjail_start.c index 0cc020275..c82392a08 100644 --- a/src/testbed/testbed_api_cmd_netjail_start.c +++ b/src/testing/testing_api_cmd_netjail_start.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include "platform.h" | 26 | #include "platform.h" |
27 | #include "gnunet_util_lib.h" | 27 | #include "gnunet_util_lib.h" |
28 | #include "gnunet_testing_ng_lib.h" | 28 | #include "gnunet_testing_ng_lib.h" |
29 | #include "gnunet_testbed_ng_service.h" | ||
30 | 29 | ||
31 | #define NETJAIL_START_SCRIPT "./../testing/netjail_start.sh" | 30 | #define NETJAIL_START_SCRIPT "./../testing/netjail_start.sh" |
32 | 31 | ||
diff --git a/src/testing/testing_api_cmd_netjail_start_testsystem.c b/src/testing/testing_api_cmd_netjail_start_testsystem.c new file mode 100644 index 000000000..5c2f71168 --- /dev/null +++ b/src/testing/testing_api_cmd_netjail_start_testsystem.c | |||
@@ -0,0 +1,541 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2021 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 testing/testing_api_cmd_hello_world.c | ||
23 | * @brief Command to start the netjail peers. | ||
24 | * @author t3sserakt | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_testing_ng_lib.h" | ||
28 | #include "testing_cmds.h" | ||
29 | |||
30 | #define NETJAIL_EXEC_SCRIPT "./../testing/netjail_exec.sh" | ||
31 | |||
32 | struct HelperMessage; | ||
33 | |||
34 | struct HelperMessage | ||
35 | { | ||
36 | |||
37 | struct HelperMessage *next; | ||
38 | |||
39 | struct HelperMessage *prev; | ||
40 | |||
41 | /** | ||
42 | * Size of the original message. | ||
43 | */ | ||
44 | uint16_t bytes_msg; | ||
45 | |||
46 | /* Followed by @e bytes_msg of msg.*/ | ||
47 | }; | ||
48 | |||
49 | |||
50 | |||
51 | struct NetJailState | ||
52 | { | ||
53 | |||
54 | unsigned int *rv; | ||
55 | |||
56 | struct HelperMessage *hp_messages_head; | ||
57 | |||
58 | struct HelperMessage *hp_messages_tail; | ||
59 | |||
60 | /** | ||
61 | * The process handle | ||
62 | */ | ||
63 | struct GNUNET_HELPER_Handle **helper; | ||
64 | |||
65 | unsigned int n_helper; | ||
66 | |||
67 | char *binary_name; | ||
68 | |||
69 | char *local_m; | ||
70 | |||
71 | char *global_n; | ||
72 | |||
73 | /** | ||
74 | * The send handle for the helper | ||
75 | */ | ||
76 | struct GNUNET_HELPER_SendHandle **shandle; | ||
77 | |||
78 | unsigned int n_shandle; | ||
79 | |||
80 | /** | ||
81 | * The message corresponding to send handle | ||
82 | */ | ||
83 | struct GNUNET_MessageHeader **msg; | ||
84 | |||
85 | unsigned int n_msg; | ||
86 | |||
87 | unsigned int number_of_testsystems_started; | ||
88 | |||
89 | unsigned int number_of_peers_started; | ||
90 | |||
91 | unsigned int number_of_local_test_finished; | ||
92 | |||
93 | char *plugin_name; | ||
94 | }; | ||
95 | |||
96 | struct TestingSystemCount | ||
97 | { | ||
98 | unsigned int count; | ||
99 | |||
100 | struct NetJailState *ns; | ||
101 | }; | ||
102 | |||
103 | /** | ||
104 | * | ||
105 | * | ||
106 | * @param cls closure | ||
107 | * @param cmd current CMD being cleaned up. | ||
108 | */ | ||
109 | static void | ||
110 | netjail_exec_cleanup (void *cls, | ||
111 | const struct GNUNET_TESTING_Command *cmd) | ||
112 | { | ||
113 | struct NetJailState *ns = cls; | ||
114 | |||
115 | GNUNET_free (ns->binary_name); | ||
116 | } | ||
117 | |||
118 | |||
119 | /** | ||
120 | * | ||
121 | * | ||
122 | * @param cls closure. | ||
123 | * @param[out] ret result | ||
124 | * @param trait name of the trait. | ||
125 | * @param index index number of the object to offer. | ||
126 | * @return #GNUNET_OK on success. | ||
127 | */ | ||
128 | static int | ||
129 | netjail_exec_traits (void *cls, | ||
130 | const void **ret, | ||
131 | const char *trait, | ||
132 | unsigned int index) | ||
133 | { | ||
134 | struct NetJailState *ns = cls; | ||
135 | struct GNUNET_HELPER_Handle **helper = ns->helper; | ||
136 | struct HelperMessage *hp_messages_head = ns->hp_messages_head; | ||
137 | |||
138 | |||
139 | struct GNUNET_TESTING_Trait traits[] = { | ||
140 | { | ||
141 | .index = 0, | ||
142 | .trait_name = "helper_handles", | ||
143 | .ptr = (const void *) helper, | ||
144 | }, | ||
145 | { | ||
146 | .index = 1, | ||
147 | .trait_name = "hp_msgs_head", | ||
148 | .ptr = (const void *) hp_messages_head, | ||
149 | }, | ||
150 | GNUNET_TESTING_trait_end () | ||
151 | }; | ||
152 | |||
153 | return GNUNET_TESTING_get_trait (traits, | ||
154 | ret, | ||
155 | trait, | ||
156 | index); | ||
157 | } | ||
158 | |||
159 | |||
160 | /** | ||
161 | * Offer handles to testing cmd helper from trait | ||
162 | * | ||
163 | * @param cmd command to extract the message from. | ||
164 | * @param pt pointer to message. | ||
165 | * @return #GNUNET_OK on success. | ||
166 | */ | ||
167 | int | ||
168 | GNUNET_TESTING_get_trait_helper_handles (const struct | ||
169 | GNUNET_TESTING_Command *cmd, | ||
170 | struct GNUNET_HELPER_Handle ***helper) | ||
171 | { | ||
172 | return cmd->traits (cmd->cls, | ||
173 | (const void **) helper, | ||
174 | "helper_handles", | ||
175 | (unsigned int) 0); | ||
176 | } | ||
177 | |||
178 | /** | ||
179 | * Offer messages received via testing cmd helper from trait | ||
180 | * | ||
181 | * @param cmd command to extract the message from. | ||
182 | * @param pt pointer to message. | ||
183 | * @return #GNUNET_OK on success. | ||
184 | */ | ||
185 | int | ||
186 | GNUNET_TESTING_get_trait_helper_messages (const struct | ||
187 | GNUNET_TESTING_Command *cmd, | ||
188 | struct HelperMessage *** | ||
189 | hp_messages_head) | ||
190 | { | ||
191 | return cmd->traits (cmd->cls, | ||
192 | (const void **) hp_messages_head, | ||
193 | "hp_msgs_head", | ||
194 | (unsigned int) 1); | ||
195 | } | ||
196 | |||
197 | |||
198 | /** | ||
199 | * Continuation function from GNUNET_HELPER_send() | ||
200 | * | ||
201 | * @param cls closure | ||
202 | * @param result GNUNET_OK on success, | ||
203 | * GNUNET_NO if helper process died | ||
204 | * GNUNET_SYSERR during GNUNET_HELPER_stop | ||
205 | */ | ||
206 | static void | ||
207 | clear_msg (void *cls, int result) | ||
208 | { | ||
209 | struct TestingSystemCount *tbc = cls; | ||
210 | struct NetJailState *ns = tbc->ns; | ||
211 | |||
212 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
213 | "clear_msg tbc->count: %d\n", | ||
214 | tbc->count); | ||
215 | GNUNET_assert (NULL != ns->shandle[tbc->count - 1]); | ||
216 | ns->shandle[tbc->count - 1] = NULL; | ||
217 | GNUNET_free (ns->msg[tbc->count - 1]); | ||
218 | ns->msg[tbc->count - 1] = NULL; | ||
219 | } | ||
220 | |||
221 | |||
222 | /** | ||
223 | * Functions with this signature are called whenever a | ||
224 | * complete message is received by the tokenizer. | ||
225 | * | ||
226 | * Do not call GNUNET_SERVER_mst_destroy in callback | ||
227 | * | ||
228 | * @param cls closure | ||
229 | * @param client identification of the client | ||
230 | * @param message the actual message | ||
231 | * | ||
232 | * @return #GNUNET_OK on success, #GNUNET_SYSERR to stop further processing | ||
233 | */ | ||
234 | static int | ||
235 | helper_mst (void *cls, const struct GNUNET_MessageHeader *message) | ||
236 | { | ||
237 | struct TestingSystemCount *tbc = cls; | ||
238 | struct NetJailState *ns = tbc->ns; | ||
239 | struct HelperMessage *hp_msg; | ||
240 | |||
241 | if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_REPLY == ntohs (message->type)) | ||
242 | { | ||
243 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
244 | "helper_mst tbc->count: %d\n", | ||
245 | tbc->count); | ||
246 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
247 | "Received message from helper.\n"); | ||
248 | ns->number_of_testsystems_started++; | ||
249 | } | ||
250 | else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_PEER_STARTED == ntohs ( | ||
251 | message->type)) | ||
252 | { | ||
253 | ns->number_of_peers_started++; | ||
254 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
255 | "number_of_peers_started: %d\n", | ||
256 | ns->number_of_peers_started); | ||
257 | } | ||
258 | else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED == ntohs ( | ||
259 | message->type)) | ||
260 | { | ||
261 | ns->number_of_local_test_finished++; | ||
262 | } | ||
263 | else | ||
264 | { | ||
265 | hp_msg = GNUNET_new (struct HelperMessage); | ||
266 | hp_msg->bytes_msg = message->size; | ||
267 | memcpy (&hp_msg[1], message, message->size); | ||
268 | GNUNET_CONTAINER_DLL_insert (ns->hp_messages_head, ns->hp_messages_tail, | ||
269 | hp_msg); | ||
270 | } | ||
271 | |||
272 | return GNUNET_OK; | ||
273 | } | ||
274 | |||
275 | |||
276 | static void | ||
277 | exp_cb (void *cls) | ||
278 | { | ||
279 | struct NetJailState *ns = cls; | ||
280 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Called exp_cb.\n"); | ||
281 | *ns->rv = 1; | ||
282 | } | ||
283 | |||
284 | |||
285 | static struct GNUNET_CMDS_HelperInit * | ||
286 | create_helper_init_msg_ (char *m_char, | ||
287 | char *n_char, | ||
288 | const char *plugin_name) | ||
289 | { | ||
290 | struct GNUNET_CMDS_HelperInit *msg; | ||
291 | uint16_t plugin_name_len; | ||
292 | uint16_t msg_size; | ||
293 | |||
294 | GNUNET_assert (NULL != plugin_name); | ||
295 | plugin_name_len = strlen (plugin_name); | ||
296 | msg_size = sizeof(struct GNUNET_CMDS_HelperInit) + plugin_name_len; | ||
297 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
298 | "msg_size: %d \n", | ||
299 | msg_size); | ||
300 | msg = GNUNET_malloc (msg_size); | ||
301 | msg->header.size = htons (msg_size); | ||
302 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_INIT); | ||
303 | msg->plugin_name_size = htons (plugin_name_len); | ||
304 | GNUNET_memcpy ((char *) &msg[1], | ||
305 | plugin_name, | ||
306 | plugin_name_len); | ||
307 | return msg; | ||
308 | } | ||
309 | |||
310 | |||
311 | static void | ||
312 | start_helper (struct NetJailState *ns, struct | ||
313 | GNUNET_CONFIGURATION_Handle *config, | ||
314 | char *m_char, | ||
315 | char *n_char) | ||
316 | { | ||
317 | // struct GNUNET_CONFIGURATION_Handle *cfg; | ||
318 | struct GNUNET_CMDS_HelperInit *msg; | ||
319 | struct TestingSystemCount *tbc; | ||
320 | char *const script_argv[] = {NETJAIL_EXEC_SCRIPT, | ||
321 | m_char, | ||
322 | n_char, | ||
323 | GNUNET_OS_get_libexec_binary_path ( | ||
324 | HELPER_CMDS_BINARY), | ||
325 | ns->global_n, | ||
326 | ns->local_m, | ||
327 | NULL}; | ||
328 | unsigned int m = atoi (m_char); | ||
329 | unsigned int n = atoi (n_char); | ||
330 | unsigned int helper_check = GNUNET_OS_check_helper_binary ( | ||
331 | NETJAIL_EXEC_SCRIPT, | ||
332 | GNUNET_YES, | ||
333 | NULL); | ||
334 | |||
335 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
336 | "m: %d n: %d\n", | ||
337 | m, | ||
338 | n); | ||
339 | |||
340 | tbc = GNUNET_new (struct TestingSystemCount); | ||
341 | tbc->ns = ns; | ||
342 | tbc->count = (n - 1) * atoi (ns->local_m) + m; | ||
343 | |||
344 | |||
345 | if (GNUNET_NO == helper_check) | ||
346 | { | ||
347 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
348 | "No SUID for %s!\n", | ||
349 | NETJAIL_EXEC_SCRIPT); | ||
350 | *ns->rv = 1; | ||
351 | } | ||
352 | else if (GNUNET_NO == helper_check) | ||
353 | { | ||
354 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
355 | "%s not found!\n", | ||
356 | NETJAIL_EXEC_SCRIPT); | ||
357 | *ns->rv = 1; | ||
358 | } | ||
359 | |||
360 | GNUNET_array_append (ns->helper, ns->n_helper, GNUNET_HELPER_start ( | ||
361 | GNUNET_YES, | ||
362 | NETJAIL_EXEC_SCRIPT, | ||
363 | script_argv, | ||
364 | &helper_mst, | ||
365 | &exp_cb, | ||
366 | tbc)); | ||
367 | |||
368 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
369 | "First using helper %d %d\n", | ||
370 | tbc->count - 1, | ||
371 | ns->n_helper); | ||
372 | struct GNUNET_HELPER_Handle *helper = ns->helper[tbc->count - 1]; | ||
373 | |||
374 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
375 | "First using helper %d %d %p\n", | ||
376 | tbc->count - 1, | ||
377 | ns->n_helper, | ||
378 | helper); | ||
379 | |||
380 | msg = create_helper_init_msg_ (m_char, | ||
381 | n_char, | ||
382 | ns->plugin_name); | ||
383 | GNUNET_array_append (ns->msg, ns->n_msg, &msg->header); | ||
384 | |||
385 | GNUNET_array_append (ns->shandle, ns->n_shandle, GNUNET_HELPER_send ( | ||
386 | helper, | ||
387 | &msg->header, | ||
388 | GNUNET_NO, | ||
389 | &clear_msg, | ||
390 | tbc)); | ||
391 | |||
392 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
393 | "Message %d send!\n", | ||
394 | tbc->count); | ||
395 | |||
396 | if (NULL == ns->shandle[tbc->count - 1]) | ||
397 | { | ||
398 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
399 | "Send handle is NULL!\n"); | ||
400 | GNUNET_free (msg); | ||
401 | *ns->rv = 1; | ||
402 | } | ||
403 | } | ||
404 | |||
405 | |||
406 | /** | ||
407 | * Run the "hello world" CMD. | ||
408 | * | ||
409 | * @param cls closure. | ||
410 | * @param cmd CMD being run. | ||
411 | * @param is interpreter state. | ||
412 | */ | ||
413 | static void | ||
414 | netjail_exec_run (void *cls, | ||
415 | const struct GNUNET_TESTING_Command *cmd, | ||
416 | struct GNUNET_TESTING_Interpreter *is) | ||
417 | { | ||
418 | char str_m[12]; | ||
419 | char str_n[12]; | ||
420 | struct NetJailState *ns = cls; | ||
421 | struct GNUNET_CONFIGURATION_Handle *config = | ||
422 | GNUNET_CONFIGURATION_create (); | ||
423 | |||
424 | for (int i = 1; i <= atoi (ns->global_n); i++) { | ||
425 | for (int j = 1; j <= atoi (ns->local_m); j++) | ||
426 | { | ||
427 | sprintf (str_n, "%d", i); | ||
428 | sprintf (str_m, "%d", j); | ||
429 | start_helper (ns, config, | ||
430 | str_m, | ||
431 | str_n); | ||
432 | } | ||
433 | } | ||
434 | } | ||
435 | |||
436 | |||
437 | static int | ||
438 | netjail_start_finish (void *cls, | ||
439 | GNUNET_SCHEDULER_TaskCallback cont, | ||
440 | void *cont_cls) | ||
441 | { | ||
442 | unsigned int ret = GNUNET_NO; | ||
443 | struct NetJailState *ns = cls; | ||
444 | unsigned int total_number = atoi (ns->local_m) * atoi (ns->global_n); | ||
445 | struct GNUNET_CMDS_ALL_PEERS_STARTED *reply; | ||
446 | size_t msg_length; | ||
447 | struct GNUNET_HELPER_Handle *helper; | ||
448 | struct TestingSystemCount *tbc; | ||
449 | |||
450 | if (ns->number_of_local_test_finished == total_number) | ||
451 | { | ||
452 | ret = GNUNET_YES; | ||
453 | cont (cont_cls); | ||
454 | } | ||
455 | |||
456 | if (ns->number_of_testsystems_started == total_number) | ||
457 | { | ||
458 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
459 | "All helpers started!\n"); | ||
460 | ns->number_of_testsystems_started = 0; | ||
461 | } | ||
462 | |||
463 | if (ns->number_of_peers_started == total_number) | ||
464 | { | ||
465 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
466 | "All peers started!\n"); | ||
467 | |||
468 | for (int i = 1; i <= atoi (ns->global_n); i++) { | ||
469 | for (int j = 1; j <= atoi (ns->local_m); j++) | ||
470 | { | ||
471 | tbc = GNUNET_new (struct TestingSystemCount); | ||
472 | tbc->ns = ns; | ||
473 | // TODO This needs to be more generic. As we send more messages back and forth, we can not grow the arrays again and again, because this is to error prone. | ||
474 | tbc->count = (i - 1) * atoi (ns->local_m) + j + total_number; | ||
475 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
476 | "Second using helper %d %d %d\n", | ||
477 | tbc->count - 1 - total_number, | ||
478 | i, | ||
479 | j); | ||
480 | helper = ns->helper[tbc->count - 1 - total_number]; | ||
481 | msg_length = sizeof(struct GNUNET_CMDS_ALL_PEERS_STARTED); | ||
482 | reply = GNUNET_new (struct GNUNET_CMDS_ALL_PEERS_STARTED); | ||
483 | reply->header.type = htons ( | ||
484 | GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_PEERS_STARTED); | ||
485 | reply->header.size = htons ((uint16_t) msg_length); | ||
486 | |||
487 | GNUNET_array_append (ns->msg, ns->n_msg, &reply->header); | ||
488 | |||
489 | struct GNUNET_HELPER_SendHandle *sh = GNUNET_HELPER_send ( | ||
490 | helper, | ||
491 | &reply->header, | ||
492 | GNUNET_NO, | ||
493 | &clear_msg, | ||
494 | tbc); | ||
495 | |||
496 | GNUNET_array_append (ns->shandle, ns->n_shandle, sh); | ||
497 | |||
498 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
499 | "All peers started message %d send!\n", | ||
500 | tbc->count); | ||
501 | } | ||
502 | } | ||
503 | ns->number_of_peers_started = 0; | ||
504 | } | ||
505 | return ret; | ||
506 | } | ||
507 | |||
508 | |||
509 | /** | ||
510 | * Create command. | ||
511 | * | ||
512 | * @param label name for command. | ||
513 | * @param binaryname to exec. | ||
514 | * @return command. | ||
515 | */ | ||
516 | struct GNUNET_TESTING_Command | ||
517 | GNUNET_TESTING_cmd_netjail_start_testing_system (const char *label, | ||
518 | char *local_m, | ||
519 | char *global_n, | ||
520 | char *plugin_name, | ||
521 | unsigned int *rv) | ||
522 | { | ||
523 | struct NetJailState *ns; | ||
524 | |||
525 | ns = GNUNET_new (struct NetJailState); | ||
526 | ns->local_m = local_m; | ||
527 | ns->global_n = global_n; | ||
528 | ns->plugin_name = plugin_name; | ||
529 | ns->rv = rv; | ||
530 | |||
531 | struct GNUNET_TESTING_Command cmd = { | ||
532 | .cls = ns, | ||
533 | .label = label, | ||
534 | .run = &netjail_exec_run, | ||
535 | .finish = &netjail_start_finish, | ||
536 | .cleanup = &netjail_exec_cleanup, | ||
537 | .traits = &netjail_exec_traits | ||
538 | }; | ||
539 | |||
540 | return cmd; | ||
541 | } | ||
diff --git a/src/testbed/testbed_api_cmd_netjail_stop.c b/src/testing/testing_api_cmd_netjail_stop.c index f837ec08c..710b4fbf4 100644 --- a/src/testbed/testbed_api_cmd_netjail_stop.c +++ b/src/testing/testing_api_cmd_netjail_stop.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include "platform.h" | 26 | #include "platform.h" |
27 | #include "gnunet_util_lib.h" | 27 | #include "gnunet_util_lib.h" |
28 | #include "gnunet_testing_ng_lib.h" | 28 | #include "gnunet_testing_ng_lib.h" |
29 | #include "gnunet_testbed_ng_service.h" | ||
30 | 29 | ||
31 | 30 | ||
32 | #define NETJAIL_STOP_SCRIPT "./../testing/netjail_stop.sh" | 31 | #define NETJAIL_STOP_SCRIPT "./../testing/netjail_stop.sh" |
diff --git a/src/testbed/testbed_api_cmd_netjail_stop_testbed.c b/src/testing/testing_api_cmd_netjail_stop_testsystem.c index c74c1e94f..bed9f3ebf 100644 --- a/src/testbed/testbed_api_cmd_netjail_stop_testbed.c +++ b/src/testing/testing_api_cmd_netjail_stop_testsystem.c | |||
@@ -25,9 +25,7 @@ | |||
25 | */ | 25 | */ |
26 | #include "platform.h" | 26 | #include "platform.h" |
27 | #include "gnunet_testing_ng_lib.h" | 27 | #include "gnunet_testing_ng_lib.h" |
28 | #include "gnunet_testbed_ng_service.h" | 28 | #include "testing_cmds.h" |
29 | #include "testbed_api.h" | ||
30 | #include "testbed_api_hosts.h" | ||
31 | 29 | ||
32 | 30 | ||
33 | struct StopHelperState | 31 | struct StopHelperState |
diff --git a/src/testing/testing_api_cmd_send_peer_ready.c b/src/testing/testing_api_cmd_send_peer_ready.c index e5e004924..afe28de77 100644 --- a/src/testing/testing_api_cmd_send_peer_ready.c +++ b/src/testing/testing_api_cmd_send_peer_ready.c | |||
@@ -26,8 +26,7 @@ | |||
26 | #include "platform.h" | 26 | #include "platform.h" |
27 | #include "gnunet_util_lib.h" | 27 | #include "gnunet_util_lib.h" |
28 | #include "gnunet_testing_ng_lib.h" | 28 | #include "gnunet_testing_ng_lib.h" |
29 | #include "testbed_api.h" | 29 | #include "testing_cmds.h" |
30 | #include "testbed_helper.h" | ||
31 | 30 | ||
32 | 31 | ||
33 | struct SendPeerReadyState | 32 | struct SendPeerReadyState |
@@ -68,7 +67,7 @@ send_peer_ready_run (void *cls, | |||
68 | struct GNUNET_CMDS_PEER_STARTED *reply; | 67 | struct GNUNET_CMDS_PEER_STARTED *reply; |
69 | size_t msg_length; | 68 | size_t msg_length; |
70 | 69 | ||
71 | msg_length = sizeof(struct GNUNET_CMDS_HelperInit);// GNUNET_CMDS_PEER_STARTED); | 70 | msg_length = sizeof(struct GNUNET_CMDS_PEER_STARTED); |
72 | reply = GNUNET_new (struct GNUNET_CMDS_PEER_STARTED); | 71 | reply = GNUNET_new (struct GNUNET_CMDS_PEER_STARTED); |
73 | reply->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_PEER_STARTED); | 72 | reply->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_PEER_STARTED); |
74 | reply->header.size = htons ((uint16_t) msg_length); | 73 | reply->header.size = htons ((uint16_t) msg_length); |
diff --git a/src/testing/testing_cmds.h b/src/testing/testing_cmds.h new file mode 100644 index 000000000..7a5860aea --- /dev/null +++ b/src/testing/testing_cmds.h | |||
@@ -0,0 +1,90 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2021 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 testing/testing_cmds.h | ||
23 | * @brief Message formats for communication between testing cmds helper and testcase plugins. | ||
24 | * @author t3sserakt | ||
25 | */ | ||
26 | |||
27 | #ifndef TESTING_CMDS_H | ||
28 | #define TESTING_CMDS_H | ||
29 | |||
30 | #define HELPER_CMDS_BINARY "gnunet-cmds-helper" | ||
31 | |||
32 | GNUNET_NETWORK_STRUCT_BEGIN | ||
33 | |||
34 | /** | ||
35 | * Initialization message for gnunet-cmds-testbed to start cmd binary. | ||
36 | */ | ||
37 | struct GNUNET_CMDS_HelperInit | ||
38 | { | ||
39 | /** | ||
40 | * Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_INIT | ||
41 | */ | ||
42 | struct GNUNET_MessageHeader header; | ||
43 | |||
44 | /** | ||
45 | * | ||
46 | */ | ||
47 | uint16_t plugin_name_size GNUNET_PACKED; | ||
48 | |||
49 | /* Followed by plugin name of the plugin running the test case. This is not NULL | ||
50 | * terminated */ | ||
51 | }; | ||
52 | |||
53 | /** | ||
54 | * Reply message from cmds helper process | ||
55 | */ | ||
56 | struct GNUNET_CMDS_HelperReply | ||
57 | { | ||
58 | /** | ||
59 | * Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_REPLY | ||
60 | */ | ||
61 | struct GNUNET_MessageHeader header; | ||
62 | }; | ||
63 | |||
64 | struct GNUNET_CMDS_PEER_STARTED | ||
65 | { | ||
66 | /** | ||
67 | * Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_PEER_STARTED | ||
68 | */ | ||
69 | struct GNUNET_MessageHeader header; | ||
70 | }; | ||
71 | |||
72 | struct GNUNET_CMDS_ALL_PEERS_STARTED | ||
73 | { | ||
74 | /** | ||
75 | * Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_PEERS_STARTED | ||
76 | */ | ||
77 | struct GNUNET_MessageHeader header; | ||
78 | }; | ||
79 | |||
80 | struct GNUNET_CMDS_LOCAL_FINISHED | ||
81 | { | ||
82 | /** | ||
83 | * Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED | ||
84 | */ | ||
85 | struct GNUNET_MessageHeader header; | ||
86 | }; | ||
87 | |||
88 | GNUNET_NETWORK_STRUCT_END | ||
89 | #endif | ||
90 | /* end of testing_cmds.h */ | ||
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am index 0782a631b..0696188c5 100644 --- a/src/transport/Makefile.am +++ b/src/transport/Makefile.am | |||
@@ -398,20 +398,19 @@ plugin_LTLIBRARIES = \ | |||
398 | $(HTTP_SERVER_PLUGIN_LA) \ | 398 | $(HTTP_SERVER_PLUGIN_LA) \ |
399 | $(HTTPS_SERVER_PLUGIN_LA) \ | 399 | $(HTTPS_SERVER_PLUGIN_LA) \ |
400 | $(WLAN_PLUGIN_LA) \ | 400 | $(WLAN_PLUGIN_LA) \ |
401 | $(BT_PLUGIN_LA) | 401 | $(BT_PLUGIN_LA) \ |
402 | # libgnunet_plugin_cmd_simple_send.la | 402 | libgnunet_test_transport_plugin_cmd_simple_send.la |
403 | 403 | ||
404 | #libgnunet_plugin_cmd_simple_send_la_SOURCES = \ | 404 | libgnunet_test_transport_plugin_cmd_simple_send_la_SOURCES = \ |
405 | # plugin_cmd_simple_send.c | 405 | test_transport_plugin_cmd_simple_send.c |
406 | #libgnunet_plugin_cmd_simple_send_la_LIBADD = \ | 406 | libgnunet_test_transport_plugin_cmd_simple_send_la_LIBADD = \ |
407 | # $(top_builddir)/src/util/libgnunetutil.la \ | 407 | $(top_builddir)/src/util/libgnunetutil.la \ |
408 | # $(top_builddir)/src/testing/libgnunettesting.la \ | 408 | $(top_builddir)/src/testing/libgnunettesting.la \ |
409 | # $(top_builddir)/src/statistics/libgnunetstatistics.la \ | 409 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ |
410 | # $(top_builddir)/src/testbed/libgnunettestbed.la \ | 410 | libgnunettransporttesting2.la \ |
411 | # libgnunettransporttesting2.la \ | 411 | $(LTLIBINTL) |
412 | # $(LTLIBINTL) | 412 | libgnunet_test_transport_plugin_cmd_simple_send_la_LDFLAGS = \ |
413 | #libgnunet_plugin_cmd_simple_send_la_LDFLAGS = \ | 413 | $(GN_PLUGIN_LDFLAGS) |
414 | # $(GN_PLUGIN_LDFLAGS) | ||
415 | 414 | ||
416 | if HAVE_EXPERIMENTAL | 415 | if HAVE_EXPERIMENTAL |
417 | plugin_LTLIBRARIES += libgnunet_plugin_transport_udp.la | 416 | plugin_LTLIBRARIES += libgnunet_plugin_transport_udp.la |
diff --git a/src/transport/test_transport_api_cmd_simple_send.c b/src/transport/test_transport_api_cmd_simple_send.c index 1cc16f307..13497366e 100644 --- a/src/transport/test_transport_api_cmd_simple_send.c +++ b/src/transport/test_transport_api_cmd_simple_send.c | |||
@@ -25,7 +25,6 @@ | |||
25 | */ | 25 | */ |
26 | #include "platform.h" | 26 | #include "platform.h" |
27 | #include "gnunet_testing_ng_lib.h" | 27 | #include "gnunet_testing_ng_lib.h" |
28 | #include "gnunet_testbed_ng_service.h" | ||
29 | #include "gnunet_util_lib.h" | 28 | #include "gnunet_util_lib.h" |
30 | 29 | ||
31 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120) | 30 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120) |
@@ -49,7 +48,7 @@ run (void *cls) | |||
49 | GNUNET_TESTING_cmd_netjail_start_testing_system ("netjail-start-testbed-1", | 48 | GNUNET_TESTING_cmd_netjail_start_testing_system ("netjail-start-testbed-1", |
50 | "2", | 49 | "2", |
51 | "1", | 50 | "1", |
52 | "libgnunet_plugin_cmd_simple_send", | 51 | "libgnunet_test_transport_plugin_cmd_simple_send", |
53 | &rv), | 52 | &rv), |
54 | GNUNET_TESTING_cmd_stop_testing_system ("stop-testbed", | 53 | GNUNET_TESTING_cmd_stop_testing_system ("stop-testbed", |
55 | "netjail-start-testbed-1", | 54 | "netjail-start-testbed-1", |
diff --git a/src/transport/plugin_cmd_simple_send.c b/src/transport/test_transport_plugin_cmd_simple_send.c index 468f4e48a..c4f7fcfe3 100644 --- a/src/transport/plugin_cmd_simple_send.c +++ b/src/transport/test_transport_plugin_cmd_simple_send.c | |||
@@ -1,19 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | Copyright (C) 2013, 2014 GNUnet e.V. | 3 | Copyright (C) 2021 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 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 | 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, | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | or (at your option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 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/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
@@ -27,8 +27,6 @@ | |||
27 | #include "gnunet_testing_ng_lib.h" | 27 | #include "gnunet_testing_ng_lib.h" |
28 | #include "gnunet_util_lib.h" | 28 | #include "gnunet_util_lib.h" |
29 | #include "gnunet_transport_application_service.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" | 30 | #include "transport-testing2.h" |
33 | #include "transport-testing-cmds.h" | 31 | #include "transport-testing-cmds.h" |
34 | 32 | ||
@@ -166,7 +164,7 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip, | |||
166 | * @return the exported block API | 164 | * @return the exported block API |
167 | */ | 165 | */ |
168 | void * | 166 | void * |
169 | libgnunet_plugin_cmd_simple_send_init (void *cls) | 167 | libgnunet_test_transport_plugin_cmd_simple_send_init (void *cls) |
170 | { | 168 | { |
171 | struct GNUNET_TESTING_PluginFunctions *api; | 169 | struct GNUNET_TESTING_PluginFunctions *api; |
172 | 170 | ||
@@ -180,11 +178,11 @@ libgnunet_plugin_cmd_simple_send_init (void *cls) | |||
180 | /** | 178 | /** |
181 | * Exit point from the plugin. | 179 | * Exit point from the plugin. |
182 | * | 180 | * |
183 | * @param cls the return value from #libgnunet_plugin_block_test_init | 181 | * @param cls the return value from #libgnunet_test_transport_plugin_block_test_init |
184 | * @return NULL | 182 | * @return NULL |
185 | */ | 183 | */ |
186 | void * | 184 | void * |
187 | libgnunet_plugin_cmd_simple_send_done (void *cls) | 185 | libgnunet_test_transport_plugin_cmd_simple_send_done (void *cls) |
188 | { | 186 | { |
189 | struct GNUNET_TESTING_PluginFunctions *api = cls; | 187 | struct GNUNET_TESTING_PluginFunctions *api = cls; |
190 | 188 | ||