aboutsummaryrefslogtreecommitdiff
path: root/src/testing/testing_api_cmd_netjail_stop_testsystem.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/testing_api_cmd_netjail_stop_testsystem.c')
-rw-r--r--src/testing/testing_api_cmd_netjail_stop_testsystem.c79
1 files changed, 50 insertions, 29 deletions
diff --git a/src/testing/testing_api_cmd_netjail_stop_testsystem.c b/src/testing/testing_api_cmd_netjail_stop_testsystem.c
index 04b0e4e94..d3754153d 100644
--- a/src/testing/testing_api_cmd_netjail_stop_testsystem.c
+++ b/src/testing/testing_api_cmd_netjail_stop_testsystem.c
@@ -42,9 +42,15 @@ struct StopHelperState
42 */ 42 */
43 struct GNUNET_HELPER_Handle **helper; 43 struct GNUNET_HELPER_Handle **helper;
44 44
45 char *local_m; 45 unsigned int local_m;
46 46
47 char *global_n; 47 unsigned int global_n;
48
49 /**
50 * Number of global known nodes.
51 *
52 */
53 unsigned int known;
48}; 54};
49 55
50 56
@@ -57,6 +63,7 @@ struct StopHelperState
57static void 63static void
58stop_testing_system_cleanup (void *cls) 64stop_testing_system_cleanup (void *cls)
59{ 65{
66
60} 67}
61 68
62 69
@@ -64,13 +71,13 @@ stop_testing_system_cleanup (void *cls)
64 * Trait function of this cmd does nothing. 71 * Trait function of this cmd does nothing.
65 * 72 *
66 */ 73 */
67static enum GNUNET_GenericReturnValue 74static int
68stop_testing_system_traits (void *cls, 75stop_testing_system_traits (void *cls,
69 const void **ret, 76 const void **ret,
70 const char *trait, 77 const char *trait,
71 unsigned int index) 78 unsigned int index)
72{ 79{
73 return GNUNET_NO; 80 return GNUNET_OK;
74} 81}
75 82
76 83
@@ -88,17 +95,30 @@ stop_testing_system_run (void *cls,
88 struct GNUNET_HELPER_Handle **helper; 95 struct GNUNET_HELPER_Handle **helper;
89 const struct GNUNET_TESTING_Command *start_helper_cmd; 96 const struct GNUNET_TESTING_Command *start_helper_cmd;
90 97
91 start_helper_cmd = GNUNET_TESTING_interpreter_lookup_command ( 98 start_helper_cmd = GNUNET_TESTING_interpreter_lookup_command (NULL,
92 is, 99 shs->
93 shs->helper_start_label); 100 helper_start_label);
94 GNUNET_TESTING_get_trait_helper_handles (start_helper_cmd, 101 GNUNET_TESTING_get_trait_helper_handles (start_helper_cmd,
95 &helper); 102 &helper);
96 103
97 for (int i = 1; i <= atoi (shs->global_n); i++) 104 for (int i = 1; i <= shs->known; i++)
105 {
106 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
107 "i: %u\n",
108 i);
109 GNUNET_HELPER_stop (helper[i - 1],
110 GNUNET_YES);
111 }
112
113 for (int i = 1; i <= shs->global_n; i++)
98 { 114 {
99 for (int j = 1; j <= atoi (shs->local_m); j++) 115 for (int j = 1; j <= shs->local_m; j++)
100 { 116 {
101 GNUNET_HELPER_stop (helper[(i - 1) * atoi (shs->local_m) + j - 1], 117 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
118 "i: %u j: %u\n",
119 i,
120 j);
121 GNUNET_HELPER_stop (helper[(i - 1) * shs->local_m + j + shs->known - 1],
102 GNUNET_YES); 122 GNUNET_YES);
103 } 123 }
104 } 124 }
@@ -107,34 +127,35 @@ stop_testing_system_run (void *cls,
107 127
108/** 128/**
109 * Create command. 129 * Create command.
110 * @param helper_start_label label of the cmd to start the test system. 130 *
111 * @param label name for command. 131 * @param label name for command.
112 * @param . 132 * @param helper_start_label label of the cmd to start the test system.
113 * @param local_m Number of nodes in a network namespace. //TODO make this a unsigned int 133 * @param topology_config Configuration file for the test topology.
114 * @param global_n Number of network namespaces. //TODO make this a unsigned int
115 * @return command. 134 * @return command.
116 */ 135 */
117struct GNUNET_TESTING_Command 136struct GNUNET_TESTING_Command
118GNUNET_TESTING_cmd_stop_testing_system (const char *label, 137GNUNET_TESTING_cmd_stop_testing_system (const char *label,
119 const char *helper_start_label, 138 const char *helper_start_label,
120 char *local_m, 139 const char *topology_config)
121 char *global_n)
122{ 140{
123 struct StopHelperState *shs; 141 struct StopHelperState *shs;
124 142
143 struct GNUNET_TESTING_NetjailTopology *topology =
144 GNUNET_TESTING_get_topo_from_file (topology_config);
145
125 shs = GNUNET_new (struct StopHelperState); 146 shs = GNUNET_new (struct StopHelperState);
126 shs->helper_start_label = helper_start_label; 147 shs->helper_start_label = helper_start_label;
127 shs->local_m = local_m; 148 shs->local_m = topology->nodes_m;
128 shs->global_n = global_n; 149 shs->global_n = topology->namespaces_n;
129 { 150 shs->known = topology->nodes_x;
130 struct GNUNET_TESTING_Command cmd = { 151
131 .cls = shs, 152 struct GNUNET_TESTING_Command cmd = {
132 .label = label, 153 .cls = shs,
133 .run = &stop_testing_system_run, 154 .label = label,
134 .cleanup = &stop_testing_system_cleanup, 155 .run = &stop_testing_system_run,
135 .traits = &stop_testing_system_traits 156 .cleanup = &stop_testing_system_cleanup,
136 }; 157 .traits = &stop_testing_system_traits
137 158 };
138 return cmd; 159
139 } 160 return cmd;
140} 161}