diff options
Diffstat (limited to 'src/transport/test_transport_start_with_config.c')
-rw-r--r-- | src/transport/test_transport_start_with_config.c | 122 |
1 files changed, 0 insertions, 122 deletions
diff --git a/src/transport/test_transport_start_with_config.c b/src/transport/test_transport_start_with_config.c deleted file mode 100644 index c4b6c55ad..000000000 --- a/src/transport/test_transport_start_with_config.c +++ /dev/null | |||
@@ -1,122 +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 transport/test_transport_start_with_config.c | ||
23 | * @brief Generic program to start testcases in an configurable topology. | ||
24 | * @author t3sserakt | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_testing_ng_lib.h" | ||
28 | #include "gnunet_testing_netjail_lib.h" | ||
29 | #include "transport-testing-cmds.h" | ||
30 | #include "gnunet_util_lib.h" | ||
31 | |||
32 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 600) | ||
33 | |||
34 | |||
35 | int | ||
36 | main (int argc, | ||
37 | char *const *argv) | ||
38 | { | ||
39 | char *topology_data; | ||
40 | char *topology_data_script; | ||
41 | struct GNUNET_TESTING_NetjailTopology *topology; | ||
42 | unsigned int read_file = GNUNET_YES; | ||
43 | int ret; | ||
44 | char *rest = NULL; | ||
45 | char *token; | ||
46 | size_t single_line_len; | ||
47 | size_t data_len; | ||
48 | |||
49 | GNUNET_log_setup ("test-netjail", | ||
50 | "DEBUG", | ||
51 | NULL); | ||
52 | |||
53 | if (0 == strcmp ("-s", argv[1])) | ||
54 | { | ||
55 | data_len = strlen (argv[2]); | ||
56 | topology_data = GNUNET_malloc (data_len); | ||
57 | topology_data_script = GNUNET_malloc (data_len); | ||
58 | token = strtok_r (argv[2], "\n", &rest); | ||
59 | while (NULL != token) | ||
60 | { | ||
61 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
62 | "token1 %s\n", | ||
63 | token); | ||
64 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
65 | "token2 %s\n", | ||
66 | token); | ||
67 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
68 | "topology_data %s\n", | ||
69 | topology_data); | ||
70 | strcat (topology_data_script, token); | ||
71 | strcat (topology_data_script, " "); | ||
72 | strcat (topology_data, token); | ||
73 | strcat (topology_data, "\n"); | ||
74 | token = strtok_r (NULL, "\n", &rest); | ||
75 | } | ||
76 | single_line_len = strlen (topology_data); | ||
77 | topology_data_script [single_line_len - 1] = '\0'; | ||
78 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
79 | "read from string\n"); | ||
80 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
81 | "topology_data %s\n", | ||
82 | topology_data); | ||
83 | read_file = GNUNET_NO; | ||
84 | topology = GNUNET_TESTING_get_topo_from_string (topology_data); | ||
85 | } | ||
86 | else | ||
87 | { | ||
88 | topology_data = argv[1]; | ||
89 | topology_data_script = argv[1]; | ||
90 | topology = GNUNET_TESTING_get_topo_from_file (topology_data); | ||
91 | } | ||
92 | |||
93 | struct GNUNET_TESTING_Command commands[] = { | ||
94 | GNUNET_TESTING_cmd_netjail_start ("netjail-start", | ||
95 | topology_data_script, | ||
96 | &read_file), | ||
97 | GNUNET_TESTING_cmd_netjail_start_cmds_helper ("netjail-start-testbed", | ||
98 | topology, | ||
99 | &read_file, | ||
100 | topology_data_script, | ||
101 | TIMEOUT), | ||
102 | GNUNET_TESTING_cmd_stop_cmds_helper ("stop-testbed", | ||
103 | "netjail-start-testbed", | ||
104 | topology), | ||
105 | GNUNET_TESTING_cmd_netjail_stop ("netjail-stop", | ||
106 | topology_data_script, | ||
107 | &read_file), | ||
108 | GNUNET_TESTING_cmd_end () | ||
109 | }; | ||
110 | |||
111 | ret = GNUNET_TESTING_main (commands, | ||
112 | TIMEOUT); | ||
113 | |||
114 | if (0 == strcmp ("-s", argv[1])) | ||
115 | { | ||
116 | GNUNET_free (topology_data_script); | ||
117 | GNUNET_free (topology_data); | ||
118 | } | ||
119 | GNUNET_TESTING_free_topology (topology); | ||
120 | |||
121 | return ret; | ||
122 | } | ||