aboutsummaryrefslogtreecommitdiff
path: root/src/transport/test_transport_api.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2011-09-01 09:49:17 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2011-09-01 09:49:17 +0000
commit8962c636773aeb4a029b9db542b454bd64b2d915 (patch)
tree2f822035bca621ea7c8e3c26c2439447a42d4116 /src/transport/test_transport_api.c
parentd7181f0e7bc21fe4d7193cea580d034cd188ea48 (diff)
downloadgnunet-8962c636773aeb4a029b9db542b454bd64b2d915.tar.gz
gnunet-8962c636773aeb4a029b9db542b454bd64b2d915.zip
porting all tests using testing lib
Diffstat (limited to 'src/transport/test_transport_api.c')
-rw-r--r--src/transport/test_transport_api.c42
1 files changed, 33 insertions, 9 deletions
diff --git a/src/transport/test_transport_api.c b/src/transport/test_transport_api.c
index 15f490947..aac8eb400 100644
--- a/src/transport/test_transport_api.c
+++ b/src/transport/test_transport_api.c
@@ -37,7 +37,7 @@
37#include "transport.h" 37#include "transport.h"
38#include "transport-testing.h" 38#include "transport-testing.h"
39 39
40#define VERBOSE GNUNET_NO 40#define VERBOSE GNUNET_YES
41 41
42#define VERBOSE_ARM GNUNET_NO 42#define VERBOSE_ARM GNUNET_NO
43 43
@@ -55,6 +55,12 @@
55 55
56#define MTYPE 12345 56#define MTYPE 12345
57 57
58static char *test_source;
59
60static char *test_plugin;
61
62static char *test_name;
63
58static int ok; 64static int ok;
59 65
60static GNUNET_SCHEDULER_TaskIdentifier die_task; 66static GNUNET_SCHEDULER_TaskIdentifier die_task;
@@ -229,6 +235,16 @@ run (void *cls, char *const *args, const char *cfgfile,
229 p2 = GNUNET_TRANSPORT_TESTING_start_peer (cfg_file_p2, &notify_receive, 235 p2 = GNUNET_TRANSPORT_TESTING_start_peer (cfg_file_p2, &notify_receive,
230 &notify_connect, &notify_disconnect, 236 &notify_connect, &notify_disconnect,
231 NULL); 237 NULL);
238
239 if ((p1 == NULL) || (p2 == NULL))
240 {
241 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Fail! Could not start peers!\n");
242 if (die_task != GNUNET_SCHEDULER_NO_TASK)
243 GNUNET_SCHEDULER_cancel (die_task);
244 die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL);
245 return;
246 }
247
232 cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1, p2, &testing_connect_cb, 248 cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1, p2, &testing_connect_cb,
233 NULL); 249 NULL);
234} 250}
@@ -255,8 +271,8 @@ check ()
255 send_task = GNUNET_SCHEDULER_NO_TASK; 271 send_task = GNUNET_SCHEDULER_NO_TASK;
256 272
257 ok = 1; 273 ok = 1;
258 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, 274 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, test_name,
259 "test-transport-api", "nohelp", options, &run, &ok); 275 "nohelp", options, &run, &ok);
260 276
261 return ok; 277 return ok;
262} 278}
@@ -265,8 +281,14 @@ int
265main (int argc, char *argv[]) 281main (int argc, char *argv[])
266{ 282{
267 int ret; 283 int ret;
284 int nat_res;
285
286 GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
287 GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
288 &test_plugin);
289 GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name);
268 290
269 GNUNET_log_setup ("test-transport-api", 291 GNUNET_log_setup (test_name,
270#if VERBOSE 292#if VERBOSE
271 "DEBUG", 293 "DEBUG",
272#else 294#else
@@ -274,10 +296,8 @@ main (int argc, char *argv[])
274#endif 296#endif
275 NULL); 297 NULL);
276 298
277 int nat_res; 299 if ((strcmp (test_plugin, "tcp_nat") == 0) ||
278 300 (strcmp (test_plugin, "udp_nat") == 0))
279 if ((strstr (argv[0], "tcp_nat") != NULL) ||
280 (strstr (argv[0], "udp_nat") != NULL))
281 { 301 {
282 nat_res = GNUNET_OS_check_helper_binary ("gnunet-nat-server"); 302 nat_res = GNUNET_OS_check_helper_binary ("gnunet-nat-server");
283 if (GNUNET_NO == nat_res) 303 if (GNUNET_NO == nat_res)
@@ -292,7 +312,6 @@ main (int argc, char *argv[])
292 "gnunet-nat-server", "file not found"); 312 "gnunet-nat-server", "file not found");
293 return 0; 313 return 0;
294 } 314 }
295
296 } 315 }
297 316
298 GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1); 317 GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1);
@@ -303,6 +322,11 @@ main (int argc, char *argv[])
303 GNUNET_free (cfg_file_p1); 322 GNUNET_free (cfg_file_p1);
304 GNUNET_free (cfg_file_p2); 323 GNUNET_free (cfg_file_p2);
305 324
325 GNUNET_free (test_source);
326 GNUNET_free (test_plugin);
327 GNUNET_free (test_name);
328
329
306 return ret; 330 return ret;
307} 331}
308 332