diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-06-13 15:18:35 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-06-13 15:18:35 +0000 |
commit | 2742cca3d2180b4f615c40609fccf10a806f05c8 (patch) | |
tree | 7a59d0d43951cec4f0edd903f02ead3dbe037a2f /src | |
parent | 832d12049add37805697104b9f8eaae420eef406 (diff) | |
download | gnunet-2742cca3d2180b4f615c40609fccf10a806f05c8.tar.gz gnunet-2742cca3d2180b4f615c40609fccf10a806f05c8.zip |
-cleaning up VERBOSE and check nonsense in util tests
Diffstat (limited to 'src')
-rw-r--r-- | src/util/test_client.c | 29 | ||||
-rw-r--r-- | src/util/test_common_logging_runtime_loglevels.c | 24 | ||||
-rw-r--r-- | src/util/test_connection.c | 54 | ||||
-rw-r--r-- | src/util/test_connection_addressing.c | 28 | ||||
-rw-r--r-- | src/util/test_connection_receive_cancel.c | 2 | ||||
-rw-r--r-- | src/util/test_connection_timeout.c | 34 | ||||
-rw-r--r-- | src/util/test_connection_timeout_no_connect.c | 32 | ||||
-rw-r--r-- | src/util/test_connection_transmit_cancel.c | 32 | ||||
-rw-r--r-- | src/util/test_getopt.c | 7 | ||||
-rw-r--r-- | src/util/test_os_network.c | 32 | ||||
-rw-r--r-- | src/util/test_os_priority.c | 1 | ||||
-rw-r--r-- | src/util/test_os_start_process.c | 35 | ||||
-rw-r--r-- | src/util/test_peer.c | 9 | ||||
-rw-r--r-- | src/util/test_plugin.c | 20 | ||||
-rw-r--r-- | src/util/test_scheduler.c | 13 | ||||
-rw-r--r-- | src/util/test_scheduler_delay.c | 21 | ||||
-rw-r--r-- | src/util/test_server.c | 2 | ||||
-rw-r--r-- | src/util/test_server_disconnect.c | 1 | ||||
-rw-r--r-- | src/util/test_server_with_client.c | 28 | ||||
-rw-r--r-- | src/util/test_server_with_client_unix.c | 30 | ||||
-rw-r--r-- | src/util/test_service.c | 32 | ||||
-rw-r--r-- | src/util/test_strings.c | 15 | ||||
-rw-r--r-- | src/util/test_time.c | 16 |
23 files changed, 107 insertions, 390 deletions
diff --git a/src/util/test_client.c b/src/util/test_client.c index 54881b2dd..7d7ec8cff 100644 --- a/src/util/test_client.c +++ b/src/util/test_client.c | |||
@@ -29,7 +29,6 @@ | |||
29 | #include "gnunet_server_lib.h" | 29 | #include "gnunet_server_lib.h" |
30 | #include "gnunet_time_lib.h" | 30 | #include "gnunet_time_lib.h" |
31 | 31 | ||
32 | #define VERBOSE GNUNET_NO | ||
33 | 32 | ||
34 | #define PORT 14325 | 33 | #define PORT 14325 |
35 | 34 | ||
@@ -174,15 +173,14 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
174 | } | 173 | } |
175 | 174 | ||
176 | 175 | ||
177 | /** | 176 | int |
178 | * Main method, starts scheduler with task1, | 177 | main (int argc, char *argv[]) |
179 | * checks that "ok" is correct at the end. | ||
180 | */ | ||
181 | static int | ||
182 | check () | ||
183 | { | 178 | { |
184 | int ok; | 179 | int ok; |
185 | 180 | ||
181 | GNUNET_log_setup ("test_client", | ||
182 | "WARNING", | ||
183 | NULL); | ||
186 | cfg = GNUNET_CONFIGURATION_create (); | 184 | cfg = GNUNET_CONFIGURATION_create (); |
187 | GNUNET_CONFIGURATION_set_value_number (cfg, MYNAME, "PORT", PORT); | 185 | GNUNET_CONFIGURATION_set_value_number (cfg, MYNAME, "PORT", PORT); |
188 | GNUNET_CONFIGURATION_set_value_string (cfg, MYNAME, "HOSTNAME", "localhost"); | 186 | GNUNET_CONFIGURATION_set_value_string (cfg, MYNAME, "HOSTNAME", "localhost"); |
@@ -194,21 +192,4 @@ check () | |||
194 | return ok; | 192 | return ok; |
195 | } | 193 | } |
196 | 194 | ||
197 | int | ||
198 | main (int argc, char *argv[]) | ||
199 | { | ||
200 | int ret = 0; | ||
201 | |||
202 | GNUNET_log_setup ("test_client", | ||
203 | #if VERBOSE | ||
204 | "DEBUG", | ||
205 | #else | ||
206 | "WARNING", | ||
207 | #endif | ||
208 | NULL); | ||
209 | ret += check (); | ||
210 | |||
211 | return ret; | ||
212 | } | ||
213 | |||
214 | /* end of test_client.c */ | 195 | /* end of test_client.c */ |
diff --git a/src/util/test_common_logging_runtime_loglevels.c b/src/util/test_common_logging_runtime_loglevels.c index b914ae1c6..5ad9d9860 100644 --- a/src/util/test_common_logging_runtime_loglevels.c +++ b/src/util/test_common_logging_runtime_loglevels.c | |||
@@ -351,34 +351,16 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
351 | runone (); | 351 | runone (); |
352 | } | 352 | } |
353 | 353 | ||
354 | /** | ||
355 | * Main method, starts scheduler with task1, | ||
356 | * checks that "ok" is correct at the end. | ||
357 | */ | ||
358 | static int | ||
359 | check () | ||
360 | { | ||
361 | ok = 1; | ||
362 | GNUNET_SCHEDULER_run (&task, &ok); | ||
363 | return ok; | ||
364 | } | ||
365 | |||
366 | 354 | ||
367 | int | 355 | int |
368 | main (int argc, char *argv[]) | 356 | main (int argc, char *argv[]) |
369 | { | 357 | { |
370 | int ret; | ||
371 | |||
372 | GNUNET_log_setup ("test-common-logging-runtime-loglevels", | 358 | GNUNET_log_setup ("test-common-logging-runtime-loglevels", |
373 | #if VERBOSE | ||
374 | "DEBUG", | ||
375 | #else | ||
376 | "WARNING", | 359 | "WARNING", |
377 | #endif | ||
378 | NULL); | 360 | NULL); |
379 | ret = check (); | 361 | ok = 1; |
380 | 362 | GNUNET_SCHEDULER_run (&task, &ok); | |
381 | return ret; | 363 | return ok; |
382 | } | 364 | } |
383 | 365 | ||
384 | /* end of test_common_logging_runtime_loglevels.c */ | 366 | /* end of test_common_logging_runtime_loglevels.c */ |
diff --git a/src/util/test_connection.c b/src/util/test_connection.c index 4568f8ecb..e129c80ea 100644 --- a/src/util/test_connection.c +++ b/src/util/test_connection.c | |||
@@ -27,8 +27,6 @@ | |||
27 | #include "gnunet_scheduler_lib.h" | 27 | #include "gnunet_scheduler_lib.h" |
28 | #include "gnunet_time_lib.h" | 28 | #include "gnunet_time_lib.h" |
29 | 29 | ||
30 | #define VERBOSE GNUNET_NO | ||
31 | |||
32 | #define PORT 12435 | 30 | #define PORT 12435 |
33 | 31 | ||
34 | 32 | ||
@@ -80,17 +78,13 @@ receive_check (void *cls, const void *buf, size_t available, | |||
80 | { | 78 | { |
81 | int *ok = cls; | 79 | int *ok = cls; |
82 | 80 | ||
83 | #if VERBOSE | ||
84 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receive validates incoming data\n"); | 81 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receive validates incoming data\n"); |
85 | #endif | ||
86 | GNUNET_assert (buf != NULL); /* no timeout */ | 82 | GNUNET_assert (buf != NULL); /* no timeout */ |
87 | if (0 == memcmp (&"Hello World"[sofar], buf, available)) | 83 | if (0 == memcmp (&"Hello World"[sofar], buf, available)) |
88 | sofar += available; | 84 | sofar += available; |
89 | if (sofar < 12) | 85 | if (sofar < 12) |
90 | { | 86 | { |
91 | #if VERBOSE | ||
92 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receive needs more data\n"); | 87 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receive needs more data\n"); |
93 | #endif | ||
94 | GNUNET_CONNECTION_receive (asock, 1024, | 88 | GNUNET_CONNECTION_receive (asock, 1024, |
95 | GNUNET_TIME_relative_multiply | 89 | GNUNET_TIME_relative_multiply |
96 | (GNUNET_TIME_UNIT_SECONDS, 5), &receive_check, | 90 | (GNUNET_TIME_UNIT_SECONDS, 5), &receive_check, |
@@ -98,9 +92,7 @@ receive_check (void *cls, const void *buf, size_t available, | |||
98 | } | 92 | } |
99 | else | 93 | else |
100 | { | 94 | { |
101 | #if VERBOSE | ||
102 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receive closes accepted socket\n"); | 95 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receive closes accepted socket\n"); |
103 | #endif | ||
104 | *ok = 0; | 96 | *ok = 0; |
105 | GNUNET_CONNECTION_destroy (asock); | 97 | GNUNET_CONNECTION_destroy (asock); |
106 | GNUNET_CONNECTION_destroy (csock); | 98 | GNUNET_CONNECTION_destroy (csock); |
@@ -111,41 +103,33 @@ receive_check (void *cls, const void *buf, size_t available, | |||
111 | static void | 103 | static void |
112 | run_accept (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 104 | run_accept (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
113 | { | 105 | { |
114 | #if VERBOSE | ||
115 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test accepts connection\n"); | 106 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test accepts connection\n"); |
116 | #endif | ||
117 | asock = GNUNET_CONNECTION_create_from_accept (NULL, NULL, ls); | 107 | asock = GNUNET_CONNECTION_create_from_accept (NULL, NULL, ls); |
118 | GNUNET_assert (asock != NULL); | 108 | GNUNET_assert (asock != NULL); |
119 | GNUNET_assert (GNUNET_YES == GNUNET_CONNECTION_check (asock)); | 109 | GNUNET_assert (GNUNET_YES == GNUNET_CONNECTION_check (asock)); |
120 | #if VERBOSE | ||
121 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test destroys listen socket\n"); | 110 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test destroys listen socket\n"); |
122 | #endif | ||
123 | GNUNET_CONNECTION_destroy (lsock); | 111 | GNUNET_CONNECTION_destroy (lsock); |
124 | #if VERBOSE | ||
125 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 112 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
126 | "Test asks to receive on accepted socket\n"); | 113 | "Test asks to receive on accepted socket\n"); |
127 | #endif | ||
128 | GNUNET_CONNECTION_receive (asock, 1024, | 114 | GNUNET_CONNECTION_receive (asock, 1024, |
129 | GNUNET_TIME_relative_multiply | 115 | GNUNET_TIME_relative_multiply |
130 | (GNUNET_TIME_UNIT_SECONDS, 5), &receive_check, | 116 | (GNUNET_TIME_UNIT_SECONDS, 5), &receive_check, |
131 | cls); | 117 | cls); |
132 | } | 118 | } |
133 | 119 | ||
120 | |||
134 | static size_t | 121 | static size_t |
135 | make_hello (void *cls, size_t size, void *buf) | 122 | make_hello (void *cls, size_t size, void *buf) |
136 | { | 123 | { |
137 | #if VERBOSE | ||
138 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 124 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
139 | "Test prepares to transmit on connect socket\n"); | 125 | "Test prepares to transmit on connect socket\n"); |
140 | #endif | ||
141 | GNUNET_assert (size >= 12); | 126 | GNUNET_assert (size >= 12); |
142 | strcpy ((char *) buf, "Hello World"); | 127 | strcpy ((char *) buf, "Hello World"); |
143 | #if VERBOSE | ||
144 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test destroys client socket\n"); | 128 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test destroys client socket\n"); |
145 | #endif | ||
146 | return 12; | 129 | return 12; |
147 | } | 130 | } |
148 | 131 | ||
132 | |||
149 | static void | 133 | static void |
150 | task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 134 | task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
151 | { | 135 | { |
@@ -154,30 +138,26 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
154 | GNUNET_assert (lsock != NULL); | 138 | GNUNET_assert (lsock != NULL); |
155 | csock = GNUNET_CONNECTION_create_from_connect (cfg, "localhost", PORT); | 139 | csock = GNUNET_CONNECTION_create_from_connect (cfg, "localhost", PORT); |
156 | GNUNET_assert (csock != NULL); | 140 | GNUNET_assert (csock != NULL); |
157 | #if VERBOSE | ||
158 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test asks for write notification\n"); | 141 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test asks for write notification\n"); |
159 | #endif | ||
160 | GNUNET_assert (NULL != | 142 | GNUNET_assert (NULL != |
161 | GNUNET_CONNECTION_notify_transmit_ready (csock, 12, | 143 | GNUNET_CONNECTION_notify_transmit_ready (csock, 12, |
162 | GNUNET_TIME_UNIT_SECONDS, | 144 | GNUNET_TIME_UNIT_SECONDS, |
163 | &make_hello, NULL)); | 145 | &make_hello, NULL)); |
164 | #if VERBOSE | ||
165 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test prepares to accept\n"); | 146 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test prepares to accept\n"); |
166 | #endif | ||
167 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, ls, &run_accept, | 147 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, ls, &run_accept, |
168 | cls); | 148 | cls); |
169 | } | 149 | } |
170 | 150 | ||
171 | 151 | ||
172 | /** | 152 | int |
173 | * Main method, starts scheduler with task , | 153 | main (int argc, char *argv[]) |
174 | * checks that "ok" is correct at the end. | ||
175 | */ | ||
176 | static int | ||
177 | check () | ||
178 | { | 154 | { |
179 | int ok; | 155 | int ok; |
180 | 156 | ||
157 | GNUNET_log_setup ("test_connection", | ||
158 | "WARNING", | ||
159 | NULL); | ||
160 | |||
181 | ok = 1; | 161 | ok = 1; |
182 | cfg = GNUNET_CONFIGURATION_create (); | 162 | cfg = GNUNET_CONFIGURATION_create (); |
183 | GNUNET_CONFIGURATION_set_value_string (cfg, "resolver", "HOSTNAME", | 163 | GNUNET_CONFIGURATION_set_value_string (cfg, "resolver", "HOSTNAME", |
@@ -187,22 +167,4 @@ check () | |||
187 | return ok; | 167 | return ok; |
188 | } | 168 | } |
189 | 169 | ||
190 | |||
191 | |||
192 | int | ||
193 | main (int argc, char *argv[]) | ||
194 | { | ||
195 | int ret = 0; | ||
196 | |||
197 | GNUNET_log_setup ("test_connection", | ||
198 | #if VERBOSE | ||
199 | "DEBUG", | ||
200 | #else | ||
201 | "WARNING", | ||
202 | #endif | ||
203 | NULL); | ||
204 | ret += check (); | ||
205 | return ret; | ||
206 | } | ||
207 | |||
208 | /* end of test_connection.c */ | 170 | /* end of test_connection.c */ |
diff --git a/src/util/test_connection_addressing.c b/src/util/test_connection_addressing.c index ba7acaefc..e5c8edeeb 100644 --- a/src/util/test_connection_addressing.c +++ b/src/util/test_connection_addressing.c | |||
@@ -27,7 +27,6 @@ | |||
27 | #include "gnunet_scheduler_lib.h" | 27 | #include "gnunet_scheduler_lib.h" |
28 | #include "gnunet_time_lib.h" | 28 | #include "gnunet_time_lib.h" |
29 | 29 | ||
30 | #define VERBOSE GNUNET_NO | ||
31 | 30 | ||
32 | #define PORT 12435 | 31 | #define PORT 12435 |
33 | 32 | ||
@@ -174,36 +173,17 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
174 | } | 173 | } |
175 | 174 | ||
176 | 175 | ||
177 | /** | ||
178 | * Main method, starts scheduler with task , | ||
179 | * checks that "ok" is correct at the end. | ||
180 | */ | ||
181 | static int | ||
182 | check () | ||
183 | { | ||
184 | int ok; | ||
185 | |||
186 | ok = 1; | ||
187 | GNUNET_SCHEDULER_run (&task, &ok); | ||
188 | return ok; | ||
189 | } | ||
190 | |||
191 | |||
192 | |||
193 | int | 176 | int |
194 | main (int argc, char *argv[]) | 177 | main (int argc, char *argv[]) |
195 | { | 178 | { |
196 | int ret = 0; | 179 | int ok; |
197 | 180 | ||
198 | GNUNET_log_setup ("test_connection_addressing", | 181 | GNUNET_log_setup ("test_connection_addressing", |
199 | #if VERBOSE | ||
200 | "DEBUG", | ||
201 | #else | ||
202 | "WARNING", | 182 | "WARNING", |
203 | #endif | ||
204 | NULL); | 183 | NULL); |
205 | ret += check (); | 184 | ok = 1; |
206 | return ret; | 185 | GNUNET_SCHEDULER_run (&task, &ok); |
186 | return ok; | ||
207 | } | 187 | } |
208 | 188 | ||
209 | /* end of test_connection_addressing.c */ | 189 | /* end of test_connection_addressing.c */ |
diff --git a/src/util/test_connection_receive_cancel.c b/src/util/test_connection_receive_cancel.c index 93fcd5fdf..90490343c 100644 --- a/src/util/test_connection_receive_cancel.c +++ b/src/util/test_connection_receive_cancel.c | |||
@@ -27,8 +27,6 @@ | |||
27 | #include "gnunet_scheduler_lib.h" | 27 | #include "gnunet_scheduler_lib.h" |
28 | #include "gnunet_time_lib.h" | 28 | #include "gnunet_time_lib.h" |
29 | 29 | ||
30 | #define VERBOSE GNUNET_NO | ||
31 | |||
32 | #define PORT 12435 | 30 | #define PORT 12435 |
33 | 31 | ||
34 | 32 | ||
diff --git a/src/util/test_connection_timeout.c b/src/util/test_connection_timeout.c index c0597b24b..8d3f775b5 100644 --- a/src/util/test_connection_timeout.c +++ b/src/util/test_connection_timeout.c | |||
@@ -27,8 +27,6 @@ | |||
27 | #include "gnunet_scheduler_lib.h" | 27 | #include "gnunet_scheduler_lib.h" |
28 | #include "gnunet_time_lib.h" | 28 | #include "gnunet_time_lib.h" |
29 | 29 | ||
30 | #define VERBOSE GNUNET_NO | ||
31 | |||
32 | #define PORT 12435 | 30 | #define PORT 12435 |
33 | 31 | ||
34 | static struct GNUNET_CONNECTION_Handle *csock; | 32 | static struct GNUNET_CONNECTION_Handle *csock; |
@@ -78,18 +76,14 @@ send_kilo (void *cls, size_t size, void *buf) | |||
78 | 76 | ||
79 | if (size == 0) | 77 | if (size == 0) |
80 | { | 78 | { |
81 | #if VERBOSE | ||
82 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got the desired timeout!\n"); | 79 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got the desired timeout!\n"); |
83 | #endif | ||
84 | GNUNET_assert (buf == NULL); | 80 | GNUNET_assert (buf == NULL); |
85 | *ok = 0; | 81 | *ok = 0; |
86 | GNUNET_CONNECTION_destroy (lsock); | 82 | GNUNET_CONNECTION_destroy (lsock); |
87 | GNUNET_CONNECTION_destroy (csock); | 83 | GNUNET_CONNECTION_destroy (csock); |
88 | return 0; | 84 | return 0; |
89 | } | 85 | } |
90 | #if VERBOSE | ||
91 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending kilo to fill buffer.\n"); | 86 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending kilo to fill buffer.\n"); |
92 | #endif | ||
93 | GNUNET_assert (size >= 1024); | 87 | GNUNET_assert (size >= 1024); |
94 | memset (buf, 42, 1024); | 88 | memset (buf, 42, 1024); |
95 | 89 | ||
@@ -117,15 +111,15 @@ task_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
117 | } | 111 | } |
118 | 112 | ||
119 | 113 | ||
120 | 114 | int | |
121 | /** | 115 | main (int argc, char *argv[]) |
122 | * Main method, starts scheduler with task_timeout. | ||
123 | */ | ||
124 | static int | ||
125 | check_timeout () | ||
126 | { | 116 | { |
127 | int ok; | 117 | int ok; |
128 | 118 | ||
119 | GNUNET_log_setup ("test_connection_timeout", | ||
120 | "WARNING", | ||
121 | NULL); | ||
122 | |||
129 | ok = 1; | 123 | ok = 1; |
130 | cfg = GNUNET_CONFIGURATION_create (); | 124 | cfg = GNUNET_CONFIGURATION_create (); |
131 | GNUNET_CONFIGURATION_set_value_string (cfg, "resolver", "HOSTNAME", | 125 | GNUNET_CONFIGURATION_set_value_string (cfg, "resolver", "HOSTNAME", |
@@ -135,20 +129,4 @@ check_timeout () | |||
135 | return ok; | 129 | return ok; |
136 | } | 130 | } |
137 | 131 | ||
138 | int | ||
139 | main (int argc, char *argv[]) | ||
140 | { | ||
141 | int ret = 0; | ||
142 | |||
143 | GNUNET_log_setup ("test_connection_timeout", | ||
144 | #if VERBOSE | ||
145 | "DEBUG", | ||
146 | #else | ||
147 | "WARNING", | ||
148 | #endif | ||
149 | NULL); | ||
150 | ret += check_timeout (); | ||
151 | return ret; | ||
152 | } | ||
153 | |||
154 | /* end of test_connection_timeout.c */ | 132 | /* end of test_connection_timeout.c */ |
diff --git a/src/util/test_connection_timeout_no_connect.c b/src/util/test_connection_timeout_no_connect.c index 2e8f9be2e..50eaf709a 100644 --- a/src/util/test_connection_timeout_no_connect.c +++ b/src/util/test_connection_timeout_no_connect.c | |||
@@ -27,8 +27,6 @@ | |||
27 | #include "gnunet_scheduler_lib.h" | 27 | #include "gnunet_scheduler_lib.h" |
28 | #include "gnunet_time_lib.h" | 28 | #include "gnunet_time_lib.h" |
29 | 29 | ||
30 | #define VERBOSE GNUNET_NO | ||
31 | |||
32 | #define PORT 13425 | 30 | #define PORT 13425 |
33 | 31 | ||
34 | static struct GNUNET_CONNECTION_Handle *csock; | 32 | static struct GNUNET_CONNECTION_Handle *csock; |
@@ -40,10 +38,7 @@ handle_timeout (void *cls, size_t size, void *buf) | |||
40 | { | 38 | { |
41 | int *ok = cls; | 39 | int *ok = cls; |
42 | 40 | ||
43 | #if VERBOSE | ||
44 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received timeout signal.\n"); | 41 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received timeout signal.\n"); |
45 | #endif | ||
46 | |||
47 | GNUNET_assert (size == 0); | 42 | GNUNET_assert (size == 0); |
48 | GNUNET_assert (buf == NULL); | 43 | GNUNET_assert (buf == NULL); |
49 | *ok = 0; | 44 | *ok = 0; |
@@ -64,15 +59,14 @@ task_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
64 | } | 59 | } |
65 | 60 | ||
66 | 61 | ||
67 | 62 | int | |
68 | /** | 63 | main (int argc, char *argv[]) |
69 | * Main method, starts scheduler with task_timeout. | ||
70 | */ | ||
71 | static int | ||
72 | check_timeout () | ||
73 | { | 64 | { |
74 | int ok; | 65 | int ok; |
75 | 66 | ||
67 | GNUNET_log_setup ("test_connection_timeout_no_connect", | ||
68 | "WARNING", | ||
69 | NULL); | ||
76 | ok = 1; | 70 | ok = 1; |
77 | cfg = GNUNET_CONFIGURATION_create (); | 71 | cfg = GNUNET_CONFIGURATION_create (); |
78 | GNUNET_CONFIGURATION_set_value_string (cfg, "resolver", "HOSTNAME", | 72 | GNUNET_CONFIGURATION_set_value_string (cfg, "resolver", "HOSTNAME", |
@@ -82,20 +76,4 @@ check_timeout () | |||
82 | return ok; | 76 | return ok; |
83 | } | 77 | } |
84 | 78 | ||
85 | int | ||
86 | main (int argc, char *argv[]) | ||
87 | { | ||
88 | int ret = 0; | ||
89 | |||
90 | GNUNET_log_setup ("test_connection_timeout_no_connect", | ||
91 | #if VERBOSE | ||
92 | "DEBUG", | ||
93 | #else | ||
94 | "WARNING", | ||
95 | #endif | ||
96 | NULL); | ||
97 | ret += check_timeout (); | ||
98 | return ret; | ||
99 | } | ||
100 | |||
101 | /* end of test_connection_timeout_no_connect.c */ | 79 | /* end of test_connection_timeout_no_connect.c */ |
diff --git a/src/util/test_connection_transmit_cancel.c b/src/util/test_connection_transmit_cancel.c index fec72d273..195ac689b 100644 --- a/src/util/test_connection_transmit_cancel.c +++ b/src/util/test_connection_transmit_cancel.c | |||
@@ -27,8 +27,6 @@ | |||
27 | #include "gnunet_scheduler_lib.h" | 27 | #include "gnunet_scheduler_lib.h" |
28 | #include "gnunet_time_lib.h" | 28 | #include "gnunet_time_lib.h" |
29 | 29 | ||
30 | #define VERBOSE GNUNET_NO | ||
31 | |||
32 | #define PORT 12435 | 30 | #define PORT 12435 |
33 | 31 | ||
34 | static struct GNUNET_CONFIGURATION_Handle *cfg; | 32 | static struct GNUNET_CONFIGURATION_Handle *cfg; |
@@ -61,16 +59,14 @@ task_transmit_cancel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
61 | } | 59 | } |
62 | 60 | ||
63 | 61 | ||
64 | 62 | int | |
65 | 63 | main (int argc, char *argv[]) | |
66 | /** | ||
67 | * Main method, starts scheduler with task_timeout. | ||
68 | */ | ||
69 | static int | ||
70 | check_transmit_cancel () | ||
71 | { | 64 | { |
72 | int ok; | 65 | int ok; |
73 | 66 | ||
67 | GNUNET_log_setup ("test_connection_transmit_cancel", | ||
68 | "WARNING", | ||
69 | NULL); | ||
74 | ok = 1; | 70 | ok = 1; |
75 | cfg = GNUNET_CONFIGURATION_create (); | 71 | cfg = GNUNET_CONFIGURATION_create (); |
76 | GNUNET_CONFIGURATION_set_value_string (cfg, "resolver", "HOSTNAME", | 72 | GNUNET_CONFIGURATION_set_value_string (cfg, "resolver", "HOSTNAME", |
@@ -80,22 +76,4 @@ check_transmit_cancel () | |||
80 | return ok; | 76 | return ok; |
81 | } | 77 | } |
82 | 78 | ||
83 | |||
84 | int | ||
85 | main (int argc, char *argv[]) | ||
86 | { | ||
87 | int ret = 0; | ||
88 | |||
89 | GNUNET_log_setup ("test_connection_transmit_cancel", | ||
90 | #if VERBOSE | ||
91 | "DEBUG", | ||
92 | #else | ||
93 | "WARNING", | ||
94 | #endif | ||
95 | NULL); | ||
96 | ret += check_transmit_cancel (); | ||
97 | |||
98 | return ret; | ||
99 | } | ||
100 | |||
101 | /* end of test_connection_transmit_cancel.c */ | 79 | /* end of test_connection_transmit_cancel.c */ |
diff --git a/src/util/test_getopt.c b/src/util/test_getopt.c index a517887bf..f068a6ab0 100644 --- a/src/util/test_getopt.c +++ b/src/util/test_getopt.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include "gnunet_configuration_lib.h" | 26 | #include "gnunet_configuration_lib.h" |
27 | #include "gnunet_getopt_lib.h" | 27 | #include "gnunet_getopt_lib.h" |
28 | 28 | ||
29 | #define VERBOSE 0 | ||
30 | 29 | ||
31 | static int | 30 | static int |
32 | testMinimal () | 31 | testMinimal () |
@@ -45,6 +44,7 @@ testMinimal () | |||
45 | return 0; | 44 | return 0; |
46 | } | 45 | } |
47 | 46 | ||
47 | |||
48 | static int | 48 | static int |
49 | testVerbose () | 49 | testVerbose () |
50 | { | 50 | { |
@@ -75,6 +75,7 @@ testVerbose () | |||
75 | return 0; | 75 | return 0; |
76 | } | 76 | } |
77 | 77 | ||
78 | |||
78 | static int | 79 | static int |
79 | testVersion () | 80 | testVersion () |
80 | { | 81 | { |
@@ -96,6 +97,7 @@ testVersion () | |||
96 | return 0; | 97 | return 0; |
97 | } | 98 | } |
98 | 99 | ||
100 | |||
99 | static int | 101 | static int |
100 | testAbout () | 102 | testAbout () |
101 | { | 103 | { |
@@ -117,6 +119,7 @@ testAbout () | |||
117 | return 0; | 119 | return 0; |
118 | } | 120 | } |
119 | 121 | ||
122 | |||
120 | static int | 123 | static int |
121 | testLogOpts () | 124 | testLogOpts () |
122 | { | 125 | { |
@@ -153,6 +156,7 @@ testLogOpts () | |||
153 | return 0; | 156 | return 0; |
154 | } | 157 | } |
155 | 158 | ||
159 | |||
156 | static int | 160 | static int |
157 | testFlagNum () | 161 | testFlagNum () |
158 | { | 162 | { |
@@ -190,6 +194,7 @@ testFlagNum () | |||
190 | return 0; | 194 | return 0; |
191 | } | 195 | } |
192 | 196 | ||
197 | |||
193 | int | 198 | int |
194 | main (int argc, char *argv[]) | 199 | main (int argc, char *argv[]) |
195 | { | 200 | { |
diff --git a/src/util/test_os_network.c b/src/util/test_os_network.c index 4486e6a99..2cdd75040 100644 --- a/src/util/test_os_network.c +++ b/src/util/test_os_network.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include "gnunet_configuration_lib.h" | 26 | #include "gnunet_configuration_lib.h" |
27 | #include "gnunet_os_lib.h" | 27 | #include "gnunet_os_lib.h" |
28 | 28 | ||
29 | #define VERBOSE 1 | ||
30 | 29 | ||
31 | /** | 30 | /** |
32 | * Check if the address we got is IPv4 or IPv6 loopback (which should | 31 | * Check if the address we got is IPv4 or IPv6 loopback (which should |
@@ -40,20 +39,20 @@ proc (void *cls, const char *name, int isDefault, const struct sockaddr *addr, | |||
40 | { | 39 | { |
41 | int *ok = cls; | 40 | int *ok = cls; |
42 | char buf[INET6_ADDRSTRLEN]; | 41 | char buf[INET6_ADDRSTRLEN]; |
42 | const char * protocol; | ||
43 | 43 | ||
44 | if (NULL == addr) | 44 | if (NULL == addr) |
45 | return GNUNET_OK; | 45 | return GNUNET_OK; |
46 | #if VERBOSE | ||
47 | const char * protocol; | ||
48 | if (addrlen == sizeof (struct sockaddr_in)) | 46 | if (addrlen == sizeof (struct sockaddr_in)) |
49 | protocol = "IPv4"; | 47 | protocol = "IPv4"; |
50 | else | 48 | else |
51 | protocol = "IPv6"; | 49 | protocol = "IPv6"; |
52 | printf ("%s Address `%s'\n", protocol, GNUNET_a2s ((const struct sockaddr *) addr,addrlen) ); | 50 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
53 | printf (" Netmask `%s'\n", GNUNET_a2s ((const struct sockaddr *) netmask, addrlen) ); | 51 | "%s Address `%s'\n", protocol, GNUNET_a2s ((const struct sockaddr *) addr,addrlen) ); |
54 | printf (" Broadcast `%s'\n", GNUNET_a2s ((const struct sockaddr *) broadcast_addr,addrlen) ); | 52 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
55 | #endif | 53 | "Netmask `%s'\n", GNUNET_a2s ((const struct sockaddr *) netmask, addrlen) ); |
56 | 54 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | |
55 | "`%s'\n", GNUNET_a2s ((const struct sockaddr *) broadcast_addr,addrlen) ); | ||
57 | inet_ntop (addr->sa_family, | 56 | inet_ntop (addr->sa_family, |
58 | (addr->sa_family == | 57 | (addr->sa_family == |
59 | AF_INET) ? (void *) &((struct sockaddr_in *) addr)->sin_addr | 58 | AF_INET) ? (void *) &((struct sockaddr_in *) addr)->sin_addr |
@@ -64,23 +63,16 @@ proc (void *cls, const char *name, int isDefault, const struct sockaddr *addr, | |||
64 | return GNUNET_OK; | 63 | return GNUNET_OK; |
65 | } | 64 | } |
66 | 65 | ||
67 | static int | 66 | |
68 | testifcs () | 67 | int |
68 | main (int argc, char *argv[]) | ||
69 | { | 69 | { |
70 | int ret; | 70 | int ret; |
71 | 71 | ||
72 | GNUNET_log_setup ("test-os-network", "WARNING", NULL); | ||
72 | ret = 1; | 73 | ret = 1; |
73 | GNUNET_OS_network_interfaces_list (&proc, &ret); | 74 | GNUNET_OS_network_interfaces_list (&proc, &ret); |
74 | return ret; | 75 | return ret; |
75 | } | 76 | } |
76 | 77 | ||
77 | int | 78 | /* end of test_os_network.c */ |
78 | main (int argc, char *argv[]) | ||
79 | { | ||
80 | int errCnt = 0; | ||
81 | |||
82 | GNUNET_log_setup ("test-os-network", "WARNING", NULL); | ||
83 | if (0 != testifcs ()) | ||
84 | errCnt++; | ||
85 | return errCnt; | ||
86 | } | ||
diff --git a/src/util/test_os_priority.c b/src/util/test_os_priority.c index 94e2719a2..bb740db5f 100644 --- a/src/util/test_os_priority.c +++ b/src/util/test_os_priority.c | |||
@@ -25,7 +25,6 @@ | |||
25 | #include "gnunet_common.h" | 25 | #include "gnunet_common.h" |
26 | #include "gnunet_os_lib.h" | 26 | #include "gnunet_os_lib.h" |
27 | 27 | ||
28 | #define VERBOSE 0 | ||
29 | 28 | ||
30 | static int | 29 | static int |
31 | testprio () | 30 | testprio () |
diff --git a/src/util/test_os_start_process.c b/src/util/test_os_start_process.c index 0d1481857..5b9973250 100644 --- a/src/util/test_os_start_process.c +++ b/src/util/test_os_start_process.c | |||
@@ -33,21 +33,26 @@ | |||
33 | #include "gnunet_scheduler_lib.h" | 33 | #include "gnunet_scheduler_lib.h" |
34 | #include "disk.h" | 34 | #include "disk.h" |
35 | 35 | ||
36 | #define VERBOSE GNUNET_NO | ||
37 | 36 | ||
38 | static char *test_phrase = "HELLO WORLD"; | 37 | static const char *test_phrase = "HELLO WORLD"; |
38 | |||
39 | static int ok; | 39 | static int ok; |
40 | 40 | ||
41 | static struct GNUNET_OS_Process *proc; | 41 | static struct GNUNET_OS_Process *proc; |
42 | 42 | ||
43 | /* Pipe to write to started processes stdin (on write end) */ | 43 | /** |
44 | * Pipe to write to started processes stdin (on write end) | ||
45 | */ | ||
44 | static struct GNUNET_DISK_PipeHandle *hello_pipe_stdin; | 46 | static struct GNUNET_DISK_PipeHandle *hello_pipe_stdin; |
45 | 47 | ||
46 | /* Pipe to read from started processes stdout (on read end) */ | 48 | /** |
49 | * Pipe to read from started processes stdout (on read end) | ||
50 | */ | ||
47 | static struct GNUNET_DISK_PipeHandle *hello_pipe_stdout; | 51 | static struct GNUNET_DISK_PipeHandle *hello_pipe_stdout; |
48 | 52 | ||
49 | static GNUNET_SCHEDULER_TaskIdentifier die_task; | 53 | static GNUNET_SCHEDULER_TaskIdentifier die_task; |
50 | 54 | ||
55 | |||
51 | static void | 56 | static void |
52 | end_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 57 | end_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
53 | { | 58 | { |
@@ -62,6 +67,7 @@ end_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
62 | GNUNET_DISK_pipe_close (hello_pipe_stdin); | 67 | GNUNET_DISK_pipe_close (hello_pipe_stdin); |
63 | } | 68 | } |
64 | 69 | ||
70 | |||
65 | static void | 71 | static void |
66 | read_call (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 72 | read_call (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
67 | { | 73 | { |
@@ -73,9 +79,7 @@ read_call (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
73 | 79 | ||
74 | bytes = GNUNET_DISK_file_read (stdout_read_handle, &buf, sizeof (buf)); | 80 | bytes = GNUNET_DISK_file_read (stdout_read_handle, &buf, sizeof (buf)); |
75 | 81 | ||
76 | #if VERBOSE | 82 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "bytes is %d\n", bytes); |
77 | FPRINTF (stderr, "bytes is %d\n", bytes); | ||
78 | #endif | ||
79 | 83 | ||
80 | if (bytes < 1) | 84 | if (bytes < 1) |
81 | { | 85 | { |
@@ -87,10 +91,8 @@ read_call (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
87 | } | 91 | } |
88 | 92 | ||
89 | ok = strncmp (&buf[0], test_phrase, strlen (test_phrase)); | 93 | ok = strncmp (&buf[0], test_phrase, strlen (test_phrase)); |
90 | #if VERBOSE | 94 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "read %s\n", &buf[0]); |
91 | FPRINTF (stderr, "read %s\n", &buf[0]); | 95 | if (0 == ok) |
92 | #endif | ||
93 | if (ok == 0) | ||
94 | { | 96 | { |
95 | GNUNET_SCHEDULER_cancel (die_task); | 97 | GNUNET_SCHEDULER_cancel (die_task); |
96 | GNUNET_SCHEDULER_add_now (&end_task, NULL); | 98 | GNUNET_SCHEDULER_add_now (&end_task, NULL); |
@@ -190,11 +192,9 @@ check_kill () | |||
190 | proc = | 192 | proc = |
191 | GNUNET_OS_start_process (GNUNET_YES, hello_pipe_stdin, hello_pipe_stdout, "cat", | 193 | GNUNET_OS_start_process (GNUNET_YES, hello_pipe_stdin, hello_pipe_stdout, "cat", |
192 | "gnunet-service-resolver", "-", NULL); | 194 | "gnunet-service-resolver", "-", NULL); |
193 | sleep (1); /* give process time to start and open pipe */ | 195 | sleep (1); /* give process time to start, so we actually use the pipe-kill mechanism! */ |
194 | if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) | 196 | if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) |
195 | { | ||
196 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); | 197 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); |
197 | } | ||
198 | GNUNET_assert (GNUNET_OK == GNUNET_OS_process_wait (proc)); | 198 | GNUNET_assert (GNUNET_OK == GNUNET_OS_process_wait (proc)); |
199 | GNUNET_OS_process_destroy (proc); | 199 | GNUNET_OS_process_destroy (proc); |
200 | proc = NULL; | 200 | proc = NULL; |
@@ -238,16 +238,13 @@ main (int argc, char *argv[]) | |||
238 | int ret; | 238 | int ret; |
239 | 239 | ||
240 | GNUNET_log_setup ("test-os-start-process", | 240 | GNUNET_log_setup ("test-os-start-process", |
241 | #if VERBOSE | ||
242 | "DEBUG", | ||
243 | #else | ||
244 | "WARNING", | 241 | "WARNING", |
245 | #endif | ||
246 | NULL); | 242 | NULL); |
247 | ret = 0; | 243 | ret = 0; |
248 | ret |= check_run (); | 244 | ret |= check_run (); |
249 | ret |= check_kill (); | 245 | ret |= check_kill (); |
250 | ret |= check_instant_kill (); | 246 | ret |= check_instant_kill (); |
251 | |||
252 | return ret; | 247 | return ret; |
253 | } | 248 | } |
249 | |||
250 | /* end of test_os_start_process.c */ | ||
diff --git a/src/util/test_peer.c b/src/util/test_peer.c index 2a4840102..fa4d31b8d 100644 --- a/src/util/test_peer.c +++ b/src/util/test_peer.c | |||
@@ -29,8 +29,6 @@ | |||
29 | 29 | ||
30 | #define NUMBER_OF_PEERS 10 | 30 | #define NUMBER_OF_PEERS 10 |
31 | 31 | ||
32 | #define VERBOSE GNUNET_NO | ||
33 | |||
34 | /** | 32 | /** |
35 | * A list of Peer ID's to play with | 33 | * A list of Peer ID's to play with |
36 | */ | 34 | */ |
@@ -46,9 +44,8 @@ generatePeerIdList () | |||
46 | { | 44 | { |
47 | GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, | 45 | GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, |
48 | &pidArr[i].hashPubKey); | 46 | &pidArr[i].hashPubKey); |
49 | #if VERBOSE | 47 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
50 | printf ("Peer %d: %s\n", i, GNUNET_i2s (&pidArr[i])); | 48 | "Peer %d: %s\n", i, GNUNET_i2s (&pidArr[i])); |
51 | #endif | ||
52 | } | 49 | } |
53 | } | 50 | } |
54 | 51 | ||
@@ -124,7 +121,7 @@ check () | |||
124 | int | 121 | int |
125 | main () | 122 | main () |
126 | { | 123 | { |
127 | int i; | 124 | unsigned int i; |
128 | 125 | ||
129 | GNUNET_log_setup ("test-peer", "ERROR", NULL); | 126 | GNUNET_log_setup ("test-peer", "ERROR", NULL); |
130 | for (i = 0; i < 1; i++) | 127 | for (i = 0; i < 1; i++) |
diff --git a/src/util/test_plugin.c b/src/util/test_plugin.c index 428cdaffb..122d5f480 100644 --- a/src/util/test_plugin.c +++ b/src/util/test_plugin.c | |||
@@ -24,7 +24,6 @@ | |||
24 | #include "platform.h" | 24 | #include "platform.h" |
25 | #include "gnunet_plugin_lib.h" | 25 | #include "gnunet_plugin_lib.h" |
26 | 26 | ||
27 | #define VERBOSE GNUNET_NO | ||
28 | 27 | ||
29 | static void | 28 | static void |
30 | test_cb (void *cls, const char *libname, void *lib_ret) | 29 | test_cb (void *cls, const char *libname, void *lib_ret) |
@@ -39,11 +38,12 @@ test_cb (void *cls, const char *libname, void *lib_ret) | |||
39 | } | 38 | } |
40 | 39 | ||
41 | 40 | ||
42 | static int | 41 | int |
43 | check () | 42 | main (int argc, char *argv[]) |
44 | { | 43 | { |
45 | void *ret; | 44 | void *ret; |
46 | 45 | ||
46 | GNUNET_log_setup ("test-plugin", "WARNING", NULL); | ||
47 | GNUNET_log_skip (1, GNUNET_NO); | 47 | GNUNET_log_skip (1, GNUNET_NO); |
48 | ret = GNUNET_PLUGIN_load ("libgnunet_plugin_missing", NULL); | 48 | ret = GNUNET_PLUGIN_load ("libgnunet_plugin_missing", NULL); |
49 | GNUNET_log_skip (0, GNUNET_NO); | 49 | GNUNET_log_skip (0, GNUNET_NO); |
@@ -52,7 +52,7 @@ check () | |||
52 | ret = GNUNET_PLUGIN_load ("libgnunet_plugin_test", "in"); | 52 | ret = GNUNET_PLUGIN_load ("libgnunet_plugin_test", "in"); |
53 | if (ret == NULL) | 53 | if (ret == NULL) |
54 | return 1; | 54 | return 1; |
55 | if (0 != strcmp (ret, "Hello")) | 55 | if (0 != strcmp (ret, "Hello")) |
56 | return 2; | 56 | return 2; |
57 | ret = GNUNET_PLUGIN_unload ("libgnunet_plugin_test", "out"); | 57 | ret = GNUNET_PLUGIN_unload ("libgnunet_plugin_test", "out"); |
58 | if (ret == NULL) | 58 | if (ret == NULL) |
@@ -60,20 +60,8 @@ check () | |||
60 | if (0 != strcmp (ret, "World")) | 60 | if (0 != strcmp (ret, "World")) |
61 | return 4; | 61 | return 4; |
62 | free (ret); | 62 | free (ret); |
63 | |||
64 | GNUNET_PLUGIN_load_all ("libgnunet_plugin_tes", "in", &test_cb, "test"); | 63 | GNUNET_PLUGIN_load_all ("libgnunet_plugin_tes", "in", &test_cb, "test"); |
65 | return 0; | 64 | return 0; |
66 | } | 65 | } |
67 | 66 | ||
68 | int | ||
69 | main (int argc, char *argv[]) | ||
70 | { | ||
71 | int ret; | ||
72 | |||
73 | GNUNET_log_setup ("test-plugin", "WARNING", NULL); | ||
74 | ret = check (); | ||
75 | |||
76 | return ret; | ||
77 | } | ||
78 | |||
79 | /* end of test_plugin.c */ | 67 | /* end of test_plugin.c */ |
diff --git a/src/util/test_scheduler.c b/src/util/test_scheduler.c index 9832ade6f..2a9ed2db1 100644 --- a/src/util/test_scheduler.c +++ b/src/util/test_scheduler.c | |||
@@ -27,7 +27,11 @@ | |||
27 | #include "gnunet_time_lib.h" | 27 | #include "gnunet_time_lib.h" |
28 | #include "gnunet_disk_lib.h" | 28 | #include "gnunet_disk_lib.h" |
29 | 29 | ||
30 | #define VERBOSE GNUNET_NO | 30 | |
31 | struct GNUNET_DISK_PipeHandle *p; | ||
32 | |||
33 | static const struct GNUNET_DISK_FileHandle *fds[2]; | ||
34 | |||
31 | 35 | ||
32 | static void | 36 | static void |
33 | task2 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 37 | task2 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
@@ -51,9 +55,6 @@ task3 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
51 | (*ok) = 4; | 55 | (*ok) = 4; |
52 | } | 56 | } |
53 | 57 | ||
54 | struct GNUNET_DISK_PipeHandle *p; | ||
55 | static const struct GNUNET_DISK_FileHandle *fds[2]; | ||
56 | |||
57 | 58 | ||
58 | static void | 59 | static void |
59 | taskWrt (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 60 | taskWrt (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
@@ -74,6 +75,7 @@ taskNeverRun (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
74 | GNUNET_assert (0); | 75 | GNUNET_assert (0); |
75 | } | 76 | } |
76 | 77 | ||
78 | |||
77 | static void | 79 | static void |
78 | taskLast (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 80 | taskLast (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
79 | { | 81 | { |
@@ -84,6 +86,7 @@ taskLast (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
84 | (*ok) = 0; | 86 | (*ok) = 0; |
85 | } | 87 | } |
86 | 88 | ||
89 | |||
87 | static void | 90 | static void |
88 | taskRd (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 91 | taskRd (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
89 | { | 92 | { |
@@ -132,7 +135,6 @@ task1 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
132 | } | 135 | } |
133 | 136 | ||
134 | 137 | ||
135 | |||
136 | /** | 138 | /** |
137 | * Main method, starts scheduler with task1, | 139 | * Main method, starts scheduler with task1, |
138 | * checks that "ok" is correct at the end. | 140 | * checks that "ok" is correct at the end. |
@@ -229,7 +231,6 @@ checkCancel () | |||
229 | } | 231 | } |
230 | 232 | ||
231 | 233 | ||
232 | |||
233 | int | 234 | int |
234 | main (int argc, char *argv[]) | 235 | main (int argc, char *argv[]) |
235 | { | 236 | { |
diff --git a/src/util/test_scheduler_delay.c b/src/util/test_scheduler_delay.c index 8ba35f5b9..a246e96a6 100644 --- a/src/util/test_scheduler_delay.c +++ b/src/util/test_scheduler_delay.c | |||
@@ -28,8 +28,6 @@ | |||
28 | #include "gnunet_scheduler_lib.h" | 28 | #include "gnunet_scheduler_lib.h" |
29 | #include "gnunet_time_lib.h" | 29 | #include "gnunet_time_lib.h" |
30 | 30 | ||
31 | #define VERBOSE GNUNET_NO | ||
32 | |||
33 | static struct GNUNET_TIME_Absolute target; | 31 | static struct GNUNET_TIME_Absolute target; |
34 | 32 | ||
35 | static int i; | 33 | static int i; |
@@ -71,9 +69,13 @@ test_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
71 | i += INCR; | 69 | i += INCR; |
72 | } | 70 | } |
73 | 71 | ||
74 | static int | 72 | |
75 | check () | 73 | int |
74 | main (int argc, char *argv[]) | ||
76 | { | 75 | { |
76 | int ret; | ||
77 | |||
78 | GNUNET_log_setup ("test-scheduler-delay", "WARNING", NULL); | ||
77 | target = GNUNET_TIME_absolute_get (); | 79 | target = GNUNET_TIME_absolute_get (); |
78 | GNUNET_SCHEDULER_run (&test_task, NULL); | 80 | GNUNET_SCHEDULER_run (&test_task, NULL); |
79 | FPRINTF (stdout, "Sleep precision: %llu ms. ", | 81 | FPRINTF (stdout, "Sleep precision: %llu ms. ", |
@@ -89,15 +91,4 @@ check () | |||
89 | return 0; | 91 | return 0; |
90 | } | 92 | } |
91 | 93 | ||
92 | int | ||
93 | main (int argc, char *argv[]) | ||
94 | { | ||
95 | int ret; | ||
96 | |||
97 | GNUNET_log_setup ("test-scheduler-delay", "WARNING", NULL); | ||
98 | ret = check (); | ||
99 | |||
100 | return ret; | ||
101 | } | ||
102 | |||
103 | /* end of test_scheduler_delay.c */ | 94 | /* end of test_scheduler_delay.c */ |
diff --git a/src/util/test_server.c b/src/util/test_server.c index 0faf61bee..19f993249 100644 --- a/src/util/test_server.c +++ b/src/util/test_server.c | |||
@@ -28,8 +28,6 @@ | |||
28 | #include "gnunet_server_lib.h" | 28 | #include "gnunet_server_lib.h" |
29 | #include "gnunet_time_lib.h" | 29 | #include "gnunet_time_lib.h" |
30 | 30 | ||
31 | #define VERBOSE GNUNET_NO | ||
32 | |||
33 | #define PORT 12435 | 31 | #define PORT 12435 |
34 | 32 | ||
35 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2) | 33 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2) |
diff --git a/src/util/test_server_disconnect.c b/src/util/test_server_disconnect.c index c54f9cbc8..b54df4889 100644 --- a/src/util/test_server_disconnect.c +++ b/src/util/test_server_disconnect.c | |||
@@ -28,7 +28,6 @@ | |||
28 | #include "gnunet_server_lib.h" | 28 | #include "gnunet_server_lib.h" |
29 | #include "gnunet_time_lib.h" | 29 | #include "gnunet_time_lib.h" |
30 | 30 | ||
31 | #define VERBOSE GNUNET_NO | ||
32 | 31 | ||
33 | #define PORT 12435 | 32 | #define PORT 12435 |
34 | 33 | ||
diff --git a/src/util/test_server_with_client.c b/src/util/test_server_with_client.c index ad56071fa..c49456301 100644 --- a/src/util/test_server_with_client.c +++ b/src/util/test_server_with_client.c | |||
@@ -30,8 +30,6 @@ | |||
30 | #include "gnunet_server_lib.h" | 30 | #include "gnunet_server_lib.h" |
31 | #include "gnunet_time_lib.h" | 31 | #include "gnunet_time_lib.h" |
32 | 32 | ||
33 | #define VERBOSE GNUNET_NO | ||
34 | |||
35 | #define PORT 22335 | 33 | #define PORT 22335 |
36 | 34 | ||
37 | #define MY_TYPE 128 | 35 | #define MY_TYPE 128 |
@@ -190,35 +188,15 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
190 | } | 188 | } |
191 | 189 | ||
192 | 190 | ||
193 | /** | ||
194 | * Main method, starts scheduler with task1, | ||
195 | * checks that "ok" is correct at the end. | ||
196 | */ | ||
197 | static int | ||
198 | check () | ||
199 | { | ||
200 | |||
201 | ok = 1; | ||
202 | GNUNET_SCHEDULER_run (&task, NULL); | ||
203 | return ok; | ||
204 | } | ||
205 | |||
206 | |||
207 | int | 191 | int |
208 | main (int argc, char *argv[]) | 192 | main (int argc, char *argv[]) |
209 | { | 193 | { |
210 | int ret = 0; | ||
211 | |||
212 | GNUNET_log_setup ("test_server_with_client", | 194 | GNUNET_log_setup ("test_server_with_client", |
213 | #if VERBOSE | ||
214 | "DEBUG", | ||
215 | #else | ||
216 | "WARNING", | 195 | "WARNING", |
217 | #endif | ||
218 | NULL); | 196 | NULL); |
219 | ret += check (); | 197 | ok = 1; |
220 | 198 | GNUNET_SCHEDULER_run (&task, NULL); | |
221 | return ret; | 199 | return ok; |
222 | } | 200 | } |
223 | 201 | ||
224 | /* end of test_server_with_client.c */ | 202 | /* end of test_server_with_client.c */ |
diff --git a/src/util/test_server_with_client_unix.c b/src/util/test_server_with_client_unix.c index eae80e4e8..57a67d3f4 100644 --- a/src/util/test_server_with_client_unix.c +++ b/src/util/test_server_with_client_unix.c | |||
@@ -30,8 +30,6 @@ | |||
30 | #include "gnunet_server_lib.h" | 30 | #include "gnunet_server_lib.h" |
31 | #include "gnunet_time_lib.h" | 31 | #include "gnunet_time_lib.h" |
32 | 32 | ||
33 | #define VERBOSE GNUNET_NO | ||
34 | |||
35 | #define MY_TYPE 128 | 33 | #define MY_TYPE 128 |
36 | 34 | ||
37 | 35 | ||
@@ -43,6 +41,7 @@ static struct GNUNET_CONFIGURATION_Handle *cfg; | |||
43 | 41 | ||
44 | static int ok; | 42 | static int ok; |
45 | 43 | ||
44 | |||
46 | static void | 45 | static void |
47 | send_done (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 46 | send_done (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
48 | { | 47 | { |
@@ -150,7 +149,6 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
150 | un.sun_path[0] = '\0'; | 149 | un.sun_path[0] = '\0'; |
151 | #endif | 150 | #endif |
152 | 151 | ||
153 | |||
154 | sap[0] = (struct sockaddr *) &un; | 152 | sap[0] = (struct sockaddr *) &un; |
155 | slens[0] = sizeof (un); | 153 | slens[0] = sizeof (un); |
156 | sap[1] = NULL; | 154 | sap[1] = NULL; |
@@ -178,35 +176,15 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
178 | } | 176 | } |
179 | 177 | ||
180 | 178 | ||
181 | /** | ||
182 | * Main method, starts scheduler with task1, | ||
183 | * checks that "ok" is correct at the end. | ||
184 | */ | ||
185 | static int | ||
186 | check () | ||
187 | { | ||
188 | |||
189 | ok = 1; | ||
190 | GNUNET_SCHEDULER_run (&task, NULL); | ||
191 | return ok; | ||
192 | } | ||
193 | |||
194 | |||
195 | int | 179 | int |
196 | main (int argc, char *argv[]) | 180 | main (int argc, char *argv[]) |
197 | { | 181 | { |
198 | int ret = 0; | ||
199 | |||
200 | GNUNET_log_setup ("test_server_with_client_unix", | 182 | GNUNET_log_setup ("test_server_with_client_unix", |
201 | #if VERBOSE | ||
202 | "DEBUG", | ||
203 | #else | ||
204 | "WARNING", | 183 | "WARNING", |
205 | #endif | ||
206 | NULL); | 184 | NULL); |
207 | ret += check (); | 185 | ok = 1; |
208 | 186 | GNUNET_SCHEDULER_run (&task, NULL); | |
209 | return ret; | 187 | return ok; |
210 | } | 188 | } |
211 | 189 | ||
212 | /* end of test_server_with_client_unix.c */ | 190 | /* end of test_server_with_client_unix.c */ |
diff --git a/src/util/test_service.c b/src/util/test_service.c index 554724972..be49d1877 100644 --- a/src/util/test_service.c +++ b/src/util/test_service.c | |||
@@ -31,8 +31,6 @@ | |||
31 | #include "gnunet_time_lib.h" | 31 | #include "gnunet_time_lib.h" |
32 | 32 | ||
33 | 33 | ||
34 | #define VERBOSE GNUNET_NO | ||
35 | |||
36 | #define PORT 12435 | 34 | #define PORT 12435 |
37 | 35 | ||
38 | #define MY_TYPE 256 | 36 | #define MY_TYPE 256 |
@@ -148,17 +146,11 @@ check () | |||
148 | "test_service", | 146 | "test_service", |
149 | "-c", | 147 | "-c", |
150 | "test_service_data.conf", | 148 | "test_service_data.conf", |
151 | "-L", | ||
152 | #if VERBOSE | ||
153 | "DEBUG", | ||
154 | #else | ||
155 | "WARNING", | ||
156 | #endif | ||
157 | NULL | 149 | NULL |
158 | }; | 150 | }; |
159 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting service\n"); | 151 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting service\n"); |
160 | GNUNET_assert (GNUNET_OK == | 152 | GNUNET_assert (GNUNET_OK == |
161 | GNUNET_SERVICE_run (5, argv, "test_service", | 153 | GNUNET_SERVICE_run (3, argv, "test_service", |
162 | GNUNET_SERVICE_OPTION_NONE, &runner, &ok)); | 154 | GNUNET_SERVICE_OPTION_NONE, &runner, &ok)); |
163 | GNUNET_assert (0 == ok); | 155 | GNUNET_assert (0 == ok); |
164 | return ok; | 156 | return ok; |
@@ -201,17 +193,11 @@ check6 () | |||
201 | "test_service6", | 193 | "test_service6", |
202 | "-c", | 194 | "-c", |
203 | "test_service_data.conf", | 195 | "test_service_data.conf", |
204 | "-L", | ||
205 | #if VERBOSE | ||
206 | "DEBUG", | ||
207 | #else | ||
208 | "WARNING", | ||
209 | #endif | ||
210 | NULL | 196 | NULL |
211 | }; | 197 | }; |
212 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting v6 service\n"); | 198 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting v6 service\n"); |
213 | GNUNET_assert (GNUNET_OK == | 199 | GNUNET_assert (GNUNET_OK == |
214 | GNUNET_SERVICE_run (5, argv, "test_service6", | 200 | GNUNET_SERVICE_run (3, argv, "test_service6", |
215 | GNUNET_SERVICE_OPTION_NONE, &runner6, | 201 | GNUNET_SERVICE_OPTION_NONE, &runner6, |
216 | &ok)); | 202 | &ok)); |
217 | GNUNET_assert (0 == ok); | 203 | GNUNET_assert (0 == ok); |
@@ -241,12 +227,6 @@ check_start_stop () | |||
241 | "test-service-program", | 227 | "test-service-program", |
242 | "-c", | 228 | "-c", |
243 | "test_service_data.conf", | 229 | "test_service_data.conf", |
244 | "-L", | ||
245 | #if VERBOSE | ||
246 | "DEBUG", | ||
247 | #else | ||
248 | "WARNING", | ||
249 | #endif | ||
250 | NULL | 230 | NULL |
251 | }; | 231 | }; |
252 | const struct GNUNET_GETOPT_CommandLineOption options[] = { | 232 | const struct GNUNET_GETOPT_CommandLineOption options[] = { |
@@ -255,9 +235,9 @@ check_start_stop () | |||
255 | int ret = 1; | 235 | int ret = 1; |
256 | 236 | ||
257 | GNUNET_assert (GNUNET_OK == | 237 | GNUNET_assert (GNUNET_OK == |
258 | GNUNET_PROGRAM_run (5, argv, "test-service-program", "no help", | 238 | GNUNET_PROGRAM_run (3, argv, "test-service-program", "no help", |
259 | options, &start_stop_main, &ret)); | 239 | options, &start_stop_main, &ret)); |
260 | 240 | ||
261 | GNUNET_break (0 == ret); | 241 | GNUNET_break (0 == ret); |
262 | return ret; | 242 | return ret; |
263 | } | 243 | } |
@@ -270,11 +250,7 @@ main (int argc, char *argv[]) | |||
270 | struct GNUNET_NETWORK_Handle *s = NULL; | 250 | struct GNUNET_NETWORK_Handle *s = NULL; |
271 | 251 | ||
272 | GNUNET_log_setup ("test-service", | 252 | GNUNET_log_setup ("test-service", |
273 | #if VERBOSE | ||
274 | "DEBUG", | ||
275 | #else | ||
276 | "WARNING", | 253 | "WARNING", |
277 | #endif | ||
278 | NULL); | 254 | NULL); |
279 | ret += check (); | 255 | ret += check (); |
280 | ret += check (); | 256 | ret += check (); |
diff --git a/src/util/test_strings.c b/src/util/test_strings.c index b662623e8..45dd904f4 100644 --- a/src/util/test_strings.c +++ b/src/util/test_strings.c | |||
@@ -25,13 +25,12 @@ | |||
25 | #include "gnunet_common.h" | 25 | #include "gnunet_common.h" |
26 | #include "gnunet_strings_lib.h" | 26 | #include "gnunet_strings_lib.h" |
27 | 27 | ||
28 | #define VERBOSE GNUNET_NO | ||
29 | 28 | ||
30 | #define WANT(a,b) if (0 != strcmp(a,b)) { fprintf(stderr, "Got `%s', wanted `%s'\n", b, a); GNUNET_free(b); GNUNET_break(0); return 1;} else { GNUNET_free (b); } | 29 | #define WANT(a,b) if (0 != strcmp(a,b)) { fprintf(stderr, "Got `%s', wanted `%s'\n", b, a); GNUNET_free(b); GNUNET_break(0); return 1;} else { GNUNET_free (b); } |
31 | #define WANTB(a,b,l) if (0 != memcmp(a,b,l)) { GNUNET_break(0); return 1;} else { } | 30 | #define WANTB(a,b,l) if (0 != memcmp(a,b,l)) { GNUNET_break(0); return 1;} else { } |
32 | 31 | ||
33 | static int | 32 | int |
34 | check () | 33 | main (int argc, char *argv[]) |
35 | { | 34 | { |
36 | char buf[128]; | 35 | char buf[128]; |
37 | char *r; | 36 | char *r; |
@@ -39,6 +38,7 @@ check () | |||
39 | struct GNUNET_TIME_Absolute at; | 38 | struct GNUNET_TIME_Absolute at; |
40 | const char *hdir; | 39 | const char *hdir; |
41 | 40 | ||
41 | GNUNET_log_setup ("test_strings", "ERROR", NULL); | ||
42 | sprintf (buf, "4 %s", _( /* size unit */ "b")); | 42 | sprintf (buf, "4 %s", _( /* size unit */ "b")); |
43 | b = GNUNET_STRINGS_byte_size_fancy (4); | 43 | b = GNUNET_STRINGS_byte_size_fancy (4); |
44 | WANT (buf, b); | 44 | WANT (buf, b); |
@@ -106,14 +106,5 @@ check () | |||
106 | return 0; | 106 | return 0; |
107 | } | 107 | } |
108 | 108 | ||
109 | int | ||
110 | main (int argc, char *argv[]) | ||
111 | { | ||
112 | int ret; | ||
113 | |||
114 | GNUNET_log_setup ("test_strings", "ERROR", NULL); | ||
115 | ret = check (); | ||
116 | return ret; | ||
117 | } | ||
118 | 109 | ||
119 | /* end of test_strings.c */ | 110 | /* end of test_strings.c */ |
diff --git a/src/util/test_time.c b/src/util/test_time.c index b4c723344..cd1175416 100644 --- a/src/util/test_time.c +++ b/src/util/test_time.c | |||
@@ -25,10 +25,9 @@ | |||
25 | #include "gnunet_common.h" | 25 | #include "gnunet_common.h" |
26 | #include "gnunet_time_lib.h" | 26 | #include "gnunet_time_lib.h" |
27 | 27 | ||
28 | #define VERBOSE GNUNET_NO | ||
29 | 28 | ||
30 | static int | 29 | int |
31 | check () | 30 | main (int argc, char *argv[]) |
32 | { | 31 | { |
33 | struct GNUNET_TIME_Absolute now; | 32 | struct GNUNET_TIME_Absolute now; |
34 | struct GNUNET_TIME_AbsoluteNBO nown; | 33 | struct GNUNET_TIME_AbsoluteNBO nown; |
@@ -43,6 +42,7 @@ check () | |||
43 | struct GNUNET_TIME_RelativeNBO reln; | 42 | struct GNUNET_TIME_RelativeNBO reln; |
44 | unsigned int i; | 43 | unsigned int i; |
45 | 44 | ||
45 | GNUNET_log_setup ("test-time", "WARNING", NULL); | ||
46 | forever = GNUNET_TIME_UNIT_FOREVER_ABS; | 46 | forever = GNUNET_TIME_UNIT_FOREVER_ABS; |
47 | relForever = GNUNET_TIME_UNIT_FOREVER_REL; | 47 | relForever = GNUNET_TIME_UNIT_FOREVER_REL; |
48 | relUnit = GNUNET_TIME_UNIT_MILLISECONDS; | 48 | relUnit = GNUNET_TIME_UNIT_MILLISECONDS; |
@@ -230,15 +230,5 @@ check () | |||
230 | return 0; | 230 | return 0; |
231 | } | 231 | } |
232 | 232 | ||
233 | int | ||
234 | main (int argc, char *argv[]) | ||
235 | { | ||
236 | int ret; | ||
237 | |||
238 | GNUNET_log_setup ("test-time", "WARNING", NULL); | ||
239 | ret = check (); | ||
240 | |||
241 | return ret; | ||
242 | } | ||
243 | 233 | ||
244 | /* end of test_time.c */ | 234 | /* end of test_time.c */ |