diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2013-06-27 09:14:53 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2013-06-27 09:14:53 +0000 |
commit | 596878227cf1c326cba9273c0bedd6a00e142552 (patch) | |
tree | ff573544cbf3f8e540891aaeb80352a290e2662c /src/transport/test_plugin_transport.c | |
parent | ea7eed529e12dcbed6a6775b818d8b93b9505f18 (diff) | |
download | gnunet-596878227cf1c326cba9273c0bedd6a00e142552.tar.gz gnunet-596878227cf1c326cba9273c0bedd6a00e142552.zip |
updated test
Diffstat (limited to 'src/transport/test_plugin_transport.c')
-rw-r--r-- | src/transport/test_plugin_transport.c | 55 |
1 files changed, 37 insertions, 18 deletions
diff --git a/src/transport/test_plugin_transport.c b/src/transport/test_plugin_transport.c index d2d03daa7..c90c5bc4a 100644 --- a/src/transport/test_plugin_transport.c +++ b/src/transport/test_plugin_transport.c | |||
@@ -341,7 +341,6 @@ env_notify_address (void *cls, | |||
341 | const char *plugin) | 341 | const char *plugin) |
342 | { | 342 | { |
343 | struct AddressWrapper *w; | 343 | struct AddressWrapper *w; |
344 | char *a2s; | ||
345 | void *s2a; | 344 | void *s2a; |
346 | size_t s2a_len; | 345 | size_t s2a_len; |
347 | 346 | ||
@@ -357,14 +356,10 @@ env_notify_address (void *cls, | |||
357 | memcpy (w->addr, addr, addrlen); | 356 | memcpy (w->addr, addr, addrlen); |
358 | GNUNET_CONTAINER_DLL_insert(head, tail, w); | 357 | GNUNET_CONTAINER_DLL_insert(head, tail, w); |
359 | got_reply = GNUNET_NO; | 358 | got_reply = GNUNET_NO; |
360 | pretty_printers_running ++; | 359 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
361 | api->address_pretty_printer (api->cls, plugin, addr, addrlen, | 360 | "Testing: address_to_string \n"); |
362 | GNUNET_YES, GNUNET_TIME_UNIT_MINUTES, | 361 | w->addrstring = strdup (api->address_to_string (api, w->addr, w->addrlen)); |
363 | &address_pretty_printer_cb, | 362 | if (NULL == w->addrstring) |
364 | w); | ||
365 | |||
366 | a2s = strdup (api->address_to_string (api, w->addr, w->addrlen)); | ||
367 | if (NULL == a2s) | ||
368 | { | 363 | { |
369 | GNUNET_break (0); | 364 | GNUNET_break (0); |
370 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 365 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -372,11 +367,19 @@ env_notify_address (void *cls, | |||
372 | end_badly_now(); | 367 | end_badly_now(); |
373 | return; | 368 | return; |
374 | } | 369 | } |
375 | w->addrstring = strdup (api->address_to_string (api, w->addr, w->addrlen)); | 370 | else |
376 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 371 | { |
377 | "Plugin added address `%s'\n", a2s); | 372 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
373 | "Plugin added address `%s'\n", w->addrstring); | ||
374 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
375 | "Testing address_to_string: OK\n"); | ||
376 | } | ||
378 | 377 | ||
379 | if ((GNUNET_OK != api->string_to_address (api, a2s, strlen (a2s)+1, &s2a, &s2a_len)) || (NULL == s2a)) | 378 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
379 | "Testing: string_to_address \n"); | ||
380 | s2a = NULL; | ||
381 | s2a_len = 0; | ||
382 | if ((GNUNET_OK != api->string_to_address (api, w->addrstring, strlen (w->addrstring)+1, &s2a, &s2a_len)) || (NULL == s2a)) | ||
380 | { | 383 | { |
381 | GNUNET_break (0); | 384 | GNUNET_break (0); |
382 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 385 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -384,20 +387,36 @@ env_notify_address (void *cls, | |||
384 | end_badly_now(); | 387 | end_badly_now(); |
385 | return; | 388 | return; |
386 | } | 389 | } |
387 | 390 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | |
391 | "Plugin creates `%s' %u\n",api->address_to_string (api, s2a, s2a_len), s2a_len); | ||
392 | /* | ||
393 | int c1; | ||
394 | for (c1 = 0; c1 < s2a_len; c1++ ) | ||
395 | fprintf (stderr, "%u == %u\n", ((char *) s2a)[c1], ((char *) w->addr)[c1]); | ||
396 | */ | ||
388 | if (s2a_len != w->addrlen) | 397 | if (s2a_len != w->addrlen) |
389 | { | 398 | { |
390 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 399 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
391 | "Plugin creates different address length when converting address->string->address: %u != %u\n", w->addrlen, s2a_len); | 400 | "Plugin creates different address length when converting address->string->address: %u != %u\n", w->addrlen, s2a_len); |
392 | } | 401 | } |
393 | else | 402 | else if (0 != memcmp (s2a, w->addr, s2a_len)) |
394 | { | 403 | { |
395 | if (0 != memcmp (s2a, w->addr, s2a_len)) | ||
396 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 404 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
397 | "Plugin creates different address length when connecting back and forth!\n"); | 405 | "Plugin creates different address length when converting back and forth %i!\n", memcmp (s2a, w->addr, s2a_len)); |
406 | } | ||
407 | else | ||
408 | { | ||
409 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
410 | "Testing string_to_address: OK\n"); | ||
398 | } | 411 | } |
399 | GNUNET_free (s2a); | 412 | GNUNET_free (s2a); |
400 | GNUNET_free (a2s); | 413 | |
414 | pretty_printers_running ++; | ||
415 | api->address_pretty_printer (api->cls, plugin, addr, addrlen, | ||
416 | GNUNET_YES, GNUNET_TIME_UNIT_MINUTES, | ||
417 | &address_pretty_printer_cb, | ||
418 | w); | ||
419 | |||
401 | if (GNUNET_OK != api->check_address (api->cls, w->addr, w->addrlen)) | 420 | if (GNUNET_OK != api->check_address (api->cls, w->addr, w->addrlen)) |
402 | { | 421 | { |
403 | GNUNET_break (0); | 422 | GNUNET_break (0); |