diff options
author | Nathan S. Evans <evans@in.tum.de> | 2010-11-16 13:02:52 +0000 |
---|---|---|
committer | Nathan S. Evans <evans@in.tum.de> | 2010-11-16 13:02:52 +0000 |
commit | b0685d4301b6ddf5d95e5467add39a23b51aa5a1 (patch) | |
tree | a9808ba0b435e871f1b85ac4e7006895979e9d8b /src/testing/test_testing_group_remote.c | |
parent | 7f082ef1cd69b48984b05ae72f3c124493fdd86e (diff) | |
download | gnunet-b0685d4301b6ddf5d95e5467add39a23b51aa5a1.tar.gz gnunet-b0685d4301b6ddf5d95e5467add39a23b51aa5a1.zip |
Fix for testing where peer_start callback immediately calls peer_stop (also white space changes)
Diffstat (limited to 'src/testing/test_testing_group_remote.c')
-rw-r--r-- | src/testing/test_testing_group_remote.c | 133 |
1 files changed, 68 insertions, 65 deletions
diff --git a/src/testing/test_testing_group_remote.c b/src/testing/test_testing_group_remote.c index e0338f534..8547e4de5 100644 --- a/src/testing/test_testing_group_remote.c +++ b/src/testing/test_testing_group_remote.c | |||
@@ -50,14 +50,13 @@ static unsigned long long num_peers; | |||
50 | /** | 50 | /** |
51 | * Check whether peers successfully shut down. | 51 | * Check whether peers successfully shut down. |
52 | */ | 52 | */ |
53 | void shutdown_callback (void *cls, | 53 | void |
54 | const char *emsg) | 54 | shutdown_callback (void *cls, const char *emsg) |
55 | { | 55 | { |
56 | if (emsg != NULL) | 56 | if (emsg != NULL) |
57 | { | 57 | { |
58 | #if VERBOSE | 58 | #if VERBOSE |
59 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 59 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown of peers failed!\n"); |
60 | "Shutdown of peers failed!\n"); | ||
61 | #endif | 60 | #endif |
62 | if (ok == 0) | 61 | if (ok == 0) |
63 | ok = 666; | 62 | ok = 666; |
@@ -91,7 +90,8 @@ my_cb (void *cls, | |||
91 | } | 90 | } |
92 | else if (peers_failed == peers_left) | 91 | else if (peers_failed == peers_left) |
93 | { | 92 | { |
94 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Too many peers failed, ending test!\n"); | 93 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
94 | "Too many peers failed, ending test!\n"); | ||
95 | //GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); | 95 | //GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); |
96 | } | 96 | } |
97 | } | 97 | } |
@@ -121,7 +121,7 @@ run (void *cls, | |||
121 | &num_peers)) | 121 | &num_peers)) |
122 | num_peers = DEFAULT_NUM_PEERS; | 122 | num_peers = DEFAULT_NUM_PEERS; |
123 | 123 | ||
124 | GNUNET_assert(num_peers > 0 && num_peers < (unsigned long long)-1); | 124 | GNUNET_assert (num_peers > 0 && num_peers < (unsigned long long) -1); |
125 | if (GNUNET_OK != | 125 | if (GNUNET_OK != |
126 | GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "hostfile", | 126 | GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "hostfile", |
127 | &hostfile)) | 127 | &hostfile)) |
@@ -132,64 +132,72 @@ run (void *cls, | |||
132 | if (hostfile != NULL) | 132 | if (hostfile != NULL) |
133 | { | 133 | { |
134 | if (GNUNET_OK != GNUNET_DISK_file_test (hostfile)) | 134 | if (GNUNET_OK != GNUNET_DISK_file_test (hostfile)) |
135 | GNUNET_DISK_fn_write (hostfile, NULL, 0, GNUNET_DISK_PERM_USER_READ | 135 | GNUNET_DISK_fn_write (hostfile, NULL, 0, GNUNET_DISK_PERM_USER_READ |
136 | | GNUNET_DISK_PERM_USER_WRITE); | 136 | | GNUNET_DISK_PERM_USER_WRITE); |
137 | if ((0 != STAT (hostfile, &frstat)) || (frstat.st_size == 0)) | 137 | if ((0 != STAT (hostfile, &frstat)) || (frstat.st_size == 0)) |
138 | { | 138 | { |
139 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 139 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
140 | "Could not open file specified for host list, ending test!"); | 140 | "Could not open file specified for host list, ending test!"); |
141 | ok = 1119; | 141 | ok = 1119; |
142 | GNUNET_free(hostfile); | 142 | GNUNET_free (hostfile); |
143 | return; | ||
144 | } | ||
145 | |||
146 | data = GNUNET_malloc_large (frstat.st_size); | ||
147 | GNUNET_assert (data != NULL); | ||
148 | if (frstat.st_size != | ||
149 | GNUNET_DISK_fn_read (hostfile, data, frstat.st_size)) | ||
150 | { | ||
151 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
152 | "Could not read file %s specified for host list, ending test!", | ||
153 | hostfile); | ||
154 | GNUNET_free (hostfile); | ||
155 | GNUNET_free (data); | ||
143 | return; | 156 | return; |
144 | } | 157 | } |
145 | 158 | ||
146 | data = GNUNET_malloc_large (frstat.st_size); | 159 | GNUNET_free_non_null (hostfile); |
147 | GNUNET_assert(data != NULL); | 160 | |
148 | if (frstat.st_size != | 161 | buf = data; |
149 | GNUNET_DISK_fn_read (hostfile, data, frstat.st_size)) | 162 | count = 0; |
150 | { | 163 | while (count < frstat.st_size) |
151 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 164 | { |
152 | "Could not read file %s specified for host list, ending test!", hostfile); | 165 | count++; |
153 | GNUNET_free (hostfile); | 166 | if (count >= frstat.st_size) |
154 | GNUNET_free (data); | 167 | break; |
155 | return; | 168 | |
156 | } | 169 | /* if (((data[count] == '\n') || (data[count] == '\0')) && (buf != &data[count])) */ |
157 | 170 | if (((data[count] == '\n')) && (buf != &data[count])) | |
158 | GNUNET_free_non_null(hostfile); | 171 | { |
159 | 172 | data[count] = '\0'; | |
160 | buf = data; | 173 | temphost = GNUNET_malloc (sizeof (struct GNUNET_TESTING_Host)); |
161 | count = 0; | 174 | ret = |
162 | while (count < frstat.st_size) | 175 | sscanf (buf, "%a[a-zA-Z0-9]@%a[a-zA-Z0-9.]:%hd", |
163 | { | 176 | &temphost->username, &temphost->hostname, |
164 | count++; | 177 | &temphost->port); |
165 | if (count >= frstat.st_size) | 178 | if (3 == ret) |
166 | break; | 179 | { |
167 | 180 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | |
168 | /* if (((data[count] == '\n') || (data[count] == '\0')) && (buf != &data[count]))*/ | 181 | "Successfully read host %s, port %d and user %s from file\n", |
169 | if (((data[count] == '\n')) && (buf != &data[count])) | 182 | temphost->hostname, temphost->port, |
170 | { | 183 | temphost->username); |
171 | data[count] = '\0'; | 184 | } |
172 | temphost = GNUNET_malloc(sizeof(struct GNUNET_TESTING_Host)); | 185 | else |
173 | ret = sscanf(buf, "%a[a-zA-Z0-9]@%a[a-zA-Z0-9.]:%hd", &temphost->username, &temphost->hostname, &temphost->port); | 186 | { |
174 | if (3 == ret) | 187 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
175 | { | 188 | "Error reading line `%s' in hostfile\n", buf); |
176 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Successfully read host %s, port %d and user %s from file\n", temphost->hostname, temphost->port, temphost->username); | 189 | GNUNET_free (temphost); |
177 | } | 190 | buf = &data[count + 1]; |
178 | else | 191 | continue; |
179 | { | 192 | } |
180 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Error reading line `%s' in hostfile\n", buf); | 193 | /* temphost->hostname = buf; */ |
181 | GNUNET_free(temphost); | 194 | temphost->next = hosts; |
182 | buf = &data[count + 1]; | 195 | hosts = temphost; |
183 | continue; | 196 | buf = &data[count + 1]; |
184 | } | 197 | } |
185 | /* temphost->hostname = buf; */ | 198 | else if ((data[count] == '\n') || (data[count] == '\0')) |
186 | temphost->next = hosts; | ||
187 | hosts = temphost; | ||
188 | buf = &data[count + 1]; | 199 | buf = &data[count + 1]; |
189 | } | 200 | } |
190 | else if ((data[count] == '\n') || (data[count] == '\0')) | ||
191 | buf = &data[count + 1]; | ||
192 | } | ||
193 | } | 201 | } |
194 | 202 | ||
195 | peers_left = num_peers; | 203 | peers_left = num_peers; |
@@ -197,22 +205,17 @@ run (void *cls, | |||
197 | peers_left, | 205 | peers_left, |
198 | TIMEOUT, | 206 | TIMEOUT, |
199 | NULL, | 207 | NULL, |
200 | NULL, | 208 | NULL, &my_cb, NULL, NULL, NULL, hosts); |
201 | &my_cb, | ||
202 | NULL, | ||
203 | NULL, | ||
204 | NULL, | ||
205 | hosts); | ||
206 | hostpos = hosts; | 209 | hostpos = hosts; |
207 | while (hostpos != NULL) | 210 | while (hostpos != NULL) |
208 | { | 211 | { |
209 | temphost = hostpos->next; | 212 | temphost = hostpos->next; |
210 | GNUNET_free(hostpos->hostname); | 213 | GNUNET_free (hostpos->hostname); |
211 | GNUNET_free(hostpos->username); | 214 | GNUNET_free (hostpos->username); |
212 | GNUNET_free(hostpos); | 215 | GNUNET_free (hostpos); |
213 | hostpos = temphost; | 216 | hostpos = temphost; |
214 | } | 217 | } |
215 | GNUNET_free_non_null(data); | 218 | GNUNET_free_non_null (data); |
216 | GNUNET_assert (pg != NULL); | 219 | GNUNET_assert (pg != NULL); |
217 | 220 | ||
218 | } | 221 | } |