aboutsummaryrefslogtreecommitdiff
path: root/src/fs/test_fs_uri.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-06-15 08:38:53 +0000
committerChristian Grothoff <christian@grothoff.org>2012-06-15 08:38:53 +0000
commit36ca9fcc68935edd109481d30f9e6e15a825c282 (patch)
tree5c976b741a314b5c3486124a9bff74b4ab5f5b78 /src/fs/test_fs_uri.c
parente825548ea9a45d1f4b25898f87b5c74f8bc4cc25 (diff)
downloadgnunet-36ca9fcc68935edd109481d30f9e6e15a825c282.tar.gz
gnunet-36ca9fcc68935edd109481d30f9e6e15a825c282.zip
-simplifying tests with new testing lib
Diffstat (limited to 'src/fs/test_fs_uri.c')
-rw-r--r--src/fs/test_fs_uri.c50
1 files changed, 23 insertions, 27 deletions
diff --git a/src/fs/test_fs_uri.c b/src/fs/test_fs_uri.c
index b7a58ec0f..9d6c4abe0 100644
--- a/src/fs/test_fs_uri.c
+++ b/src/fs/test_fs_uri.c
@@ -17,19 +17,16 @@
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20
21/** 20/**
22 * @file fs/test_fs_uri.c 21 * @file fs/test_fs_uri.c
23 * @brief Test for fs_uri.c 22 * @brief Test for fs_uri.c
24 * @author Christian Grothoff 23 * @author Christian Grothoff
25 */ 24 */
26
27#include "platform.h" 25#include "platform.h"
28#include "gnunet_util_lib.h" 26#include "gnunet_util_lib.h"
29#include "gnunet_fs_service.h" 27#include "gnunet_fs_service.h"
30#include "fs_api.h" 28#include "fs_api.h"
31 29
32#define ABORT() { fprintf(stderr, "Error at %s:%d\n", __FILE__, __LINE__); return 1; }
33 30
34static int 31static int
35testKeyword () 32testKeyword ()
@@ -41,26 +38,26 @@ testKeyword ()
41 if (NULL != (ret = GNUNET_FS_uri_parse ("gnunet://fs/ksk/++", &emsg))) 38 if (NULL != (ret = GNUNET_FS_uri_parse ("gnunet://fs/ksk/++", &emsg)))
42 { 39 {
43 GNUNET_FS_uri_destroy (ret); 40 GNUNET_FS_uri_destroy (ret);
44 ABORT (); 41 GNUNET_assert (0);
45 } 42 }
46 GNUNET_free (emsg); 43 GNUNET_free (emsg);
47 ret = GNUNET_FS_uri_parse ("gnunet://fs/ksk/foo+bar", &emsg); 44 ret = GNUNET_FS_uri_parse ("gnunet://fs/ksk/foo+bar", &emsg);
48 if (ret == NULL) 45 if (ret == NULL)
49 { 46 {
50 GNUNET_free (emsg); 47 GNUNET_free (emsg);
51 ABORT (); 48 GNUNET_assert (0);
52 } 49 }
53 if (!GNUNET_FS_uri_test_ksk (ret)) 50 if (!GNUNET_FS_uri_test_ksk (ret))
54 { 51 {
55 GNUNET_FS_uri_destroy (ret); 52 GNUNET_FS_uri_destroy (ret);
56 ABORT (); 53 GNUNET_assert (0);
57 } 54 }
58 if ((2 != ret->data.ksk.keywordCount) || 55 if ((2 != ret->data.ksk.keywordCount) ||
59 (0 != strcmp (" foo", ret->data.ksk.keywords[0])) || 56 (0 != strcmp (" foo", ret->data.ksk.keywords[0])) ||
60 (0 != strcmp (" bar", ret->data.ksk.keywords[1]))) 57 (0 != strcmp (" bar", ret->data.ksk.keywords[1])))
61 { 58 {
62 GNUNET_FS_uri_destroy (ret); 59 GNUNET_FS_uri_destroy (ret);
63 ABORT (); 60 GNUNET_assert (0);
64 } 61 }
65 62
66 uri = GNUNET_FS_uri_to_string (ret); 63 uri = GNUNET_FS_uri_to_string (ret);
@@ -68,13 +65,14 @@ testKeyword ()
68 { 65 {
69 GNUNET_free (uri); 66 GNUNET_free (uri);
70 GNUNET_FS_uri_destroy (ret); 67 GNUNET_FS_uri_destroy (ret);
71 ABORT (); 68 GNUNET_assert (0);
72 } 69 }
73 GNUNET_free (uri); 70 GNUNET_free (uri);
74 GNUNET_FS_uri_destroy (ret); 71 GNUNET_FS_uri_destroy (ret);
75 return 0; 72 return 0;
76} 73}
77 74
75
78static int 76static int
79testLocation () 77testLocation ()
80{ 78{
@@ -157,6 +155,7 @@ testLocation ()
157 return 0; 155 return 0;
158} 156}
159 157
158
160static int 159static int
161testNamespace (int i) 160testNamespace (int i)
162{ 161{
@@ -170,7 +169,7 @@ testNamespace (int i)
170 &emsg))) 169 &emsg)))
171 { 170 {
172 GNUNET_FS_uri_destroy (ret); 171 GNUNET_FS_uri_destroy (ret);
173 ABORT (); 172 GNUNET_assert (0);
174 } 173 }
175 GNUNET_free (emsg); 174 GNUNET_free (emsg);
176 if (NULL != 175 if (NULL !=
@@ -179,13 +178,13 @@ testNamespace (int i)
179 ("gnunet://fs/sks/D1KJS9H2A82Q65VKQ0ML3RFU6U1D3V/test", &emsg))) 178 ("gnunet://fs/sks/D1KJS9H2A82Q65VKQ0ML3RFU6U1D3V/test", &emsg)))
180 { 179 {
181 GNUNET_FS_uri_destroy (ret); 180 GNUNET_FS_uri_destroy (ret);
182 ABORT (); 181 GNUNET_assert (0);
183 } 182 }
184 GNUNET_free (emsg); 183 GNUNET_free (emsg);
185 if (NULL != (ret = GNUNET_FS_uri_parse ("gnunet://fs/sks/test", &emsg))) 184 if (NULL != (ret = GNUNET_FS_uri_parse ("gnunet://fs/sks/test", &emsg)))
186 { 185 {
187 GNUNET_FS_uri_destroy (ret); 186 GNUNET_FS_uri_destroy (ret);
188 ABORT (); 187 GNUNET_assert (0);
189 } 188 }
190 GNUNET_free (emsg); 189 GNUNET_free (emsg);
191 ret = 190 ret =
@@ -195,17 +194,17 @@ testNamespace (int i)
195 if (ret == NULL) 194 if (ret == NULL)
196 { 195 {
197 GNUNET_free (emsg); 196 GNUNET_free (emsg);
198 ABORT (); 197 GNUNET_assert (0);
199 } 198 }
200 if (GNUNET_FS_uri_test_ksk (ret)) 199 if (GNUNET_FS_uri_test_ksk (ret))
201 { 200 {
202 GNUNET_FS_uri_destroy (ret); 201 GNUNET_FS_uri_destroy (ret);
203 ABORT (); 202 GNUNET_assert (0);
204 } 203 }
205 if (!GNUNET_FS_uri_test_sks (ret)) 204 if (!GNUNET_FS_uri_test_sks (ret))
206 { 205 {
207 GNUNET_FS_uri_destroy (ret); 206 GNUNET_FS_uri_destroy (ret);
208 ABORT (); 207 GNUNET_assert (0);
209 } 208 }
210 209
211 uri = GNUNET_FS_uri_to_string (ret); 210 uri = GNUNET_FS_uri_to_string (ret);
@@ -215,7 +214,7 @@ testNamespace (int i)
215 { 214 {
216 GNUNET_FS_uri_destroy (ret); 215 GNUNET_FS_uri_destroy (ret);
217 GNUNET_free (uri); 216 GNUNET_free (uri);
218 ABORT (); 217 GNUNET_assert (0);
219 } 218 }
220 GNUNET_free (uri); 219 GNUNET_free (uri);
221 GNUNET_FS_uri_destroy (ret); 220 GNUNET_FS_uri_destroy (ret);
@@ -236,7 +235,7 @@ testFile (int i)
236 &emsg))) 235 &emsg)))
237 { 236 {
238 GNUNET_FS_uri_destroy (ret); 237 GNUNET_FS_uri_destroy (ret);
239 ABORT (); 238 GNUNET_assert (0);
240 } 239 }
241 GNUNET_free (emsg); 240 GNUNET_free (emsg);
242 if (NULL != 241 if (NULL !=
@@ -246,7 +245,7 @@ testFile (int i)
246 &emsg))) 245 &emsg)))
247 { 246 {
248 GNUNET_FS_uri_destroy (ret); 247 GNUNET_FS_uri_destroy (ret);
249 ABORT (); 248 GNUNET_assert (0);
250 } 249 }
251 GNUNET_free (emsg); 250 GNUNET_free (emsg);
252 if (NULL != 251 if (NULL !=
@@ -256,7 +255,7 @@ testFile (int i)
256 &emsg))) 255 &emsg)))
257 { 256 {
258 GNUNET_FS_uri_destroy (ret); 257 GNUNET_FS_uri_destroy (ret);
259 ABORT (); 258 GNUNET_assert (0);
260 } 259 }
261 GNUNET_free (emsg); 260 GNUNET_free (emsg);
262 ret = 261 ret =
@@ -266,22 +265,22 @@ testFile (int i)
266 if (ret == NULL) 265 if (ret == NULL)
267 { 266 {
268 GNUNET_free (emsg); 267 GNUNET_free (emsg);
269 ABORT (); 268 GNUNET_assert (0);
270 } 269 }
271 if (GNUNET_FS_uri_test_ksk (ret)) 270 if (GNUNET_FS_uri_test_ksk (ret))
272 { 271 {
273 GNUNET_FS_uri_destroy (ret); 272 GNUNET_FS_uri_destroy (ret);
274 ABORT (); 273 GNUNET_assert (0);
275 } 274 }
276 if (GNUNET_FS_uri_test_sks (ret)) 275 if (GNUNET_FS_uri_test_sks (ret))
277 { 276 {
278 GNUNET_FS_uri_destroy (ret); 277 GNUNET_FS_uri_destroy (ret);
279 ABORT (); 278 GNUNET_assert (0);
280 } 279 }
281 if (GNUNET_ntohll (ret->data.chk.file_length) != 42) 280 if (GNUNET_ntohll (ret->data.chk.file_length) != 42)
282 { 281 {
283 GNUNET_FS_uri_destroy (ret); 282 GNUNET_FS_uri_destroy (ret);
284 ABORT (); 283 GNUNET_assert (0);
285 } 284 }
286 285
287 uri = GNUNET_FS_uri_to_string (ret); 286 uri = GNUNET_FS_uri_to_string (ret);
@@ -291,13 +290,14 @@ testFile (int i)
291 { 290 {
292 GNUNET_free (uri); 291 GNUNET_free (uri);
293 GNUNET_FS_uri_destroy (ret); 292 GNUNET_FS_uri_destroy (ret);
294 ABORT (); 293 GNUNET_assert (0);
295 } 294 }
296 GNUNET_free (uri); 295 GNUNET_free (uri);
297 GNUNET_FS_uri_destroy (ret); 296 GNUNET_FS_uri_destroy (ret);
298 return 0; 297 return 0;
299} 298}
300 299
300
301int 301int
302main (int argc, char *argv[]) 302main (int argc, char *argv[])
303{ 303{
@@ -305,11 +305,7 @@ main (int argc, char *argv[])
305 int i; 305 int i;
306 306
307 GNUNET_log_setup ("test_fs_uri", 307 GNUNET_log_setup ("test_fs_uri",
308#if VERBOSE
309 "DEBUG",
310#else
311 "WARNING", 308 "WARNING",
312#endif
313 NULL); 309 NULL);
314 GNUNET_CRYPTO_random_disable_entropy_gathering (); 310 GNUNET_CRYPTO_random_disable_entropy_gathering ();
315 failureCount += testKeyword (); 311 failureCount += testKeyword ();