diff options
author | Christian Grothoff <christian@grothoff.org> | 2009-10-05 10:34:14 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2009-10-05 10:34:14 +0000 |
commit | d67a58fd833e1cbe980799af5f89524dba36c500 (patch) | |
tree | daf76474e09f88a40cc754305cb049bda870ccf7 /src/hello/test_hello.c | |
parent | 432e1e621c428190d752af86017ad99199b05292 (diff) | |
download | gnunet-d67a58fd833e1cbe980799af5f89524dba36c500.tar.gz gnunet-d67a58fd833e1cbe980799af5f89524dba36c500.zip |
be less verbose
Diffstat (limited to 'src/hello/test_hello.c')
-rw-r--r-- | src/hello/test_hello.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/hello/test_hello.c b/src/hello/test_hello.c index 2f61bd702..eaaa29d68 100644 --- a/src/hello/test_hello.c +++ b/src/hello/test_hello.c | |||
@@ -25,7 +25,10 @@ | |||
25 | #include "platform.h" | 25 | #include "platform.h" |
26 | #include "gnunet_hello_lib.h" | 26 | #include "gnunet_hello_lib.h" |
27 | 27 | ||
28 | #define DEBUG 0 | 28 | #define DEBUG GNUNET_NO |
29 | |||
30 | #define VERBOSE GNUNET_NO | ||
31 | |||
29 | 32 | ||
30 | static size_t | 33 | static size_t |
31 | my_addr_gen (void *cls, size_t max, void *buf) | 34 | my_addr_gen (void *cls, size_t max, void *buf) |
@@ -103,49 +106,65 @@ main (int argc, char *argv[]) | |||
103 | GNUNET_log_setup ("test-hello", "DEBUG", NULL); | 106 | GNUNET_log_setup ("test-hello", "DEBUG", NULL); |
104 | startup_time = GNUNET_TIME_absolute_get (); | 107 | startup_time = GNUNET_TIME_absolute_get (); |
105 | memset (&publicKey, 42, sizeof (publicKey)); | 108 | memset (&publicKey, 42, sizeof (publicKey)); |
109 | #if VERBOSE | ||
106 | fprintf (stderr, "Testing HELLO creation (without addresses)...\n"); | 110 | fprintf (stderr, "Testing HELLO creation (without addresses)...\n"); |
111 | #endif | ||
107 | i = 0; | 112 | i = 0; |
108 | msg1 = GNUNET_HELLO_create (&publicKey, &my_addr_gen, &i); | 113 | msg1 = GNUNET_HELLO_create (&publicKey, &my_addr_gen, &i); |
109 | GNUNET_assert (msg1 != NULL); | 114 | GNUNET_assert (msg1 != NULL); |
110 | GNUNET_assert (0 < GNUNET_HELLO_size (msg1)); | 115 | GNUNET_assert (0 < GNUNET_HELLO_size (msg1)); |
111 | 116 | ||
117 | #if VERBOSE | ||
112 | fprintf (stderr, "Testing address iteration (empty set)...\n"); | 118 | fprintf (stderr, "Testing address iteration (empty set)...\n"); |
119 | #endif | ||
113 | GNUNET_assert (NULL == | 120 | GNUNET_assert (NULL == |
114 | GNUNET_HELLO_iterate_addresses (msg1, | 121 | GNUNET_HELLO_iterate_addresses (msg1, |
115 | GNUNET_NO, &check_addr, &i)); | 122 | GNUNET_NO, &check_addr, &i)); |
116 | 123 | ||
124 | #if VERBOSE | ||
117 | fprintf (stderr, "Testing HELLO creation (with one address)...\n"); | 125 | fprintf (stderr, "Testing HELLO creation (with one address)...\n"); |
126 | #endif | ||
118 | i = 1; | 127 | i = 1; |
119 | msg2 = GNUNET_HELLO_create (&publicKey, &my_addr_gen, &i); | 128 | msg2 = GNUNET_HELLO_create (&publicKey, &my_addr_gen, &i); |
120 | GNUNET_assert (msg2 != NULL); | 129 | GNUNET_assert (msg2 != NULL); |
121 | GNUNET_assert (GNUNET_HELLO_size (msg1) < GNUNET_HELLO_size (msg2)); | 130 | GNUNET_assert (GNUNET_HELLO_size (msg1) < GNUNET_HELLO_size (msg2)); |
122 | 131 | ||
132 | #if VERBOSE | ||
123 | fprintf (stderr, "Testing address iteration (one address)...\n"); | 133 | fprintf (stderr, "Testing address iteration (one address)...\n"); |
134 | #endif | ||
124 | i = 1; | 135 | i = 1; |
125 | GNUNET_assert (NULL == | 136 | GNUNET_assert (NULL == |
126 | GNUNET_HELLO_iterate_addresses (msg2, | 137 | GNUNET_HELLO_iterate_addresses (msg2, |
127 | GNUNET_NO, &check_addr, &i)); | 138 | GNUNET_NO, &check_addr, &i)); |
128 | GNUNET_assert (i == 0); | 139 | GNUNET_assert (i == 0); |
129 | 140 | ||
141 | #if VERBOSE | ||
130 | fprintf (stderr, "Testing get_key from HELLO...\n"); | 142 | fprintf (stderr, "Testing get_key from HELLO...\n"); |
143 | #endif | ||
131 | GNUNET_assert (GNUNET_OK == GNUNET_HELLO_get_key (msg2, &pk)); | 144 | GNUNET_assert (GNUNET_OK == GNUNET_HELLO_get_key (msg2, &pk)); |
132 | GNUNET_assert (0 == memcmp (&publicKey, &pk, sizeof (pk))); | 145 | GNUNET_assert (0 == memcmp (&publicKey, &pk, sizeof (pk))); |
133 | GNUNET_free (msg1); | 146 | GNUNET_free (msg1); |
134 | 147 | ||
148 | #if VERBOSE | ||
135 | fprintf (stderr, "Testing HELLO creation (with two addresses)...\n"); | 149 | fprintf (stderr, "Testing HELLO creation (with two addresses)...\n"); |
150 | #endif | ||
136 | i = 2; | 151 | i = 2; |
137 | msg3 = GNUNET_HELLO_create (&publicKey, &my_addr_gen, &i); | 152 | msg3 = GNUNET_HELLO_create (&publicKey, &my_addr_gen, &i); |
138 | GNUNET_assert (msg3 != NULL); | 153 | GNUNET_assert (msg3 != NULL); |
139 | GNUNET_assert (GNUNET_HELLO_size (msg2) < GNUNET_HELLO_size (msg3)); | 154 | GNUNET_assert (GNUNET_HELLO_size (msg2) < GNUNET_HELLO_size (msg3)); |
140 | 155 | ||
156 | #if VERBOSE | ||
141 | fprintf (stderr, "Testing address iteration (two addresses)...\n"); | 157 | fprintf (stderr, "Testing address iteration (two addresses)...\n"); |
158 | #endif | ||
142 | i = 3; | 159 | i = 3; |
143 | GNUNET_assert (NULL == | 160 | GNUNET_assert (NULL == |
144 | GNUNET_HELLO_iterate_addresses (msg3, | 161 | GNUNET_HELLO_iterate_addresses (msg3, |
145 | GNUNET_NO, &check_addr, &i)); | 162 | GNUNET_NO, &check_addr, &i)); |
146 | GNUNET_assert (i == 0); | 163 | GNUNET_assert (i == 0); |
147 | 164 | ||
165 | #if VERBOSE | ||
148 | fprintf (stderr, "Testing HELLO merge...\n"); | 166 | fprintf (stderr, "Testing HELLO merge...\n"); |
167 | #endif | ||
149 | msg1 = GNUNET_HELLO_merge (msg2, msg3); | 168 | msg1 = GNUNET_HELLO_merge (msg2, msg3); |
150 | GNUNET_assert (GNUNET_HELLO_size (msg1) == GNUNET_HELLO_size (msg3)); | 169 | GNUNET_assert (GNUNET_HELLO_size (msg1) == GNUNET_HELLO_size (msg3)); |
151 | 170 | ||
@@ -156,7 +175,9 @@ main (int argc, char *argv[]) | |||
156 | GNUNET_assert (i == 0); | 175 | GNUNET_assert (i == 0); |
157 | GNUNET_free (msg1); | 176 | GNUNET_free (msg1); |
158 | 177 | ||
178 | #if VERBOSE | ||
159 | fprintf (stderr, "Testing address iteration to copy HELLO...\n"); | 179 | fprintf (stderr, "Testing address iteration to copy HELLO...\n"); |
180 | #endif | ||
160 | i = 2; | 181 | i = 2; |
161 | msg1 = GNUNET_HELLO_iterate_addresses (msg3, GNUNET_YES, &remove_some, &i); | 182 | msg1 = GNUNET_HELLO_iterate_addresses (msg3, GNUNET_YES, &remove_some, &i); |
162 | GNUNET_assert (msg1 != NULL); | 183 | GNUNET_assert (msg1 != NULL); |
@@ -168,7 +189,9 @@ main (int argc, char *argv[]) | |||
168 | GNUNET_assert (i == 0); | 189 | GNUNET_assert (i == 0); |
169 | GNUNET_free (msg1); | 190 | GNUNET_free (msg1); |
170 | 191 | ||
192 | #if VERBOSE | ||
171 | fprintf (stderr, "Testing delta address iteration...\n"); | 193 | fprintf (stderr, "Testing delta address iteration...\n"); |
194 | #endif | ||
172 | i = 2; | 195 | i = 2; |
173 | GNUNET_HELLO_iterate_new_addresses (msg3, | 196 | GNUNET_HELLO_iterate_new_addresses (msg3, |
174 | msg2, startup_time, &check_addr, &i); | 197 | msg2, startup_time, &check_addr, &i); |