aboutsummaryrefslogtreecommitdiff
path: root/src/hello/test_hello.c
diff options
context:
space:
mode:
authorDavid Barksdale <amatus.amongus@gmail.com>2013-07-22 08:26:16 -0500
committerDavid Barksdale <amatus.amongus@gmail.com>2013-08-01 08:12:45 -0500
commit000ad0090a0b4eb9889f4c45d35d4d7af2dbbe27 (patch)
treedda00bef19b649c154ba6a2b37f0f73fa1697c30 /src/hello/test_hello.c
parent0f8d8bc0c5c09246d647d233767cf3437c6e8bcd (diff)
Imported Upstream version 0.9.5a
Diffstat (limited to 'src/hello/test_hello.c')
-rw-r--r--src/hello/test_hello.c71
1 files changed, 26 insertions, 45 deletions
diff --git a/src/hello/test_hello.c b/src/hello/test_hello.c
index bdabc72..28d4aec 100644
--- a/src/hello/test_hello.c
+++ b/src/hello/test_hello.c
@@ -25,11 +25,6 @@
#include "platform.h"
#include "gnunet_hello_lib.h"
-#define DEBUG GNUNET_NO
-
-#define VERBOSE GNUNET_NO
-
-
static size_t
my_addr_gen (void *cls, size_t max, void *buf)
{
@@ -37,9 +32,8 @@ my_addr_gen (void *cls, size_t max, void *buf)
size_t ret;
struct GNUNET_HELLO_Address address;
-#if DEBUG
- FPRINTF (stderr, "DEBUG: my_addr_gen called with i = %d\n", *i);
-#endif
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "DEBUG: my_addr_gen called with i = %d\n", *i);
if (0 == *i)
return 0;
memset (&address.peer, 0, sizeof (struct GNUNET_PeerIdentity));
@@ -60,10 +54,9 @@ check_addr (void *cls, const struct GNUNET_HELLO_Address *address,
{
unsigned int *i = cls;
-#if DEBUG
- FPRINTF (stderr, "DEBUG: check_addr called with i = %d and addrlen = %u\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "DEBUG: check_addr called with i = %d and addrlen = %u\n",
*i, (unsigned int) address->address_length);
-#endif
GNUNET_assert (address->address_length > 0);
GNUNET_assert (*i & (1 << (address->address_length - 1)));
*i -= (1 << (address->address_length - 1));
@@ -81,10 +74,9 @@ remove_some (void *cls, const struct GNUNET_HELLO_Address *address,
{
unsigned int *i = cls;
-#if DEBUG
- FPRINTF (stderr, "DEBUG: remove_some called with i = %d and addrlen = %u\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "DEBUG: remove_some called with i = %d and addrlen = %u\n",
*i, (unsigned int) address->address_length);
-#endif
GNUNET_assert (address->address_length > 0);
if (*i & (1 << (address->address_length - 1)))
{
@@ -109,65 +101,56 @@ main (int argc, char *argv[])
GNUNET_log_setup ("test-hello", "DEBUG", NULL);
startup_time = GNUNET_TIME_absolute_get ();
memset (&publicKey, 42, sizeof (publicKey));
-#if VERBOSE
- FPRINTF (stderr, "%s", "Testing HELLO creation (without addresses)...\n");
-#endif
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Testing HELLO creation (without addresses)...\n");
i = 0;
msg1 = GNUNET_HELLO_create (&publicKey, &my_addr_gen, &i);
GNUNET_assert (msg1 != NULL);
GNUNET_assert (0 < GNUNET_HELLO_size (msg1));
-#if VERBOSE
- FPRINTF (stderr, "%s", "Testing address iteration (empty set)...\n");
-#endif
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Testing address iteration (empty set)...\n");
GNUNET_assert (NULL ==
GNUNET_HELLO_iterate_addresses (msg1, GNUNET_NO, &check_addr,
&i));
-
-#if VERBOSE
- FPRINTF (stderr, "%s", "Testing HELLO creation (with one address)...\n");
-#endif
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Testing HELLO creation (with one address)...\n");
i = 1;
msg2 = GNUNET_HELLO_create (&publicKey, &my_addr_gen, &i);
GNUNET_assert (msg2 != NULL);
GNUNET_assert (GNUNET_HELLO_size (msg1) < GNUNET_HELLO_size (msg2));
-#if VERBOSE
- FPRINTF (stderr, "%s", "Testing address iteration (one address)...\n");
-#endif
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Testing address iteration (one address)...\n");
i = 1;
GNUNET_assert (NULL ==
GNUNET_HELLO_iterate_addresses (msg2, GNUNET_NO, &check_addr,
&i));
GNUNET_assert (i == 0);
-#if VERBOSE
- FPRINTF (stderr, "%s", "Testing get_key from HELLO...\n");
-#endif
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Testing get_key from HELLO...\n");
GNUNET_assert (GNUNET_OK == GNUNET_HELLO_get_key (msg2, &pk));
GNUNET_assert (0 == memcmp (&publicKey, &pk, sizeof (pk)));
GNUNET_free (msg1);
-#if VERBOSE
- FPRINTF (stderr, "%s", "Testing HELLO creation (with two addresses)...\n");
-#endif
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Testing HELLO creation (with two addresses)...\n");
i = 2;
msg3 = GNUNET_HELLO_create (&publicKey, &my_addr_gen, &i);
GNUNET_assert (msg3 != NULL);
GNUNET_assert (GNUNET_HELLO_size (msg2) < GNUNET_HELLO_size (msg3));
-#if VERBOSE
- FPRINTF (stderr, "%s", "Testing address iteration (two addresses)...\n");
-#endif
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Testing address iteration (two addresses)...\n");
i = 3;
GNUNET_assert (NULL ==
GNUNET_HELLO_iterate_addresses (msg3, GNUNET_NO, &check_addr,
&i));
GNUNET_assert (i == 0);
-#if VERBOSE
- FPRINTF (stderr, "%s", "Testing HELLO merge...\n");
-#endif
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Testing HELLO merge...\n");
msg1 = GNUNET_HELLO_merge (msg2, msg3);
GNUNET_assert (GNUNET_HELLO_size (msg1) == GNUNET_HELLO_size (msg3));
@@ -178,9 +161,8 @@ main (int argc, char *argv[])
GNUNET_assert (i == 0);
GNUNET_free (msg1);
-#if VERBOSE
- FPRINTF (stderr, "%s", "Testing address iteration to copy HELLO...\n");
-#endif
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Testing address iteration to copy HELLO...\n");
i = 2;
msg1 = GNUNET_HELLO_iterate_addresses (msg3, GNUNET_YES, &remove_some, &i);
GNUNET_assert (msg1 != NULL);
@@ -192,9 +174,8 @@ main (int argc, char *argv[])
GNUNET_assert (i == 0);
GNUNET_free (msg1);
-#if VERBOSE
- FPRINTF (stderr, "%s", "Testing delta address iteration...\n");
-#endif
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Testing delta address iteration...\n");
i = 2;
GNUNET_HELLO_iterate_new_addresses (msg3, msg2, startup_time, &check_addr,
&i);