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.c76
1 files changed, 68 insertions, 8 deletions
diff --git a/src/transport/test_transport_start_with_config.c b/src/transport/test_transport_start_with_config.c
index 932b0e583..7eb92d629 100644
--- a/src/transport/test_transport_start_with_config.c
+++ b/src/transport/test_transport_start_with_config.c
@@ -25,6 +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_testing_netjail_lib.h"
28#include "gnunet_util_lib.h" 29#include "gnunet_util_lib.h"
29 30
30#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120) 31#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120)
@@ -34,27 +35,86 @@ int
34main (int argc, 35main (int argc,
35 char *const *argv) 36 char *const *argv)
36{ 37{
37 char *topology_config; 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;
38 47
39 GNUNET_log_setup ("test-netjail", 48 GNUNET_log_setup ("test-netjail",
40 "DEBUG", 49 "DEBUG",
41 NULL); 50 NULL);
42 51
43 topology_config = argv[1]; 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 }
44 91
45 struct GNUNET_TESTING_Command commands[] = { 92 struct GNUNET_TESTING_Command commands[] = {
46 GNUNET_TESTING_cmd_netjail_start ("netjail-start", 93 GNUNET_TESTING_cmd_netjail_start ("netjail-start",
47 topology_config), 94 topology_data_script,
95 &read_file),
48 GNUNET_TESTING_cmd_netjail_start_testing_system ("netjail-start-testbed", 96 GNUNET_TESTING_cmd_netjail_start_testing_system ("netjail-start-testbed",
49 topology_config), 97 topology,
98 &read_file,
99 topology_data_script),
50 GNUNET_TESTING_cmd_stop_testing_system ("stop-testbed", 100 GNUNET_TESTING_cmd_stop_testing_system ("stop-testbed",
51 "netjail-start-testbed", 101 "netjail-start-testbed",
52 topology_config), 102 topology),
53 GNUNET_TESTING_cmd_netjail_stop ("netjail-stop", 103 GNUNET_TESTING_cmd_netjail_stop ("netjail-stop",
54 topology_config), 104 topology_data_script,
105 &read_file),
55 GNUNET_TESTING_cmd_end () 106 GNUNET_TESTING_cmd_end ()
56 }; 107 };
57 108
58 return GNUNET_TESTING_main (commands, 109 ret = GNUNET_TESTING_main (commands,
59 TIMEOUT); 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;
60} 120}