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